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

- File List
- File Members

# /home/coin/SVN-release/Osi-0.98.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 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 = (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 = (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 = (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
    01454
    01455   //---------------------------------------------------------------------------
    01456
    01466     void setApplicationData (void * appData);
    01473     void setAuxiliaryInfo(OsiAuxInfo * auxiliaryInfo);
    01474
    01476     void * getApplicationData() const;
    01478     OsiAuxInfo * getAuxiliaryInfo() const;
    01480   //---------------------------------------------------------------------------
    01481
    01495   void passInMessageHandler(CoinMessageHandler * handler);
    01497   void newLanguage(CoinMessages::Language language);
    01498   inline void setLanguage(CoinMessages::Language language)
    01499   {newLanguage(language);}
    01501   inline CoinMessageHandler * messageHandler() const
    01502   {return handler_;}
    01504   inline CoinMessages messages()
    01505   {return messages_;}
    01507   inline CoinMessages * messagesPointer()
    01508   {return &messages_;}
    01510   inline bool defaultHandler() const
    01511   { return defaultHandler_;}
    01513   //---------------------------------------------------------------------------
    01528     void findIntegers(bool justCount);
    01539     virtual int findIntegersAndSOS(bool justCount);
    01541     inline int numberObjects() const { return numberObjects_;}
    01543     inline void setNumberObjects(int number)
    01544     {  numberObjects_=number;}
    01545
    01547     inline OsiObject ** objects() const { return object_;}
    01548
    01550     const inline OsiObject * object(int which) const { return object_[which];}
    01552     inline OsiObject * modifiableObject(int which) const { return object_[which];}
    01553
    01555     void deleteObjects();
    01556
    01561     void addObjects(int numberObjects, OsiObject ** objects);
    01566     double forceFeasible();
    01568   //---------------------------------------------------------------------------
    01569
    01578     virtual void activateRowCutDebugger (const char * modelName);
    01579
    01585     virtual void activateRowCutDebugger( const double * solution);
    01595     const OsiRowCutDebugger * getRowCutDebugger() const;
    01597     const OsiRowCutDebugger * getRowCutDebuggerAlways() const;
    01598
    01600
    01601
    01609 public:
    01611
    01612
    01615   virtual int canDoSimplexInterface() const;
    01622   virtual void enableSimplexInterface(bool doingPrimal) ;
    01623
    01625   virtual void disableSimplexInterface() ;
    01626
    01633   virtual void enableFactorization() const;
    01635   virtual void disableFactorization() const;
    01636
    01641   virtual bool basisIsAvailable() const ;
    01643   inline bool optimalBasisIsAvailable() const
    01644   { return basisIsAvailable();}
    01645
    01658   virtual void getBasisStatus(int* cstat, int* rstat) const ;
    01659
    01666   virtual int setBasisStatus(const int* cstat, const int* rstat) ;
    01667
    01675   virtual int pivot(int colIn, int colOut, int outStatus) ;
    01676
    01688   virtual int primalPivotResult(int colIn, int sign,
    01689                                 int& colOut, int& outStatus,
    01690                                 double& t, CoinPackedVector* dx);
    01691
    01698   virtual int dualPivotResult(int& colIn, int& sign,
    01699                               int colOut, int outStatus,
    01700                               double& t, CoinPackedVector* dx) ;
    01701
    01703   virtual void getReducedGradient(double* columnReducedCosts,
    01704                                   double * duals,
    01705                                   const double * c) ;
    01706
    01709   virtual void setObjectiveAndRefresh(double* c) ;
    01710
    01712   virtual void getBInvARow(int row, double* z, double * slack=NULL) const ;
    01713
    01715   virtual void getBInvRow(int row, double* z) const ;
    01716
    01718   virtual void getBInvACol(int col, double* vec) const ;
    01719
    01721   virtual void getBInvCol(int col, double* vec) const ;
    01722
    01727   virtual void getBasics(int* index) const ;
    01729
    01730   //---------------------------------------------------------------------------
    01731
    01733
    01734
    01735     OsiSolverInterface();
    01736
    01742     virtual OsiSolverInterface * clone(bool copyData = true) const = 0;
    01743
    01745     OsiSolverInterface(const OsiSolverInterface &);
    01746
    01748     OsiSolverInterface & operator=(const OsiSolverInterface& rhs);
    01749
    01751     virtual ~OsiSolverInterface ();
    01752
    01759     virtual void reset();
    01761
    01762   //---------------------------------------------------------------------------
    01763
    01764 protected:
    01766
    01767
    01768     virtual void applyRowCut( const OsiRowCut & rc ) = 0;
    01769
    01771     virtual void applyColCut( const OsiColCut & cc ) = 0;
    01772
    01775     inline void
    01776     convertBoundToSense(const double lower, const double upper,
    01777                         char& sense, double& right, double& range) const;
    01780     inline void
    01781     convertSenseToBound(const char sense, const double right,
    01782                         const double range,
    01783                         double& lower, double& upper) const;
    01786     template <class T> inline T
    01787     forceIntoRange(const T value, const T lower, const T upper) const {
    01788       return value < lower ? lower : (value > upper ? upper : value);
    01789     }
    01796     void setInitialData();
    01798
    01800
    01801
    01802     OsiRowCutDebugger * rowCutDebugger_;
    01803    // Why not just make useful stuff protected?
    01805   CoinMessageHandler * handler_;
    01811   bool defaultHandler_;
    01813   CoinMessages messages_;
    01815   int numberIntegers_;
    01817   int numberObjects_;
    01818
    01820   OsiObject ** object_;
    01826   mutable char * columnType_;
    01827
    01829
    01830   //---------------------------------------------------------------------------
    01831
    01832 private:
    01834
    01835
    01836     OsiAuxInfo * appDataEtc_;
    01838     int intParam_[OsiLastIntParam];
    01840     double dblParam_[OsiLastDblParam];
    01842     std::string strParam_[OsiLastStrParam];
    01844     bool hintParam_[OsiLastHintParam];
    01846     OsiHintStrength hintStrength_[OsiLastHintParam];
    01849     CoinWarmStart* ws_;
    01851     std::vector<double> strictColSolution_;
    01852
    01854     OsiNameVec rowNames_ ;
    01856     OsiNameVec colNames_ ;
    01858     std::string objName_ ;
    01859
    01861 };
    01862
    01863 //#############################################################################
    01871 int
    01872 OsiSolverInterfaceCommonUnitTest(
    01873    const OsiSolverInterface* emptySi,
    01874    const std::string & mpsDir,
    01875    const std::string & netlibDir);
    01876
    01877 //#############################################################################
    01880 int
    01881 OsiSolverInterfaceMpsUnitTest(
    01882    const std::vector<OsiSolverInterface*> & vecSiP,
    01883    const std::string & mpsDir);
    01884
    01885 //#############################################################################
    01888 inline void
    01889 OsiSolverInterface::convertBoundToSense(const double lower, const double upper,
    01890                                         char& sense, double& right,
    01891                                         double& range) const
    01892 {
    01893   double inf = getInfinity();
    01894   range = 0.0;
    01895   if (lower > -inf) {
    01896     if (upper < inf) {
    01897       right = upper;
    01898       if (upper==lower) {
    01899         sense = 'E';
    01900       } else {
    01901         sense = 'R';
    01902         range = upper - lower;
    01903       }
    01904     } else {
    01905       sense = 'G';
    01906       right = lower;
    01907     }
    01908   } else {
    01909     if (upper < inf) {
    01910       sense = 'L';
    01911       right = upper;
    01912     } else {
    01913       sense = 'N';
    01914       right = 0.0;
    01915     }
    01916   }
    01917 }
    01918
    01919 //-----------------------------------------------------------------------------
    01922 inline void
    01923 OsiSolverInterface::convertSenseToBound(const char sense, const double right,
    01924                                         const double range,
    01925                                         double& lower, double& upper) const
    01926 {
    01927   double inf=getInfinity();
    01928   switch (sense) {
    01929   case 'E':
    01930     lower = upper = right;
    01931     break;
    01932   case 'L':
    01933     lower = -inf;
    01934     upper = right;
    01935     break;
    01936   case 'G':
    01937     lower = right;
    01938     upper = inf;
    01939     break;
    01940   case 'R':
    01941     lower = right - range;
    01942     upper = right;
    01943     break;
    01944   case 'N':
    01945     lower = -inf;
    01946     upper = inf;
    01947     break;
    01948   }
    01949 }
    01950
    01951 #endif