/home/coin/SVN-release/Cbc-1.1.1/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 diagonalNorm() const
00182   { return diagonalNorm_;};
00184   inline double linearPerturbation() const
00185   { return linearPerturbation_;};
00186   inline void setLinearPerturbation(double value)
00187   { linearPerturbation_=value;};
00189   inline double diagonalPerturbation() const
00190   { return diagonalPerturbation_;};
00191   inline void setDiagonalPerturbation(double value)
00192   { diagonalPerturbation_=value;};
00194   inline double gamma() const
00195   { return gamma_;};
00196   inline void setGamma(double value)
00197   { gamma_=value;};
00199   inline double delta() const
00200   { return delta_;};
00201   inline void setDelta(double value)
00202   { delta_=value;};
00204   inline double complementarityGap() const 
00205           { return complementarityGap_;} ;
00207 
00210 
00211   inline double largestPrimalError() const
00212           { return largestPrimalError_;} ;
00214   inline double largestDualError() const
00215           { return largestDualError_;} ;
00217   inline int maximumBarrierIterations() const
00218   { return maximumBarrierIterations_;};
00219   inline void setMaximumBarrierIterations(int value)
00220   { maximumBarrierIterations_=value;};
00222   void setCholesky(ClpCholeskyBase * cholesky);
00224   int numberFixed() const;
00227   void fixFixed(bool reallyFix=true);
00229   inline double * primalR() const
00230   { return primalR_;};
00232   inline double * dualR() const
00233   { return dualR_;};
00235 
00236   protected:
00239 
00240   void gutsOfDelete();
00242   void gutsOfCopy(const ClpInterior & rhs);
00244   bool createWorkingData();
00245   void deleteWorkingData();
00247   bool sanityCheck();
00249   int housekeeping();
00251   public:
00254 
00255   inline double rawObjectiveValue() const
00256   { return objectiveValue_;};
00258   inline int isColumn(int sequence) const
00259   { return sequence<numberColumns_ ? 1 : 0;};
00261   inline int sequenceWithin(int sequence) const
00262   { return sequence<numberColumns_ ? sequence : sequence-numberColumns_;};
00264   void checkSolution();
00267   double quadraticDjs(double * djRegion, const double * solution,
00268                       double scaleFactor);
00269 
00271   inline void setFixed( int sequence)
00272   {
00273     status_[sequence] |= 1;
00274   };
00275   inline void clearFixed( int sequence)
00276   {
00277     status_[sequence] &= ~1;
00278   };
00279   inline bool fixed(int sequence) const
00280   {return ((status_[sequence]&1)!=0);};
00281 
00283   inline void setFlagged( int sequence)
00284   {
00285     status_[sequence] |= 2;
00286   };
00287   inline void clearFlagged( int sequence)
00288   {
00289     status_[sequence] &= ~2;
00290   };
00291   inline bool flagged(int sequence) const
00292   {return ((status_[sequence]&2)!=0);};
00293 
00295   inline void setFixedOrFree( int sequence)
00296   {
00297     status_[sequence] |= 4;
00298   };
00299   inline void clearFixedOrFree( int sequence)
00300   {
00301     status_[sequence] &= ~4;
00302   };
00303   inline bool fixedOrFree(int sequence) const
00304   {return ((status_[sequence]&4)!=0);};
00305 
00307   inline void setLowerBound( int sequence)
00308   {
00309     status_[sequence] |= 8;
00310   };
00311   inline void clearLowerBound( int sequence)
00312   {
00313     status_[sequence] &= ~8;
00314   };
00315   inline bool lowerBound(int sequence) const
00316   {return ((status_[sequence]&8)!=0);};
00317 
00319   inline void setUpperBound( int sequence)
00320   {
00321     status_[sequence] |= 16;
00322   };
00323   inline void clearUpperBound( int sequence)
00324   {
00325     status_[sequence] &= ~16;
00326   };
00327   inline bool upperBound(int sequence) const
00328   {return ((status_[sequence]&16)!=0);};
00329 
00331   inline void setFakeLower( int sequence)
00332   {
00333     status_[sequence] |= 32;
00334   };
00335   inline void clearFakeLower( int sequence)
00336   {
00337     status_[sequence] &= ~32;
00338   };
00339   inline bool fakeLower(int sequence) const
00340   {return ((status_[sequence]&32)!=0);};
00341 
00343   inline void setFakeUpper( int sequence)
00344   {
00345     status_[sequence] |= 64;
00346   };
00347   inline void clearFakeUpper( int sequence)
00348   {
00349     status_[sequence] &= ~64;
00350   };
00351   inline bool fakeUpper(int sequence) const
00352   {return ((status_[sequence]&64)!=0);};
00354 
00356 protected:
00357 
00364 
00365   double largestPrimalError_;
00367   double largestDualError_;
00369   double sumDualInfeasibilities_;
00371   double sumPrimalInfeasibilities_;
00373   double worstComplementarity_;
00375 public:
00376   double xsize_;
00377   double zsize_;
00378 protected:
00380   double * lower_;
00382   double * rowLowerWork_;
00384   double * columnLowerWork_;
00386   double * upper_;
00388   double * rowUpperWork_;
00390   double * columnUpperWork_;
00392   double * cost_;
00393 public:
00395   double * rhs_;
00396   double * x_;
00397   double * y_;
00398   double * dj_;
00399 protected:
00401   ClpLsqr * lsqrObject_;
00403   ClpPdcoBase * pdcoStuff_;
00406   double mu_;
00408   double objectiveNorm_;
00410   double rhsNorm_;
00412   double solutionNorm_;
00414   double dualObjective_;
00416   double primalObjective_;
00418   double diagonalNorm_;
00420   double stepLength_;
00422   double linearPerturbation_;
00424   double diagonalPerturbation_;
00425   // gamma from Saunders and Tomlin regularized
00426   double gamma_;
00427   // delta from Saunders and Tomlin regularized
00428   double delta_;
00430   double targetGap_;
00432   double projectionTolerance_;
00434   double maximumRHSError_;
00436   double maximumBoundInfeasibility_;
00438   double maximumDualError_;
00440   double diagonalScaleFactor_;
00442   double scaleFactor_;
00444   double actualPrimalStep_;
00446   double actualDualStep_;
00448   double smallestInfeasibility_;
00450 #define LENGTH_HISTORY 5
00451   double historyInfeasibility_[LENGTH_HISTORY];
00453   double complementarityGap_;
00455   double baseObjectiveNorm_;
00457   double worstDirectionAccuracy_;
00459   double maximumRHSChange_;
00461   double * errorRegion_;
00463   double * rhsFixRegion_;
00465   double * upperSlack_;
00467   double * lowerSlack_;
00469   double * diagonal_;
00471   double * solution_;
00473   double * workArray_;
00475   double * deltaX_;
00477   double * deltaY_;
00479   double * deltaZ_;
00481   double * deltaW_;
00483   double * deltaSU_;
00484   double * deltaSL_;
00486   double * primalR_;
00488   double * dualR_;
00490   double * rhsB_;
00492   double * rhsU_;
00494   double * rhsL_;
00496   double * rhsZ_;
00498   double * rhsW_;
00500   double * rhsC_;
00502   double * zVec_;
00504   double * wVec_;
00506   ClpCholeskyBase * cholesky_;
00508   int numberComplementarityPairs_;
00510   int numberComplementarityItems_;
00512   int maximumBarrierIterations_;
00514   bool gonePrimalFeasible_;
00516   bool goneDualFeasible_;
00518   int algorithm_;
00520 };
00521 //#############################################################################
00530 void
00531 ClpInteriorUnitTest(const std::string & mpsDir,
00532                    const std::string & netlibDir);
00533 
00534 
00535 #endif

Generated on Thu May 15 21:59:05 2008 by  doxygen 1.4.7