Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

/home/coinadmin/Update/COIN/Clp/include/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;
00024 // ******** DATA to be moved into protected section of ClpInterior
00025 typedef struct{
00026   double  atolmin;
00027   double  r3norm;
00028   double  LSdamp;
00029   double* deltay;
00030 } Info;
00031 
00032 typedef struct{
00033   double  atolold;
00034   double  atolnew;
00035   double  r3ratio;
00036   int   istop;
00037   int   itncg;
00038 } Outfo;
00039   
00040 typedef struct{
00041 double  gamma;
00042 double  delta;
00043 int MaxIter;
00044 double  FeaTol;
00045 double  OptTol;
00046 double  StepTol;
00047 double  x0min;
00048 double  z0min;
00049 double  mu0;
00050 int   LSmethod;   // 1=Cholesky    2=QR    3=LSQR
00051 int   LSproblem;  // See below
00052 int LSQRMaxIter;
00053 double  LSQRatol1; // Initial  atol
00054 double  LSQRatol2; // Smallest atol (unless atol1 is smaller)
00055 double  LSQRconlim;
00056 int  wait;
00057 } Options;
00058 class Lsqr;
00059 class ClpCholeskyBase;
00060 // ***** END
00068 class ClpInterior : public ClpModel {
00069    friend void ClpInteriorUnitTest(const std::string & mpsDir,
00070                                   const std::string & netlibDir);
00071 
00072 public:
00073 
00076 
00077     ClpInterior (  );
00078 
00080   ClpInterior(const ClpInterior &);
00082   ClpInterior(const ClpModel &);
00087   ClpInterior (const ClpModel * wholeModel,
00088               int numberRows, const int * whichRows,
00089               int numberColumns, const int * whichColumns,
00090               bool dropNames=true, bool dropIntegers=true);
00092     ClpInterior & operator=(const ClpInterior & rhs);
00094    ~ClpInterior (  );
00095   // Ones below are just ClpModel with some changes
00107   void loadProblem (  const ClpMatrixBase& matrix,
00108                      const double* collb, const double* colub,   
00109                      const double* obj,
00110                      const double* rowlb, const double* rowub,
00111                       const double * rowObjective=NULL);
00112   void loadProblem (  const CoinPackedMatrix& matrix,
00113                      const double* collb, const double* colub,   
00114                      const double* obj,
00115                      const double* rowlb, const double* rowub,
00116                       const double * rowObjective=NULL);
00117 
00120   void loadProblem (  const int numcols, const int numrows,
00121                      const CoinBigIndex* start, const int* index,
00122                      const double* value,
00123                      const double* collb, const double* colub,   
00124                      const double* obj,
00125                       const double* rowlb, const double* rowub,
00126                       const double * rowObjective=NULL);
00128   void loadProblem (  const int numcols, const int numrows,
00129                      const CoinBigIndex* start, const int* index,
00130                       const double* value,const int * length,
00131                      const double* collb, const double* colub,   
00132                      const double* obj,
00133                       const double* rowlb, const double* rowub,
00134                       const double * rowObjective=NULL);
00136   int readMps(const char *filename,
00137               bool keepNames=false,
00138               bool ignoreErrors = false);
00143   void borrowModel(ClpModel & otherModel);
00145   void returnModel(ClpModel & otherModel);
00147 
00151   int pdco();
00152   // ** Temporary version
00153   int  pdco( ClpPdcoBase * stuff, Options &options, Info &info, Outfo &outfo);
00155   int primalDual();
00157 
00160 
00161   inline bool primalFeasible() const
00162          { return (sumPrimalInfeasibilities_<=1.0e-5);};
00164   inline bool dualFeasible() const
00165          { return (sumDualInfeasibilities_<=1.0e-5);};
00167   inline int algorithm() const 
00168   {return algorithm_; } ;
00170   inline void setAlgorithm(int value)
00171   {algorithm_=value; } ;
00173   inline double sumDualInfeasibilities() const 
00174           { return sumDualInfeasibilities_;} ;
00176   inline double sumPrimalInfeasibilities() const 
00177           { return sumPrimalInfeasibilities_;} ;
00179   inline double diagonalNorm() const
00180   { return diagonalNorm_;};
00182   inline double linearPerturbation() const
00183   { return linearPerturbation_;};
00184   inline void setLinearPerturbation(double value)
00185   { linearPerturbation_=value;};
00187   inline double diagonalPerturbation() const
00188   { return diagonalPerturbation_;};
00189   inline void setDiagonalPerturbation(double value)
00190   { diagonalPerturbation_=value;};
00192   inline double gamma() const
00193   { return gamma_;};
00194   inline void setGamma(double value)
00195   { gamma_=value;};
00197   inline double delta() const
00198   { return delta_;};
00199   inline void setDelta(double value)
00200   { delta_=value;};
00202   inline double complementarityGap() const 
00203           { return complementarityGap_;} ;
00205 
00208 
00209   inline double largestPrimalError() const
00210           { return largestPrimalError_;} ;
00212   inline double largestDualError() const
00213           { return largestDualError_;} ;
00215   inline int maximumBarrierIterations() const
00216   { return maximumBarrierIterations_;};
00217   inline void setMaximumBarrierIterations(int value)
00218   { maximumBarrierIterations_=value;};
00220   void setCholesky(ClpCholeskyBase * cholesky);
00222   int numberFixed() const;
00225   void fixFixed(bool reallyFix=true);
00227   inline double * primalR() const
00228   { return primalR_;};
00230   inline double * dualR() const
00231   { return dualR_;};
00233 
00234   protected:
00237 
00238   void gutsOfDelete();
00240   void gutsOfCopy(const ClpInterior & rhs);
00242   bool createWorkingData();
00243   void deleteWorkingData();
00245   bool sanityCheck();
00247   int housekeeping();
00249   public:
00252 
00253   inline double rawObjectiveValue() const
00254   { return objectiveValue_;};
00256   inline int isColumn(int sequence) const
00257   { return sequence<numberColumns_ ? 1 : 0;};
00259   inline int sequenceWithin(int sequence) const
00260   { return sequence<numberColumns_ ? sequence : sequence-numberColumns_;};
00262   void checkSolution();
00265   double quadraticDjs(double * djRegion, const double * solution,
00266                       double scaleFactor);
00267 
00269   inline void setFixed( int sequence)
00270   {
00271     status_[sequence] |= 1;
00272   };
00273   inline void clearFixed( int sequence)
00274   {
00275     status_[sequence] &= ~1;
00276   };
00277   inline bool fixed(int sequence) const
00278   {return ((status_[sequence]&1)!=0);};
00279 
00281   inline void setFlagged( int sequence)
00282   {
00283     status_[sequence] |= 2;
00284   };
00285   inline void clearFlagged( int sequence)
00286   {
00287     status_[sequence] &= ~2;
00288   };
00289   inline bool flagged(int sequence) const
00290   {return ((status_[sequence]&2)!=0);};
00291 
00293   inline void setFixedOrFree( int sequence)
00294   {
00295     status_[sequence] |= 4;
00296   };
00297   inline void clearFixedOrFree( int sequence)
00298   {
00299     status_[sequence] &= ~4;
00300   };
00301   inline bool fixedOrFree(int sequence) const
00302   {return ((status_[sequence]&4)!=0);};
00303 
00305   inline void setLowerBound( int sequence)
00306   {
00307     status_[sequence] |= 8;
00308   };
00309   inline void clearLowerBound( int sequence)
00310   {
00311     status_[sequence] &= ~8;
00312   };
00313   inline bool lowerBound(int sequence) const
00314   {return ((status_[sequence]&8)!=0);};
00315 
00317   inline void setUpperBound( int sequence)
00318   {
00319     status_[sequence] |= 16;
00320   };
00321   inline void clearUpperBound( int sequence)
00322   {
00323     status_[sequence] &= ~16;
00324   };
00325   inline bool upperBound(int sequence) const
00326   {return ((status_[sequence]&16)!=0);};
00327 
00329   inline void setFakeLower( int sequence)
00330   {
00331     status_[sequence] |= 32;
00332   };
00333   inline void clearFakeLower( int sequence)
00334   {
00335     status_[sequence] &= ~32;
00336   };
00337   inline bool fakeLower(int sequence) const
00338   {return ((status_[sequence]&32)!=0);};
00339 
00341   inline void setFakeUpper( int sequence)
00342   {
00343     status_[sequence] |= 64;
00344   };
00345   inline void clearFakeUpper( int sequence)
00346   {
00347     status_[sequence] &= ~64;
00348   };
00349   inline bool fakeUpper(int sequence) const
00350   {return ((status_[sequence]&64)!=0);};
00352 
00354 protected:
00355 
00362 
00363   double largestPrimalError_;
00365   double largestDualError_;
00367   double sumDualInfeasibilities_;
00369   double sumPrimalInfeasibilities_;
00371   double worstComplementarity_;
00373 public:
00374   double xsize_;
00375   double zsize_;
00376 protected:
00378   double * lower_;
00380   double * rowLowerWork_;
00382   double * columnLowerWork_;
00384   double * upper_;
00386   double * rowUpperWork_;
00388   double * columnUpperWork_;
00390   double * cost_;
00391 public:
00393   double * rhs_;
00394   double * x_;
00395   double * y_;
00396   double * dj_;
00397 protected:
00399   ClpLsqr * lsqrObject_;
00401   ClpPdcoBase * pdcoStuff_;
00404   double mu_;
00406   double objectiveNorm_;
00408   double rhsNorm_;
00410   double solutionNorm_;
00412   double dualObjective_;
00414   double primalObjective_;
00416   double diagonalNorm_;
00418   double stepLength_;
00420   double linearPerturbation_;
00422   double diagonalPerturbation_;
00423   // gamma from Saunders and Tomlin regularized
00424   double gamma_;
00425   // delta from Saunders and Tomlin regularized
00426   double delta_;
00428   double targetGap_;
00430   double projectionTolerance_;
00432   double maximumRHSError_;
00434   double maximumBoundInfeasibility_;
00436   double maximumDualError_;
00438   double diagonalScaleFactor_;
00440   double scaleFactor_;
00442   double actualPrimalStep_;
00444   double actualDualStep_;
00446   double smallestInfeasibility_;
00448 #define LENGTH_HISTORY 5
00449   double historyInfeasibility_[LENGTH_HISTORY];
00451   double complementarityGap_;
00453   double baseObjectiveNorm_;
00455   double worstDirectionAccuracy_;
00457   double maximumRHSChange_;
00459   double * errorRegion_;
00461   double * rhsFixRegion_;
00463   double * upperSlack_;
00465   double * lowerSlack_;
00467   double * diagonal_;
00469   double * solution_;
00471   double * workArray_;
00473   double * deltaX_;
00475   double * deltaY_;
00477   double * deltaZ_;
00479   double * deltaW_;
00481   double * deltaSU_;
00482   double * deltaSL_;
00484   double * primalR_;
00486   double * dualR_;
00488   double * rhsB_;
00490   double * rhsU_;
00492   double * rhsL_;
00494   double * rhsZ_;
00496   double * rhsW_;
00498   double * rhsC_;
00500   double * zVec_;
00502   double * wVec_;
00504   ClpCholeskyBase * cholesky_;
00506   int numberComplementarityPairs_;
00508   int numberComplementarityItems_;
00510   int maximumBarrierIterations_;
00512   bool gonePrimalFeasible_;
00514   bool goneDualFeasible_;
00516   int algorithm_;
00518 };
00519 //#############################################################################
00528 void
00529 ClpInteriorUnitTest(const std::string & mpsDir,
00530                    const std::string & netlibDir);
00531 
00532 
00533 #endif

Generated on Fri Aug 6 02:01:31 2004 by doxygen1.3-rc2