|
Osi
trunk
|
00001 // Copyright (C) 2000, International Business Machines 00002 // Corporation and others. All Rights Reserved. 00003 // This code is licensed under the terms of the Eclipse Public License (EPL). 00004 00005 #ifndef OsiSolverInterface_H 00006 #define OsiSolverInterface_H 00007 00008 #include <cstdlib> 00009 #include <string> 00010 #include <vector> 00011 00012 #include "CoinTypes.hpp" 00013 #include "CoinMessageHandler.hpp" 00014 #include "CoinPackedVectorBase.hpp" 00015 #include "CoinPackedMatrix.hpp" 00016 #include "CoinWarmStart.hpp" 00017 #include "CoinFinite.hpp" 00018 #include "CoinError.hpp" 00019 00020 #include "OsiCollections.hpp" 00021 #include "OsiSolverParameters.hpp" 00022 00023 class CoinSnapshot; 00024 class CoinLpIO; 00025 class CoinMpsIO; 00026 00027 class OsiCuts; 00028 class OsiAuxInfo; 00029 class OsiRowCut; 00030 class OsiRowCutDebugger; 00031 class CoinSet; 00032 class CoinBuild; 00033 class CoinModel; 00034 class OsiSolverBranch; 00035 class OsiSolverResult; 00036 class OsiObject; 00037 00038 00039 //############################################################################# 00040 00062 class OsiSolverInterface { 00063 friend void OsiSolverInterfaceCommonUnitTest( 00064 const OsiSolverInterface* emptySi, 00065 const std::string & mpsDir, 00066 const std::string & netlibDir); 00067 friend void OsiSolverInterfaceMpsUnitTest( 00068 const std::vector<OsiSolverInterface*> & vecSiP, 00069 const std::string & mpsDir); 00070 00071 public: 00072 00074 class ApplyCutsReturnCode { 00075 friend class OsiSolverInterface; 00076 friend class OsiClpSolverInterface; 00077 friend class OsiGrbSolverInterface; 00078 00079 public: 00081 00082 00083 ApplyCutsReturnCode(): 00084 intInconsistent_(0), 00085 extInconsistent_(0), 00086 infeasible_(0), 00087 ineffective_(0), 00088 applied_(0) {} 00090 ApplyCutsReturnCode(const ApplyCutsReturnCode & rhs): 00091 intInconsistent_(rhs.intInconsistent_), 00092 extInconsistent_(rhs.extInconsistent_), 00093 infeasible_(rhs.infeasible_), 00094 ineffective_(rhs.ineffective_), 00095 applied_(rhs.applied_) {} 00097 ApplyCutsReturnCode & operator=(const ApplyCutsReturnCode& rhs) 00098 { 00099 if (this != &rhs) { 00100 intInconsistent_ = rhs.intInconsistent_; 00101 extInconsistent_ = rhs.extInconsistent_; 00102 infeasible_ = rhs.infeasible_; 00103 ineffective_ = rhs.ineffective_; 00104 applied_ = rhs.applied_; 00105 } 00106 return *this; 00107 } 00109 ~ApplyCutsReturnCode(){} 00111 00114 00115 inline int getNumInconsistent() const 00116 {return intInconsistent_;} 00118 inline int getNumInconsistentWrtIntegerModel() const 00119 {return extInconsistent_;} 00121 inline int getNumInfeasible() const 00122 {return infeasible_;} 00124 inline int getNumIneffective() const 00125 {return ineffective_;} 00127 inline int getNumApplied() const 00128 {return applied_;} 00130 00131 private: 00134 00135 inline void incrementInternallyInconsistent(){intInconsistent_++;} 00137 inline void incrementExternallyInconsistent(){extInconsistent_++;} 00139 inline void incrementInfeasible(){infeasible_++;} 00141 inline void incrementIneffective(){ineffective_++;} 00143 inline void incrementApplied(){applied_++;} 00145 00147 00148 00149 int intInconsistent_; 00151 int extInconsistent_; 00153 int infeasible_; 00155 int ineffective_; 00157 int applied_; 00159 }; 00160 00161 //--------------------------------------------------------------------------- 00162 00164 00165 00166 virtual void initialSolve() = 0; 00167 00173 virtual void resolve() = 0; 00174 00176 virtual void branchAndBound() = 0; 00177 00178 #ifdef CBC_NEXT_VERSION 00179 /* 00180 Would it make sense to collect all of these routines in a `MIP Helper' 00181 section? It'd make it easier for users and implementors to find them. 00182 */ 00200 virtual int solveBranches(int depth,const OsiSolverBranch * branch, 00201 OsiSolverResult * result, 00202 int & numberSolves, int & numberIterations, 00203 bool forceBranch=false); 00204 #endif 00205 00206 00207 //--------------------------------------------------------------------------- 00265 00266 virtual bool setIntParam(OsiIntParam key, int value) { 00267 if (key == OsiLastIntParam) return (false) ; 00268 intParam_[key] = value; 00269 return true; 00270 } 00272 virtual bool setDblParam(OsiDblParam key, double value) { 00273 if (key == OsiLastDblParam) return (false) ; 00274 dblParam_[key] = value; 00275 return true; 00276 } 00278 virtual bool setStrParam(OsiStrParam key, const std::string & value) { 00279 if (key == OsiLastStrParam) return (false) ; 00280 strParam_[key] = value; 00281 return true; 00282 } 00294 virtual bool setHintParam(OsiHintParam key, bool yesNo=true, 00295 OsiHintStrength strength=OsiHintTry, 00296 void * /*otherInformation*/ = NULL) { 00297 if (key==OsiLastHintParam) 00298 return false; 00299 hintParam_[key] = yesNo; 00300 hintStrength_[key] = strength; 00301 if (strength == OsiForceDo) 00302 throw CoinError("OsiForceDo illegal", 00303 "setHintParam", "OsiSolverInterface"); 00304 return true; 00305 } 00307 virtual bool getIntParam(OsiIntParam key, int& value) const { 00308 if (key == OsiLastIntParam) return (false) ; 00309 value = intParam_[key]; 00310 return true; 00311 } 00313 virtual bool getDblParam(OsiDblParam key, double& value) const { 00314 if (key == OsiLastDblParam) return (false) ; 00315 value = dblParam_[key]; 00316 return true; 00317 } 00319 virtual bool getStrParam(OsiStrParam key, std::string& value) const { 00320 if (key == OsiLastStrParam) return (false) ; 00321 value = strParam_[key]; 00322 return true; 00323 } 00333 virtual bool getHintParam(OsiHintParam key, bool& yesNo, 00334 OsiHintStrength& strength, 00335 void *& otherInformation) const { 00336 if (key==OsiLastHintParam) 00337 return false; 00338 yesNo = hintParam_[key]; 00339 strength = hintStrength_[key]; 00340 otherInformation=NULL; 00341 return true; 00342 } 00347 virtual bool getHintParam(OsiHintParam key, bool& yesNo, 00348 OsiHintStrength& strength) const { 00349 if (key==OsiLastHintParam) 00350 return false; 00351 yesNo = hintParam_[key]; 00352 strength = hintStrength_[key]; 00353 return true; 00354 } 00359 virtual bool getHintParam(OsiHintParam key, bool& yesNo) const { 00360 if (key==OsiLastHintParam) 00361 return false; 00362 yesNo = hintParam_[key]; 00363 return true; 00364 } 00371 void copyParameters(OsiSolverInterface & rhs); 00372 00386 inline double getIntegerTolerance() const 00387 { return dblParam_[OsiPrimalTolerance];} 00389 00390 //--------------------------------------------------------------------------- 00392 00393 00394 virtual bool isAbandoned() const = 0; 00396 virtual bool isProvenOptimal() const = 0; 00398 virtual bool isProvenPrimalInfeasible() const = 0; 00400 virtual bool isProvenDualInfeasible() const = 0; 00402 virtual bool isPrimalObjectiveLimitReached() const; 00404 virtual bool isDualObjectiveLimitReached() const; 00406 virtual bool isIterationLimitReached() const = 0; 00408 00409 //--------------------------------------------------------------------------- 00427 virtual CoinWarmStart *getEmptyWarmStart () const = 0 ; 00428 00435 virtual CoinWarmStart* getWarmStart() const = 0; 00444 virtual CoinWarmStart* getPointerToWarmStart(bool & mustDelete) ; 00445 00454 virtual bool setWarmStart(const CoinWarmStart* warmstart) = 0; 00456 00457 //--------------------------------------------------------------------------- 00478 00479 virtual void markHotStart(); 00481 virtual void solveFromHotStart(); 00483 virtual void unmarkHotStart(); 00485 00486 //--------------------------------------------------------------------------- 00497 00498 virtual int getNumCols() const = 0; 00499 00501 virtual int getNumRows() const = 0; 00502 00504 virtual int getNumElements() const = 0; 00505 00507 virtual int getNumIntegers() const ; 00508 00510 virtual const double * getColLower() const = 0; 00511 00513 virtual const double * getColUpper() const = 0; 00514 00525 virtual const char * getRowSense() const = 0; 00526 00540 virtual const double * getRightHandSide() const = 0; 00541 00551 virtual const double * getRowRange() const = 0; 00552 00554 virtual const double * getRowLower() const = 0; 00555 00557 virtual const double * getRowUpper() const = 0; 00558 00562 virtual const double * getObjCoefficients() const = 0; 00563 00569 virtual double getObjSense() const = 0; 00570 00572 virtual bool isContinuous(int colIndex) const = 0; 00573 00575 virtual bool isBinary(int colIndex) const; 00576 00581 virtual bool isInteger(int colIndex) const; 00582 00584 virtual bool isIntegerNonBinary(int colIndex) const; 00585 00587 virtual bool isFreeBinary(int colIndex) const; 00588 00593 inline const char *columnType(bool refresh=false) const 00594 { return getColType(refresh); } 00595 00607 virtual const char * getColType(bool refresh=false) const; 00608 00610 virtual const CoinPackedMatrix * getMatrixByRow() const = 0; 00611 00613 virtual const CoinPackedMatrix * getMatrixByCol() const = 0; 00614 00620 virtual CoinPackedMatrix * getMutableMatrixByRow() const {return NULL;} 00621 00627 virtual CoinPackedMatrix * getMutableMatrixByCol() const {return NULL;} 00628 00630 virtual double getInfinity() const = 0; 00632 00635 00636 virtual const double * getColSolution() const = 0; 00637 00641 virtual const double * getStrictColSolution(); 00642 00644 virtual const double * getRowPrice() const = 0; 00645 00647 virtual const double * getReducedCost() const = 0; 00648 00654 virtual const double * getRowActivity() const = 0; 00655 00657 virtual double getObjValue() const = 0; 00658 00662 virtual int getIterationCount() const = 0; 00663 00686 virtual std::vector<double*> getDualRays(int maxNumRays, 00687 bool fullRay = false) const = 0; 00688 00704 virtual std::vector<double*> getPrimalRays(int maxNumRays) const = 0; 00705 00708 virtual OsiVectorInt getFractionalIndices(const double etol=1.e-05) 00709 const; 00711 00712 //------------------------------------------------------------------------- 00725 virtual void setObjCoeff( int elementIndex, double elementValue ) = 0; 00726 00728 virtual void setObjCoeffSet(const int* indexFirst, 00729 const int* indexLast, 00730 const double* coeffList); 00731 00737 virtual void setObjective(const double * array); 00738 00749 virtual void setObjSense(double s) = 0; 00750 00751 00754 virtual void setColLower( int elementIndex, double elementValue ) = 0; 00755 00761 virtual void setColLower(const double * array); 00762 00765 virtual void setColUpper( int elementIndex, double elementValue ) = 0; 00766 00772 virtual void setColUpper(const double * array); 00773 00774 00778 virtual void setColBounds( int elementIndex, 00779 double lower, double upper ) { 00780 setColLower(elementIndex, lower); 00781 setColUpper(elementIndex, upper); 00782 } 00783 00790 virtual void setColSetBounds(const int* indexFirst, 00791 const int* indexLast, 00792 const double* boundList); 00793 00796 virtual void setRowLower( int elementIndex, double elementValue ) = 0; 00797 00800 virtual void setRowUpper( int elementIndex, double elementValue ) = 0; 00801 00805 virtual void setRowBounds( int elementIndex, 00806 double lower, double upper ) { 00807 setRowLower(elementIndex, lower); 00808 setRowUpper(elementIndex, upper); 00809 } 00810 00817 virtual void setRowSetBounds(const int* indexFirst, 00818 const int* indexLast, 00819 const double* boundList); 00820 00821 00823 virtual void setRowType(int index, char sense, double rightHandSide, 00824 double range) = 0; 00825 00830 virtual void setRowSetTypes(const int* indexFirst, 00831 const int* indexLast, 00832 const char* senseList, 00833 const double* rhsList, 00834 const double* rangeList); 00835 00845 virtual void setColSolution(const double *colsol) = 0; 00846 00856 virtual void setRowPrice(const double * rowprice) = 0; 00857 00866 virtual int reducedCostFix(double gap, bool justInteger=true); 00868 00869 //------------------------------------------------------------------------- 00873 virtual void setContinuous(int index) = 0; 00875 virtual void setInteger(int index) = 0; 00878 virtual void setContinuous(const int* indices, int len); 00881 virtual void setInteger(const int* indices, int len); 00883 //------------------------------------------------------------------------- 00884 00885 //------------------------------------------------------------------------- 00886 00888 typedef std::vector<std::string> OsiNameVec ; 00889 00910 00920 virtual std::string dfltRowColName(char rc, 00921 int ndx, unsigned digits = 7) const ; 00922 00925 virtual std::string getObjName (unsigned maxLen = static_cast<unsigned>(std::string::npos)) const ; 00926 00929 virtual inline void setObjName (std::string name) 00930 { objName_ = name ; } 00931 00938 virtual std::string getRowName(int rowIndex, 00939 unsigned maxLen = static_cast<unsigned>(std::string::npos)) const ; 00940 00952 virtual const OsiNameVec &getRowNames() ; 00953 00959 virtual void setRowName(int ndx, std::string name) ; 00960 00967 virtual void setRowNames(OsiNameVec &srcNames, 00968 int srcStart, int len, int tgtStart) ; 00969 00975 virtual void deleteRowNames(int tgtStart, int len) ; 00976 00983 virtual std::string getColName(int colIndex, 00984 unsigned maxLen = static_cast<unsigned>(std::string::npos)) const ; 00985 00995 virtual const OsiNameVec &getColNames() ; 00996 01002 virtual void setColName(int ndx, std::string name) ; 01003 01010 virtual void setColNames(OsiNameVec &srcNames, 01011 int srcStart, int len, int tgtStart) ; 01012 01018 virtual void deleteColNames(int tgtStart, int len) ; 01019 01020 01027 void setRowColNames(const CoinMpsIO &mps) ; 01028 01034 void setRowColNames(CoinModel &mod) ; 01035 01042 void setRowColNames(CoinLpIO &mod) ; 01043 01045 //------------------------------------------------------------------------- 01046 01047 //------------------------------------------------------------------------- 01053 01055 virtual void addCol(const CoinPackedVectorBase& vec, 01056 const double collb, const double colub, 01057 const double obj) = 0; 01058 01064 virtual void addCol(const CoinPackedVectorBase& vec, 01065 const double collb, const double colub, 01066 const double obj, std::string name) ; 01067 01069 virtual void addCol(int numberElements, 01070 const int* rows, const double* elements, 01071 const double collb, const double colub, 01072 const double obj) ; 01073 01079 virtual void addCol(int numberElements, 01080 const int* rows, const double* elements, 01081 const double collb, const double colub, 01082 const double obj, std::string name) ; 01083 01089 virtual void addCols(const int numcols, 01090 const CoinPackedVectorBase * const * cols, 01091 const double* collb, const double* colub, 01092 const double* obj); 01093 01099 virtual void addCols(const int numcols, const int* columnStarts, 01100 const int* rows, const double* elements, 01101 const double* collb, const double* colub, 01102 const double* obj); 01103 01105 void addCols(const CoinBuild & buildObject); 01106 01112 int addCols(CoinModel & modelObject); 01113 01114 #if 0 01115 01116 virtual void addCols(const CoinPackedMatrix& matrix, 01117 const double* collb, const double* colub, 01118 const double* obj); 01119 #endif 01120 01127 virtual void deleteCols(const int num, const int * colIndices) = 0; 01128 01130 virtual void addRow(const CoinPackedVectorBase& vec, 01131 const double rowlb, const double rowub) = 0; 01132 01138 virtual void addRow(const CoinPackedVectorBase& vec, 01139 const double rowlb, const double rowub, 01140 std::string name) ; 01141 01143 virtual void addRow(const CoinPackedVectorBase& vec, 01144 const char rowsen, const double rowrhs, 01145 const double rowrng) = 0; 01146 01152 virtual void addRow(const CoinPackedVectorBase& vec, 01153 const char rowsen, const double rowrhs, 01154 const double rowrng, std::string name) ; 01155 01160 virtual void addRow(int numberElements, 01161 const int *columns, const double *element, 01162 const double rowlb, const double rowub) ; 01163 01169 virtual void addRows(const int numrows, 01170 const CoinPackedVectorBase * const * rows, 01171 const double* rowlb, const double* rowub); 01172 01178 virtual void addRows(const int numrows, 01179 const CoinPackedVectorBase * const * rows, 01180 const char* rowsen, const double* rowrhs, 01181 const double* rowrng); 01182 01188 virtual void addRows(const int numrows, const int *rowStarts, 01189 const int *columns, const double *element, 01190 const double *rowlb, const double *rowub); 01191 01193 void addRows(const CoinBuild &buildObject); 01194 01203 int addRows(CoinModel &modelObject); 01204 01205 #if 0 01206 01207 virtual void addRows(const CoinPackedMatrix& matrix, 01208 const double* rowlb, const double* rowub); 01210 virtual void addRows(const CoinPackedMatrix& matrix, 01211 const char* rowsen, const double* rowrhs, 01212 const double* rowrng); 01213 #endif 01214 01220 virtual void deleteRows(const int num, const int * rowIndices) = 0; 01221 01228 virtual void replaceMatrixOptional(const CoinPackedMatrix & ) {} 01229 01234 virtual void replaceMatrix(const CoinPackedMatrix & ) {abort();} 01235 01240 virtual void saveBaseModel() {} 01241 01255 virtual void restoreBaseModel(int numberRows); 01256 //----------------------------------------------------------------------- 01279 virtual ApplyCutsReturnCode applyCuts(const OsiCuts & cs, 01280 double effectivenessLb = 0.0); 01281 01286 virtual void applyRowCuts(int numberCuts, const OsiRowCut * cuts); 01287 01291 virtual void applyRowCuts(int numberCuts, const OsiRowCut ** cuts); 01292 01294 void deleteBranchingInfo(int numberDeleted, const int * which); 01295 01297 01298 //--------------------------------------------------------------------------- 01299 01317 virtual void loadProblem (const CoinPackedMatrix& matrix, 01318 const double* collb, const double* colub, 01319 const double* obj, 01320 const double* rowlb, const double* rowub) = 0; 01321 01331 virtual void assignProblem (CoinPackedMatrix*& matrix, 01332 double*& collb, double*& colub, double*& obj, 01333 double*& rowlb, double*& rowub) = 0; 01334 01351 virtual void loadProblem (const CoinPackedMatrix& matrix, 01352 const double* collb, const double* colub, 01353 const double* obj, 01354 const char* rowsen, const double* rowrhs, 01355 const double* rowrng) = 0; 01356 01366 virtual void assignProblem (CoinPackedMatrix*& matrix, 01367 double*& collb, double*& colub, double*& obj, 01368 char*& rowsen, double*& rowrhs, 01369 double*& rowrng) = 0; 01370 01383 virtual void loadProblem (const int numcols, const int numrows, 01384 const CoinBigIndex * start, const int* index, 01385 const double* value, 01386 const double* collb, const double* colub, 01387 const double* obj, 01388 const double* rowlb, const double* rowub) = 0; 01389 01402 virtual void loadProblem (const int numcols, const int numrows, 01403 const CoinBigIndex * start, const int* index, 01404 const double* value, 01405 const double* collb, const double* colub, 01406 const double* obj, 01407 const char* rowsen, const double* rowrhs, 01408 const double* rowrng) = 0; 01409 01416 virtual int loadFromCoinModel (CoinModel & modelObject, 01417 bool keepSolution=false); 01418 01424 virtual int readMps (const char *filename, 01425 const char *extension = "mps") ; 01426 01433 virtual int readMps (const char *filename, const char*extension, 01434 int & numberSets, CoinSet ** & sets); 01435 01441 virtual int readGMPL (const char *filename, const char *dataname=NULL); 01442 01449 virtual void writeMps (const char *filename, 01450 const char *extension = "mps", 01451 double objSense=0.0) const = 0; 01452 01466 int writeMpsNative (const char *filename, 01467 const char ** rowNames, const char ** columnNames, 01468 int formatType=0,int numberAcross=2, 01469 double objSense=0.0, int numberSOS=0, 01470 const CoinSet * setInfo=NULL) const ; 01471 01472 /***********************************************************************/ 01473 // Lp files 01474 01494 virtual void writeLp(const char *filename, 01495 const char *extension = "lp", 01496 double epsilon = 1e-5, 01497 int numberAcross = 10, 01498 int decimals = 5, 01499 double objSense = 0.0, 01500 bool useRowNames = true) const; 01501 01506 virtual void writeLp(FILE *fp, 01507 double epsilon = 1e-5, 01508 int numberAcross = 10, 01509 int decimals = 5, 01510 double objSense = 0.0, 01511 bool useRowNames = true) const; 01512 01531 int writeLpNative(const char *filename, 01532 char const * const * const rowNames, 01533 char const * const * const columnNames, 01534 const double epsilon = 1.0e-5, 01535 const int numberAcross = 10, 01536 const int decimals = 5, 01537 const double objSense = 0.0, 01538 const bool useRowNames = true) const; 01539 01544 int writeLpNative(FILE *fp, 01545 char const * const * const rowNames, 01546 char const * const * const columnNames, 01547 const double epsilon = 1.0e-5, 01548 const int numberAcross = 10, 01549 const int decimals = 5, 01550 const double objSense = 0.0, 01551 const bool useRowNames = true) const; 01552 01555 virtual int readLp(const char *filename, const double epsilon = 1e-5); 01556 01559 int readLp(FILE *fp, const double epsilon = 1e-5); 01560 01562 01563 //--------------------------------------------------------------------------- 01564 01572 int differentModel(OsiSolverInterface & other, 01573 bool ignoreNames=true); 01574 #ifdef COIN_SNAPSHOT 01575 01576 virtual CoinSnapshot * snapshot(bool createArrays=true) const; 01577 #endif 01578 #ifdef COIN_FACTORIZATION_INFO 01579 01580 virtual CoinBigIndex getSizeL() const; 01582 virtual CoinBigIndex getSizeU() const; 01583 #endif 01584 01585 01586 //--------------------------------------------------------------------------- 01587 01597 void setApplicationData (void * appData); 01604 void setAuxiliaryInfo(OsiAuxInfo * auxiliaryInfo); 01605 01607 void * getApplicationData() const; 01609 OsiAuxInfo * getAuxiliaryInfo() const; 01611 //--------------------------------------------------------------------------- 01612 01626 virtual void passInMessageHandler(CoinMessageHandler * handler); 01628 void newLanguage(CoinMessages::Language language); 01629 inline void setLanguage(CoinMessages::Language language) 01630 {newLanguage(language);} 01632 inline CoinMessageHandler * messageHandler() const 01633 {return handler_;} 01635 inline CoinMessages messages() 01636 {return messages_;} 01638 inline CoinMessages * messagesPointer() 01639 {return &messages_;} 01641 inline bool defaultHandler() const 01642 { return defaultHandler_;} 01644 //--------------------------------------------------------------------------- 01659 void findIntegers(bool justCount); 01670 virtual int findIntegersAndSOS(bool justCount); 01672 inline int numberObjects() const { return numberObjects_;} 01674 inline void setNumberObjects(int number) 01675 { numberObjects_=number;} 01676 01678 inline OsiObject ** objects() const { return object_;} 01679 01681 const inline OsiObject * object(int which) const { return object_[which];} 01683 inline OsiObject * modifiableObject(int which) const { return object_[which];} 01684 01686 void deleteObjects(); 01687 01692 void addObjects(int numberObjects, OsiObject ** objects); 01697 double forceFeasible(); 01699 //--------------------------------------------------------------------------- 01700 01712 virtual void activateRowCutDebugger (const char *modelName); 01713 01727 virtual void activateRowCutDebugger(const double *solution, 01728 bool enforceOptimality = true); 01729 01741 const OsiRowCutDebugger *getRowCutDebugger() const; 01742 01750 OsiRowCutDebugger * getRowCutDebuggerAlways() const; 01752 01761 01772 virtual int canDoSimplexInterface() const ; 01774 01782 01791 virtual void enableFactorization() const ; 01792 01794 virtual void disableFactorization() const ; 01795 01806 virtual bool basisIsAvailable() const ; 01807 01809 inline bool optimalBasisIsAvailable() const { return basisIsAvailable() ; } 01810 01834 virtual void getBasisStatus(int* cstat, int* rstat) const ; 01835 01850 virtual int setBasisStatus(const int* cstat, const int* rstat) ; 01851 01857 virtual void getReducedGradient(double* columnReducedCosts, 01858 double* duals, const double* c) const ; 01859 01865 virtual void getBInvARow(int row, double* z, double* slack = NULL) const ; 01866 01868 virtual void getBInvRow(int row, double* z) const ; 01869 01871 virtual void getBInvACol(int col, double* vec) const ; 01872 01874 virtual void getBInvCol(int col, double* vec) const ; 01875 01883 virtual void getBasics(int* index) const ; 01884 01886 01894 01901 virtual void enableSimplexInterface(bool doingPrimal) ; 01902 01904 virtual void disableSimplexInterface() ; 01912 virtual int pivot(int colIn, int colOut, int outStatus) ; 01913 01925 virtual int primalPivotResult(int colIn, int sign, 01926 int& colOut, int& outStatus, 01927 double& t, CoinPackedVector* dx); 01928 01935 virtual int dualPivotResult(int& colIn, int& sign, 01936 int colOut, int outStatus, 01937 double& t, CoinPackedVector* dx) ; 01939 01940 //--------------------------------------------------------------------------- 01941 01943 01944 01945 OsiSolverInterface(); 01946 01952 virtual OsiSolverInterface * clone(bool copyData = true) const = 0; 01953 01955 OsiSolverInterface(const OsiSolverInterface &); 01956 01958 OsiSolverInterface & operator=(const OsiSolverInterface& rhs); 01959 01961 virtual ~OsiSolverInterface (); 01962 01969 virtual void reset(); 01971 01972 //--------------------------------------------------------------------------- 01973 01974 protected: 01976 01977 01978 virtual void applyRowCut( const OsiRowCut & rc ) = 0; 01979 01981 virtual void applyColCut( const OsiColCut & cc ) = 0; 01982 01985 inline void 01986 convertBoundToSense(const double lower, const double upper, 01987 char& sense, double& right, double& range) const; 01990 inline void 01991 convertSenseToBound(const char sense, const double right, 01992 const double range, 01993 double& lower, double& upper) const; 01996 template <class T> inline T 01997 forceIntoRange(const T value, const T lower, const T upper) const { 01998 return value < lower ? lower : (value > upper ? upper : value); 01999 } 02006 void setInitialData(); 02008 02010 02011 02016 mutable OsiRowCutDebugger * rowCutDebugger_; 02017 // Why not just make useful stuff protected? 02019 CoinMessageHandler * handler_; 02025 bool defaultHandler_; 02027 CoinMessages messages_; 02029 int numberIntegers_; 02031 int numberObjects_; 02032 02034 OsiObject ** object_; 02040 mutable char * columnType_; 02041 02043 02044 //--------------------------------------------------------------------------- 02045 02046 private: 02048 02049 02050 OsiAuxInfo * appDataEtc_; 02052 int intParam_[OsiLastIntParam]; 02054 double dblParam_[OsiLastDblParam]; 02056 std::string strParam_[OsiLastStrParam]; 02058 bool hintParam_[OsiLastHintParam]; 02060 OsiHintStrength hintStrength_[OsiLastHintParam]; 02063 CoinWarmStart* ws_; 02065 std::vector<double> strictColSolution_; 02066 02068 OsiNameVec rowNames_ ; 02070 OsiNameVec colNames_ ; 02072 std::string objName_ ; 02073 02075 }; 02076 02077 //############################################################################# 02080 inline void 02081 OsiSolverInterface::convertBoundToSense(const double lower, const double upper, 02082 char& sense, double& right, 02083 double& range) const 02084 { 02085 double inf = getInfinity(); 02086 range = 0.0; 02087 if (lower > -inf) { 02088 if (upper < inf) { 02089 right = upper; 02090 if (upper==lower) { 02091 sense = 'E'; 02092 } else { 02093 sense = 'R'; 02094 range = upper - lower; 02095 } 02096 } else { 02097 sense = 'G'; 02098 right = lower; 02099 } 02100 } else { 02101 if (upper < inf) { 02102 sense = 'L'; 02103 right = upper; 02104 } else { 02105 sense = 'N'; 02106 right = 0.0; 02107 } 02108 } 02109 } 02110 02111 //----------------------------------------------------------------------------- 02114 inline void 02115 OsiSolverInterface::convertSenseToBound(const char sense, const double right, 02116 const double range, 02117 double& lower, double& upper) const 02118 { 02119 double inf=getInfinity(); 02120 switch (sense) { 02121 case 'E': 02122 lower = upper = right; 02123 break; 02124 case 'L': 02125 lower = -inf; 02126 upper = right; 02127 break; 02128 case 'G': 02129 lower = right; 02130 upper = inf; 02131 break; 02132 case 'R': 02133 lower = right - range; 02134 upper = right; 02135 break; 02136 case 'N': 02137 lower = -inf; 02138 upper = inf; 02139 break; 02140 } 02141 } 02142 02143 #endif
1.7.6.1