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

- File List
- File Members

# /home/coin/svn-release/Smi-0.93.1/Osi/src/Osi/OsiSolverInterface.hpp

Go to the documentation of this file.

    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 OsiOslSolverInterface;
    00077     friend class OsiClpSolverInterface;
    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(){return intInconsistent_;}
    00117       inline int getNumInconsistentWrtIntegerModel(){return extInconsistent_;}
    00119       inline int getNumInfeasible(){return infeasible_;}
    00121       inline int getNumIneffective(){return ineffective_;}
    00123       inline int getNumApplied(){return applied_;}
    00125
    00126   private:
    00129
    00130       inline void incrementInternallyInconsistent(){intInconsistent_++;}
    00132       inline void incrementExternallyInconsistent(){extInconsistent_++;}
    00134       inline void incrementInfeasible(){infeasible_++;}
    00136       inline void incrementIneffective(){ineffective_++;}
    00138       inline void incrementApplied(){applied_++;}
    00140
    00142
    00143
    00144       int intInconsistent_;
    00146       int extInconsistent_;
    00148       int infeasible_;
    00150       int ineffective_;
    00152       int applied_;
    00154   };
    00155
    00156   //---------------------------------------------------------------------------
    00157
    00159
    00160
    00161     virtual void initialSolve() = 0;
    00162
    00168     virtual void resolve() = 0;
    00169
    00171     virtual void branchAndBound() = 0;
    00172
    00173 #ifdef CBC_NEXT_VERSION
    00174     /*
    00175       Would it make sense to collect all of these routines in a `MIP Helper'
    00176       section? It'd make it easier for users and implementors to find them.
    00177     */
    00195     virtual int solveBranches(int depth,const OsiSolverBranch * branch,
    00196                               OsiSolverResult * result,
    00197                               int & numberSolves, int & numberIterations,
    00198                               bool forceBranch=false);
    00199 #endif
    00200
    00201
    00202   //---------------------------------------------------------------------------
    00260
    00261     virtual bool setIntParam(OsiIntParam key, int value) {
    00262       if (key == OsiLastIntParam) return (false) ;
    00263       intParam_[key] = value;
    00264       return true;
    00265     }
    00267     virtual bool setDblParam(OsiDblParam key, double value) {
    00268       if (key == OsiLastDblParam) return (false) ;
    00269       dblParam_[key] = value;
    00270       return true;
    00271     }
    00273     virtual bool setStrParam(OsiStrParam key, const std::string & value) {
    00274       if (key == OsiLastStrParam) return (false) ;
    00275       strParam_[key] = value;
    00276       return true;
    00277     }
    00289     virtual bool setHintParam(OsiHintParam key, bool yesNo=true,
    00290                               OsiHintStrength strength=OsiHintTry,
    00291                               void * /*otherInformation*/ = NULL) {
    00292       if (key==OsiLastHintParam)
    00293         return false;
    00294       hintParam_[key] = yesNo;
    00295       hintStrength_[key] = strength;
    00296       if (strength == OsiForceDo)
    00297         throw CoinError("OsiForceDo illegal",
    00298                         "setHintParam", "OsiSolverInterface");
    00299       return true;
    00300     }
    00302     virtual bool getIntParam(OsiIntParam key, int& value) const {
    00303       if (key == OsiLastIntParam) return (false) ;
    00304       value = intParam_[key];
    00305       return true;
    00306     }
    00308     virtual bool getDblParam(OsiDblParam key, double& value) const {
    00309       if (key == OsiLastDblParam) return (false) ;
    00310       value = dblParam_[key];
    00311       return true;
    00312     }
    00314     virtual bool getStrParam(OsiStrParam key, std::string& value) const {
    00315       if (key == OsiLastStrParam) return (false) ;
    00316       value = strParam_[key];
    00317       return true;
    00318     }
    00328     virtual bool getHintParam(OsiHintParam key, bool& yesNo,
    00329                               OsiHintStrength& strength,
    00330                               void *& otherInformation) const {
    00331       if (key==OsiLastHintParam)
    00332         return false;
    00333       yesNo = hintParam_[key];
    00334       strength = hintStrength_[key];
    00335       otherInformation=NULL;
    00336       return true;
    00337     }
    00342     virtual bool getHintParam(OsiHintParam key, bool& yesNo,
    00343                               OsiHintStrength& strength) const {
    00344       if (key==OsiLastHintParam)
    00345         return false;
    00346       yesNo = hintParam_[key];
    00347       strength = hintStrength_[key];
    00348       return true;
    00349     }
    00354     virtual bool getHintParam(OsiHintParam key, bool& yesNo) const {
    00355       if (key==OsiLastHintParam)
    00356         return false;
    00357       yesNo = hintParam_[key];
    00358       return true;
    00359     }
    00366     void copyParameters(OsiSolverInterface & rhs);
    00367
    00381     inline double getIntegerTolerance() const
    00382     { return dblParam_[OsiPrimalTolerance];}
    00384
    00385   //---------------------------------------------------------------------------
    00387
    00388
    00389     virtual bool isAbandoned() const = 0;
    00391     virtual bool isProvenOptimal() const = 0;
    00393     virtual bool isProvenPrimalInfeasible() const = 0;
    00395     virtual bool isProvenDualInfeasible() const = 0;
    00397     virtual bool isPrimalObjectiveLimitReached() const;
    00399     virtual bool isDualObjectiveLimitReached() const;
    00401     virtual bool isIterationLimitReached() const = 0;
    00403
    00404   //---------------------------------------------------------------------------
    00422     virtual CoinWarmStart *getEmptyWarmStart () const = 0 ;
    00423
    00430     virtual CoinWarmStart* getWarmStart() const = 0;
    00439     virtual CoinWarmStart* getPointerToWarmStart(bool & mustDelete) ;
    00440
    00449     virtual bool setWarmStart(const CoinWarmStart* warmstart) = 0;
    00451
    00452   //---------------------------------------------------------------------------
    00473
    00474     virtual void markHotStart();
    00476     virtual void solveFromHotStart();
    00478     virtual void unmarkHotStart();
    00480
    00481   //---------------------------------------------------------------------------
    00492
    00493     virtual int getNumCols() const = 0;
    00494
    00496     virtual int getNumRows() const = 0;
    00497
    00499     virtual int getNumElements() const = 0;
    00500
    00502     virtual int getNumIntegers() const ;
    00503
    00505     virtual const double * getColLower() const = 0;
    00506
    00508     virtual const double * getColUpper() const = 0;
    00509
    00520     virtual const char * getRowSense() const = 0;
    00521
    00535     virtual const double * getRightHandSide() const = 0;
    00536
    00546     virtual const double * getRowRange() const = 0;
    00547
    00549     virtual const double * getRowLower() const = 0;
    00550
    00552     virtual const double * getRowUpper() const = 0;
    00553
    00557     virtual const double * getObjCoefficients() const = 0;
    00558
    00564     virtual double getObjSense() const = 0;
    00565
    00567     virtual bool isContinuous(int colIndex) const = 0;
    00568
    00570     virtual bool isBinary(int colIndex) const;
    00571
    00576     virtual bool isInteger(int colIndex) const;
    00577
    00579     virtual bool isIntegerNonBinary(int colIndex) const;
    00580
    00582     virtual bool isFreeBinary(int colIndex) const;
    00583
    00588     inline const char *columnType(bool refresh=false) const
    00589     { return getColType(refresh); }
    00590
    00602     virtual const char * getColType(bool refresh=false) const;
    00603
    00605     virtual const CoinPackedMatrix * getMatrixByRow() const = 0;
    00606
    00608     virtual const CoinPackedMatrix * getMatrixByCol() const = 0;
    00609
    00615     virtual CoinPackedMatrix * getMutableMatrixByRow() const {return NULL;}
    00616
    00622     virtual CoinPackedMatrix * getMutableMatrixByCol() const {return NULL;}
    00623
    00625     virtual double getInfinity() const = 0;
    00627
    00630
    00631     virtual const double * getColSolution() const = 0;
    00632
    00636     virtual const double * getStrictColSolution();
    00637
    00639     virtual const double * getRowPrice() const = 0;
    00640
    00642     virtual const double * getReducedCost() const = 0;
    00643
    00649     virtual const double * getRowActivity() const = 0;
    00650
    00652     virtual double getObjValue() const = 0;
    00653
    00657     virtual int getIterationCount() const = 0;
    00658
    00681     virtual std::vector<double*> getDualRays(int maxNumRays,
    00682                                              bool fullRay = false) const = 0;
    00683
    00699     virtual std::vector<double*> getPrimalRays(int maxNumRays) const = 0;
    00700
    00703     virtual OsiVectorInt getFractionalIndices(const double etol=1.e-05)
    00704       const;
    00706
    00707   //-------------------------------------------------------------------------
    00720     virtual void setObjCoeff( int elementIndex, double elementValue ) = 0;
    00721
    00723     virtual void setObjCoeffSet(const int* indexFirst,
    00724                                 const int* indexLast,
    00725                                 const double* coeffList);
    00726
    00732     virtual void setObjective(const double * array);
    00733
    00744     virtual void setObjSense(double s) = 0;
    00745
    00746
    00749     virtual void setColLower( int elementIndex, double elementValue ) = 0;
    00750
    00756     virtual void setColLower(const double * array);
    00757
    00760     virtual void setColUpper( int elementIndex, double elementValue ) = 0;
    00761
    00767     virtual void setColUpper(const double * array);
    00768
    00769
    00773     virtual void setColBounds( int elementIndex,
    00774                                double lower, double upper ) {
    00775        setColLower(elementIndex, lower);
    00776        setColUpper(elementIndex, upper);
    00777     }
    00778
    00785     virtual void setColSetBounds(const int* indexFirst,
    00786                                  const int* indexLast,
    00787                                  const double* boundList);
    00788
    00791     virtual void setRowLower( int elementIndex, double elementValue ) = 0;
    00792
    00795     virtual void setRowUpper( int elementIndex, double elementValue ) = 0;
    00796
    00800     virtual void setRowBounds( int elementIndex,
    00801                                double lower, double upper ) {
    00802        setRowLower(elementIndex, lower);
    00803        setRowUpper(elementIndex, upper);
    00804     }
    00805
    00812     virtual void setRowSetBounds(const int* indexFirst,
    00813                                  const int* indexLast,
    00814                                  const double* boundList);
    00815
    00816
    00818     virtual void setRowType(int index, char sense, double rightHandSide,
    00819                             double range) = 0;
    00820
    00825     virtual void setRowSetTypes(const int* indexFirst,
    00826                                 const int* indexLast,
    00827                                 const char* senseList,
    00828                                 const double* rhsList,
    00829                                 const double* rangeList);
    00830
    00840     virtual void setColSolution(const double *colsol) = 0;
    00841
    00851     virtual void setRowPrice(const double * rowprice) = 0;
    00852
    00861     virtual int reducedCostFix(double gap, bool justInteger=true);
    00863
    00864   //-------------------------------------------------------------------------
    00868     virtual void setContinuous(int index) = 0;
    00870     virtual void setInteger(int index) = 0;
    00873     virtual void setContinuous(const int* indices, int len);
    00876     virtual void setInteger(const int* indices, int len);
    00878   //-------------------------------------------------------------------------
    00879
    00880   //-------------------------------------------------------------------------
    00881
    00883     typedef std::vector<std::string> OsiNameVec ;
    00884
    00905
    00915     virtual std::string dfltRowColName(char rc,
    00916                                  int ndx, unsigned digits = 7) const ;
    00917
    00920   virtual std::string getObjName (unsigned maxLen = static_cast<unsigned>(std::string::npos)) const ;
    00921
    00924     virtual inline void setObjName (std::string name)
    00925     { objName_ = name ; }
    00926
    00933     virtual std::string getRowName(int rowIndex,
    00934                                    unsigned maxLen = static_cast<unsigned>(std::string::npos)) const ;
    00935
    00947     virtual const OsiNameVec &getRowNames() ;
    00948
    00954     virtual void setRowName(int ndx, std::string name) ;
    00955
    00962     virtual void setRowNames(OsiNameVec &srcNames,
    00963                      int srcStart, int len, int tgtStart) ;
    00964
    00970     virtual void deleteRowNames(int tgtStart, int len) ;
    00971
    00978     virtual std::string getColName(int colIndex,
    00979                                    unsigned maxLen = static_cast<unsigned>(std::string::npos)) const ;
    00980
    00990     virtual const OsiNameVec &getColNames() ;
    00991
    00997     virtual void setColName(int ndx, std::string name) ;
    00998
    01005     virtual void setColNames(OsiNameVec &srcNames,
    01006                      int srcStart, int len, int tgtStart) ;
    01007
    01013     virtual void deleteColNames(int tgtStart, int len) ;
    01014
    01015
    01022     void setRowColNames(const CoinMpsIO &mps) ;
    01023
    01029     void setRowColNames(CoinModel &mod) ;
    01030
    01037     void setRowColNames(CoinLpIO &mod) ;
    01038
    01040   //-------------------------------------------------------------------------
    01041
    01042   //-------------------------------------------------------------------------
    01048
    01050     virtual void addCol(const CoinPackedVectorBase& vec,
    01051                         const double collb, const double colub,
    01052                         const double obj) = 0;
    01053
    01059     virtual void addCol(const CoinPackedVectorBase& vec,
    01060                         const double collb, const double colub,
    01061                         const double obj, std::string name) ;
    01062
    01064     virtual void addCol(int numberElements,
    01065                         const int* rows, const double* elements,
    01066                         const double collb, const double colub,
    01067                         const double obj) ;
    01068
    01074     virtual void addCol(int numberElements,
    01075                         const int* rows, const double* elements,
    01076                         const double collb, const double colub,
    01077                         const double obj, std::string name) ;
    01078
    01084     virtual void addCols(const int numcols,
    01085                          const CoinPackedVectorBase * const * cols,
    01086                          const double* collb, const double* colub,
    01087                          const double* obj);
    01088
    01094     virtual void addCols(const int numcols, const int* columnStarts,
    01095                          const int* rows, const double* elements,
    01096                          const double* collb, const double* colub,
    01097                          const double* obj);
    01098
    01100     void addCols(const CoinBuild & buildObject);
    01101
    01107     int addCols(CoinModel & modelObject);
    01108
    01109 #if 0
    01110
    01111     virtual void addCols(const CoinPackedMatrix& matrix,
    01112                          const double* collb, const double* colub,
    01113                          const double* obj);
    01114 #endif
    01115
    01122     virtual void deleteCols(const int num, const int * colIndices) = 0;
    01123
    01125     virtual void addRow(const CoinPackedVectorBase& vec,
    01126                         const double rowlb, const double rowub) = 0;
    01127
    01133     virtual void addRow(const CoinPackedVectorBase& vec,
    01134                         const double rowlb, const double rowub,
    01135                         std::string name) ;
    01136
    01138     virtual void addRow(const CoinPackedVectorBase& vec,
    01139                         const char rowsen, const double rowrhs,
    01140                         const double rowrng) = 0;
    01141
    01147     virtual void addRow(const CoinPackedVectorBase& vec,
    01148                         const char rowsen, const double rowrhs,
    01149                         const double rowrng, std::string name) ;
    01150
    01155     virtual void addRow(int numberElements,
    01156                         const int *columns, const double *element,
    01157                         const double rowlb, const double rowub) ;
    01158
    01164     virtual void addRows(const int numrows,
    01165                          const CoinPackedVectorBase * const * rows,
    01166                          const double* rowlb, const double* rowub);
    01167
    01173     virtual void addRows(const int numrows,
    01174                          const CoinPackedVectorBase * const * rows,
    01175                          const char* rowsen, const double* rowrhs,
    01176                          const double* rowrng);
    01177
    01183     virtual void addRows(const int numrows, const int *rowStarts,
    01184                          const int *columns, const double *element,
    01185                          const double *rowlb, const double *rowub);
    01186
    01188     void addRows(const CoinBuild &buildObject);
    01189
    01198     int addRows(CoinModel &modelObject);
    01199
    01200 #if 0
    01201
    01202     virtual void addRows(const CoinPackedMatrix& matrix,
    01203                          const double* rowlb, const double* rowub);
    01205     virtual void addRows(const CoinPackedMatrix& matrix,
    01206                          const char* rowsen, const double* rowrhs,
    01207                          const double* rowrng);
    01208 #endif
    01209
    01215     virtual void deleteRows(const int num, const int * rowIndices) = 0;
    01216
    01223     virtual void replaceMatrixOptional(const CoinPackedMatrix & ) {}
    01224
    01229     virtual void replaceMatrix(const CoinPackedMatrix & ) {abort();}
    01230
    01235     virtual void saveBaseModel() {}
    01236
    01250     virtual void restoreBaseModel(int numberRows);
    01251     //-----------------------------------------------------------------------
    01274     virtual ApplyCutsReturnCode applyCuts(const OsiCuts & cs,
    01275                                           double effectivenessLb = 0.0);
    01276
    01281     virtual void applyRowCuts(int numberCuts, const OsiRowCut * cuts);
    01282
    01286     virtual void applyRowCuts(int numberCuts, const OsiRowCut ** cuts);
    01287
    01289     void deleteBranchingInfo(int numberDeleted, const int * which);
    01290
    01292
    01293   //---------------------------------------------------------------------------
    01294
    01312     virtual void loadProblem (const CoinPackedMatrix& matrix,
    01313                               const double* collb, const double* colub,
    01314                               const double* obj,
    01315                               const double* rowlb, const double* rowub) = 0;
    01316
    01326     virtual void assignProblem (CoinPackedMatrix*& matrix,
    01327                                 double*& collb, double*& colub, double*& obj,
    01328                                 double*& rowlb, double*& rowub) = 0;
    01329
    01346     virtual void loadProblem (const CoinPackedMatrix& matrix,
    01347                               const double* collb, const double* colub,
    01348                               const double* obj,
    01349                               const char* rowsen, const double* rowrhs,
    01350                               const double* rowrng) = 0;
    01351
    01361     virtual void assignProblem (CoinPackedMatrix*& matrix,
    01362                                 double*& collb, double*& colub, double*& obj,
    01363                                 char*& rowsen, double*& rowrhs,
    01364                                 double*& rowrng) = 0;
    01365
    01378     virtual void loadProblem (const int numcols, const int numrows,
    01379                               const CoinBigIndex * start, const int* index,
    01380                               const double* value,
    01381                               const double* collb, const double* colub,
    01382                               const double* obj,
    01383                               const double* rowlb, const double* rowub) = 0;
    01384
    01397     virtual void loadProblem (const int numcols, const int numrows,
    01398                               const CoinBigIndex * start, const int* index,
    01399                               const double* value,
    01400                               const double* collb, const double* colub,
    01401                               const double* obj,
    01402                               const char* rowsen, const double* rowrhs,
    01403                               const double* rowrng) = 0;
    01404
    01411     virtual int loadFromCoinModel (CoinModel & modelObject,
    01412                                    bool keepSolution=false);
    01413
    01419     virtual int readMps (const char *filename,
    01420                          const char *extension = "mps") ;
    01421
    01428     virtual int readMps (const char *filename, const char*extension,
    01429                         int & numberSets, CoinSet ** & sets);
    01430
    01436     virtual int readGMPL (const char *filename, const char *dataname=NULL);
    01437
    01444     virtual void writeMps (const char *filename,
    01445                            const char *extension = "mps",
    01446                            double objSense=0.0) const = 0;
    01447
    01461     int writeMpsNative (const char *filename,
    01462                         const char ** rowNames, const char ** columnNames,
    01463                         int formatType=0,int numberAcross=2,
    01464                         double objSense=0.0, int numberSOS=0,
    01465                         const CoinSet * setInfo=NULL) const ;
    01466
    01467 /***********************************************************************/
    01468 // Lp files
    01469
    01489   virtual void writeLp(const char *filename,
    01490                const char *extension = "lp",
    01491                 double epsilon = 1e-5,
    01492                 int numberAcross = 10,
    01493                 int decimals = 5,
    01494                 double objSense = 0.0,
    01495                 bool useRowNames = true) const;
    01496
    01501   virtual void writeLp(FILE *fp,
    01502                 double epsilon = 1e-5,
    01503                 int numberAcross = 10,
    01504                 int decimals = 5,
    01505                 double objSense = 0.0,
    01506                 bool useRowNames = true) const;
    01507
    01526   int writeLpNative(const char *filename,
    01527                     char const * const * const rowNames,
    01528                     char const * const * const columnNames,
    01529                     const double epsilon = 1.0e-5,
    01530                     const int numberAcross = 10,
    01531                     const int decimals = 5,
    01532                     const double objSense = 0.0,
    01533                     const bool useRowNames = true) const;
    01534
    01539   int writeLpNative(FILE *fp,
    01540                     char const * const * const rowNames,
    01541                     char const * const * const columnNames,
    01542                     const double epsilon = 1.0e-5,
    01543                     const int numberAcross = 10,
    01544                     const int decimals = 5,
    01545                     const double objSense = 0.0,
    01546                     const bool useRowNames = true) const;
    01547
    01550   virtual int readLp(const char *filename, const double epsilon = 1e-5);
    01551
    01554   int readLp(FILE *fp, const double epsilon = 1e-5);
    01555
    01557
    01558   //---------------------------------------------------------------------------
    01559
    01562 #ifdef COIN_SNAPSHOT
    01564   virtual CoinSnapshot * snapshot(bool createArrays=true) const;
    01565 #endif
    01566 #ifdef COIN_FACTORIZATION_INFO
    01568   virtual CoinBigIndex getSizeL() const;
    01570   virtual CoinBigIndex getSizeU() const;
    01571 #endif
    01572
    01573
    01574   //---------------------------------------------------------------------------
    01575
    01585     void setApplicationData (void * appData);
    01592     void setAuxiliaryInfo(OsiAuxInfo * auxiliaryInfo);
    01593
    01595     void * getApplicationData() const;
    01597     OsiAuxInfo * getAuxiliaryInfo() const;
    01599   //---------------------------------------------------------------------------
    01600
    01614   virtual void passInMessageHandler(CoinMessageHandler * handler);
    01616   void newLanguage(CoinMessages::Language language);
    01617   inline void setLanguage(CoinMessages::Language language)
    01618   {newLanguage(language);}
    01620   inline CoinMessageHandler * messageHandler() const
    01621   {return handler_;}
    01623   inline CoinMessages messages()
    01624   {return messages_;}
    01626   inline CoinMessages * messagesPointer()
    01627   {return &messages_;}
    01629   inline bool defaultHandler() const
    01630   { return defaultHandler_;}
    01632   //---------------------------------------------------------------------------
    01647     void findIntegers(bool justCount);
    01658     virtual int findIntegersAndSOS(bool justCount);
    01660     inline int numberObjects() const { return numberObjects_;}
    01662     inline void setNumberObjects(int number)
    01663     {  numberObjects_=number;}
    01664
    01666     inline OsiObject ** objects() const { return object_;}
    01667
    01669     const inline OsiObject * object(int which) const { return object_[which];}
    01671     inline OsiObject * modifiableObject(int which) const { return object_[which];}
    01672
    01674     void deleteObjects();
    01675
    01680     void addObjects(int numberObjects, OsiObject ** objects);
    01685     double forceFeasible();
    01687   //---------------------------------------------------------------------------
    01688
    01700     virtual void activateRowCutDebugger (const char *modelName);
    01701
    01715     virtual void activateRowCutDebugger(const double *solution,
    01716                                         bool enforceOptimality = true);
    01717
    01729     const OsiRowCutDebugger *getRowCutDebugger() const;
    01730
    01738     OsiRowCutDebugger * getRowCutDebuggerAlways() const;
    01740
    01749
    01760   virtual int canDoSimplexInterface() const ;
    01762
    01770
    01779   virtual void enableFactorization() const ;
    01780
    01782   virtual void disableFactorization() const ;
    01783
    01794   virtual bool basisIsAvailable() const ;
    01795
    01797   inline bool optimalBasisIsAvailable() const { return basisIsAvailable() ; }
    01798
    01822   virtual void getBasisStatus(int* cstat, int* rstat) const ;
    01823
    01838   virtual int setBasisStatus(const int* cstat, const int* rstat) ;
    01839
    01845   virtual void getReducedGradient(double* columnReducedCosts,
    01846                                   double* duals, const double* c) const ;
    01847
    01853   virtual void getBInvARow(int row, double* z, double* slack = NULL) const ;
    01854
    01856   virtual void getBInvRow(int row, double* z) const ;
    01857
    01859   virtual void getBInvACol(int col, double* vec) const ;
    01860
    01862   virtual void getBInvCol(int col, double* vec) const ;
    01863
    01871   virtual void getBasics(int* index) const ;
    01872
    01874
    01882
    01889   virtual void enableSimplexInterface(bool doingPrimal) ;
    01890
    01892   virtual void disableSimplexInterface() ;
    01900   virtual int pivot(int colIn, int colOut, int outStatus) ;
    01901
    01913   virtual int primalPivotResult(int colIn, int sign,
    01914                                 int& colOut, int& outStatus,
    01915                                 double& t, CoinPackedVector* dx);
    01916
    01923   virtual int dualPivotResult(int& colIn, int& sign,
    01924                               int colOut, int outStatus,
    01925                               double& t, CoinPackedVector* dx) ;
    01927
    01928   //---------------------------------------------------------------------------
    01929
    01931
    01932
    01933     OsiSolverInterface();
    01934
    01940     virtual OsiSolverInterface * clone(bool copyData = true) const = 0;
    01941
    01943     OsiSolverInterface(const OsiSolverInterface &);
    01944
    01946     OsiSolverInterface & operator=(const OsiSolverInterface& rhs);
    01947
    01949     virtual ~OsiSolverInterface ();
    01950
    01957     virtual void reset();
    01959
    01960   //---------------------------------------------------------------------------
    01961
    01962 protected:
    01964
    01965
    01966     virtual void applyRowCut( const OsiRowCut & rc ) = 0;
    01967
    01969     virtual void applyColCut( const OsiColCut & cc ) = 0;
    01970
    01973     inline void
    01974     convertBoundToSense(const double lower, const double upper,
    01975                         char& sense, double& right, double& range) const;
    01978     inline void
    01979     convertSenseToBound(const char sense, const double right,
    01980                         const double range,
    01981                         double& lower, double& upper) const;
    01984     template <class T> inline T
    01985     forceIntoRange(const T value, const T lower, const T upper) const {
    01986       return value < lower ? lower : (value > upper ? upper : value);
    01987     }
    01994     void setInitialData();
    01996
    01998
    01999
    02004     mutable OsiRowCutDebugger * rowCutDebugger_;
    02005    // Why not just make useful stuff protected?
    02007   CoinMessageHandler * handler_;
    02013   bool defaultHandler_;
    02015   CoinMessages messages_;
    02017   int numberIntegers_;
    02019   int numberObjects_;
    02020
    02022   OsiObject ** object_;
    02028   mutable char * columnType_;
    02029
    02031
    02032   //---------------------------------------------------------------------------
    02033
    02034 private:
    02036
    02037
    02038     OsiAuxInfo * appDataEtc_;
    02040     int intParam_[OsiLastIntParam];
    02042     double dblParam_[OsiLastDblParam];
    02044     std::string strParam_[OsiLastStrParam];
    02046     bool hintParam_[OsiLastHintParam];
    02048     OsiHintStrength hintStrength_[OsiLastHintParam];
    02051     CoinWarmStart* ws_;
    02053     std::vector<double> strictColSolution_;
    02054
    02056     OsiNameVec rowNames_ ;
    02058     OsiNameVec colNames_ ;
    02060     std::string objName_ ;
    02061
    02063 };
    02064
    02065 //#############################################################################
    02068 inline void
    02069 OsiSolverInterface::convertBoundToSense(const double lower, const double upper,
    02070                                         char& sense, double& right,
    02071                                         double& range) const
    02072 {
    02073   double inf = getInfinity();
    02074   range = 0.0;
    02075   if (lower > -inf) {
    02076     if (upper < inf) {
    02077       right = upper;
    02078       if (upper==lower) {
    02079         sense = 'E';
    02080       } else {
    02081         sense = 'R';
    02082         range = upper - lower;
    02083       }
    02084     } else {
    02085       sense = 'G';
    02086       right = lower;
    02087     }
    02088   } else {
    02089     if (upper < inf) {
    02090       sense = 'L';
    02091       right = upper;
    02092     } else {
    02093       sense = 'N';
    02094       right = 0.0;
    02095     }
    02096   }
    02097 }
    02098
    02099 //-----------------------------------------------------------------------------
    02102 inline void
    02103 OsiSolverInterface::convertSenseToBound(const char sense, const double right,
    02104                                         const double range,
    02105                                         double& lower, double& upper) const
    02106 {
    02107   double inf=getInfinity();
    02108   switch (sense) {
    02109   case 'E':
    02110     lower = upper = right;
    02111     break;
    02112   case 'L':
    02113     lower = -inf;
    02114     upper = right;
    02115     break;
    02116   case 'G':
    02117     lower = right;
    02118     upper = inf;
    02119     break;
    02120   case 'R':
    02121     lower = right - range;
    02122     upper = right;
    02123     break;
    02124   case 'N':
    02125     lower = -inf;
    02126     upper = inf;
    02127     break;
    02128   }
    02129 }
    02130
    02131 #endif