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

- File List
- File Members

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

Go to the documentation of this file.

    00001 /* $Id: ClpInterior.hpp 1458 2009-11-05 12:34:07Z forrest $ */
    00002 // Copyright (C) 2003, International Business Machines
    00003 // Corporation and others.  All Rights Reserved.
    00004
    00005 /*
    00006    Authors
    00007
    00008    John Tomlin (pdco)
    00009    John Forrest (standard predictor-corrector)
    00010
    00011    Note JJF has added arrays - this takes more memory but makes
    00012    flow easier to understand and hopefully easier to extend
    00013
    00014  */
    00015 #ifndef ClpInterior_H
    00016 #define ClpInterior_H
    00017
    00018 #include <iostream>
    00019 #include <cfloat>
    00020 #include "ClpModel.hpp"
    00021 #include "ClpMatrixBase.hpp"
    00022 #include "ClpSolve.hpp"
    00023 #include "CoinDenseVector.hpp"
    00024 class ClpLsqr;
    00025 class ClpPdcoBase;
    00027 typedef struct{
    00028   double  atolmin;
    00029   double  r3norm;
    00030   double  LSdamp;
    00031   double* deltay;
    00032 } Info;
    00034
    00035 typedef struct{
    00036   double  atolold;
    00037   double  atolnew;
    00038   double  r3ratio;
    00039   int   istop;
    00040   int   itncg;
    00041 } Outfo;
    00043
    00044 typedef struct{
    00045 double  gamma;
    00046 double  delta;
    00047 int MaxIter;
    00048 double  FeaTol;
    00049 double  OptTol;
    00050 double  StepTol;
    00051 double  x0min;
    00052 double  z0min;
    00053 double  mu0;
    00054 int   LSmethod;   // 1=Cholesky    2=QR    3=LSQR
    00055 int   LSproblem;  // See below
    00056 int LSQRMaxIter;
    00057 double  LSQRatol1; // Initial  atol
    00058 double  LSQRatol2; // Smallest atol (unless atol1 is smaller)
    00059 double  LSQRconlim;
    00060 int  wait;
    00061 } Options;
    00062 class Lsqr;
    00063 class ClpCholeskyBase;
    00064 // ***** END
    00072 class ClpInterior : public ClpModel {
    00073    friend void ClpInteriorUnitTest(const std::string & mpsDir,
    00074                                   const std::string & netlibDir);
    00075
    00076 public:
    00077
    00080
    00081     ClpInterior (  );
    00082
    00084   ClpInterior(const ClpInterior &);
    00086   ClpInterior(const ClpModel &);
    00091   ClpInterior (const ClpModel * wholeModel,
    00092               int numberRows, const int * whichRows,
    00093               int numberColumns, const int * whichColumns,
    00094               bool dropNames=true, bool dropIntegers=true);
    00096     ClpInterior & operator=(const ClpInterior & rhs);
    00098    ~ClpInterior (  );
    00099   // Ones below are just ClpModel with some changes
    00111   void loadProblem (  const ClpMatrixBase& matrix,
    00112                      const double* collb, const double* colub,
    00113                      const double* obj,
    00114                      const double* rowlb, const double* rowub,
    00115                       const double * rowObjective=NULL);
    00116   void loadProblem (  const CoinPackedMatrix& matrix,
    00117                      const double* collb, const double* colub,
    00118                      const double* obj,
    00119                      const double* rowlb, const double* rowub,
    00120                       const double * rowObjective=NULL);
    00121
    00124   void loadProblem (  const int numcols, const int numrows,
    00125                      const CoinBigIndex* start, const int* index,
    00126                      const double* value,
    00127                      const double* collb, const double* colub,
    00128                      const double* obj,
    00129                       const double* rowlb, const double* rowub,
    00130                       const double * rowObjective=NULL);
    00132   void loadProblem (  const int numcols, const int numrows,
    00133                      const CoinBigIndex* start, const int* index,
    00134                       const double* value,const int * length,
    00135                      const double* collb, const double* colub,
    00136                      const double* obj,
    00137                       const double* rowlb, const double* rowub,
    00138                       const double * rowObjective=NULL);
    00140   int readMps(const char *filename,
    00141               bool keepNames=false,
    00142               bool ignoreErrors = false);
    00147   void borrowModel(ClpModel & otherModel);
    00149   void returnModel(ClpModel & otherModel);
    00151
    00155   int pdco();
    00156   // ** Temporary version
    00157   int  pdco( ClpPdcoBase * stuff, Options &options, Info &info, Outfo &outfo);
    00159   int primalDual();
    00161
    00164
    00165   inline bool primalFeasible() const
    00166          { return (sumPrimalInfeasibilities_<=1.0e-5);}
    00168   inline bool dualFeasible() const
    00169          { return (sumDualInfeasibilities_<=1.0e-5);}
    00171   inline int algorithm() const
    00172   {return algorithm_; }
    00174   inline void setAlgorithm(int value)
    00175   {algorithm_=value; }
    00177   inline CoinWorkDouble sumDualInfeasibilities() const
    00178           { return sumDualInfeasibilities_;}
    00180   inline CoinWorkDouble sumPrimalInfeasibilities() const
    00181           { return sumPrimalInfeasibilities_;}
    00183   inline CoinWorkDouble dualObjective() const
    00184   { return dualObjective_;}
    00186   inline CoinWorkDouble primalObjective() const
    00187   { return primalObjective_;}
    00189   inline CoinWorkDouble diagonalNorm() const
    00190   { return diagonalNorm_;}
    00192   inline CoinWorkDouble linearPerturbation() const
    00193   { return linearPerturbation_;}
    00194   inline void setLinearPerturbation(CoinWorkDouble value)
    00195   { linearPerturbation_=value;}
    00197   inline CoinWorkDouble projectionTolerance() const
    00198   { return projectionTolerance_;}
    00199   inline void setProjectionTolerance(CoinWorkDouble value)
    00200   { projectionTolerance_=value;}
    00202   inline CoinWorkDouble diagonalPerturbation() const
    00203   { return diagonalPerturbation_;}
    00204   inline void setDiagonalPerturbation(CoinWorkDouble value)
    00205   { diagonalPerturbation_=value;}
    00207   inline CoinWorkDouble gamma() const
    00208   { return gamma_;}
    00209   inline void setGamma(CoinWorkDouble value)
    00210   { gamma_=value;}
    00212   inline CoinWorkDouble delta() const
    00213   { return delta_;}
    00214   inline void setDelta(CoinWorkDouble value)
    00215   { delta_=value;}
    00217   inline CoinWorkDouble complementarityGap() const
    00218           { return complementarityGap_;}
    00220
    00223
    00224   inline CoinWorkDouble largestPrimalError() const
    00225           { return largestPrimalError_;}
    00227   inline CoinWorkDouble largestDualError() const
    00228           { return largestDualError_;}
    00230   inline int maximumBarrierIterations() const
    00231   { return maximumBarrierIterations_;}
    00232   inline void setMaximumBarrierIterations(int value)
    00233   { maximumBarrierIterations_=value;}
    00235   void setCholesky(ClpCholeskyBase * cholesky);
    00237   int numberFixed() const;
    00240   void fixFixed(bool reallyFix=true);
    00242   inline CoinWorkDouble * primalR() const
    00243   { return primalR_;}
    00245   inline CoinWorkDouble * dualR() const
    00246   { return dualR_;}
    00248
    00249   protected:
    00252
    00253   void gutsOfDelete();
    00255   void gutsOfCopy(const ClpInterior & rhs);
    00257   bool createWorkingData();
    00258   void deleteWorkingData();
    00260   bool sanityCheck();
    00262   int housekeeping();
    00264   public:
    00267
    00268   inline CoinWorkDouble rawObjectiveValue() const
    00269   { return objectiveValue_;}
    00271   inline int isColumn(int sequence) const
    00272   { return sequence<numberColumns_ ? 1 : 0;}
    00274   inline int sequenceWithin(int sequence) const
    00275   { return sequence<numberColumns_ ? sequence : sequence-numberColumns_;}
    00277   void checkSolution();
    00280   CoinWorkDouble quadraticDjs(CoinWorkDouble * djRegion, const CoinWorkDouble * solution,
    00281                       CoinWorkDouble scaleFactor);
    00282
    00284   inline void setFixed( int sequence)
    00285   {
    00286     status_[sequence] = static_cast<unsigned char>(status_[sequence] | 1) ;
    00287   }
    00288   inline void clearFixed( int sequence)
    00289   {
    00290     status_[sequence] = static_cast<unsigned char>(status_[sequence] & ~1) ;
    00291   }
    00292   inline bool fixed(int sequence) const
    00293   {return ((status_[sequence]&1)!=0);}
    00294
    00296   inline void setFlagged( int sequence)
    00297   {
    00298     status_[sequence] = static_cast<unsigned char>(status_[sequence] | 2) ;
    00299   }
    00300   inline void clearFlagged( int sequence)
    00301   {
    00302     status_[sequence] = static_cast<unsigned char>(status_[sequence] & ~2) ;
    00303   }
    00304   inline bool flagged(int sequence) const
    00305   {return ((status_[sequence]&2)!=0);}
    00306
    00308   inline void setFixedOrFree( int sequence)
    00309   {
    00310     status_[sequence] = static_cast<unsigned char>(status_[sequence] | 4) ;
    00311   }
    00312   inline void clearFixedOrFree( int sequence)
    00313   {
    00314     status_[sequence] = static_cast<unsigned char>(status_[sequence] & ~4) ;
    00315   }
    00316   inline bool fixedOrFree(int sequence) const
    00317   {return ((status_[sequence]&4)!=0);}
    00318
    00320   inline void setLowerBound( int sequence)
    00321   {
    00322     status_[sequence] = static_cast<unsigned char>(status_[sequence] | 8) ;
    00323   }
    00324   inline void clearLowerBound( int sequence)
    00325   {
    00326     status_[sequence] = static_cast<unsigned char>(status_[sequence] & ~8) ;
    00327   }
    00328   inline bool lowerBound(int sequence) const
    00329   {return ((status_[sequence]&8)!=0);}
    00330
    00332   inline void setUpperBound( int sequence)
    00333   {
    00334     status_[sequence] = static_cast<unsigned char>(status_[sequence] | 16) ;
    00335   }
    00336   inline void clearUpperBound( int sequence)
    00337   {
    00338     status_[sequence] = static_cast<unsigned char>(status_[sequence] & ~16) ;
    00339   }
    00340   inline bool upperBound(int sequence) const
    00341   {return ((status_[sequence]&16)!=0);}
    00342
    00344   inline void setFakeLower( int sequence)
    00345   {
    00346     status_[sequence] = static_cast<unsigned char>(status_[sequence] | 32) ;
    00347   }
    00348   inline void clearFakeLower( int sequence)
    00349   {
    00350     status_[sequence] = static_cast<unsigned char>(status_[sequence] & ~32) ;
    00351   }
    00352   inline bool fakeLower(int sequence) const
    00353   {return ((status_[sequence]&32)!=0);}
    00354
    00356   inline void setFakeUpper( int sequence)
    00357   {
    00358     status_[sequence] = static_cast<unsigned char>(status_[sequence] | 64) ;
    00359   }
    00360   inline void clearFakeUpper( int sequence)
    00361   {
    00362     status_[sequence] = static_cast<unsigned char>(status_[sequence] & ~64) ;
    00363   }
    00364   inline bool fakeUpper(int sequence) const
    00365   {return ((status_[sequence]&64)!=0);}
    00367
    00369 protected:
    00370
    00377
    00378   CoinWorkDouble largestPrimalError_;
    00380   CoinWorkDouble largestDualError_;
    00382   CoinWorkDouble sumDualInfeasibilities_;
    00384   CoinWorkDouble sumPrimalInfeasibilities_;
    00386   CoinWorkDouble worstComplementarity_;
    00388 public:
    00389   CoinWorkDouble xsize_;
    00390   CoinWorkDouble zsize_;
    00391 protected:
    00393   CoinWorkDouble * lower_;
    00395   CoinWorkDouble * rowLowerWork_;
    00397   CoinWorkDouble * columnLowerWork_;
    00399   CoinWorkDouble * upper_;
    00401   CoinWorkDouble * rowUpperWork_;
    00403   CoinWorkDouble * columnUpperWork_;
    00405   CoinWorkDouble * cost_;
    00406 public:
    00408   CoinWorkDouble * rhs_;
    00409   CoinWorkDouble * x_;
    00410   CoinWorkDouble * y_;
    00411   CoinWorkDouble * dj_;
    00412 protected:
    00414   ClpLsqr * lsqrObject_;
    00416   ClpPdcoBase * pdcoStuff_;
    00419   CoinWorkDouble mu_;
    00421   CoinWorkDouble objectiveNorm_;
    00423   CoinWorkDouble rhsNorm_;
    00425   CoinWorkDouble solutionNorm_;
    00427   CoinWorkDouble dualObjective_;
    00429   CoinWorkDouble primalObjective_;
    00431   CoinWorkDouble diagonalNorm_;
    00433   CoinWorkDouble stepLength_;
    00435   CoinWorkDouble linearPerturbation_;
    00437   CoinWorkDouble diagonalPerturbation_;
    00438   // gamma from Saunders and Tomlin regularized
    00439   CoinWorkDouble gamma_;
    00440   // delta from Saunders and Tomlin regularized
    00441   CoinWorkDouble delta_;
    00443   CoinWorkDouble targetGap_;
    00445   CoinWorkDouble projectionTolerance_;
    00447   CoinWorkDouble maximumRHSError_;
    00449   CoinWorkDouble maximumBoundInfeasibility_;
    00451   CoinWorkDouble maximumDualError_;
    00453   CoinWorkDouble diagonalScaleFactor_;
    00455   CoinWorkDouble scaleFactor_;
    00457   CoinWorkDouble actualPrimalStep_;
    00459   CoinWorkDouble actualDualStep_;
    00461   CoinWorkDouble smallestInfeasibility_;
    00463 #define LENGTH_HISTORY 5
    00464   CoinWorkDouble historyInfeasibility_[LENGTH_HISTORY];
    00466   CoinWorkDouble complementarityGap_;
    00468   CoinWorkDouble baseObjectiveNorm_;
    00470   CoinWorkDouble worstDirectionAccuracy_;
    00472   CoinWorkDouble maximumRHSChange_;
    00474   CoinWorkDouble * errorRegion_;
    00476   CoinWorkDouble * rhsFixRegion_;
    00478   CoinWorkDouble * upperSlack_;
    00480   CoinWorkDouble * lowerSlack_;
    00482   CoinWorkDouble * diagonal_;
    00484   CoinWorkDouble * solution_;
    00486   CoinWorkDouble * workArray_;
    00488   CoinWorkDouble * deltaX_;
    00490   CoinWorkDouble * deltaY_;
    00492   CoinWorkDouble * deltaZ_;
    00494   CoinWorkDouble * deltaW_;
    00496   CoinWorkDouble * deltaSU_;
    00497   CoinWorkDouble * deltaSL_;
    00499   CoinWorkDouble * primalR_;
    00501   CoinWorkDouble * dualR_;
    00503   CoinWorkDouble * rhsB_;
    00505   CoinWorkDouble * rhsU_;
    00507   CoinWorkDouble * rhsL_;
    00509   CoinWorkDouble * rhsZ_;
    00511   CoinWorkDouble * rhsW_;
    00513   CoinWorkDouble * rhsC_;
    00515   CoinWorkDouble * zVec_;
    00517   CoinWorkDouble * wVec_;
    00519   ClpCholeskyBase * cholesky_;
    00521   int numberComplementarityPairs_;
    00523   int numberComplementarityItems_;
    00525   int maximumBarrierIterations_;
    00527   bool gonePrimalFeasible_;
    00529   bool goneDualFeasible_;
    00531   int algorithm_;
    00533 };
    00534 //#############################################################################
    00543 void
    00544 ClpInteriorUnitTest(const std::string & mpsDir,
    00545                    const std::string & netlibDir);
    00546
    00547
    00548 #endif