/home/coin/SVN-release/Cbc-2.0.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 void OsiSolverInterfaceCommonUnitTest(
00061       const OsiSolverInterface* emptySi,
00062       const std::string & mpsDir,
00063       const std::string & netlibDir);
00064    friend void 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 
00075   public:
00077 
00078 
00079       ApplyCutsReturnCode():
00080          intInconsistent_(0),
00081          extInconsistent_(0),
00082          infeasible_(0),
00083          ineffective_(0),
00084          applied_(0) {} 
00086       ApplyCutsReturnCode(const ApplyCutsReturnCode & rhs):
00087          intInconsistent_(rhs.intInconsistent_),
00088          extInconsistent_(rhs.extInconsistent_),
00089          infeasible_(rhs.infeasible_),
00090          ineffective_(rhs.ineffective_),
00091          applied_(rhs.applied_) {} 
00093       ApplyCutsReturnCode & operator=(const ApplyCutsReturnCode& rhs)
00094       { 
00095         if (this != &rhs) { 
00096           intInconsistent_ = rhs.intInconsistent_;
00097           extInconsistent_ = rhs.extInconsistent_;
00098           infeasible_      = rhs.infeasible_;
00099           ineffective_     = rhs.ineffective_;
00100           applied_         = rhs.applied_;
00101         }
00102         return *this;
00103       }
00105       ~ApplyCutsReturnCode(){}
00107 
00110 
00111       inline int getNumInconsistent(){return intInconsistent_;}
00113       inline int getNumInconsistentWrtIntegerModel(){return extInconsistent_;}
00115       inline int getNumInfeasible(){return infeasible_;}
00117       inline int getNumIneffective(){return ineffective_;}
00119       inline int getNumApplied(){return applied_;}
00121 
00122   private: 
00125 
00126       inline void incrementInternallyInconsistent(){intInconsistent_++;}
00128       inline void incrementExternallyInconsistent(){extInconsistent_++;}
00130       inline void incrementInfeasible(){infeasible_++;}
00132       inline void incrementIneffective(){ineffective_++;}
00134       inline void incrementApplied(){applied_++;}
00136 
00138 
00139 
00140       int intInconsistent_;
00142       int extInconsistent_;
00144       int infeasible_;
00146       int ineffective_;
00148       int applied_;
00150   };
00151 
00152   //---------------------------------------------------------------------------
00153 
00155 
00156 
00157     virtual void initialSolve() = 0; 
00158 
00160     virtual void resolve() = 0;
00161 
00163     virtual void branchAndBound() = 0;
00164 
00165 #ifdef CBC_NEXT_VERSION
00166 
00183     virtual int solveBranches(int depth,const OsiSolverBranch * branch,
00184                               OsiSolverResult * result,
00185                               int & numberSolves, int & numberIterations,
00186                               bool forceBranch=false);
00187 #endif
00188 
00189 
00190   //---------------------------------------------------------------------------
00248     // Set an integer parameter
00249     virtual bool setIntParam(OsiIntParam key, int value) {
00250       if (key == OsiLastIntParam) return (false) ;
00251       intParam_[key] = value;
00252       return true;
00253     }
00254     // Set an double parameter
00255     virtual bool setDblParam(OsiDblParam key, double value) {
00256       if (key == OsiLastDblParam) return (false) ;
00257       dblParam_[key] = value;
00258       return true;
00259     }
00260     // Set an string parameter
00261     virtual bool setStrParam(OsiStrParam key, const std::string & value) {
00262       if (key == OsiLastStrParam) return (false) ;
00263       strParam_[key] = value;
00264       return true;
00265     }
00266     // Set a hint parameter
00267     virtual bool setHintParam(OsiHintParam key, bool yesNo=true,
00268                               OsiHintStrength strength=OsiHintTry,
00269                               void * otherInformation=NULL) {
00270       if (key==OsiLastHintParam)
00271         return false; 
00272       hintParam_[key] = yesNo;
00273       hintStrength_[key] = strength;
00274       if (strength == OsiForceDo)
00275         throw CoinError("OsiForceDo illegal",
00276                         "setHintParam", "OsiSolverInterface");
00277       return true;
00278     }
00279     // Get an integer parameter
00280     virtual bool getIntParam(OsiIntParam key, int& value) const {
00281       if (key == OsiLastIntParam) return (false) ;
00282       value = intParam_[key];
00283       return true;
00284     }
00285     // Get an double parameter
00286     virtual bool getDblParam(OsiDblParam key, double& value) const {
00287       if (key == OsiLastDblParam) return (false) ;
00288       value = dblParam_[key];
00289       return true;
00290     }
00294     inline double getIntegerTolerance() const
00295     { return dblParam_[OsiPrimalTolerance];}
00296     // Get a string parameter
00297     virtual bool getStrParam(OsiStrParam key, std::string& value) const {
00298       if (key == OsiLastStrParam) return (false) ;
00299       value = strParam_[key];
00300       return true;
00301     }
00302     // get a hint parameter
00303     virtual bool getHintParam(OsiHintParam key, bool& yesNo,
00304                               OsiHintStrength& strength,
00305                               void *& otherInformation) const {
00306       if (key==OsiLastHintParam)
00307         return false; 
00308       yesNo = hintParam_[key];
00309       strength = hintStrength_[key];
00310       otherInformation=NULL;
00311       return true;
00312     }
00313     // get a hint parameter (less information)
00314     virtual bool getHintParam(OsiHintParam key, bool& yesNo,
00315                               OsiHintStrength& strength) const {
00316       if (key==OsiLastHintParam)
00317         return false; 
00318       yesNo = hintParam_[key];
00319       strength = hintStrength_[key];
00320       return true;
00321     }
00322     // get a hint parameter (even less information)
00323     virtual bool getHintParam(OsiHintParam key, bool& yesNo) const {
00324       if (key==OsiLastHintParam)
00325         return false; 
00326       yesNo = hintParam_[key];
00327       return true;
00328     }
00329     // copy all parameters in this section from one solver to another
00330     void copyParameters(OsiSolverInterface & rhs);
00332 
00333   //---------------------------------------------------------------------------
00335 
00336 
00337     virtual bool isAbandoned() const = 0;
00339     virtual bool isProvenOptimal() const = 0;
00341     virtual bool isProvenPrimalInfeasible() const = 0;
00343     virtual bool isProvenDualInfeasible() const = 0;
00345     virtual bool isPrimalObjectiveLimitReached() const = 0;
00347     virtual bool isDualObjectiveLimitReached() const = 0;
00349     virtual bool isIterationLimitReached() const = 0;
00351 
00352   //---------------------------------------------------------------------------
00370     virtual CoinWarmStart *getEmptyWarmStart () const = 0 ;
00371 
00378     virtual CoinWarmStart* getWarmStart() const = 0;
00379 
00387     virtual bool setWarmStart(const CoinWarmStart* warmstart) = 0;
00389 
00390   //---------------------------------------------------------------------------
00411 
00412     virtual void markHotStart();
00414     virtual void solveFromHotStart();
00416     virtual void unmarkHotStart();
00418 
00419   //---------------------------------------------------------------------------
00430 
00431     virtual int getNumCols() const = 0;
00432 
00434     virtual int getNumRows() const = 0;
00435 
00437     virtual int getNumElements() const = 0;
00438 
00440     virtual int getNumIntegers() const ;
00441 
00443     virtual const double * getColLower() const = 0;
00444 
00446     virtual const double * getColUpper() const = 0;
00447 
00457     virtual const char * getRowSense() const = 0;
00458 
00471     virtual const double * getRightHandSide() const = 0;
00472 
00481     virtual const double * getRowRange() const = 0;
00482 
00484     virtual const double * getRowLower() const = 0;
00485 
00487     virtual const double * getRowUpper() const = 0;
00488 
00490     virtual const double * getObjCoefficients() const = 0;
00491 
00493     virtual double getObjSense() const = 0;
00494 
00496     virtual bool isContinuous(int colIndex) const = 0;
00497 
00499     virtual bool isBinary(int colIndex) const;
00500 
00505     virtual bool isInteger(int colIndex) const;
00506 
00508     virtual bool isIntegerNonBinary(int colIndex) const;
00509 
00511     virtual bool isFreeBinary(int colIndex) const; 
00512   
00514     virtual const CoinPackedMatrix * getMatrixByRow() const = 0;
00515 
00517     virtual const CoinPackedMatrix * getMatrixByCol() const = 0;
00518 
00520     virtual CoinPackedMatrix * getMutableMatrixByRow() const {return NULL;}
00521 
00523     virtual CoinPackedMatrix * getMutableMatrixByCol() const {return NULL;}
00524 
00526     virtual double getInfinity() const = 0;
00528     
00531 
00532     virtual const double * getColSolution() const = 0;
00533 
00535     virtual const double * getRowPrice() const = 0;
00536 
00538     virtual const double * getReducedCost() const = 0;
00539 
00542     virtual const double * getRowActivity() const = 0;
00543 
00545     virtual double getObjValue() const = 0;
00546 
00549     virtual int getIterationCount() const = 0;
00550 
00564     virtual std::vector<double*> getDualRays(int maxNumRays) const = 0;
00576     virtual std::vector<double*> getPrimalRays(int maxNumRays) const = 0;
00577 
00580     virtual OsiVectorInt getFractionalIndices(const double etol=1.e-05)
00581       const;
00583 
00584   //-------------------------------------------------------------------------
00597     virtual void setObjCoeff( int elementIndex, double elementValue ) = 0;
00598 
00600     virtual void setObjCoeffSet(const int* indexFirst,
00601                                 const int* indexLast,
00602                                 const double* coeffList);
00603 
00606     virtual void setColLower( int elementIndex, double elementValue ) = 0;
00607     
00610     virtual void setColUpper( int elementIndex, double elementValue ) = 0;
00611     
00615     virtual void setColBounds( int elementIndex,
00616                                double lower, double upper ) {
00617        setColLower(elementIndex, lower);
00618        setColUpper(elementIndex, upper);
00619     }
00620   
00627     virtual void setColSetBounds(const int* indexFirst,
00628                                  const int* indexLast,
00629                                  const double* boundList);
00630     
00633     virtual void setRowLower( int elementIndex, double elementValue ) = 0;
00634     
00637     virtual void setRowUpper( int elementIndex, double elementValue ) = 0;
00638   
00642     virtual void setRowBounds( int elementIndex,
00643                                double lower, double upper ) {
00644        setRowLower(elementIndex, lower);
00645        setRowUpper(elementIndex, upper);
00646     }
00647   
00649     virtual void setRowType(int index, char sense, double rightHandSide,
00650                             double range) = 0;
00651   
00656     virtual void setRowSetBounds(const int* indexFirst,
00657                                  const int* indexLast,
00658                                  const double* boundList);
00659   
00664     virtual void setRowSetTypes(const int* indexFirst,
00665                                 const int* indexLast,
00666                                 const char* senseList,
00667                                 const double* rhsList,
00668                                 const double* rangeList);
00669 
00672   virtual void setObjSense(double s) = 0;
00673   
00683   virtual void setColSolution(const double *colsol) = 0;
00684 
00695  virtual void setRowPrice(const double * rowprice) = 0;
00696 
00701   virtual void setObjective(const double * array);
00702 
00707   virtual void setColLower(const double * array);
00708 
00713   virtual void setColUpper(const double * array);
00717   virtual int reducedCostFix(double gap, bool justInteger=true);
00719 
00720   //-------------------------------------------------------------------------
00724     virtual void setContinuous(int index) = 0;
00726     virtual void setInteger(int index) = 0;
00729     virtual void setContinuous(const int* indices, int len);
00732     virtual void setInteger(const int* indices, int len);
00734   //-------------------------------------------------------------------------
00735 
00736   //-------------------------------------------------------------------------
00737 
00739     typedef std::vector<std::string> OsiNameVec ;
00740 
00761 
00771     virtual std::string dfltRowColName(char rc,
00772                                  int ndx, unsigned digits = 7) const ;
00773 
00776     virtual std::string getObjName (unsigned maxLen = (unsigned)std::string::npos) const ;
00777 
00780     virtual inline void setObjName (std::string name)
00781     { objName_ = name ; }
00782 
00789     virtual std::string getRowName(int rowIndex,
00790                                    unsigned maxLen = (unsigned)std::string::npos) const ;
00791 
00803     virtual const OsiNameVec &getRowNames() ;
00804 
00810     virtual void setRowName(int ndx, std::string name) ;
00811 
00818     virtual void setRowNames(OsiNameVec &srcNames,
00819                      int srcStart, int len, int tgtStart) ;
00820 
00826     virtual void deleteRowNames(int tgtStart, int len) ;
00827   
00834     virtual std::string getColName(int colIndex,
00835                                    unsigned maxLen = (unsigned)std::string::npos) const ;
00836 
00846     virtual const OsiNameVec &getColNames() ;
00847 
00853     virtual void setColName(int ndx, std::string name) ;
00854 
00861     virtual void setColNames(OsiNameVec &srcNames,
00862                      int srcStart, int len, int tgtStart) ;
00863 
00869     virtual void deleteColNames(int tgtStart, int len) ;
00870   
00871 
00878     void setRowColNames(const CoinMpsIO &mps) ;
00879 
00885     void setRowColNames(CoinModel &mod) ;
00886 
00893     void setRowColNames(CoinLpIO &mod) ;
00894 
00896   //-------------------------------------------------------------------------
00897     
00898   //-------------------------------------------------------------------------
00904 
00906     virtual void addCol(const CoinPackedVectorBase& vec,
00907                         const double collb, const double colub,   
00908                         const double obj) = 0;
00909 
00915     virtual void addCol(const CoinPackedVectorBase& vec,
00916                         const double collb, const double colub,   
00917                         const double obj, std::string name) ;
00918 
00920     virtual void addCol(int numberElements,
00921                         const int* rows, const double* elements,
00922                         const double collb, const double colub,   
00923                         const double obj) ;
00924 
00930     virtual void addCol(int numberElements,
00931                         const int* rows, const double* elements,
00932                         const double collb, const double colub,   
00933                         const double obj, std::string name) ;
00934 
00940     virtual void addCols(const int numcols,
00941                          const CoinPackedVectorBase * const * cols,
00942                          const double* collb, const double* colub,   
00943                          const double* obj);
00944 
00950     virtual void addCols(const int numcols, const int* columnStarts,
00951                          const int* rows, const double* elements,
00952                          const double* collb, const double* colub,   
00953                          const double* obj);
00954 
00956     void addCols(const CoinBuild & buildObject);
00957 
00963     int addCols(CoinModel & modelObject);
00964 
00965 #if 0
00966 
00967     virtual void addCols(const CoinPackedMatrix& matrix,
00968                          const double* collb, const double* colub,   
00969                          const double* obj);
00970 #endif
00971 
00978     virtual void deleteCols(const int num, const int * colIndices) = 0;
00979   
00981     virtual void addRow(const CoinPackedVectorBase& vec,
00982                         const double rowlb, const double rowub) = 0;
00983 
00989     virtual void addRow(const CoinPackedVectorBase& vec,
00990                         const double rowlb, const double rowub,
00991                         std::string name) ;
00992 
00994     virtual void addRow(const CoinPackedVectorBase& vec,
00995                         const char rowsen, const double rowrhs,   
00996                         const double rowrng) = 0;
00997 
01003     virtual void addRow(const CoinPackedVectorBase& vec,
01004                         const char rowsen, const double rowrhs,   
01005                         const double rowrng, std::string name) ;
01006 
01011     virtual void addRow(int numberElements,
01012                         const int *columns, const double *element,
01013                         const double rowlb, const double rowub) ;
01014 
01020     virtual void addRows(const int numrows,
01021                          const CoinPackedVectorBase * const * rows,
01022                          const double* rowlb, const double* rowub);
01023 
01029     virtual void addRows(const int numrows,
01030                          const CoinPackedVectorBase * const * rows,
01031                          const char* rowsen, const double* rowrhs,   
01032                          const double* rowrng);
01033 
01039     virtual void addRows(const int numrows, const int *rowStarts,
01040                          const int *columns, const double *element,
01041                          const double *rowlb, const double *rowub);
01042 
01044     void addRows(const CoinBuild &buildObject);
01045 
01054     int addRows(CoinModel &modelObject);
01055 
01056 #if 0
01057 
01058     virtual void addRows(const CoinPackedMatrix& matrix,
01059                          const double* rowlb, const double* rowub);
01061     virtual void addRows(const CoinPackedMatrix& matrix,
01062                          const char* rowsen, const double* rowrhs,   
01063                          const double* rowrng);
01064 #endif
01065 
01071     virtual void deleteRows(const int num, const int * rowIndices) = 0;
01072   
01073     //-----------------------------------------------------------------------
01096     virtual ApplyCutsReturnCode applyCuts(const OsiCuts & cs,
01097                                           double effectivenessLb = 0.0);
01098 
01103     virtual void applyRowCuts(int numberCuts, const OsiRowCut * cuts);
01104 
01108     virtual void applyRowCuts(int numberCuts, const OsiRowCut ** cuts);
01109 
01111     void deleteBranchingInfo(int numberDeleted, const int * which);
01112 
01114 
01115   //---------------------------------------------------------------------------
01116 
01134     virtual void loadProblem (const CoinPackedMatrix& matrix,
01135                               const double* collb, const double* colub,   
01136                               const double* obj,
01137                               const double* rowlb, const double* rowub) = 0;
01138                             
01148     virtual void assignProblem (CoinPackedMatrix*& matrix,
01149                                 double*& collb, double*& colub, double*& obj,
01150                                 double*& rowlb, double*& rowub) = 0;
01151 
01168     virtual void loadProblem (const CoinPackedMatrix& matrix,
01169                               const double* collb, const double* colub,
01170                               const double* obj,
01171                               const char* rowsen, const double* rowrhs,   
01172                               const double* rowrng) = 0;
01173 
01183     virtual void assignProblem (CoinPackedMatrix*& matrix,
01184                                 double*& collb, double*& colub, double*& obj,
01185                                 char*& rowsen, double*& rowrhs,
01186                                 double*& rowrng) = 0;
01187 
01200     virtual void loadProblem (const int numcols, const int numrows,
01201                               const CoinBigIndex * start, const int* index,
01202                               const double* value,
01203                               const double* collb, const double* colub,   
01204                               const double* obj,
01205                               const double* rowlb, const double* rowub) = 0;
01206 
01219     virtual void loadProblem (const int numcols, const int numrows,
01220                               const CoinBigIndex * start, const int* index,
01221                               const double* value,
01222                               const double* collb, const double* colub,   
01223                               const double* obj,
01224                               const char* rowsen, const double* rowrhs,   
01225                               const double* rowrng) = 0;
01226 
01233     virtual int loadFromCoinModel (CoinModel & modelObject,
01234                                    bool keepSolution=false);
01235 
01241     virtual int readMps (const char *filename,
01242                          const char *extension = "mps") ;
01243 
01250     virtual int readMps (const char *filename, const char*extension,
01251                         int & numberSets, CoinSet ** & sets);
01252 
01258     virtual int readGMPL (const char *filename, const char *dataname=NULL);
01259 
01266     virtual void writeMps (const char *filename,
01267                            const char *extension = "mps",
01268                            double objSense=0.0) const = 0;
01269 
01283     int writeMpsNative (const char *filename, 
01284                         const char ** rowNames, const char ** columnNames,
01285                         int formatType=0,int numberAcross=2,
01286                         double objSense=0.0, int numberSOS=0,
01287                         const CoinSet * setInfo=NULL) const ;
01288 
01289 /***********************************************************************/
01290 // Lp files 
01291 
01311   virtual void writeLp(const char *filename,
01312                const char *extension = "lp",
01313                 double epsilon = 1e-5,
01314                 int numberAcross = 10,
01315                 int decimals = 5,
01316                 double objSense = 0.0,
01317                 bool useRowNames = true) const;
01318 
01323   virtual void writeLp(FILE *fp,
01324                 double epsilon = 1e-5,
01325                 int numberAcross = 10,
01326                 int decimals = 5,
01327                 double objSense = 0.0,
01328                 bool useRowNames = true) const;
01329 
01348   int writeLpNative(const char *filename,
01349                     char const * const * const rowNames,
01350                     char const * const * const columnNames,
01351                     const double epsilon = 1.0e-5,
01352                     const int numberAcross = 10,
01353                     const int decimals = 5,
01354                     const double objSense = 0.0,
01355                     const bool useRowNames = true) const;
01356 
01361   int writeLpNative(FILE *fp,
01362                     char const * const * const rowNames,
01363                     char const * const * const columnNames,
01364                     const double epsilon = 1.0e-5,
01365                     const int numberAcross = 10,
01366                     const int decimals = 5,
01367                     const double objSense = 0.0,
01368                     const bool useRowNames = true) const;
01369 
01372   virtual int readLp(const char *filename, const double epsilon = 1e-5);
01373 
01376   int readLp(FILE *fp, const double epsilon = 1e-5);
01377 
01383   virtual void replaceMatrixOptional(const CoinPackedMatrix & matrix) {}
01385   virtual void replaceMatrix(const CoinPackedMatrix & matrix) {abort();}
01387 
01388   //---------------------------------------------------------------------------
01389 
01392 #ifdef COIN_SNAPSHOT
01394   virtual CoinSnapshot * snapshot(bool createArrays=true) const;
01395 #endif
01396 
01397 
01398   //---------------------------------------------------------------------------
01399 
01409     void setApplicationData (void * appData);
01416     void setAuxiliaryInfo(OsiAuxInfo * auxiliaryInfo);
01417 
01419     void * getApplicationData() const;
01421     OsiAuxInfo * getAuxiliaryInfo() const;
01423   //---------------------------------------------------------------------------
01424 
01438   void passInMessageHandler(CoinMessageHandler * handler);
01440   void newLanguage(CoinMessages::Language language);
01441   inline void setLanguage(CoinMessages::Language language)
01442   {newLanguage(language);}
01444   inline CoinMessageHandler * messageHandler() const
01445   {return handler_;}
01447   inline CoinMessages messages() 
01448   {return messages_;}
01450   inline CoinMessages * messagesPointer() 
01451   {return &messages_;}
01453   inline bool defaultHandler() const
01454   { return defaultHandler_;}
01456   //---------------------------------------------------------------------------
01471     void findIntegers(bool justCount);
01482     virtual int findIntegersAndSOS(bool justCount);
01484     inline int numberObjects() const { return numberObjects_;}
01486     inline void setNumberObjects(int number) 
01487     {  numberObjects_=number;}
01488 
01490     inline OsiObject ** objects() const { return object_;}
01491 
01493     const inline OsiObject * object(int which) const { return object_[which];}
01495     inline OsiObject * modifiableObject(int which) const { return object_[which];}
01496 
01498     void deleteObjects();
01499 
01504     void addObjects(int numberObjects, OsiObject ** objects);
01509     double forceFeasible();
01511   //---------------------------------------------------------------------------
01512 
01521     virtual void activateRowCutDebugger (const char * modelName);
01522 
01528     virtual void activateRowCutDebugger( const double * solution);
01538     const OsiRowCutDebugger * getRowCutDebugger() const;
01540     const OsiRowCutDebugger * getRowCutDebuggerAlways() const;
01541 
01543 
01544   
01552 public:
01554 
01555 
01558   virtual int canDoSimplexInterface() const;
01565   virtual void enableSimplexInterface(bool doingPrimal) ;
01566 
01568   virtual void disableSimplexInterface() ;
01569 
01576   virtual void enableFactorization() const;
01578   virtual void disableFactorization() const;
01579 
01584   virtual bool basisIsAvailable() const ;
01586   inline bool optimalBasisIsAvailable() const
01587   { return basisIsAvailable();}
01588 
01601   virtual void getBasisStatus(int* cstat, int* rstat) const ;
01602 
01609   virtual int setBasisStatus(const int* cstat, const int* rstat) ;
01610 
01618   virtual int pivot(int colIn, int colOut, int outStatus) ;
01619 
01631   virtual int primalPivotResult(int colIn, int sign, 
01632                                 int& colOut, int& outStatus, 
01633                                 double& t, CoinPackedVector* dx);
01634 
01641   virtual int dualPivotResult(int& colIn, int& sign, 
01642                               int colOut, int outStatus, 
01643                               double& t, CoinPackedVector* dx) ;
01644 
01646   virtual void getReducedGradient(double* columnReducedCosts, 
01647                                   double * duals,
01648                                   const double * c) ;
01649 
01652   virtual void setObjectiveAndRefresh(double* c) ;
01653 
01655   virtual void getBInvARow(int row, double* z, double * slack=NULL) const ;
01656 
01658   virtual void getBInvRow(int row, double* z) const ;
01659 
01661   virtual void getBInvACol(int col, double* vec) const ;
01662 
01664   virtual void getBInvCol(int col, double* vec) const ;
01665 
01670   virtual void getBasics(int* index) const ;
01672    
01673   //---------------------------------------------------------------------------
01674 
01676 
01677 
01678     OsiSolverInterface(); 
01679     
01685     virtual OsiSolverInterface * clone(bool copyData = true) const = 0;
01686   
01688     OsiSolverInterface(const OsiSolverInterface &);
01689   
01691     OsiSolverInterface & operator=(const OsiSolverInterface& rhs);
01692   
01694     virtual ~OsiSolverInterface ();
01695 
01702     virtual void reset();
01704 
01705   //---------------------------------------------------------------------------
01706 
01707 protected:
01709 
01710 
01711     virtual void applyRowCut( const OsiRowCut & rc ) = 0;
01712 
01714     virtual void applyColCut( const OsiColCut & cc ) = 0;
01715 
01718     inline void
01719     convertBoundToSense(const double lower, const double upper,
01720                         char& sense, double& right, double& range) const;
01723     inline void
01724     convertSenseToBound(const char sense, const double right,
01725                         const double range,
01726                         double& lower, double& upper) const;
01729     template <class T> inline T
01730     forceIntoRange(const T value, const T lower, const T upper) const {
01731       return value < lower ? lower : (value > upper ? upper : value);
01732     }
01739     void setInitialData();
01741 
01743 
01744 
01745     OsiRowCutDebugger * rowCutDebugger_;
01746    // Why not just make useful stuff protected?
01748   CoinMessageHandler * handler_;
01754   bool defaultHandler_;
01756   CoinMessages messages_;
01758   int numberIntegers_;
01760   int numberObjects_;
01761 
01763   OsiObject ** object_;
01764 
01766   
01767   //---------------------------------------------------------------------------
01768 
01769 private:
01771 
01772 
01773     OsiAuxInfo * appDataEtc_;
01775     int intParam_[OsiLastIntParam];
01777     double dblParam_[OsiLastDblParam];
01779     std::string strParam_[OsiLastStrParam];
01781     bool hintParam_[OsiLastHintParam];
01783     OsiHintStrength hintStrength_[OsiLastHintParam];
01786     CoinWarmStart* ws_;
01787 
01789     OsiNameVec rowNames_ ;
01791     OsiNameVec colNames_ ;
01793     std::string objName_ ;
01794 
01796 };
01797 
01798 //#############################################################################
01806 void
01807 OsiSolverInterfaceCommonUnitTest(
01808    const OsiSolverInterface* emptySi,
01809    const std::string & mpsDir,
01810    const std::string & netlibDir);
01811 
01812 //#############################################################################
01815 void
01816 OsiSolverInterfaceMpsUnitTest(
01817    const std::vector<OsiSolverInterface*> & vecSiP,
01818    const std::string & mpsDir);
01819 
01820 //#############################################################################
01823 inline void
01824 OsiSolverInterface::convertBoundToSense(const double lower, const double upper,
01825                                         char& sense, double& right,
01826                                         double& range) const
01827 {
01828   double inf = getInfinity();
01829   range = 0.0;
01830   if (lower > -inf) {
01831     if (upper < inf) {
01832       right = upper;
01833       if (upper==lower) {
01834         sense = 'E';
01835       } else {
01836         sense = 'R';
01837         range = upper - lower;
01838       }
01839     } else {
01840       sense = 'G';
01841       right = lower;
01842     }
01843   } else {
01844     if (upper < inf) {
01845       sense = 'L';
01846       right = upper;
01847     } else {
01848       sense = 'N';
01849       right = 0.0;
01850     }
01851   }
01852 }
01853 
01854 //-----------------------------------------------------------------------------
01857 inline void
01858 OsiSolverInterface::convertSenseToBound(const char sense, const double right,
01859                                         const double range,
01860                                         double& lower, double& upper) const
01861 {
01862   double inf=getInfinity();
01863   switch (sense) {
01864   case 'E':
01865     lower = upper = right;
01866     break;
01867   case 'L':
01868     lower = -inf;
01869     upper = right;
01870     break;
01871   case 'G':
01872     lower = right;
01873     upper = inf;
01874     break;
01875   case 'R':
01876     lower = right - range;
01877     upper = right;
01878     break;
01879   case 'N':
01880     lower = -inf;
01881     upper = inf;
01882     break;
01883   }
01884 }
01885 
01886 #endif

Generated on Thu May 15 22:07:41 2008 by  doxygen 1.4.7