/home/coin/DyLP-1.2.1/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);
00715 
00716   //-------------------------------------------------------------------------
00720     virtual void setContinuous(int index) = 0;
00722     virtual void setInteger(int index) = 0;
00725     virtual void setContinuous(const int* indices, int len);
00728     virtual void setInteger(const int* indices, int len);
00730   //-------------------------------------------------------------------------
00731 
00732   //-------------------------------------------------------------------------
00733 
00735     typedef std::vector<std::string> OsiNameVec ;
00736 
00757 
00767     virtual std::string dfltRowColName(char rc,
00768                                  int ndx, unsigned digits = 7) const ;
00769 
00772     virtual std::string getObjName (unsigned maxLen = std::string::npos) const ;
00773 
00776     virtual inline void setObjName (std::string name)
00777     { objName_ = name ; }
00778 
00785     virtual std::string getRowName(int rowIndex,
00786                                    unsigned maxLen = std::string::npos) const ;
00787 
00799     virtual const OsiNameVec &getRowNames() ;
00800 
00806     virtual void setRowName(int ndx, std::string name) ;
00807 
00814     virtual void setRowNames(OsiNameVec &srcNames,
00815                      int srcStart, int len, int tgtStart) ;
00816 
00822     virtual void deleteRowNames(int tgtStart, int len) ;
00823   
00830     virtual std::string getColName(int colIndex,
00831                                    unsigned maxLen = std::string::npos) const ;
00832 
00842     virtual const OsiNameVec &getColNames() ;
00843 
00849     virtual void setColName(int ndx, std::string name) ;
00850 
00857     virtual void setColNames(OsiNameVec &srcNames,
00858                      int srcStart, int len, int tgtStart) ;
00859 
00865     virtual void deleteColNames(int tgtStart, int len) ;
00866   
00867 
00874     void setRowColNames(const CoinMpsIO &mps) ;
00875 
00881     void setRowColNames(CoinModel &mod) ;
00882 
00889     void setRowColNames(CoinLpIO &mod) ;
00890 
00892   //-------------------------------------------------------------------------
00893     
00894   //-------------------------------------------------------------------------
00900 
00902     virtual void addCol(const CoinPackedVectorBase& vec,
00903                         const double collb, const double colub,   
00904                         const double obj) = 0;
00905 
00911     virtual void addCol(const CoinPackedVectorBase& vec,
00912                         const double collb, const double colub,   
00913                         const double obj, std::string name) ;
00914 
00916     virtual void addCol(int numberElements,
00917                         const int* rows, const double* elements,
00918                         const double collb, const double colub,   
00919                         const double obj) ;
00920 
00926     virtual void addCol(int numberElements,
00927                         const int* rows, const double* elements,
00928                         const double collb, const double colub,   
00929                         const double obj, std::string name) ;
00930 
00936     virtual void addCols(const int numcols,
00937                          const CoinPackedVectorBase * const * cols,
00938                          const double* collb, const double* colub,   
00939                          const double* obj);
00940 
00946     virtual void addCols(const int numcols, const int* columnStarts,
00947                          const int* rows, const double* elements,
00948                          const double* collb, const double* colub,   
00949                          const double* obj);
00950 
00952     void addCols(const CoinBuild & buildObject);
00953 
00959     int addCols(CoinModel & modelObject);
00960 
00961 #if 0
00962 
00963     virtual void addCols(const CoinPackedMatrix& matrix,
00964                          const double* collb, const double* colub,   
00965                          const double* obj);
00966 #endif
00967 
00974     virtual void deleteCols(const int num, const int * colIndices) = 0;
00975   
00977     virtual void addRow(const CoinPackedVectorBase& vec,
00978                         const double rowlb, const double rowub) = 0;
00979 
00985     virtual void addRow(const CoinPackedVectorBase& vec,
00986                         const double rowlb, const double rowub,
00987                         std::string name) ;
00988 
00990     virtual void addRow(const CoinPackedVectorBase& vec,
00991                         const char rowsen, const double rowrhs,   
00992                         const double rowrng) = 0;
00993 
00999     virtual void addRow(const CoinPackedVectorBase& vec,
01000                         const char rowsen, const double rowrhs,   
01001                         const double rowrng, std::string name) ;
01002 
01007     virtual void addRow(int numberElements,
01008                         const int *columns, const double *element,
01009                         const double rowlb, const double rowub) ;
01010 
01016     virtual void addRows(const int numrows,
01017                          const CoinPackedVectorBase * const * rows,
01018                          const double* rowlb, const double* rowub);
01019 
01025     virtual void addRows(const int numrows,
01026                          const CoinPackedVectorBase * const * rows,
01027                          const char* rowsen, const double* rowrhs,   
01028                          const double* rowrng);
01029 
01035     virtual void addRows(const int numrows, const int *rowStarts,
01036                          const int *columns, const double *element,
01037                          const double *rowlb, const double *rowub);
01038 
01040     void addRows(const CoinBuild &buildObject);
01041 
01050     int addRows(CoinModel &modelObject);
01051 
01052 #if 0
01053 
01054     virtual void addRows(const CoinPackedMatrix& matrix,
01055                          const double* rowlb, const double* rowub);
01057     virtual void addRows(const CoinPackedMatrix& matrix,
01058                          const char* rowsen, const double* rowrhs,   
01059                          const double* rowrng);
01060 #endif
01061 
01067     virtual void deleteRows(const int num, const int * rowIndices) = 0;
01068   
01069     //-----------------------------------------------------------------------
01092     virtual ApplyCutsReturnCode applyCuts(const OsiCuts & cs,
01093                                           double effectivenessLb = 0.0);
01094 
01099     virtual void applyRowCuts(int numberCuts, const OsiRowCut * cuts);
01100 
01104     virtual void applyRowCuts(int numberCuts, const OsiRowCut ** cuts);
01105 
01107     void deleteBranchingInfo(int numberDeleted, const int * which);
01108 
01110 
01111   //---------------------------------------------------------------------------
01112 
01126     virtual void loadProblem(const CoinPackedMatrix& matrix,
01127                              const double* collb, const double* colub,   
01128                              const double* obj,
01129                              const double* rowlb, const double* rowub) = 0;
01130                             
01140     virtual void assignProblem(CoinPackedMatrix*& matrix,
01141                                double*& collb, double*& colub, double*& obj,
01142                                double*& rowlb, double*& rowub) = 0;
01143 
01156     virtual void loadProblem(const CoinPackedMatrix& matrix,
01157                              const double* collb, const double* colub,
01158                              const double* obj,
01159                              const char* rowsen, const double* rowrhs,   
01160                              const double* rowrng) = 0;
01161 
01171     virtual void assignProblem(CoinPackedMatrix*& matrix,
01172                                double*& collb, double*& colub, double*& obj,
01173                                char*& rowsen, double*& rowrhs,
01174                                double*& rowrng) = 0;
01175 
01178     virtual void loadProblem(const int numcols, const int numrows,
01179                              const CoinBigIndex * start, const int* index,
01180                              const double* value,
01181                              const double* collb, const double* colub,   
01182                              const double* obj,
01183                              const double* rowlb, const double* rowub) = 0;
01184 
01187     virtual void loadProblem(const int numcols, const int numrows,
01188                              const CoinBigIndex * start, const int* index,
01189                              const double* value,
01190                              const double* collb, const double* colub,   
01191                              const double* obj,
01192                              const char* rowsen, const double* rowrhs,   
01193                              const double* rowrng) = 0;
01199      virtual int loadFromCoinModel (  CoinModel & modelObject, bool keepSolution=false);
01200 
01206     virtual int readMps(const char *filename,
01207                          const char *extension = "mps") ;
01208 
01215   virtual int readMps(const char *filename, const char*extension,
01216                         int & numberSets, CoinSet ** & sets);
01217 
01222    virtual int readGMPL(const char *filename, const char * dataname=NULL);
01229     virtual void writeMps(const char *filename,
01230                           const char *extension = "mps",
01231                           double objSense=0.0) const = 0;
01232 
01245     int writeMpsNative(const char *filename, 
01246                        const char ** rowNames, const char ** columnNames,
01247                        int formatType=0,int numberAcross=2,
01248                        double objSense=0.0, int numberSOS=0,
01249                        const CoinSet * setInfo=NULL) const ;
01250 
01251 /***********************************************************************/
01252 // Lp files 
01253 
01273   virtual void writeLp(const char *filename,
01274                const char *extension = "lp",
01275                 double epsilon = 1e-5,
01276                 int numberAcross = 10,
01277                 int decimals = 5,
01278                 double objSense = 0.0,
01279                 bool useRowNames = true) const;
01280 
01285   virtual void writeLp(FILE *fp,
01286                 double epsilon = 1e-5,
01287                 int numberAcross = 10,
01288                 int decimals = 5,
01289                 double objSense = 0.0,
01290                 bool useRowNames = true) const;
01291 
01310   int writeLpNative(const char *filename,
01311                     char const * const * const rowNames,
01312                     char const * const * const columnNames,
01313                     const double epsilon = 1.0e-5,
01314                     const int numberAcross = 10,
01315                     const int decimals = 5,
01316                     const double objSense = 0.0,
01317                     const bool useRowNames = true) const;
01318 
01323   int writeLpNative(FILE *fp,
01324                     char const * const * const rowNames,
01325                     char const * const * const columnNames,
01326                     const double epsilon = 1.0e-5,
01327                     const int numberAcross = 10,
01328                     const int decimals = 5,
01329                     const double objSense = 0.0,
01330                     const bool useRowNames = true) const;
01331 
01334   virtual int readLp(const char *filename, const double epsilon = 1e-5);
01335 
01338   int readLp(FILE *fp, const double epsilon = 1e-5);
01339 
01345   virtual void replaceMatrixOptional(const CoinPackedMatrix & matrix) {};
01347   virtual void replaceMatrix(const CoinPackedMatrix & matrix) {abort();};
01349 
01350   //---------------------------------------------------------------------------
01351 
01354 #ifdef COIN_SNAPSHOT
01356   virtual CoinSnapshot * snapshot(bool createArrays=true) const;
01357 #endif
01358 
01359 
01360   //---------------------------------------------------------------------------
01361 
01371     void setApplicationData (void * appData);
01378     void setAuxiliaryInfo(OsiAuxInfo * auxiliaryInfo);
01379 
01381     void * getApplicationData() const;
01383     OsiAuxInfo * getAuxiliaryInfo() const;
01385   //---------------------------------------------------------------------------
01386 
01400   void passInMessageHandler(CoinMessageHandler * handler);
01402   void newLanguage(CoinMessages::Language language);
01403   void setLanguage(CoinMessages::Language language)
01404   {newLanguage(language);};
01406   CoinMessageHandler * messageHandler() const
01407   {return handler_;};
01409   CoinMessages messages() 
01410   {return messages_;};
01412   CoinMessages * messagesPointer() 
01413   {return &messages_;};
01415   //---------------------------------------------------------------------------
01430     void findIntegers(bool justCount);
01441     virtual int findIntegersAndSOS(bool justCount);
01443     inline int numberObjects() const { return numberObjects_;};
01445     inline void setNumberObjects(int number) 
01446     {  numberObjects_=number;};
01447 
01449     inline OsiObject ** objects() const { return object_;};
01450 
01452     const inline OsiObject * object(int which) const { return object_[which];};
01454     inline OsiObject * modifiableObject(int which) const { return object_[which];};
01455 
01457     void deleteObjects();
01458 
01463     void addObjects(int numberObjects, OsiObject ** objects);
01468     double forceFeasible();
01470   //---------------------------------------------------------------------------
01471 
01480     virtual void activateRowCutDebugger (const char * modelName);
01481 
01487     virtual void activateRowCutDebugger( const double * solution);
01497     const OsiRowCutDebugger * getRowCutDebugger() const;
01499     const OsiRowCutDebugger * getRowCutDebuggerAlways() const;
01500 
01502 
01503   
01511 public:
01513 
01514 
01517   virtual int canDoSimplexInterface() const;
01524   virtual void enableSimplexInterface(bool doingPrimal) ;
01525 
01527   virtual void disableSimplexInterface() ;
01528 
01535   virtual void enableFactorization() const;
01537   virtual void disableFactorization() const;
01538 
01543   virtual bool basisIsAvailable() const ;
01545   inline bool optimalBasisIsAvailable() const
01546   { return basisIsAvailable();};
01547 
01560   virtual void getBasisStatus(int* cstat, int* rstat) const ;
01561 
01568   virtual int setBasisStatus(const int* cstat, const int* rstat) ;
01569 
01577   virtual int pivot(int colIn, int colOut, int outStatus) ;
01578 
01590   virtual int primalPivotResult(int colIn, int sign, 
01591                                 int& colOut, int& outStatus, 
01592                                 double& t, CoinPackedVector* dx);
01593 
01600   virtual int dualPivotResult(int& colIn, int& sign, 
01601                               int colOut, int outStatus, 
01602                               double& t, CoinPackedVector* dx) ;
01603 
01605   virtual void getReducedGradient(double* columnReducedCosts, 
01606                                   double * duals,
01607                                   const double * c) ;
01608 
01611   virtual void setObjectiveAndRefresh(double* c) ;
01612 
01614   virtual void getBInvARow(int row, double* z, double * slack=NULL) const ;
01615 
01617   virtual void getBInvRow(int row, double* z) const ;
01618 
01620   virtual void getBInvACol(int col, double* vec) const ;
01621 
01623   virtual void getBInvCol(int col, double* vec) const ;
01624 
01629   virtual void getBasics(int* index) const ;
01631    
01632   //---------------------------------------------------------------------------
01633 
01635 
01636 
01637     OsiSolverInterface(); 
01638     
01644     virtual OsiSolverInterface * clone(bool copyData = true) const = 0;
01645   
01647     OsiSolverInterface(const OsiSolverInterface &);
01648   
01650     OsiSolverInterface & operator=(const OsiSolverInterface& rhs);
01651   
01653     virtual ~OsiSolverInterface ();
01654 
01661     virtual void reset();
01663 
01664   //---------------------------------------------------------------------------
01665 
01666 protected:
01668 
01669 
01670     virtual void applyRowCut( const OsiRowCut & rc ) = 0;
01671 
01673     virtual void applyColCut( const OsiColCut & cc ) = 0;
01674 
01677     inline void
01678     convertBoundToSense(const double lower, const double upper,
01679                         char& sense, double& right, double& range) const;
01682     inline void
01683     convertSenseToBound(const char sense, const double right,
01684                         const double range,
01685                         double& lower, double& upper) const;
01688     template <class T> inline T
01689     forceIntoRange(const T value, const T lower, const T upper) const {
01690       return value < lower ? lower : (value > upper ? upper : value);
01691     }
01698     void setInitialData();
01700 
01702 
01703 
01704     OsiRowCutDebugger * rowCutDebugger_;
01705    // Why not just make useful stuff protected?
01707   CoinMessageHandler * handler_;
01713   bool defaultHandler_;
01715   CoinMessages messages_;
01717   int numberIntegers_;
01719   int numberObjects_;
01720 
01722   OsiObject ** object_;
01723 
01725   
01726   //---------------------------------------------------------------------------
01727 
01728 private:
01730 
01731 
01732     OsiAuxInfo * appDataEtc_;
01734     int intParam_[OsiLastIntParam];
01736     double dblParam_[OsiLastDblParam];
01738     std::string strParam_[OsiLastStrParam];
01740     bool hintParam_[OsiLastHintParam];
01742     OsiHintStrength hintStrength_[OsiLastHintParam];
01745     CoinWarmStart* ws_;
01746 
01748     OsiNameVec rowNames_ ;
01750     OsiNameVec colNames_ ;
01752     std::string objName_ ;
01753 
01755 };
01756 
01757 //#############################################################################
01765 void
01766 OsiSolverInterfaceCommonUnitTest(
01767    const OsiSolverInterface* emptySi,
01768    const std::string & mpsDir,
01769    const std::string & netlibDir);
01770 
01771 //#############################################################################
01774 void
01775 OsiSolverInterfaceMpsUnitTest(
01776    const std::vector<OsiSolverInterface*> & vecSiP,
01777    const std::string & mpsDir);
01778 
01779 //#############################################################################
01782 inline void
01783 OsiSolverInterface::convertBoundToSense(const double lower, const double upper,
01784                                         char& sense, double& right,
01785                                         double& range) const
01786 {
01787   double inf = getInfinity();
01788   range = 0.0;
01789   if (lower > -inf) {
01790     if (upper < inf) {
01791       right = upper;
01792       if (upper==lower) {
01793         sense = 'E';
01794       } else {
01795         sense = 'R';
01796         range = upper - lower;
01797       }
01798     } else {
01799       sense = 'G';
01800       right = lower;
01801     }
01802   } else {
01803     if (upper < inf) {
01804       sense = 'L';
01805       right = upper;
01806     } else {
01807       sense = 'N';
01808       right = 0.0;
01809     }
01810   }
01811 }
01812 
01813 //-----------------------------------------------------------------------------
01816 inline void
01817 OsiSolverInterface::convertSenseToBound(const char sense, const double right,
01818                                         const double range,
01819                                         double& lower, double& upper) const
01820 {
01821   double inf=getInfinity();
01822   switch (sense) {
01823   case 'E':
01824     lower = upper = right;
01825     break;
01826   case 'L':
01827     lower = -inf;
01828     upper = right;
01829     break;
01830   case 'G':
01831     lower = right;
01832     upper = inf;
01833     break;
01834   case 'R':
01835     lower = right - range;
01836     upper = right;
01837     break;
01838   case 'N':
01839     lower = -inf;
01840     upper = inf;
01841     break;
01842   }
01843 }
01844 
01845 #endif

Generated on Wed Aug 22 05:50:08 2007 by  doxygen 1.4.7