- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- File List
- File Members

# /home/coin/SVN-release/Clp-1.5.0/Clp/src/ClpInterior.hpp

Go to the documentation of this file.

    00001 // Copyright (C) 2003, International Business Machines
    00002 // Corporation and others.  All Rights Reserved.
    00003
    00004 /*
    00005    Authors
    00006
    00007    John Tomlin (pdco)
    00008    John Forrest (standard predictor-corrector)
    00009
    00010    Note JJF has added arrays - this takes more memory but makes
    00011    flow easier to understand and hopefully easier to extend
    00012
    00013  */
    00014 #ifndef ClpInterior_H
    00015 #define ClpInterior_H
    00016
    00017 #include <iostream>
    00018 #include <cfloat>
    00019 #include "ClpModel.hpp"
    00020 #include "ClpMatrixBase.hpp"
    00021 #include "ClpSolve.hpp"
    00022 class ClpLsqr;
    00023 class ClpPdcoBase;
    00025 typedef struct{
    00026   double  atolmin;
    00027   double  r3norm;
    00028   double  LSdamp;
    00029   double* deltay;
    00030 } Info;
    00032
    00033 typedef struct{
    00034   double  atolold;
    00035   double  atolnew;
    00036   double  r3ratio;
    00037   int   istop;
    00038   int   itncg;
    00039 } Outfo;
    00041
    00042 typedef struct{
    00043 double  gamma;
    00044 double  delta;
    00045 int MaxIter;
    00046 double  FeaTol;
    00047 double  OptTol;
    00048 double  StepTol;
    00049 double  x0min;
    00050 double  z0min;
    00051 double  mu0;
    00052 int   LSmethod;   // 1=Cholesky    2=QR    3=LSQR
    00053 int   LSproblem;  // See below
    00054 int LSQRMaxIter;
    00055 double  LSQRatol1; // Initial  atol
    00056 double  LSQRatol2; // Smallest atol (unless atol1 is smaller)
    00057 double  LSQRconlim;
    00058 int  wait;
    00059 } Options;
    00060 class Lsqr;
    00061 class ClpCholeskyBase;
    00062 // ***** END
    00070 class ClpInterior : public ClpModel {
    00071    friend void ClpInteriorUnitTest(const std::string & mpsDir,
    00072                                   const std::string & netlibDir);
    00073
    00074 public:
    00075
    00078
    00079     ClpInterior (  );
    00080
    00082   ClpInterior(const ClpInterior &);
    00084   ClpInterior(const ClpModel &);
    00089   ClpInterior (const ClpModel * wholeModel,
    00090               int numberRows, const int * whichRows,
    00091               int numberColumns, const int * whichColumns,
    00092               bool dropNames=true, bool dropIntegers=true);
    00094     ClpInterior & operator=(const ClpInterior & rhs);
    00096    ~ClpInterior (  );
    00097   // Ones below are just ClpModel with some changes
    00109   void loadProblem (  const ClpMatrixBase& matrix,
    00110                      const double* collb, const double* colub,
    00111                      const double* obj,
    00112                      const double* rowlb, const double* rowub,
    00113                       const double * rowObjective=NULL);
    00114   void loadProblem (  const CoinPackedMatrix& matrix,
    00115                      const double* collb, const double* colub,
    00116                      const double* obj,
    00117                      const double* rowlb, const double* rowub,
    00118                       const double * rowObjective=NULL);
    00119
    00122   void loadProblem (  const int numcols, const int numrows,
    00123                      const CoinBigIndex* start, const int* index,
    00124                      const double* value,
    00125                      const double* collb, const double* colub,
    00126                      const double* obj,
    00127                       const double* rowlb, const double* rowub,
    00128                       const double * rowObjective=NULL);
    00130   void loadProblem (  const int numcols, const int numrows,
    00131                      const CoinBigIndex* start, const int* index,
    00132                       const double* value,const int * length,
    00133                      const double* collb, const double* colub,
    00134                      const double* obj,
    00135                       const double* rowlb, const double* rowub,
    00136                       const double * rowObjective=NULL);
    00138   int readMps(const char *filename,
    00139               bool keepNames=false,
    00140               bool ignoreErrors = false);
    00145   void borrowModel(ClpModel & otherModel);
    00147   void returnModel(ClpModel & otherModel);
    00149
    00153   int pdco();
    00154   // ** Temporary version
    00155   int  pdco( ClpPdcoBase * stuff, Options &options, Info &info, Outfo &outfo);
    00157   int primalDual();
    00159
    00162
    00163   inline bool primalFeasible() const
    00164          { return (sumPrimalInfeasibilities_<=1.0e-5);}
    00166   inline bool dualFeasible() const
    00167          { return (sumDualInfeasibilities_<=1.0e-5);}
    00169   inline int algorithm() const
    00170   {return algorithm_; }
    00172   inline void setAlgorithm(int value)
    00173   {algorithm_=value; }
    00175   inline double sumDualInfeasibilities() const
    00176           { return sumDualInfeasibilities_;}
    00178   inline double sumPrimalInfeasibilities() const
    00179           { return sumPrimalInfeasibilities_;}
    00181   inline double dualObjective() const
    00182   { return dualObjective_;}
    00184   inline double primalObjective() const
    00185   { return primalObjective_;}
    00187   inline double diagonalNorm() const
    00188   { return diagonalNorm_;}
    00190   inline double linearPerturbation() const
    00191   { return linearPerturbation_;}
    00192   inline void setLinearPerturbation(double value)
    00193   { linearPerturbation_=value;}
    00195   inline double diagonalPerturbation() const
    00196   { return diagonalPerturbation_;}
    00197   inline void setDiagonalPerturbation(double value)
    00198   { diagonalPerturbation_=value;}
    00200   inline double gamma() const
    00201   { return gamma_;}
    00202   inline void setGamma(double value)
    00203   { gamma_=value;}
    00205   inline double delta() const
    00206   { return delta_;}
    00207   inline void setDelta(double value)
    00208   { delta_=value;}
    00210   inline double complementarityGap() const
    00211           { return complementarityGap_;}
    00213
    00216
    00217   inline double largestPrimalError() const
    00218           { return largestPrimalError_;}
    00220   inline double largestDualError() const
    00221           { return largestDualError_;}
    00223   inline int maximumBarrierIterations() const
    00224   { return maximumBarrierIterations_;}
    00225   inline void setMaximumBarrierIterations(int value)
    00226   { maximumBarrierIterations_=value;}
    00228   void setCholesky(ClpCholeskyBase * cholesky);
    00230   int numberFixed() const;
    00233   void fixFixed(bool reallyFix=true);
    00235   inline double * primalR() const
    00236   { return primalR_;}
    00238   inline double * dualR() const
    00239   { return dualR_;}
    00241
    00242   protected:
    00245
    00246   void gutsOfDelete();
    00248   void gutsOfCopy(const ClpInterior & rhs);
    00250   bool createWorkingData();
    00251   void deleteWorkingData();
    00253   bool sanityCheck();
    00255   int housekeeping();
    00257   public:
    00260
    00261   inline double rawObjectiveValue() const
    00262   { return objectiveValue_;}
    00264   inline int isColumn(int sequence) const
    00265   { return sequence<numberColumns_ ? 1 : 0;}
    00267   inline int sequenceWithin(int sequence) const
    00268   { return sequence<numberColumns_ ? sequence : sequence-numberColumns_;}
    00270   void checkSolution();
    00273   double quadraticDjs(double * djRegion, const double * solution,
    00274                       double scaleFactor);
    00275
    00277   inline void setFixed( int sequence)
    00278   {
    00279     status_[sequence] |= 1;
    00280   }
    00281   inline void clearFixed( int sequence)
    00282   {
    00283     status_[sequence] &= ~1;
    00284   }
    00285   inline bool fixed(int sequence) const
    00286   {return ((status_[sequence]&1)!=0);}
    00287
    00289   inline void setFlagged( int sequence)
    00290   {
    00291     status_[sequence] |= 2;
    00292   }
    00293   inline void clearFlagged( int sequence)
    00294   {
    00295     status_[sequence] &= ~2;
    00296   }
    00297   inline bool flagged(int sequence) const
    00298   {return ((status_[sequence]&2)!=0);}
    00299
    00301   inline void setFixedOrFree( int sequence)
    00302   {
    00303     status_[sequence] |= 4;
    00304   }
    00305   inline void clearFixedOrFree( int sequence)
    00306   {
    00307     status_[sequence] &= ~4;
    00308   }
    00309   inline bool fixedOrFree(int sequence) const
    00310   {return ((status_[sequence]&4)!=0);}
    00311
    00313   inline void setLowerBound( int sequence)
    00314   {
    00315     status_[sequence] |= 8;
    00316   }
    00317   inline void clearLowerBound( int sequence)
    00318   {
    00319     status_[sequence] &= ~8;
    00320   }
    00321   inline bool lowerBound(int sequence) const
    00322   {return ((status_[sequence]&8)!=0);}
    00323
    00325   inline void setUpperBound( int sequence)
    00326   {
    00327     status_[sequence] |= 16;
    00328   }
    00329   inline void clearUpperBound( int sequence)
    00330   {
    00331     status_[sequence] &= ~16;
    00332   }
    00333   inline bool upperBound(int sequence) const
    00334   {return ((status_[sequence]&16)!=0);}
    00335
    00337   inline void setFakeLower( int sequence)
    00338   {
    00339     status_[sequence] |= 32;
    00340   }
    00341   inline void clearFakeLower( int sequence)
    00342   {
    00343     status_[sequence] &= ~32;
    00344   }
    00345   inline bool fakeLower(int sequence) const
    00346   {return ((status_[sequence]&32)!=0);}
    00347
    00349   inline void setFakeUpper( int sequence)
    00350   {
    00351     status_[sequence] |= 64;
    00352   }
    00353   inline void clearFakeUpper( int sequence)
    00354   {
    00355     status_[sequence] &= ~64;
    00356   }
    00357   inline bool fakeUpper(int sequence) const
    00358   {return ((status_[sequence]&64)!=0);}
    00360
    00362 protected:
    00363
    00370
    00371   double largestPrimalError_;
    00373   double largestDualError_;
    00375   double sumDualInfeasibilities_;
    00377   double sumPrimalInfeasibilities_;
    00379   double worstComplementarity_;
    00381 public:
    00382   double xsize_;
    00383   double zsize_;
    00384 protected:
    00386   double * lower_;
    00388   double * rowLowerWork_;
    00390   double * columnLowerWork_;
    00392   double * upper_;
    00394   double * rowUpperWork_;
    00396   double * columnUpperWork_;
    00398   double * cost_;
    00399 public:
    00401   double * rhs_;
    00402   double * x_;
    00403   double * y_;
    00404   double * dj_;
    00405 protected:
    00407   ClpLsqr * lsqrObject_;
    00409   ClpPdcoBase * pdcoStuff_;
    00412   double mu_;
    00414   double objectiveNorm_;
    00416   double rhsNorm_;
    00418   double solutionNorm_;
    00420   double dualObjective_;
    00422   double primalObjective_;
    00424   double diagonalNorm_;
    00426   double stepLength_;
    00428   double linearPerturbation_;
    00430   double diagonalPerturbation_;
    00431   // gamma from Saunders and Tomlin regularized
    00432   double gamma_;
    00433   // delta from Saunders and Tomlin regularized
    00434   double delta_;
    00436   double targetGap_;
    00438   double projectionTolerance_;
    00440   double maximumRHSError_;
    00442   double maximumBoundInfeasibility_;
    00444   double maximumDualError_;
    00446   double diagonalScaleFactor_;
    00448   double scaleFactor_;
    00450   double actualPrimalStep_;
    00452   double actualDualStep_;
    00454   double smallestInfeasibility_;
    00456 #define LENGTH_HISTORY 5
    00457   double historyInfeasibility_[LENGTH_HISTORY];
    00459   double complementarityGap_;
    00461   double baseObjectiveNorm_;
    00463   double worstDirectionAccuracy_;
    00465   double maximumRHSChange_;
    00467   double * errorRegion_;
    00469   double * rhsFixRegion_;
    00471   double * upperSlack_;
    00473   double * lowerSlack_;
    00475   double * diagonal_;
    00477   double * solution_;
    00479   double * workArray_;
    00481   double * deltaX_;
    00483   double * deltaY_;
    00485   double * deltaZ_;
    00487   double * deltaW_;
    00489   double * deltaSU_;
    00490   double * deltaSL_;
    00492   double * primalR_;
    00494   double * dualR_;
    00496   double * rhsB_;
    00498   double * rhsU_;
    00500   double * rhsL_;
    00502   double * rhsZ_;
    00504   double * rhsW_;
    00506   double * rhsC_;
    00508   double * zVec_;
    00510   double * wVec_;
    00512   ClpCholeskyBase * cholesky_;
    00514   int numberComplementarityPairs_;
    00516   int numberComplementarityItems_;
    00518   int maximumBarrierIterations_;
    00520   bool gonePrimalFeasible_;
    00522   bool goneDualFeasible_;
    00524   int algorithm_;
    00526 };
    00527 //#############################################################################
    00536 void
    00537 ClpInteriorUnitTest(const std::string & mpsDir,
    00538                    const std::string & netlibDir);
    00539
    00540
    00541 #endif