/home/coin/SVN-release/Osi-0.103.0/Osi/src/OsiSolverInterface.hpp

Go to the documentation of this file.
00001 // Copyright (C) 2000, International Business Machines
00002 // Corporation and others.  All Rights Reserved.
00003 #ifndef OsiSolverInterface_H
00004 #define OsiSolverInterface_H
00005 
00006 #include <string>
00007 #include <vector>
00008 
00009 #include "CoinMessageHandler.hpp"
00010 #include "CoinPackedVectorBase.hpp"
00011 
00012 #include "OsiCollections.hpp"
00013 #include "OsiSolverParameters.hpp"
00014 
00015 class CoinPackedMatrix;
00016 class CoinWarmStart;
00017 class CoinSnapshot;
00018 class CoinLpIO;
00019 class CoinMpsIO;
00020 
00021 class OsiCuts;
00022 class OsiAuxInfo;
00023 class OsiRowCut;
00024 class OsiRowCutDebugger;
00025 class CoinSet;
00026 class CoinBuild;
00027 class CoinModel;
00028 class OsiSolverBranch;
00029 class OsiSolverResult;
00030 class OsiObject;
00031 #include "CoinFinite.hpp"
00032 
00033 
00034 //#############################################################################
00035 
00059 class OsiSolverInterface  {
00060    friend int OsiSolverInterfaceCommonUnitTest(
00061       const OsiSolverInterface* emptySi,
00062       const std::string & mpsDir,
00063       const std::string & netlibDir);
00064    friend int OsiSolverInterfaceMpsUnitTest(
00065       const std::vector<OsiSolverInterface*> & vecSiP,
00066       const std::string & mpsDir);
00067 
00068 public:
00069 
00071   class ApplyCutsReturnCode {
00072     friend class OsiSolverInterface;
00073     friend class OsiOslSolverInterface;
00074     friend class OsiClpSolverInterface;
00075 
00076   public:
00078 
00079 
00080       ApplyCutsReturnCode():
00081          intInconsistent_(0),
00082          extInconsistent_(0),
00083          infeasible_(0),
00084          ineffective_(0),
00085          applied_(0) {} 
00087       ApplyCutsReturnCode(const ApplyCutsReturnCode & rhs):
00088          intInconsistent_(rhs.intInconsistent_),
00089          extInconsistent_(rhs.extInconsistent_),
00090          infeasible_(rhs.infeasible_),
00091          ineffective_(rhs.ineffective_),
00092          applied_(rhs.applied_) {} 
00094       ApplyCutsReturnCode & operator=(const ApplyCutsReturnCode& rhs)
00095       { 
00096         if (this != &rhs) { 
00097           intInconsistent_ = rhs.intInconsistent_;
00098           extInconsistent_ = rhs.extInconsistent_;
00099           infeasible_      = rhs.infeasible_;
00100           ineffective_     = rhs.ineffective_;
00101           applied_         = rhs.applied_;
00102         }
00103         return *this;
00104       }
00106       ~ApplyCutsReturnCode(){}
00108 
00111 
00112       inline int getNumInconsistent(){return intInconsistent_;}
00114       inline int getNumInconsistentWrtIntegerModel(){return extInconsistent_;}
00116       inline int getNumInfeasible(){return infeasible_;}
00118       inline int getNumIneffective(){return ineffective_;}
00120       inline int getNumApplied(){return applied_;}
00122 
00123   private: 
00126 
00127       inline void incrementInternallyInconsistent(){intInconsistent_++;}
00129       inline void incrementExternallyInconsistent(){extInconsistent_++;}
00131       inline void incrementInfeasible(){infeasible_++;}
00133       inline void incrementIneffective(){ineffective_++;}
00135       inline void incrementApplied(){applied_++;}
00137 
00139 
00140 
00141       int intInconsistent_;
00143       int extInconsistent_;
00145       int infeasible_;
00147       int ineffective_;
00149       int applied_;
00151   };
00152 
00153   //---------------------------------------------------------------------------
00154 
00156 
00157 
00158     virtual void initialSolve() = 0; 
00159 
00165     virtual void resolve() = 0;
00166 
00168     virtual void branchAndBound() = 0;
00169 
00170 #ifdef CBC_NEXT_VERSION
00171     /*
00172       Would it make sense to collect all of these routines in a `MIP Helper'
00173       section? It'd make it easier for users and implementors to find them.
00174     */
00192     virtual int solveBranches(int depth,const OsiSolverBranch * branch,
00193                               OsiSolverResult * result,
00194                               int & numberSolves, int & numberIterations,
00195                               bool forceBranch=false);
00196 #endif
00197 
00198 
00199   //---------------------------------------------------------------------------
00257 
00258     virtual bool setIntParam(OsiIntParam key, int value) {
00259       if (key == OsiLastIntParam) return (false) ;
00260       intParam_[key] = value;
00261       return true;
00262     }
00264     virtual bool setDblParam(OsiDblParam key, double value) {
00265       if (key == OsiLastDblParam) return (false) ;
00266       dblParam_[key] = value;
00267       return true;
00268     }
00270     virtual bool setStrParam(OsiStrParam key, const std::string & value) {
00271       if (key == OsiLastStrParam) return (false) ;
00272       strParam_[key] = value;
00273       return true;
00274     }
00286     virtual bool setHintParam(OsiHintParam key, bool yesNo=true,
00287                               OsiHintStrength strength=OsiHintTry,
00288                               void *otherInformation = NULL) {
00289       if (key==OsiLastHintParam)
00290         return false; 
00291       hintParam_[key] = yesNo;
00292       hintStrength_[key] = strength;
00293       if (strength == OsiForceDo)
00294         throw CoinError("OsiForceDo illegal",
00295                         "setHintParam", "OsiSolverInterface");
00296       return true;
00297     }
00299     virtual bool getIntParam(OsiIntParam key, int& value) const {
00300       if (key == OsiLastIntParam) return (false) ;
00301       value = intParam_[key];
00302       return true;
00303     }
00305     virtual bool getDblParam(OsiDblParam key, double& value) const {
00306       if (key == OsiLastDblParam) return (false) ;
00307       value = dblParam_[key];
00308       return true;
00309     }
00311     virtual bool getStrParam(OsiStrParam key, std::string& value) const {
00312       if (key == OsiLastStrParam) return (false) ;
00313       value = strParam_[key];
00314       return true;
00315     }
00325     virtual bool getHintParam(OsiHintParam key, bool& yesNo,
00326                               OsiHintStrength& strength,
00327                               void *& otherInformation) const {
00328       if (key==OsiLastHintParam)
00329         return false; 
00330       yesNo = hintParam_[key];
00331       strength = hintStrength_[key];
00332       otherInformation=NULL;
00333       return true;
00334     }
00339     virtual bool getHintParam(OsiHintParam key, bool& yesNo,
00340                               OsiHintStrength& strength) const {
00341       if (key==OsiLastHintParam)
00342         return false; 
00343       yesNo = hintParam_[key];
00344       strength = hintStrength_[key];
00345       return true;
00346     }
00351     virtual bool getHintParam(OsiHintParam key, bool& yesNo) const {
00352       if (key==OsiLastHintParam)
00353         return false; 
00354       yesNo = hintParam_[key];
00355       return true;
00356     }
00363     void copyParameters(OsiSolverInterface & rhs);
00364 
00378     inline double getIntegerTolerance() const
00379     { return dblParam_[OsiPrimalTolerance];}
00381 
00382   //---------------------------------------------------------------------------
00384 
00385 
00386     virtual bool isAbandoned() const = 0;
00388     virtual bool isProvenOptimal() const = 0;
00390     virtual bool isProvenPrimalInfeasible() const = 0;
00392     virtual bool isProvenDualInfeasible() const = 0;
00394     virtual bool isPrimalObjectiveLimitReached() const = 0;
00396     virtual bool isDualObjectiveLimitReached() const = 0;
00398     virtual bool isIterationLimitReached() const = 0;
00400 
00401   //---------------------------------------------------------------------------
00419     virtual CoinWarmStart *getEmptyWarmStart () const = 0 ;
00420 
00427     virtual CoinWarmStart* getWarmStart() const = 0;
00436     virtual CoinWarmStart* getPointerToWarmStart(bool & mustDelete) ;
00437 
00446     virtual bool setWarmStart(const CoinWarmStart* warmstart) = 0;
00448 
00449   //---------------------------------------------------------------------------
00470 
00471     virtual void markHotStart();
00473     virtual void solveFromHotStart();
00475     virtual void unmarkHotStart();
00477 
00478   //---------------------------------------------------------------------------
00489 
00490     virtual int getNumCols() const = 0;
00491 
00493     virtual int getNumRows() const = 0;
00494 
00496     virtual int getNumElements() const = 0;
00497 
00499     virtual int getNumIntegers() const ;
00500 
00502     virtual const double * getColLower() const = 0;
00503 
00505     virtual const double * getColUpper() const = 0;
00506 
00516     virtual const char * getRowSense() const = 0;
00517 
00530     virtual const double * getRightHandSide() const = 0;
00531 
00540     virtual const double * getRowRange() const = 0;
00541 
00543     virtual const double * getRowLower() const = 0;
00544 
00546     virtual const double * getRowUpper() const = 0;
00547 
00549     virtual const double * getObjCoefficients() const = 0;
00550 
00552     virtual double getObjSense() const = 0;
00553 
00555     virtual bool isContinuous(int colIndex) const = 0;
00556 
00558     virtual bool isBinary(int colIndex) const;
00559 
00564     virtual bool isInteger(int colIndex) const;
00565 
00567     virtual bool isIntegerNonBinary(int colIndex) const;
00568 
00570     virtual bool isFreeBinary(int colIndex) const; 
00577     inline const char * columnType(bool refresh=false) const
00578     { return getColType(refresh);}
00584     virtual const char * getColType(bool refresh=false) const;
00585   
00587     virtual const CoinPackedMatrix * getMatrixByRow() const = 0;
00588 
00590     virtual const CoinPackedMatrix * getMatrixByCol() const = 0;
00591 
00593     virtual CoinPackedMatrix * getMutableMatrixByRow() const {return NULL;}
00594 
00596     virtual CoinPackedMatrix * getMutableMatrixByCol() const {return NULL;}
00597 
00599     virtual double getInfinity() const = 0;
00601     
00604 
00605     virtual const double * getColSolution() const = 0;
00606 
00610     const double * getStrictColSolution();
00611 
00613     virtual const double * getRowPrice() const = 0;
00614 
00616     virtual const double * getReducedCost() const = 0;
00617 
00620     virtual const double * getRowActivity() const = 0;
00621 
00623     virtual double getObjValue() const = 0;
00624 
00627     virtual int getIterationCount() const = 0;
00628 
00642     virtual std::vector<double*> getDualRays(int maxNumRays) const = 0;
00654     virtual std::vector<double*> getPrimalRays(int maxNumRays) const = 0;
00655 
00658     virtual OsiVectorInt getFractionalIndices(const double etol=1.e-05)
00659       const;
00661 
00662   //-------------------------------------------------------------------------
00675     virtual void setObjCoeff( int elementIndex, double elementValue ) = 0;
00676 
00678     virtual void setObjCoeffSet(const int* indexFirst,
00679                                 const int* indexLast,
00680                                 const double* coeffList);
00681 
00687     virtual void setObjective(const double * array);
00688 
00699     virtual void setObjSense(double s) = 0;
00700   
00701 
00704     virtual void setColLower( int elementIndex, double elementValue ) = 0;
00705     
00711     virtual void setColLower(const double * array);
00712 
00715     virtual void setColUpper( int elementIndex, double elementValue ) = 0;
00716 
00722     virtual void setColUpper(const double * array);
00723     
00724     
00728     virtual void setColBounds( int elementIndex,
00729                                double lower, double upper ) {
00730        setColLower(elementIndex, lower);
00731        setColUpper(elementIndex, upper);
00732     }
00733   
00740     virtual void setColSetBounds(const int* indexFirst,
00741                                  const int* indexLast,
00742                                  const double* boundList);
00743 
00746     virtual void setRowLower( int elementIndex, double elementValue ) = 0;
00747     
00750     virtual void setRowUpper( int elementIndex, double elementValue ) = 0;
00751   
00755     virtual void setRowBounds( int elementIndex,
00756                                double lower, double upper ) {
00757        setRowLower(elementIndex, lower);
00758        setRowUpper(elementIndex, upper);
00759     }
00760 
00767     virtual void setRowSetBounds(const int* indexFirst,
00768                                  const int* indexLast,
00769                                  const double* boundList);
00770   
00771   
00773     virtual void setRowType(int index, char sense, double rightHandSide,
00774                             double range) = 0;
00775   
00780     virtual void setRowSetTypes(const int* indexFirst,
00781                                 const int* indexLast,
00782                                 const char* senseList,
00783                                 const double* rhsList,
00784                                 const double* rangeList);
00785 
00795     virtual void setColSolution(const double *colsol) = 0;
00796 
00806     virtual void setRowPrice(const double * rowprice) = 0;
00807 
00816     virtual int reducedCostFix(double gap, bool justInteger=true);
00818 
00819   //-------------------------------------------------------------------------
00823     virtual void setContinuous(int index) = 0;
00825     virtual void setInteger(int index) = 0;
00828     virtual void setContinuous(const int* indices, int len);
00831     virtual void setInteger(const int* indices, int len);
00833   //-------------------------------------------------------------------------
00834 
00835   //-------------------------------------------------------------------------
00836 
00838     typedef std::vector<std::string> OsiNameVec ;
00839 
00860 
00870     virtual std::string dfltRowColName(char rc,
00871                                  int ndx, unsigned digits = 7) const ;
00872 
00875   virtual std::string getObjName (unsigned maxLen = static_cast<unsigned>(std::string::npos)) const ;
00876 
00879     virtual inline void setObjName (std::string name)
00880     { objName_ = name ; }
00881 
00888     virtual std::string getRowName(int rowIndex,
00889                                    unsigned maxLen = static_cast<unsigned>(std::string::npos)) const ;
00890 
00902     virtual const OsiNameVec &getRowNames() ;
00903 
00909     virtual void setRowName(int ndx, std::string name) ;
00910 
00917     virtual void setRowNames(OsiNameVec &srcNames,
00918                      int srcStart, int len, int tgtStart) ;
00919 
00925     virtual void deleteRowNames(int tgtStart, int len) ;
00926   
00933     virtual std::string getColName(int colIndex,
00934                                    unsigned maxLen = static_cast<unsigned>(std::string::npos)) const ;
00935 
00945     virtual const OsiNameVec &getColNames() ;
00946 
00952     virtual void setColName(int ndx, std::string name) ;
00953 
00960     virtual void setColNames(OsiNameVec &srcNames,
00961                      int srcStart, int len, int tgtStart) ;
00962 
00968     virtual void deleteColNames(int tgtStart, int len) ;
00969   
00970 
00977     void setRowColNames(const CoinMpsIO &mps) ;
00978 
00984     void setRowColNames(CoinModel &mod) ;
00985 
00992     void setRowColNames(CoinLpIO &mod) ;
00993 
00995   //-------------------------------------------------------------------------
00996     
00997   //-------------------------------------------------------------------------
01003 
01005     virtual void addCol(const CoinPackedVectorBase& vec,
01006                         const double collb, const double colub,   
01007                         const double obj) = 0;
01008 
01014     virtual void addCol(const CoinPackedVectorBase& vec,
01015                         const double collb, const double colub,   
01016                         const double obj, std::string name) ;
01017 
01019     virtual void addCol(int numberElements,
01020                         const int* rows, const double* elements,
01021                         const double collb, const double colub,   
01022                         const double obj) ;
01023 
01029     virtual void addCol(int numberElements,
01030                         const int* rows, const double* elements,
01031                         const double collb, const double colub,   
01032                         const double obj, std::string name) ;
01033 
01039     virtual void addCols(const int numcols,
01040                          const CoinPackedVectorBase * const * cols,
01041                          const double* collb, const double* colub,   
01042                          const double* obj);
01043 
01049     virtual void addCols(const int numcols, const int* columnStarts,
01050                          const int* rows, const double* elements,
01051                          const double* collb, const double* colub,   
01052                          const double* obj);
01053 
01055     void addCols(const CoinBuild & buildObject);
01056 
01062     int addCols(CoinModel & modelObject);
01063 
01064 #if 0
01065 
01066     virtual void addCols(const CoinPackedMatrix& matrix,
01067                          const double* collb, const double* colub,   
01068                          const double* obj);
01069 #endif
01070 
01077     virtual void deleteCols(const int num, const int * colIndices) = 0;
01078   
01080     virtual void addRow(const CoinPackedVectorBase& vec,
01081                         const double rowlb, const double rowub) = 0;
01082 
01088     virtual void addRow(const CoinPackedVectorBase& vec,
01089                         const double rowlb, const double rowub,
01090                         std::string name) ;
01091 
01093     virtual void addRow(const CoinPackedVectorBase& vec,
01094                         const char rowsen, const double rowrhs,   
01095                         const double rowrng) = 0;
01096 
01102     virtual void addRow(const CoinPackedVectorBase& vec,
01103                         const char rowsen, const double rowrhs,   
01104                         const double rowrng, std::string name) ;
01105 
01110     virtual void addRow(int numberElements,
01111                         const int *columns, const double *element,
01112                         const double rowlb, const double rowub) ;
01113 
01119     virtual void addRows(const int numrows,
01120                          const CoinPackedVectorBase * const * rows,
01121                          const double* rowlb, const double* rowub);
01122 
01128     virtual void addRows(const int numrows,
01129                          const CoinPackedVectorBase * const * rows,
01130                          const char* rowsen, const double* rowrhs,   
01131                          const double* rowrng);
01132 
01138     virtual void addRows(const int numrows, const int *rowStarts,
01139                          const int *columns, const double *element,
01140                          const double *rowlb, const double *rowub);
01141 
01143     void addRows(const CoinBuild &buildObject);
01144 
01153     int addRows(CoinModel &modelObject);
01154 
01155 #if 0
01156 
01157     virtual void addRows(const CoinPackedMatrix& matrix,
01158                          const double* rowlb, const double* rowub);
01160     virtual void addRows(const CoinPackedMatrix& matrix,
01161                          const char* rowsen, const double* rowrhs,   
01162                          const double* rowrng);
01163 #endif
01164 
01170     virtual void deleteRows(const int num, const int * rowIndices) = 0;
01171 
01174     virtual void saveBaseModel() {}
01178     virtual void restoreBaseModel(int numberRows);
01179     //-----------------------------------------------------------------------
01202     virtual ApplyCutsReturnCode applyCuts(const OsiCuts & cs,
01203                                           double effectivenessLb = 0.0);
01204 
01209     virtual void applyRowCuts(int numberCuts, const OsiRowCut * cuts);
01210 
01214     virtual void applyRowCuts(int numberCuts, const OsiRowCut ** cuts);
01215 
01217     void deleteBranchingInfo(int numberDeleted, const int * which);
01218 
01220 
01221   //---------------------------------------------------------------------------
01222 
01240     virtual void loadProblem (const CoinPackedMatrix& matrix,
01241                               const double* collb, const double* colub,   
01242                               const double* obj,
01243                               const double* rowlb, const double* rowub) = 0;
01244                             
01254     virtual void assignProblem (CoinPackedMatrix*& matrix,
01255                                 double*& collb, double*& colub, double*& obj,
01256                                 double*& rowlb, double*& rowub) = 0;
01257 
01274     virtual void loadProblem (const CoinPackedMatrix& matrix,
01275                               const double* collb, const double* colub,
01276                               const double* obj,
01277                               const char* rowsen, const double* rowrhs,   
01278                               const double* rowrng) = 0;
01279 
01289     virtual void assignProblem (CoinPackedMatrix*& matrix,
01290                                 double*& collb, double*& colub, double*& obj,
01291                                 char*& rowsen, double*& rowrhs,
01292                                 double*& rowrng) = 0;
01293 
01306     virtual void loadProblem (const int numcols, const int numrows,
01307                               const CoinBigIndex * start, const int* index,
01308                               const double* value,
01309                               const double* collb, const double* colub,   
01310                               const double* obj,
01311                               const double* rowlb, const double* rowub) = 0;
01312 
01325     virtual void loadProblem (const int numcols, const int numrows,
01326                               const CoinBigIndex * start, const int* index,
01327                               const double* value,
01328                               const double* collb, const double* colub,   
01329                               const double* obj,
01330                               const char* rowsen, const double* rowrhs,   
01331                               const double* rowrng) = 0;
01332 
01339     virtual int loadFromCoinModel (CoinModel & modelObject,
01340                                    bool keepSolution=false);
01341 
01347     virtual int readMps (const char *filename,
01348                          const char *extension = "mps") ;
01349 
01356     virtual int readMps (const char *filename, const char*extension,
01357                         int & numberSets, CoinSet ** & sets);
01358 
01364     virtual int readGMPL (const char *filename, const char *dataname=NULL);
01365 
01372     virtual void writeMps (const char *filename,
01373                            const char *extension = "mps",
01374                            double objSense=0.0) const = 0;
01375 
01389     int writeMpsNative (const char *filename, 
01390                         const char ** rowNames, const char ** columnNames,
01391                         int formatType=0,int numberAcross=2,
01392                         double objSense=0.0, int numberSOS=0,
01393                         const CoinSet * setInfo=NULL) const ;
01394 
01395 /***********************************************************************/
01396 // Lp files 
01397 
01417   virtual void writeLp(const char *filename,
01418                const char *extension = "lp",
01419                 double epsilon = 1e-5,
01420                 int numberAcross = 10,
01421                 int decimals = 5,
01422                 double objSense = 0.0,
01423                 bool useRowNames = true) const;
01424 
01429   virtual void writeLp(FILE *fp,
01430                 double epsilon = 1e-5,
01431                 int numberAcross = 10,
01432                 int decimals = 5,
01433                 double objSense = 0.0,
01434                 bool useRowNames = true) const;
01435 
01454   int writeLpNative(const char *filename,
01455                     char const * const * const rowNames,
01456                     char const * const * const columnNames,
01457                     const double epsilon = 1.0e-5,
01458                     const int numberAcross = 10,
01459                     const int decimals = 5,
01460                     const double objSense = 0.0,
01461                     const bool useRowNames = true) const;
01462 
01467   int writeLpNative(FILE *fp,
01468                     char const * const * const rowNames,
01469                     char const * const * const columnNames,
01470                     const double epsilon = 1.0e-5,
01471                     const int numberAcross = 10,
01472                     const int decimals = 5,
01473                     const double objSense = 0.0,
01474                     const bool useRowNames = true) const;
01475 
01478   virtual int readLp(const char *filename, const double epsilon = 1e-5);
01479 
01482   int readLp(FILE *fp, const double epsilon = 1e-5);
01483 
01489   virtual void replaceMatrixOptional(const CoinPackedMatrix & ) {}
01491   virtual void replaceMatrix(const CoinPackedMatrix & ) {abort();}
01493 
01494   //---------------------------------------------------------------------------
01495 
01498 #ifdef COIN_SNAPSHOT
01500   virtual CoinSnapshot * snapshot(bool createArrays=true) const;
01501 #endif
01502 #ifdef COIN_FACTORIZATION_INFO
01504   virtual CoinBigIndex getSizeL() const;
01506   virtual CoinBigIndex getSizeU() const;
01507 #endif
01508 
01509 
01510   //---------------------------------------------------------------------------
01511 
01521     void setApplicationData (void * appData);
01528     void setAuxiliaryInfo(OsiAuxInfo * auxiliaryInfo);
01529 
01531     void * getApplicationData() const;
01533     OsiAuxInfo * getAuxiliaryInfo() const;
01535   //---------------------------------------------------------------------------
01536 
01550   virtual void passInMessageHandler(CoinMessageHandler * handler);
01552   void newLanguage(CoinMessages::Language language);
01553   inline void setLanguage(CoinMessages::Language language)
01554   {newLanguage(language);}
01556   inline CoinMessageHandler * messageHandler() const
01557   {return handler_;}
01559   inline CoinMessages messages() 
01560   {return messages_;}
01562   inline CoinMessages * messagesPointer() 
01563   {return &messages_;}
01565   inline bool defaultHandler() const
01566   { return defaultHandler_;}
01568   //---------------------------------------------------------------------------
01583     void findIntegers(bool justCount);
01594     virtual int findIntegersAndSOS(bool justCount);
01596     inline int numberObjects() const { return numberObjects_;}
01598     inline void setNumberObjects(int number) 
01599     {  numberObjects_=number;}
01600 
01602     inline OsiObject ** objects() const { return object_;}
01603 
01605     const inline OsiObject * object(int which) const { return object_[which];}
01607     inline OsiObject * modifiableObject(int which) const { return object_[which];}
01608 
01610     void deleteObjects();
01611 
01616     void addObjects(int numberObjects, OsiObject ** objects);
01621     double forceFeasible();
01623   //---------------------------------------------------------------------------
01624 
01633     virtual void activateRowCutDebugger (const char * modelName);
01634 
01640     virtual void activateRowCutDebugger( const double * solution);
01650     const OsiRowCutDebugger * getRowCutDebugger() const;
01652     const OsiRowCutDebugger * getRowCutDebuggerAlways() const;
01653 
01655 
01656   
01664 public:
01666 
01667 
01670   virtual int canDoSimplexInterface() const;
01677   virtual void enableSimplexInterface(bool doingPrimal) ;
01678 
01680   virtual void disableSimplexInterface() ;
01681 
01688   virtual void enableFactorization() const;
01690   virtual void disableFactorization() const;
01691 
01696   virtual bool basisIsAvailable() const ;
01698   inline bool optimalBasisIsAvailable() const
01699   { return basisIsAvailable();}
01700 
01713   virtual void getBasisStatus(int* cstat, int* rstat) const ;
01714 
01721   virtual int setBasisStatus(const int* cstat, const int* rstat) ;
01722 
01730   virtual int pivot(int colIn, int colOut, int outStatus) ;
01731 
01743   virtual int primalPivotResult(int colIn, int sign, 
01744                                 int& colOut, int& outStatus, 
01745                                 double& t, CoinPackedVector* dx);
01746 
01753   virtual int dualPivotResult(int& colIn, int& sign, 
01754                               int colOut, int outStatus, 
01755                               double& t, CoinPackedVector* dx) ;
01756 
01758   virtual void getReducedGradient(double* columnReducedCosts, 
01759                                   double * duals,
01760                                   const double * c) ;
01761 
01764   virtual void setObjectiveAndRefresh(double* c) ;
01765 
01767   virtual void getBInvARow(int row, double* z, double * slack=NULL) const ;
01768 
01770   virtual void getBInvRow(int row, double* z) const ;
01771 
01773   virtual void getBInvACol(int col, double* vec) const ;
01774 
01776   virtual void getBInvCol(int col, double* vec) const ;
01777 
01782   virtual void getBasics(int* index) const ;
01784    
01785   //---------------------------------------------------------------------------
01786 
01788 
01789 
01790     OsiSolverInterface(); 
01791     
01797     virtual OsiSolverInterface * clone(bool copyData = true) const = 0;
01798   
01800     OsiSolverInterface(const OsiSolverInterface &);
01801   
01803     OsiSolverInterface & operator=(const OsiSolverInterface& rhs);
01804   
01806     virtual ~OsiSolverInterface ();
01807 
01814     virtual void reset();
01816 
01817   //---------------------------------------------------------------------------
01818 
01819 protected:
01821 
01822 
01823     virtual void applyRowCut( const OsiRowCut & rc ) = 0;
01824 
01826     virtual void applyColCut( const OsiColCut & cc ) = 0;
01827 
01830     inline void
01831     convertBoundToSense(const double lower, const double upper,
01832                         char& sense, double& right, double& range) const;
01835     inline void
01836     convertSenseToBound(const char sense, const double right,
01837                         const double range,
01838                         double& lower, double& upper) const;
01841     template <class T> inline T
01842     forceIntoRange(const T value, const T lower, const T upper) const {
01843       return value < lower ? lower : (value > upper ? upper : value);
01844     }
01851     void setInitialData();
01853 
01855 
01856 
01857     OsiRowCutDebugger * rowCutDebugger_;
01858    // Why not just make useful stuff protected?
01860   CoinMessageHandler * handler_;
01866   bool defaultHandler_;
01868   CoinMessages messages_;
01870   int numberIntegers_;
01872   int numberObjects_;
01873 
01875   OsiObject ** object_;
01881   mutable char * columnType_;
01882 
01884   
01885   //---------------------------------------------------------------------------
01886 
01887 private:
01889 
01890 
01891     OsiAuxInfo * appDataEtc_;
01893     int intParam_[OsiLastIntParam];
01895     double dblParam_[OsiLastDblParam];
01897     std::string strParam_[OsiLastStrParam];
01899     bool hintParam_[OsiLastHintParam];
01901     OsiHintStrength hintStrength_[OsiLastHintParam];
01904     CoinWarmStart* ws_;
01906     std::vector<double> strictColSolution_;
01907 
01909     OsiNameVec rowNames_ ;
01911     OsiNameVec colNames_ ;
01913     std::string objName_ ;
01914 
01916 };
01917 
01918 //#############################################################################
01926 int
01927 OsiSolverInterfaceCommonUnitTest(
01928    const OsiSolverInterface* emptySi,
01929    const std::string & mpsDir,
01930    const std::string & netlibDir);
01931 
01932 //#############################################################################
01935 int
01936 OsiSolverInterfaceMpsUnitTest(
01937    const std::vector<OsiSolverInterface*> & vecSiP,
01938    const std::string & mpsDir);
01939 
01940 //#############################################################################
01943 inline void
01944 OsiSolverInterface::convertBoundToSense(const double lower, const double upper,
01945                                         char& sense, double& right,
01946                                         double& range) const
01947 {
01948   double inf = getInfinity();
01949   range = 0.0;
01950   if (lower > -inf) {
01951     if (upper < inf) {
01952       right = upper;
01953       if (upper==lower) {
01954         sense = 'E';
01955       } else {
01956         sense = 'R';
01957         range = upper - lower;
01958       }
01959     } else {
01960       sense = 'G';
01961       right = lower;
01962     }
01963   } else {
01964     if (upper < inf) {
01965       sense = 'L';
01966       right = upper;
01967     } else {
01968       sense = 'N';
01969       right = 0.0;
01970     }
01971   }
01972 }
01973 
01974 //-----------------------------------------------------------------------------
01977 inline void
01978 OsiSolverInterface::convertSenseToBound(const char sense, const double right,
01979                                         const double range,
01980                                         double& lower, double& upper) const
01981 {
01982   double inf=getInfinity();
01983   switch (sense) {
01984   case 'E':
01985     lower = upper = right;
01986     break;
01987   case 'L':
01988     lower = -inf;
01989     upper = right;
01990     break;
01991   case 'G':
01992     lower = right;
01993     upper = inf;
01994     break;
01995   case 'R':
01996     lower = right - range;
01997     upper = right;
01998     break;
01999   case 'N':
02000     lower = -inf;
02001     upper = inf;
02002     break;
02003   }
02004 }
02005 
02006 #endif

Generated on Mon Jul 5 03:13:39 2010 by  doxygen 1.4.7