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

- File List
- File Members

# /home/coin/SVN-release/Bcps-0.91.0/Osi/src/OsiSolverInterface.hpp

Go to the documentation of this file.

    00001 // Copyright (C) 2000, International Business Machines
    00002 // Corporation and others.  All Rights Reserved.
    00003 #ifndef OsiSolverInterface_H
    00004 #define OsiSolverInterface_H
    00005
    00006 #include <string>
    00007 #include <vector>
    00008
    00009 #include "CoinMessageHandler.hpp"
    00010 #include "CoinPackedVectorBase.hpp"
    00011
    00012 #include "OsiCollections.hpp"
    00013 #include "OsiSolverParameters.hpp"
    00014
    00015 class CoinPackedMatrix;
    00016 class CoinWarmStart;
    00017 class CoinSnapshot;
    00018 class CoinLpIO;
    00019 class CoinMpsIO;
    00020
    00021 class OsiCuts;
    00022 class OsiAuxInfo;
    00023 class OsiRowCut;
    00024 class OsiRowCutDebugger;
    00025 class CoinSet;
    00026 class CoinBuild;
    00027 class CoinModel;
    00028 class OsiSolverBranch;
    00029 class OsiSolverResult;
    00030 class OsiObject;
    00031 #include "CoinFinite.hpp"
    00032
    00033
    00034 //#############################################################################
    00035
    00059 class OsiSolverInterface  {
    00060    friend int OsiSolverInterfaceCommonUnitTest(
    00061       const OsiSolverInterface* emptySi,
    00062       const std::string & mpsDir,
    00063       const std::string & netlibDir);
    00064    friend int OsiSolverInterfaceMpsUnitTest(
    00065       const std::vector<OsiSolverInterface*> & vecSiP,
    00066       const std::string & mpsDir);
    00067
    00068 public:
    00069
    00071   class ApplyCutsReturnCode {
    00072     friend class OsiSolverInterface;
    00073     friend class OsiOslSolverInterface;
    00074
    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;
    00387     virtual CoinWarmStart* getPointerToWarmStart(bool & mustDelete) ;
    00388
    00397     virtual bool setWarmStart(const CoinWarmStart* warmstart) = 0;
    00399
    00400   //---------------------------------------------------------------------------
    00421
    00422     virtual void markHotStart();
    00424     virtual void solveFromHotStart();
    00426     virtual void unmarkHotStart();
    00428
    00429   //---------------------------------------------------------------------------
    00440
    00441     virtual int getNumCols() const = 0;
    00442
    00444     virtual int getNumRows() const = 0;
    00445
    00447     virtual int getNumElements() const = 0;
    00448
    00450     virtual int getNumIntegers() const ;
    00451
    00453     virtual const double * getColLower() const = 0;
    00454
    00456     virtual const double * getColUpper() const = 0;
    00457
    00467     virtual const char * getRowSense() const = 0;
    00468
    00481     virtual const double * getRightHandSide() const = 0;
    00482
    00491     virtual const double * getRowRange() const = 0;
    00492
    00494     virtual const double * getRowLower() const = 0;
    00495
    00497     virtual const double * getRowUpper() const = 0;
    00498
    00500     virtual const double * getObjCoefficients() const = 0;
    00501
    00503     virtual double getObjSense() const = 0;
    00504
    00506     virtual bool isContinuous(int colIndex) const = 0;
    00507
    00509     virtual bool isBinary(int colIndex) const;
    00510
    00515     virtual bool isInteger(int colIndex) const;
    00516
    00518     virtual bool isIntegerNonBinary(int colIndex) const;
    00519
    00521     virtual bool isFreeBinary(int colIndex) const;
    00528     inline const char * columnType(bool refresh=false) const
    00529     { return getColType(refresh);}
    00535     virtual const char * getColType(bool refresh=false) const;
    00536
    00538     virtual const CoinPackedMatrix * getMatrixByRow() const = 0;
    00539
    00541     virtual const CoinPackedMatrix * getMatrixByCol() const = 0;
    00542
    00544     virtual CoinPackedMatrix * getMutableMatrixByRow() const {return NULL;}
    00545
    00547     virtual CoinPackedMatrix * getMutableMatrixByCol() const {return NULL;}
    00548
    00550     virtual double getInfinity() const = 0;
    00552
    00555
    00556     virtual const double * getColSolution() const = 0;
    00557
    00561     const double * getStrictColSolution();
    00562
    00564     virtual const double * getRowPrice() const = 0;
    00565
    00567     virtual const double * getReducedCost() const = 0;
    00568
    00571     virtual const double * getRowActivity() const = 0;
    00572
    00574     virtual double getObjValue() const = 0;
    00575
    00578     virtual int getIterationCount() const = 0;
    00579
    00593     virtual std::vector<double*> getDualRays(int maxNumRays) const = 0;
    00605     virtual std::vector<double*> getPrimalRays(int maxNumRays) const = 0;
    00606
    00609     virtual OsiVectorInt getFractionalIndices(const double etol=1.e-05)
    00610       const;
    00612
    00613   //-------------------------------------------------------------------------
    00626     virtual void setObjCoeff( int elementIndex, double elementValue ) = 0;
    00627
    00629     virtual void setObjCoeffSet(const int* indexFirst,
    00630                                 const int* indexLast,
    00631                                 const double* coeffList);
    00632
    00638     virtual void setObjective(const double * array);
    00639
    00650     virtual void setObjSense(double s) = 0;
    00651
    00652
    00655     virtual void setColLower( int elementIndex, double elementValue ) = 0;
    00656
    00662     virtual void setColLower(const double * array);
    00663
    00666     virtual void setColUpper( int elementIndex, double elementValue ) = 0;
    00667
    00673     virtual void setColUpper(const double * array);
    00674
    00675
    00679     virtual void setColBounds( int elementIndex,
    00680                                double lower, double upper ) {
    00681        setColLower(elementIndex, lower);
    00682        setColUpper(elementIndex, upper);
    00683     }
    00684
    00691     virtual void setColSetBounds(const int* indexFirst,
    00692                                  const int* indexLast,
    00693                                  const double* boundList);
    00694
    00697     virtual void setRowLower( int elementIndex, double elementValue ) = 0;
    00698
    00701     virtual void setRowUpper( int elementIndex, double elementValue ) = 0;
    00702
    00706     virtual void setRowBounds( int elementIndex,
    00707                                double lower, double upper ) {
    00708        setRowLower(elementIndex, lower);
    00709        setRowUpper(elementIndex, upper);
    00710     }
    00711
    00718     virtual void setRowSetBounds(const int* indexFirst,
    00719                                  const int* indexLast,
    00720                                  const double* boundList);
    00721
    00722
    00724     virtual void setRowType(int index, char sense, double rightHandSide,
    00725                             double range) = 0;
    00726
    00731     virtual void setRowSetTypes(const int* indexFirst,
    00732                                 const int* indexLast,
    00733                                 const char* senseList,
    00734                                 const double* rhsList,
    00735                                 const double* rangeList);
    00736
    00746     virtual void setColSolution(const double *colsol) = 0;
    00747
    00757     virtual void setRowPrice(const double * rowprice) = 0;
    00758
    00767     virtual int reducedCostFix(double gap, bool justInteger=true);
    00769
    00770   //-------------------------------------------------------------------------
    00774     virtual void setContinuous(int index) = 0;
    00776     virtual void setInteger(int index) = 0;
    00779     virtual void setContinuous(const int* indices, int len);
    00782     virtual void setInteger(const int* indices, int len);
    00784   //-------------------------------------------------------------------------
    00785
    00786   //-------------------------------------------------------------------------
    00787
    00789     typedef std::vector<std::string> OsiNameVec ;
    00790
    00811
    00821     virtual std::string dfltRowColName(char rc,
    00822                                  int ndx, unsigned digits = 7) const ;
    00823
    00826   virtual std::string getObjName (unsigned maxLen = static_cast<unsigned>(std::string::npos)) const ;
    00827
    00830     virtual inline void setObjName (std::string name)
    00831     { objName_ = name ; }
    00832
    00839     virtual std::string getRowName(int rowIndex,
    00840                                    unsigned maxLen = static_cast<unsigned>(std::string::npos)) const ;
    00841
    00853     virtual const OsiNameVec &getRowNames() ;
    00854
    00860     virtual void setRowName(int ndx, std::string name) ;
    00861
    00868     virtual void setRowNames(OsiNameVec &srcNames,
    00869                      int srcStart, int len, int tgtStart) ;
    00870
    00876     virtual void deleteRowNames(int tgtStart, int len) ;
    00877
    00884     virtual std::string getColName(int colIndex,
    00885                                    unsigned maxLen = static_cast<unsigned>(std::string::npos)) const ;
    00886
    00896     virtual const OsiNameVec &getColNames() ;
    00897
    00903     virtual void setColName(int ndx, std::string name) ;
    00904
    00911     virtual void setColNames(OsiNameVec &srcNames,
    00912                      int srcStart, int len, int tgtStart) ;
    00913
    00919     virtual void deleteColNames(int tgtStart, int len) ;
    00920
    00921
    00928     void setRowColNames(const CoinMpsIO &mps) ;
    00929
    00935     void setRowColNames(CoinModel &mod) ;
    00936
    00943     void setRowColNames(CoinLpIO &mod) ;
    00944
    00946   //-------------------------------------------------------------------------
    00947
    00948   //-------------------------------------------------------------------------
    00954
    00956     virtual void addCol(const CoinPackedVectorBase& vec,
    00957                         const double collb, const double colub,
    00958                         const double obj) = 0;
    00959
    00965     virtual void addCol(const CoinPackedVectorBase& vec,
    00966                         const double collb, const double colub,
    00967                         const double obj, std::string name) ;
    00968
    00970     virtual void addCol(int numberElements,
    00971                         const int* rows, const double* elements,
    00972                         const double collb, const double colub,
    00973                         const double obj) ;
    00974
    00980     virtual void addCol(int numberElements,
    00981                         const int* rows, const double* elements,
    00982                         const double collb, const double colub,
    00983                         const double obj, std::string name) ;
    00984
    00990     virtual void addCols(const int numcols,
    00991                          const CoinPackedVectorBase * const * cols,
    00992                          const double* collb, const double* colub,
    00993                          const double* obj);
    00994
    01000     virtual void addCols(const int numcols, const int* columnStarts,
    01001                          const int* rows, const double* elements,
    01002                          const double* collb, const double* colub,
    01003                          const double* obj);
    01004
    01006     void addCols(const CoinBuild & buildObject);
    01007
    01013     int addCols(CoinModel & modelObject);
    01014
    01015 #if 0
    01016
    01017     virtual void addCols(const CoinPackedMatrix& matrix,
    01018                          const double* collb, const double* colub,
    01019                          const double* obj);
    01020 #endif
    01021
    01028     virtual void deleteCols(const int num, const int * colIndices) = 0;
    01029
    01031     virtual void addRow(const CoinPackedVectorBase& vec,
    01032                         const double rowlb, const double rowub) = 0;
    01033
    01039     virtual void addRow(const CoinPackedVectorBase& vec,
    01040                         const double rowlb, const double rowub,
    01041                         std::string name) ;
    01042
    01044     virtual void addRow(const CoinPackedVectorBase& vec,
    01045                         const char rowsen, const double rowrhs,
    01046                         const double rowrng) = 0;
    01047
    01053     virtual void addRow(const CoinPackedVectorBase& vec,
    01054                         const char rowsen, const double rowrhs,
    01055                         const double rowrng, std::string name) ;
    01056
    01061     virtual void addRow(int numberElements,
    01062                         const int *columns, const double *element,
    01063                         const double rowlb, const double rowub) ;
    01064
    01070     virtual void addRows(const int numrows,
    01071                          const CoinPackedVectorBase * const * rows,
    01072                          const double* rowlb, const double* rowub);
    01073
    01079     virtual void addRows(const int numrows,
    01080                          const CoinPackedVectorBase * const * rows,
    01081                          const char* rowsen, const double* rowrhs,
    01082                          const double* rowrng);
    01083
    01089     virtual void addRows(const int numrows, const int *rowStarts,
    01090                          const int *columns, const double *element,
    01091                          const double *rowlb, const double *rowub);
    01092
    01094     void addRows(const CoinBuild &buildObject);
    01095
    01104     int addRows(CoinModel &modelObject);
    01105
    01106 #if 0
    01107
    01108     virtual void addRows(const CoinPackedMatrix& matrix,
    01109                          const double* rowlb, const double* rowub);
    01111     virtual void addRows(const CoinPackedMatrix& matrix,
    01112                          const char* rowsen, const double* rowrhs,
    01113                          const double* rowrng);
    01114 #endif
    01115
    01121     virtual void deleteRows(const int num, const int * rowIndices) = 0;
    01122
    01125     virtual void saveBaseModel() {}
    01129     virtual void restoreBaseModel(int numberRows);
    01130     //-----------------------------------------------------------------------
    01153     virtual ApplyCutsReturnCode applyCuts(const OsiCuts & cs,
    01154                                           double effectivenessLb = 0.0);
    01155
    01160     virtual void applyRowCuts(int numberCuts, const OsiRowCut * cuts);
    01161
    01165     virtual void applyRowCuts(int numberCuts, const OsiRowCut ** cuts);
    01166
    01168     void deleteBranchingInfo(int numberDeleted, const int * which);
    01169
    01171
    01172   //---------------------------------------------------------------------------
    01173
    01191     virtual void loadProblem (const CoinPackedMatrix& matrix,
    01192                               const double* collb, const double* colub,
    01193                               const double* obj,
    01194                               const double* rowlb, const double* rowub) = 0;
    01195
    01205     virtual void assignProblem (CoinPackedMatrix*& matrix,
    01206                                 double*& collb, double*& colub, double*& obj,
    01207                                 double*& rowlb, double*& rowub) = 0;
    01208
    01225     virtual void loadProblem (const CoinPackedMatrix& matrix,
    01226                               const double* collb, const double* colub,
    01227                               const double* obj,
    01228                               const char* rowsen, const double* rowrhs,
    01229                               const double* rowrng) = 0;
    01230
    01240     virtual void assignProblem (CoinPackedMatrix*& matrix,
    01241                                 double*& collb, double*& colub, double*& obj,
    01242                                 char*& rowsen, double*& rowrhs,
    01243                                 double*& rowrng) = 0;
    01244
    01257     virtual void loadProblem (const int numcols, const int numrows,
    01258                               const CoinBigIndex * start, const int* index,
    01259                               const double* value,
    01260                               const double* collb, const double* colub,
    01261                               const double* obj,
    01262                               const double* rowlb, const double* rowub) = 0;
    01263
    01276     virtual void loadProblem (const int numcols, const int numrows,
    01277                               const CoinBigIndex * start, const int* index,
    01278                               const double* value,
    01279                               const double* collb, const double* colub,
    01280                               const double* obj,
    01281                               const char* rowsen, const double* rowrhs,
    01282                               const double* rowrng) = 0;
    01283
    01290     virtual int loadFromCoinModel (CoinModel & modelObject,
    01291                                    bool keepSolution=false);
    01292
    01298     virtual int readMps (const char *filename,
    01299                          const char *extension = "mps") ;
    01300
    01307     virtual int readMps (const char *filename, const char*extension,
    01308                         int & numberSets, CoinSet ** & sets);
    01309
    01315     virtual int readGMPL (const char *filename, const char *dataname=NULL);
    01316
    01323     virtual void writeMps (const char *filename,
    01324                            const char *extension = "mps",
    01325                            double objSense=0.0) const = 0;
    01326
    01340     int writeMpsNative (const char *filename,
    01341                         const char ** rowNames, const char ** columnNames,
    01342                         int formatType=0,int numberAcross=2,
    01343                         double objSense=0.0, int numberSOS=0,
    01344                         const CoinSet * setInfo=NULL) const ;
    01345
    01346 /***********************************************************************/
    01347 // Lp files
    01348
    01368   virtual void writeLp(const char *filename,
    01369                const char *extension = "lp",
    01370                 double epsilon = 1e-5,
    01371                 int numberAcross = 10,
    01372                 int decimals = 5,
    01373                 double objSense = 0.0,
    01374                 bool useRowNames = true) const;
    01375
    01380   virtual void writeLp(FILE *fp,
    01381                 double epsilon = 1e-5,
    01382                 int numberAcross = 10,
    01383                 int decimals = 5,
    01384                 double objSense = 0.0,
    01385                 bool useRowNames = true) const;
    01386
    01405   int writeLpNative(const char *filename,
    01406                     char const * const * const rowNames,
    01407                     char const * const * const columnNames,
    01408                     const double epsilon = 1.0e-5,
    01409                     const int numberAcross = 10,
    01410                     const int decimals = 5,
    01411                     const double objSense = 0.0,
    01412                     const bool useRowNames = true) const;
    01413
    01418   int writeLpNative(FILE *fp,
    01419                     char const * const * const rowNames,
    01420                     char const * const * const columnNames,
    01421                     const double epsilon = 1.0e-5,
    01422                     const int numberAcross = 10,
    01423                     const int decimals = 5,
    01424                     const double objSense = 0.0,
    01425                     const bool useRowNames = true) const;
    01426
    01429   virtual int readLp(const char *filename, const double epsilon = 1e-5);
    01430
    01433   int readLp(FILE *fp, const double epsilon = 1e-5);
    01434
    01440   virtual void replaceMatrixOptional(const CoinPackedMatrix & matrix) {}
    01442   virtual void replaceMatrix(const CoinPackedMatrix & matrix) {abort();}
    01444
    01445   //---------------------------------------------------------------------------
    01446
    01449 #ifdef COIN_SNAPSHOT
    01451   virtual CoinSnapshot * snapshot(bool createArrays=true) const;
    01452 #endif
    01453 #ifdef COIN_FACTORIZATION_INFO
    01455   virtual CoinBigIndex getSizeL() const;
    01457   virtual CoinBigIndex getSizeU() const;
    01458 #endif
    01459
    01460
    01461   //---------------------------------------------------------------------------
    01462
    01472     void setApplicationData (void * appData);
    01479     void setAuxiliaryInfo(OsiAuxInfo * auxiliaryInfo);
    01480
    01482     void * getApplicationData() const;
    01484     OsiAuxInfo * getAuxiliaryInfo() const;
    01486   //---------------------------------------------------------------------------
    01487
    01501   virtual void passInMessageHandler(CoinMessageHandler * handler);
    01503   void newLanguage(CoinMessages::Language language);
    01504   inline void setLanguage(CoinMessages::Language language)
    01505   {newLanguage(language);}
    01507   inline CoinMessageHandler * messageHandler() const
    01508   {return handler_;}
    01510   inline CoinMessages messages()
    01511   {return messages_;}
    01513   inline CoinMessages * messagesPointer()
    01514   {return &messages_;}
    01516   inline bool defaultHandler() const
    01517   { return defaultHandler_;}
    01519   //---------------------------------------------------------------------------
    01534     void findIntegers(bool justCount);
    01545     virtual int findIntegersAndSOS(bool justCount);
    01547     inline int numberObjects() const { return numberObjects_;}
    01549     inline void setNumberObjects(int number)
    01550     {  numberObjects_=number;}
    01551
    01553     inline OsiObject ** objects() const { return object_;}
    01554
    01556     const inline OsiObject * object(int which) const { return object_[which];}
    01558     inline OsiObject * modifiableObject(int which) const { return object_[which];}
    01559
    01561     void deleteObjects();
    01562
    01567     void addObjects(int numberObjects, OsiObject ** objects);
    01572     double forceFeasible();
    01574   //---------------------------------------------------------------------------
    01575
    01584     virtual void activateRowCutDebugger (const char * modelName);
    01585
    01591     virtual void activateRowCutDebugger( const double * solution);
    01601     const OsiRowCutDebugger * getRowCutDebugger() const;
    01603     const OsiRowCutDebugger * getRowCutDebuggerAlways() const;
    01604
    01606
    01607
    01615 public:
    01617
    01618
    01621   virtual int canDoSimplexInterface() const;
    01628   virtual void enableSimplexInterface(bool doingPrimal) ;
    01629
    01631   virtual void disableSimplexInterface() ;
    01632
    01639   virtual void enableFactorization() const;
    01641   virtual void disableFactorization() const;
    01642
    01647   virtual bool basisIsAvailable() const ;
    01649   inline bool optimalBasisIsAvailable() const
    01650   { return basisIsAvailable();}
    01651
    01664   virtual void getBasisStatus(int* cstat, int* rstat) const ;
    01665
    01672   virtual int setBasisStatus(const int* cstat, const int* rstat) ;
    01673
    01681   virtual int pivot(int colIn, int colOut, int outStatus) ;
    01682
    01694   virtual int primalPivotResult(int colIn, int sign,
    01695                                 int& colOut, int& outStatus,
    01696                                 double& t, CoinPackedVector* dx);
    01697
    01704   virtual int dualPivotResult(int& colIn, int& sign,
    01705                               int colOut, int outStatus,
    01706                               double& t, CoinPackedVector* dx) ;
    01707
    01709   virtual void getReducedGradient(double* columnReducedCosts,
    01710                                   double * duals,
    01711                                   const double * c) ;
    01712
    01715   virtual void setObjectiveAndRefresh(double* c) ;
    01716
    01718   virtual void getBInvARow(int row, double* z, double * slack=NULL) const ;
    01719
    01721   virtual void getBInvRow(int row, double* z) const ;
    01722
    01724   virtual void getBInvACol(int col, double* vec) const ;
    01725
    01727   virtual void getBInvCol(int col, double* vec) const ;
    01728
    01733   virtual void getBasics(int* index) const ;
    01735
    01736   //---------------------------------------------------------------------------
    01737
    01739
    01740
    01741     OsiSolverInterface();
    01742
    01748     virtual OsiSolverInterface * clone(bool copyData = true) const = 0;
    01749
    01751     OsiSolverInterface(const OsiSolverInterface &);
    01752
    01754     OsiSolverInterface & operator=(const OsiSolverInterface& rhs);
    01755
    01757     virtual ~OsiSolverInterface ();
    01758
    01765     virtual void reset();
    01767
    01768   //---------------------------------------------------------------------------
    01769
    01770 protected:
    01772
    01773
    01774     virtual void applyRowCut( const OsiRowCut & rc ) = 0;
    01775
    01777     virtual void applyColCut( const OsiColCut & cc ) = 0;
    01778
    01781     inline void
    01782     convertBoundToSense(const double lower, const double upper,
    01783                         char& sense, double& right, double& range) const;
    01786     inline void
    01787     convertSenseToBound(const char sense, const double right,
    01788                         const double range,
    01789                         double& lower, double& upper) const;
    01792     template <class T> inline T
    01793     forceIntoRange(const T value, const T lower, const T upper) const {
    01794       return value < lower ? lower : (value > upper ? upper : value);
    01795     }
    01802     void setInitialData();
    01804
    01806
    01807
    01808     OsiRowCutDebugger * rowCutDebugger_;
    01809    // Why not just make useful stuff protected?
    01811   CoinMessageHandler * handler_;
    01817   bool defaultHandler_;
    01819   CoinMessages messages_;
    01821   int numberIntegers_;
    01823   int numberObjects_;
    01824
    01826   OsiObject ** object_;
    01832   mutable char * columnType_;
    01833
    01835
    01836   //---------------------------------------------------------------------------
    01837
    01838 private:
    01840
    01841
    01842     OsiAuxInfo * appDataEtc_;
    01844     int intParam_[OsiLastIntParam];
    01846     double dblParam_[OsiLastDblParam];
    01848     std::string strParam_[OsiLastStrParam];
    01850     bool hintParam_[OsiLastHintParam];
    01852     OsiHintStrength hintStrength_[OsiLastHintParam];
    01855     CoinWarmStart* ws_;
    01857     std::vector<double> strictColSolution_;
    01858
    01860     OsiNameVec rowNames_ ;
    01862     OsiNameVec colNames_ ;
    01864     std::string objName_ ;
    01865
    01867 };
    01868
    01869 //#############################################################################
    01877 int
    01878 OsiSolverInterfaceCommonUnitTest(
    01879    const OsiSolverInterface* emptySi,
    01880    const std::string & mpsDir,
    01881    const std::string & netlibDir);
    01882
    01883 //#############################################################################
    01886 int
    01887 OsiSolverInterfaceMpsUnitTest(
    01888    const std::vector<OsiSolverInterface*> & vecSiP,
    01889    const std::string & mpsDir);
    01890
    01891 //#############################################################################
    01894 inline void
    01895 OsiSolverInterface::convertBoundToSense(const double lower, const double upper,
    01896                                         char& sense, double& right,
    01897                                         double& range) const
    01898 {
    01899   double inf = getInfinity();
    01900   range = 0.0;
    01901   if (lower > -inf) {
    01902     if (upper < inf) {
    01903       right = upper;
    01904       if (upper==lower) {
    01905         sense = 'E';
    01906       } else {
    01907         sense = 'R';
    01908         range = upper - lower;
    01909       }
    01910     } else {
    01911       sense = 'G';
    01912       right = lower;
    01913     }
    01914   } else {
    01915     if (upper < inf) {
    01916       sense = 'L';
    01917       right = upper;
    01918     } else {
    01919       sense = 'N';
    01920       right = 0.0;
    01921     }
    01922   }
    01923 }
    01924
    01925 //-----------------------------------------------------------------------------
    01928 inline void
    01929 OsiSolverInterface::convertSenseToBound(const char sense, const double right,
    01930                                         const double range,
    01931                                         double& lower, double& upper) const
    01932 {
    01933   double inf=getInfinity();
    01934   switch (sense) {
    01935   case 'E':
    01936     lower = upper = right;
    01937     break;
    01938   case 'L':
    01939     lower = -inf;
    01940     upper = right;
    01941     break;
    01942   case 'G':
    01943     lower = right;
    01944     upper = inf;
    01945     break;
    01946   case 'R':
    01947     lower = right - range;
    01948     upper = right;
    01949     break;
    01950   case 'N':
    01951     lower = -inf;
    01952     upper = inf;
    01953     break;
    01954   }
    01955 }
    01956
    01957 #endif