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

- File List
- File Members

# /home/coin/SVN-release/Bcps-0.91.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 #include "CoinDenseVector.hpp"
    00023 class ClpLsqr;
    00024 class ClpPdcoBase;
    00026 typedef struct{
    00027   double  atolmin;
    00028   double  r3norm;
    00029   double  LSdamp;
    00030   double* deltay;
    00031 } Info;
    00033
    00034 typedef struct{
    00035   double  atolold;
    00036   double  atolnew;
    00037   double  r3ratio;
    00038   int   istop;
    00039   int   itncg;
    00040 } Outfo;
    00042
    00043 typedef struct{
    00044 double  gamma;
    00045 double  delta;
    00046 int MaxIter;
    00047 double  FeaTol;
    00048 double  OptTol;
    00049 double  StepTol;
    00050 double  x0min;
    00051 double  z0min;
    00052 double  mu0;
    00053 int   LSmethod;   // 1=Cholesky    2=QR    3=LSQR
    00054 int   LSproblem;  // See below
    00055 int LSQRMaxIter;
    00056 double  LSQRatol1; // Initial  atol
    00057 double  LSQRatol2; // Smallest atol (unless atol1 is smaller)
    00058 double  LSQRconlim;
    00059 int  wait;
    00060 } Options;
    00061 class Lsqr;
    00062 class ClpCholeskyBase;
    00063 // ***** END
    00071 class ClpInterior : public ClpModel {
    00072    friend void ClpInteriorUnitTest(const std::string & mpsDir,
    00073                                   const std::string & netlibDir);
    00074
    00075 public:
    00076
    00079
    00080     ClpInterior (  );
    00081
    00083   ClpInterior(const ClpInterior &);
    00085   ClpInterior(const ClpModel &);
    00090   ClpInterior (const ClpModel * wholeModel,
    00091               int numberRows, const int * whichRows,
    00092               int numberColumns, const int * whichColumns,
    00093               bool dropNames=true, bool dropIntegers=true);
    00095     ClpInterior & operator=(const ClpInterior & rhs);
    00097    ~ClpInterior (  );
    00098   // Ones below are just ClpModel with some changes
    00110   void loadProblem (  const ClpMatrixBase& matrix,
    00111                      const double* collb, const double* colub,
    00112                      const double* obj,
    00113                      const double* rowlb, const double* rowub,
    00114                       const double * rowObjective=NULL);
    00115   void loadProblem (  const CoinPackedMatrix& matrix,
    00116                      const double* collb, const double* colub,
    00117                      const double* obj,
    00118                      const double* rowlb, const double* rowub,
    00119                       const double * rowObjective=NULL);
    00120
    00123   void loadProblem (  const int numcols, const int numrows,
    00124                      const CoinBigIndex* start, const int* index,
    00125                      const double* value,
    00126                      const double* collb, const double* colub,
    00127                      const double* obj,
    00128                       const double* rowlb, const double* rowub,
    00129                       const double * rowObjective=NULL);
    00131   void loadProblem (  const int numcols, const int numrows,
    00132                      const CoinBigIndex* start, const int* index,
    00133                       const double* value,const int * length,
    00134                      const double* collb, const double* colub,
    00135                      const double* obj,
    00136                       const double* rowlb, const double* rowub,
    00137                       const double * rowObjective=NULL);
    00139   int readMps(const char *filename,
    00140               bool keepNames=false,
    00141               bool ignoreErrors = false);
    00146   void borrowModel(ClpModel & otherModel);
    00148   void returnModel(ClpModel & otherModel);
    00150
    00154   int pdco();
    00155   // ** Temporary version
    00156   int  pdco( ClpPdcoBase * stuff, Options &options, Info &info, Outfo &outfo);
    00158   int primalDual();
    00160
    00163
    00164   inline bool primalFeasible() const
    00165          { return (sumPrimalInfeasibilities_<=1.0e-5);}
    00167   inline bool dualFeasible() const
    00168          { return (sumDualInfeasibilities_<=1.0e-5);}
    00170   inline int algorithm() const
    00171   {return algorithm_; }
    00173   inline void setAlgorithm(int value)
    00174   {algorithm_=value; }
    00176   inline double sumDualInfeasibilities() const
    00177           { return sumDualInfeasibilities_;}
    00179   inline double sumPrimalInfeasibilities() const
    00180           { return sumPrimalInfeasibilities_;}
    00182   inline double dualObjective() const
    00183   { return dualObjective_;}
    00185   inline double primalObjective() const
    00186   { return primalObjective_;}
    00188   inline double diagonalNorm() const
    00189   { return diagonalNorm_;}
    00191   inline double linearPerturbation() const
    00192   { return linearPerturbation_;}
    00193   inline void setLinearPerturbation(double value)
    00194   { linearPerturbation_=value;}
    00196   inline double diagonalPerturbation() const
    00197   { return diagonalPerturbation_;}
    00198   inline void setDiagonalPerturbation(double value)
    00199   { diagonalPerturbation_=value;}
    00201   inline double gamma() const
    00202   { return gamma_;}
    00203   inline void setGamma(double value)
    00204   { gamma_=value;}
    00206   inline double delta() const
    00207   { return delta_;}
    00208   inline void setDelta(double value)
    00209   { delta_=value;}
    00211   inline double complementarityGap() const
    00212           { return complementarityGap_;}
    00214
    00217
    00218   inline double largestPrimalError() const
    00219           { return largestPrimalError_;}
    00221   inline double largestDualError() const
    00222           { return largestDualError_;}
    00224   inline int maximumBarrierIterations() const
    00225   { return maximumBarrierIterations_;}
    00226   inline void setMaximumBarrierIterations(int value)
    00227   { maximumBarrierIterations_=value;}
    00229   void setCholesky(ClpCholeskyBase * cholesky);
    00231   int numberFixed() const;
    00234   void fixFixed(bool reallyFix=true);
    00236   inline double * primalR() const
    00237   { return primalR_;}
    00239   inline double * dualR() const
    00240   { return dualR_;}
    00242
    00243   protected:
    00246
    00247   void gutsOfDelete();
    00249   void gutsOfCopy(const ClpInterior & rhs);
    00251   bool createWorkingData();
    00252   void deleteWorkingData();
    00254   bool sanityCheck();
    00256   int housekeeping();
    00258   public:
    00261
    00262   inline double rawObjectiveValue() const
    00263   { return objectiveValue_;}
    00265   inline int isColumn(int sequence) const
    00266   { return sequence<numberColumns_ ? 1 : 0;}
    00268   inline int sequenceWithin(int sequence) const
    00269   { return sequence<numberColumns_ ? sequence : sequence-numberColumns_;}
    00271   void checkSolution();
    00274   double quadraticDjs(double * djRegion, const double * solution,
    00275                       double scaleFactor);
    00276
    00278   inline void setFixed( int sequence)
    00279   {
    00280     status_[sequence] = static_cast<unsigned char>(status_[sequence] | 1) ;
    00281   }
    00282   inline void clearFixed( int sequence)
    00283   {
    00284     status_[sequence] = static_cast<unsigned char>(status_[sequence] & ~1) ;
    00285   }
    00286   inline bool fixed(int sequence) const
    00287   {return ((status_[sequence]&1)!=0);}
    00288
    00290   inline void setFlagged( int sequence)
    00291   {
    00292     status_[sequence] = static_cast<unsigned char>(status_[sequence] | 2) ;
    00293   }
    00294   inline void clearFlagged( int sequence)
    00295   {
    00296     status_[sequence] = static_cast<unsigned char>(status_[sequence] & ~2) ;
    00297   }
    00298   inline bool flagged(int sequence) const
    00299   {return ((status_[sequence]&2)!=0);}
    00300
    00302   inline void setFixedOrFree( int sequence)
    00303   {
    00304     status_[sequence] = static_cast<unsigned char>(status_[sequence] | 4) ;
    00305   }
    00306   inline void clearFixedOrFree( int sequence)
    00307   {
    00308     status_[sequence] = static_cast<unsigned char>(status_[sequence] & ~4) ;
    00309   }
    00310   inline bool fixedOrFree(int sequence) const
    00311   {return ((status_[sequence]&4)!=0);}
    00312
    00314   inline void setLowerBound( int sequence)
    00315   {
    00316     status_[sequence] = static_cast<unsigned char>(status_[sequence] | 8) ;
    00317   }
    00318   inline void clearLowerBound( int sequence)
    00319   {
    00320     status_[sequence] = static_cast<unsigned char>(status_[sequence] & ~8) ;
    00321   }
    00322   inline bool lowerBound(int sequence) const
    00323   {return ((status_[sequence]&8)!=0);}
    00324
    00326   inline void setUpperBound( int sequence)
    00327   {
    00328     status_[sequence] = static_cast<unsigned char>(status_[sequence] | 16) ;
    00329   }
    00330   inline void clearUpperBound( int sequence)
    00331   {
    00332     status_[sequence] = static_cast<unsigned char>(status_[sequence] & ~16) ;
    00333   }
    00334   inline bool upperBound(int sequence) const
    00335   {return ((status_[sequence]&16)!=0);}
    00336
    00338   inline void setFakeLower( int sequence)
    00339   {
    00340     status_[sequence] = static_cast<unsigned char>(status_[sequence] | 32) ;
    00341   }
    00342   inline void clearFakeLower( int sequence)
    00343   {
    00344     status_[sequence] = static_cast<unsigned char>(status_[sequence] & ~32) ;
    00345   }
    00346   inline bool fakeLower(int sequence) const
    00347   {return ((status_[sequence]&32)!=0);}
    00348
    00350   inline void setFakeUpper( int sequence)
    00351   {
    00352     status_[sequence] = static_cast<unsigned char>(status_[sequence] | 64) ;
    00353   }
    00354   inline void clearFakeUpper( int sequence)
    00355   {
    00356     status_[sequence] = static_cast<unsigned char>(status_[sequence] & ~64) ;
    00357   }
    00358   inline bool fakeUpper(int sequence) const
    00359   {return ((status_[sequence]&64)!=0);}
    00361
    00363 protected:
    00364
    00371
    00372   double largestPrimalError_;
    00374   double largestDualError_;
    00376   double sumDualInfeasibilities_;
    00378   double sumPrimalInfeasibilities_;
    00380   double worstComplementarity_;
    00382 public:
    00383   double xsize_;
    00384   double zsize_;
    00385 protected:
    00387   double * lower_;
    00389   double * rowLowerWork_;
    00391   double * columnLowerWork_;
    00393   double * upper_;
    00395   double * rowUpperWork_;
    00397   double * columnUpperWork_;
    00399   double * cost_;
    00400 public:
    00402   double * rhs_;
    00403   double * x_;
    00404   double * y_;
    00405   double * dj_;
    00406 protected:
    00408   ClpLsqr * lsqrObject_;
    00410   ClpPdcoBase * pdcoStuff_;
    00413   double mu_;
    00415   double objectiveNorm_;
    00417   double rhsNorm_;
    00419   double solutionNorm_;
    00421   double dualObjective_;
    00423   double primalObjective_;
    00425   double diagonalNorm_;
    00427   double stepLength_;
    00429   double linearPerturbation_;
    00431   double diagonalPerturbation_;
    00432   // gamma from Saunders and Tomlin regularized
    00433   double gamma_;
    00434   // delta from Saunders and Tomlin regularized
    00435   double delta_;
    00437   double targetGap_;
    00439   double projectionTolerance_;
    00441   double maximumRHSError_;
    00443   double maximumBoundInfeasibility_;
    00445   double maximumDualError_;
    00447   double diagonalScaleFactor_;
    00449   double scaleFactor_;
    00451   double actualPrimalStep_;
    00453   double actualDualStep_;
    00455   double smallestInfeasibility_;
    00457 #define LENGTH_HISTORY 5
    00458   double historyInfeasibility_[LENGTH_HISTORY];
    00460   double complementarityGap_;
    00462   double baseObjectiveNorm_;
    00464   double worstDirectionAccuracy_;
    00466   double maximumRHSChange_;
    00468   double * errorRegion_;
    00470   double * rhsFixRegion_;
    00472   double * upperSlack_;
    00474   double * lowerSlack_;
    00476   double * diagonal_;
    00478   double * solution_;
    00480   double * workArray_;
    00482   double * deltaX_;
    00484   double * deltaY_;
    00486   double * deltaZ_;
    00488   double * deltaW_;
    00490   double * deltaSU_;
    00491   double * deltaSL_;
    00493   double * primalR_;
    00495   double * dualR_;
    00497   double * rhsB_;
    00499   double * rhsU_;
    00501   double * rhsL_;
    00503   double * rhsZ_;
    00505   double * rhsW_;
    00507   double * rhsC_;
    00509   double * zVec_;
    00511   double * wVec_;
    00513   ClpCholeskyBase * cholesky_;
    00515   int numberComplementarityPairs_;
    00517   int numberComplementarityItems_;
    00519   int maximumBarrierIterations_;
    00521   bool gonePrimalFeasible_;
    00523   bool goneDualFeasible_;
    00525   int algorithm_;
    00527 };
    00528 //#############################################################################
    00537 void
    00538 ClpInteriorUnitTest(const std::string & mpsDir,
    00539                    const std::string & netlibDir);
    00540
    00541
    00542 #endif