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

- File List
- File Members

# /home/coin/SVN-release/Alps-1.2.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 #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
    00057 class OsiSolverInterface  {
    00058    friend int OsiSolverInterfaceCommonUnitTest(
    00059       const OsiSolverInterface* emptySi,
    00060       const std::string & mpsDir,
    00061       const std::string & netlibDir);
    00062    friend int OsiSolverInterfaceMpsUnitTest(
    00063       const std::vector<OsiSolverInterface*> & vecSiP,
    00064       const std::string & mpsDir);
    00065
    00066 public:
    00067
    00069   class ApplyCutsReturnCode {
    00070     friend class OsiSolverInterface;
    00071     friend class OsiOslSolverInterface;
    00072     friend class OsiClpSolverInterface;
    00073
    00074   public:
    00076
    00077
    00078       ApplyCutsReturnCode():
    00079          intInconsistent_(0),
    00080          extInconsistent_(0),
    00081          infeasible_(0),
    00082          ineffective_(0),
    00083          applied_(0) {}
    00085       ApplyCutsReturnCode(const ApplyCutsReturnCode & rhs):
    00086          intInconsistent_(rhs.intInconsistent_),
    00087          extInconsistent_(rhs.extInconsistent_),
    00088          infeasible_(rhs.infeasible_),
    00089          ineffective_(rhs.ineffective_),
    00090          applied_(rhs.applied_) {}
    00092       ApplyCutsReturnCode & operator=(const ApplyCutsReturnCode& rhs)
    00093       {
    00094         if (this != &rhs) {
    00095           intInconsistent_ = rhs.intInconsistent_;
    00096           extInconsistent_ = rhs.extInconsistent_;
    00097           infeasible_      = rhs.infeasible_;
    00098           ineffective_     = rhs.ineffective_;
    00099           applied_         = rhs.applied_;
    00100         }
    00101         return *this;
    00102       }
    00104       ~ApplyCutsReturnCode(){}
    00106
    00109
    00110       inline int getNumInconsistent(){return intInconsistent_;}
    00112       inline int getNumInconsistentWrtIntegerModel(){return extInconsistent_;}
    00114       inline int getNumInfeasible(){return infeasible_;}
    00116       inline int getNumIneffective(){return ineffective_;}
    00118       inline int getNumApplied(){return applied_;}
    00120
    00121   private:
    00124
    00125       inline void incrementInternallyInconsistent(){intInconsistent_++;}
    00127       inline void incrementExternallyInconsistent(){extInconsistent_++;}
    00129       inline void incrementInfeasible(){infeasible_++;}
    00131       inline void incrementIneffective(){ineffective_++;}
    00133       inline void incrementApplied(){applied_++;}
    00135
    00137
    00138
    00139       int intInconsistent_;
    00141       int extInconsistent_;
    00143       int infeasible_;
    00145       int ineffective_;
    00147       int applied_;
    00149   };
    00150
    00151   //---------------------------------------------------------------------------
    00152
    00154
    00155
    00156     virtual void initialSolve() = 0;
    00157
    00163     virtual void resolve() = 0;
    00164
    00166     virtual void branchAndBound() = 0;
    00167
    00168 #ifdef CBC_NEXT_VERSION
    00169     /*
    00170       Would it make sense to collect all of these routines in a `MIP Helper'
    00171       section? It'd make it easier for users and implementors to find them.
    00172     */
    00190     virtual int solveBranches(int depth,const OsiSolverBranch * branch,
    00191                               OsiSolverResult * result,
    00192                               int & numberSolves, int & numberIterations,
    00193                               bool forceBranch=false);
    00194 #endif
    00195
    00196
    00197   //---------------------------------------------------------------------------
    00255
    00256     virtual bool setIntParam(OsiIntParam key, int value) {
    00257       if (key == OsiLastIntParam) return (false) ;
    00258       intParam_[key] = value;
    00259       return true;
    00260     }
    00262     virtual bool setDblParam(OsiDblParam key, double value) {
    00263       if (key == OsiLastDblParam) return (false) ;
    00264       dblParam_[key] = value;
    00265       return true;
    00266     }
    00268     virtual bool setStrParam(OsiStrParam key, const std::string & value) {
    00269       if (key == OsiLastStrParam) return (false) ;
    00270       strParam_[key] = value;
    00271       return true;
    00272     }
    00284     virtual bool setHintParam(OsiHintParam key, bool yesNo=true,
    00285                               OsiHintStrength strength=OsiHintTry,
    00286                               void *otherInformation = NULL) {
    00287       if (key==OsiLastHintParam)
    00288         return false;
    00289       hintParam_[key] = yesNo;
    00290       hintStrength_[key] = strength;
    00291       if (strength == OsiForceDo)
    00292         throw CoinError("OsiForceDo illegal",
    00293                         "setHintParam", "OsiSolverInterface");
    00294       return true;
    00295     }
    00297     virtual bool getIntParam(OsiIntParam key, int& value) const {
    00298       if (key == OsiLastIntParam) return (false) ;
    00299       value = intParam_[key];
    00300       return true;
    00301     }
    00303     virtual bool getDblParam(OsiDblParam key, double& value) const {
    00304       if (key == OsiLastDblParam) return (false) ;
    00305       value = dblParam_[key];
    00306       return true;
    00307     }
    00309     virtual bool getStrParam(OsiStrParam key, std::string& value) const {
    00310       if (key == OsiLastStrParam) return (false) ;
    00311       value = strParam_[key];
    00312       return true;
    00313     }
    00323     virtual bool getHintParam(OsiHintParam key, bool& yesNo,
    00324                               OsiHintStrength& strength,
    00325                               void *& otherInformation) const {
    00326       if (key==OsiLastHintParam)
    00327         return false;
    00328       yesNo = hintParam_[key];
    00329       strength = hintStrength_[key];
    00330       otherInformation=NULL;
    00331       return true;
    00332     }
    00337     virtual bool getHintParam(OsiHintParam key, bool& yesNo,
    00338                               OsiHintStrength& strength) const {
    00339       if (key==OsiLastHintParam)
    00340         return false;
    00341       yesNo = hintParam_[key];
    00342       strength = hintStrength_[key];
    00343       return true;
    00344     }
    00349     virtual bool getHintParam(OsiHintParam key, bool& yesNo) const {
    00350       if (key==OsiLastHintParam)
    00351         return false;
    00352       yesNo = hintParam_[key];
    00353       return true;
    00354     }
    00361     void copyParameters(OsiSolverInterface & rhs);
    00362
    00376     inline double getIntegerTolerance() const
    00377     { return dblParam_[OsiPrimalTolerance];}
    00379
    00380   //---------------------------------------------------------------------------
    00382
    00383
    00384     virtual bool isAbandoned() const = 0;
    00386     virtual bool isProvenOptimal() const = 0;
    00388     virtual bool isProvenPrimalInfeasible() const = 0;
    00390     virtual bool isProvenDualInfeasible() const = 0;
    00392     virtual bool isPrimalObjectiveLimitReached() const = 0;
    00394     virtual bool isDualObjectiveLimitReached() const = 0;
    00396     virtual bool isIterationLimitReached() const = 0;
    00398
    00399   //---------------------------------------------------------------------------
    00417     virtual CoinWarmStart *getEmptyWarmStart () const = 0 ;
    00418
    00425     virtual CoinWarmStart* getWarmStart() const = 0;
    00434     virtual CoinWarmStart* getPointerToWarmStart(bool & mustDelete) ;
    00435
    00444     virtual bool setWarmStart(const CoinWarmStart* warmstart) = 0;
    00446
    00447   //---------------------------------------------------------------------------
    00468
    00469     virtual void markHotStart();
    00471     virtual void solveFromHotStart();
    00473     virtual void unmarkHotStart();
    00475
    00476   //---------------------------------------------------------------------------
    00487
    00488     virtual int getNumCols() const = 0;
    00489
    00491     virtual int getNumRows() const = 0;
    00492
    00494     virtual int getNumElements() const = 0;
    00495
    00497     virtual int getNumIntegers() const ;
    00498
    00500     virtual const double * getColLower() const = 0;
    00501
    00503     virtual const double * getColUpper() const = 0;
    00504
    00514     virtual const char * getRowSense() const = 0;
    00515
    00528     virtual const double * getRightHandSide() const = 0;
    00529
    00538     virtual const double * getRowRange() const = 0;
    00539
    00541     virtual const double * getRowLower() const = 0;
    00542
    00544     virtual const double * getRowUpper() const = 0;
    00545
    00547     virtual const double * getObjCoefficients() const = 0;
    00548
    00550     virtual double getObjSense() const = 0;
    00551
    00553     virtual bool isContinuous(int colIndex) const = 0;
    00554
    00556     virtual bool isBinary(int colIndex) const;
    00557
    00562     virtual bool isInteger(int colIndex) const;
    00563
    00565     virtual bool isIntegerNonBinary(int colIndex) const;
    00566
    00568     virtual bool isFreeBinary(int colIndex) const;
    00575     inline const char * columnType(bool refresh=false) const
    00576     { return getColType(refresh);}
    00582     virtual const char * getColType(bool refresh=false) const;
    00583
    00585     virtual const CoinPackedMatrix * getMatrixByRow() const = 0;
    00586
    00588     virtual const CoinPackedMatrix * getMatrixByCol() const = 0;
    00589
    00591     virtual CoinPackedMatrix * getMutableMatrixByRow() const {return NULL;}
    00592
    00594     virtual CoinPackedMatrix * getMutableMatrixByCol() const {return NULL;}
    00595
    00597     virtual double getInfinity() const = 0;
    00599
    00602
    00603     virtual const double * getColSolution() const = 0;
    00604
    00608     virtual const double * getStrictColSolution();
    00609
    00611     virtual const double * getRowPrice() const = 0;
    00612
    00614     virtual const double * getReducedCost() const = 0;
    00615
    00621     virtual const double * getRowActivity() const = 0;
    00622
    00624     virtual double getObjValue() const = 0;
    00625
    00629     virtual int getIterationCount() const = 0;
    00630
    00653     virtual std::vector<double*> getDualRays(int maxNumRays,
    00654                                              bool fullRay = false) const = 0;
    00655
    00671     virtual std::vector<double*> getPrimalRays(int maxNumRays) const = 0;
    00672
    00675     virtual OsiVectorInt getFractionalIndices(const double etol=1.e-05)
    00676       const;
    00678
    00679   //-------------------------------------------------------------------------
    00692     virtual void setObjCoeff( int elementIndex, double elementValue ) = 0;
    00693
    00695     virtual void setObjCoeffSet(const int* indexFirst,
    00696                                 const int* indexLast,
    00697                                 const double* coeffList);
    00698
    00704     virtual void setObjective(const double * array);
    00705
    00716     virtual void setObjSense(double s) = 0;
    00717
    00718
    00721     virtual void setColLower( int elementIndex, double elementValue ) = 0;
    00722
    00728     virtual void setColLower(const double * array);
    00729
    00732     virtual void setColUpper( int elementIndex, double elementValue ) = 0;
    00733
    00739     virtual void setColUpper(const double * array);
    00740
    00741
    00745     virtual void setColBounds( int elementIndex,
    00746                                double lower, double upper ) {
    00747        setColLower(elementIndex, lower);
    00748        setColUpper(elementIndex, upper);
    00749     }
    00750
    00757     virtual void setColSetBounds(const int* indexFirst,
    00758                                  const int* indexLast,
    00759                                  const double* boundList);
    00760
    00763     virtual void setRowLower( int elementIndex, double elementValue ) = 0;
    00764
    00767     virtual void setRowUpper( int elementIndex, double elementValue ) = 0;
    00768
    00772     virtual void setRowBounds( int elementIndex,
    00773                                double lower, double upper ) {
    00774        setRowLower(elementIndex, lower);
    00775        setRowUpper(elementIndex, upper);
    00776     }
    00777
    00784     virtual void setRowSetBounds(const int* indexFirst,
    00785                                  const int* indexLast,
    00786                                  const double* boundList);
    00787
    00788
    00790     virtual void setRowType(int index, char sense, double rightHandSide,
    00791                             double range) = 0;
    00792
    00797     virtual void setRowSetTypes(const int* indexFirst,
    00798                                 const int* indexLast,
    00799                                 const char* senseList,
    00800                                 const double* rhsList,
    00801                                 const double* rangeList);
    00802
    00812     virtual void setColSolution(const double *colsol) = 0;
    00813
    00823     virtual void setRowPrice(const double * rowprice) = 0;
    00824
    00833     virtual int reducedCostFix(double gap, bool justInteger=true);
    00835
    00836   //-------------------------------------------------------------------------
    00840     virtual void setContinuous(int index) = 0;
    00842     virtual void setInteger(int index) = 0;
    00845     virtual void setContinuous(const int* indices, int len);
    00848     virtual void setInteger(const int* indices, int len);
    00850   //-------------------------------------------------------------------------
    00851
    00852   //-------------------------------------------------------------------------
    00853
    00855     typedef std::vector<std::string> OsiNameVec ;
    00856
    00877
    00887     virtual std::string dfltRowColName(char rc,
    00888                                  int ndx, unsigned digits = 7) const ;
    00889
    00892   virtual std::string getObjName (unsigned maxLen = static_cast<unsigned>(std::string::npos)) const ;
    00893
    00896     virtual inline void setObjName (std::string name)
    00897     { objName_ = name ; }
    00898
    00905     virtual std::string getRowName(int rowIndex,
    00906                                    unsigned maxLen = static_cast<unsigned>(std::string::npos)) const ;
    00907
    00919     virtual const OsiNameVec &getRowNames() ;
    00920
    00926     virtual void setRowName(int ndx, std::string name) ;
    00927
    00934     virtual void setRowNames(OsiNameVec &srcNames,
    00935                      int srcStart, int len, int tgtStart) ;
    00936
    00942     virtual void deleteRowNames(int tgtStart, int len) ;
    00943
    00950     virtual std::string getColName(int colIndex,
    00951                                    unsigned maxLen = static_cast<unsigned>(std::string::npos)) const ;
    00952
    00962     virtual const OsiNameVec &getColNames() ;
    00963
    00969     virtual void setColName(int ndx, std::string name) ;
    00970
    00977     virtual void setColNames(OsiNameVec &srcNames,
    00978                      int srcStart, int len, int tgtStart) ;
    00979
    00985     virtual void deleteColNames(int tgtStart, int len) ;
    00986
    00987
    00994     void setRowColNames(const CoinMpsIO &mps) ;
    00995
    01001     void setRowColNames(CoinModel &mod) ;
    01002
    01009     void setRowColNames(CoinLpIO &mod) ;
    01010
    01012   //-------------------------------------------------------------------------
    01013
    01014   //-------------------------------------------------------------------------
    01020
    01022     virtual void addCol(const CoinPackedVectorBase& vec,
    01023                         const double collb, const double colub,
    01024                         const double obj) = 0;
    01025
    01031     virtual void addCol(const CoinPackedVectorBase& vec,
    01032                         const double collb, const double colub,
    01033                         const double obj, std::string name) ;
    01034
    01036     virtual void addCol(int numberElements,
    01037                         const int* rows, const double* elements,
    01038                         const double collb, const double colub,
    01039                         const double obj) ;
    01040
    01046     virtual void addCol(int numberElements,
    01047                         const int* rows, const double* elements,
    01048                         const double collb, const double colub,
    01049                         const double obj, std::string name) ;
    01050
    01056     virtual void addCols(const int numcols,
    01057                          const CoinPackedVectorBase * const * cols,
    01058                          const double* collb, const double* colub,
    01059                          const double* obj);
    01060
    01066     virtual void addCols(const int numcols, const int* columnStarts,
    01067                          const int* rows, const double* elements,
    01068                          const double* collb, const double* colub,
    01069                          const double* obj);
    01070
    01072     void addCols(const CoinBuild & buildObject);
    01073
    01079     int addCols(CoinModel & modelObject);
    01080
    01081 #if 0
    01082
    01083     virtual void addCols(const CoinPackedMatrix& matrix,
    01084                          const double* collb, const double* colub,
    01085                          const double* obj);
    01086 #endif
    01087
    01094     virtual void deleteCols(const int num, const int * colIndices) = 0;
    01095
    01097     virtual void addRow(const CoinPackedVectorBase& vec,
    01098                         const double rowlb, const double rowub) = 0;
    01099
    01105     virtual void addRow(const CoinPackedVectorBase& vec,
    01106                         const double rowlb, const double rowub,
    01107                         std::string name) ;
    01108
    01110     virtual void addRow(const CoinPackedVectorBase& vec,
    01111                         const char rowsen, const double rowrhs,
    01112                         const double rowrng) = 0;
    01113
    01119     virtual void addRow(const CoinPackedVectorBase& vec,
    01120                         const char rowsen, const double rowrhs,
    01121                         const double rowrng, std::string name) ;
    01122
    01127     virtual void addRow(int numberElements,
    01128                         const int *columns, const double *element,
    01129                         const double rowlb, const double rowub) ;
    01130
    01136     virtual void addRows(const int numrows,
    01137                          const CoinPackedVectorBase * const * rows,
    01138                          const double* rowlb, const double* rowub);
    01139
    01145     virtual void addRows(const int numrows,
    01146                          const CoinPackedVectorBase * const * rows,
    01147                          const char* rowsen, const double* rowrhs,
    01148                          const double* rowrng);
    01149
    01155     virtual void addRows(const int numrows, const int *rowStarts,
    01156                          const int *columns, const double *element,
    01157                          const double *rowlb, const double *rowub);
    01158
    01160     void addRows(const CoinBuild &buildObject);
    01161
    01170     int addRows(CoinModel &modelObject);
    01171
    01172 #if 0
    01173
    01174     virtual void addRows(const CoinPackedMatrix& matrix,
    01175                          const double* rowlb, const double* rowub);
    01177     virtual void addRows(const CoinPackedMatrix& matrix,
    01178                          const char* rowsen, const double* rowrhs,
    01179                          const double* rowrng);
    01180 #endif
    01181
    01187     virtual void deleteRows(const int num, const int * rowIndices) = 0;
    01188
    01195     virtual void replaceMatrixOptional(const CoinPackedMatrix & ) {}
    01196
    01201     virtual void replaceMatrix(const CoinPackedMatrix & ) {abort();}
    01202
    01207     virtual void saveBaseModel() {}
    01208
    01222     virtual void restoreBaseModel(int numberRows);
    01223     //-----------------------------------------------------------------------
    01246     virtual ApplyCutsReturnCode applyCuts(const OsiCuts & cs,
    01247                                           double effectivenessLb = 0.0);
    01248
    01253     virtual void applyRowCuts(int numberCuts, const OsiRowCut * cuts);
    01254
    01258     virtual void applyRowCuts(int numberCuts, const OsiRowCut ** cuts);
    01259
    01261     void deleteBranchingInfo(int numberDeleted, const int * which);
    01262
    01264
    01265   //---------------------------------------------------------------------------
    01266
    01284     virtual void loadProblem (const CoinPackedMatrix& matrix,
    01285                               const double* collb, const double* colub,
    01286                               const double* obj,
    01287                               const double* rowlb, const double* rowub) = 0;
    01288
    01298     virtual void assignProblem (CoinPackedMatrix*& matrix,
    01299                                 double*& collb, double*& colub, double*& obj,
    01300                                 double*& rowlb, double*& rowub) = 0;
    01301
    01318     virtual void loadProblem (const CoinPackedMatrix& matrix,
    01319                               const double* collb, const double* colub,
    01320                               const double* obj,
    01321                               const char* rowsen, const double* rowrhs,
    01322                               const double* rowrng) = 0;
    01323
    01333     virtual void assignProblem (CoinPackedMatrix*& matrix,
    01334                                 double*& collb, double*& colub, double*& obj,
    01335                                 char*& rowsen, double*& rowrhs,
    01336                                 double*& rowrng) = 0;
    01337
    01350     virtual void loadProblem (const int numcols, const int numrows,
    01351                               const CoinBigIndex * start, const int* index,
    01352                               const double* value,
    01353                               const double* collb, const double* colub,
    01354                               const double* obj,
    01355                               const double* rowlb, const double* rowub) = 0;
    01356
    01369     virtual void loadProblem (const int numcols, const int numrows,
    01370                               const CoinBigIndex * start, const int* index,
    01371                               const double* value,
    01372                               const double* collb, const double* colub,
    01373                               const double* obj,
    01374                               const char* rowsen, const double* rowrhs,
    01375                               const double* rowrng) = 0;
    01376
    01383     virtual int loadFromCoinModel (CoinModel & modelObject,
    01384                                    bool keepSolution=false);
    01385
    01391     virtual int readMps (const char *filename,
    01392                          const char *extension = "mps") ;
    01393
    01400     virtual int readMps (const char *filename, const char*extension,
    01401                         int & numberSets, CoinSet ** & sets);
    01402
    01408     virtual int readGMPL (const char *filename, const char *dataname=NULL);
    01409
    01416     virtual void writeMps (const char *filename,
    01417                            const char *extension = "mps",
    01418                            double objSense=0.0) const = 0;
    01419
    01433     int writeMpsNative (const char *filename,
    01434                         const char ** rowNames, const char ** columnNames,
    01435                         int formatType=0,int numberAcross=2,
    01436                         double objSense=0.0, int numberSOS=0,
    01437                         const CoinSet * setInfo=NULL) const ;
    01438
    01439 /***********************************************************************/
    01440 // Lp files
    01441
    01461   virtual void writeLp(const char *filename,
    01462                const char *extension = "lp",
    01463                 double epsilon = 1e-5,
    01464                 int numberAcross = 10,
    01465                 int decimals = 5,
    01466                 double objSense = 0.0,
    01467                 bool useRowNames = true) const;
    01468
    01473   virtual void writeLp(FILE *fp,
    01474                 double epsilon = 1e-5,
    01475                 int numberAcross = 10,
    01476                 int decimals = 5,
    01477                 double objSense = 0.0,
    01478                 bool useRowNames = true) const;
    01479
    01498   int writeLpNative(const char *filename,
    01499                     char const * const * const rowNames,
    01500                     char const * const * const columnNames,
    01501                     const double epsilon = 1.0e-5,
    01502                     const int numberAcross = 10,
    01503                     const int decimals = 5,
    01504                     const double objSense = 0.0,
    01505                     const bool useRowNames = true) const;
    01506
    01511   int writeLpNative(FILE *fp,
    01512                     char const * const * const rowNames,
    01513                     char const * const * const columnNames,
    01514                     const double epsilon = 1.0e-5,
    01515                     const int numberAcross = 10,
    01516                     const int decimals = 5,
    01517                     const double objSense = 0.0,
    01518                     const bool useRowNames = true) const;
    01519
    01522   virtual int readLp(const char *filename, const double epsilon = 1e-5);
    01523
    01526   int readLp(FILE *fp, const double epsilon = 1e-5);
    01527
    01529
    01530   //---------------------------------------------------------------------------
    01531
    01534 #ifdef COIN_SNAPSHOT
    01536   virtual CoinSnapshot * snapshot(bool createArrays=true) const;
    01537 #endif
    01538 #ifdef COIN_FACTORIZATION_INFO
    01540   virtual CoinBigIndex getSizeL() const;
    01542   virtual CoinBigIndex getSizeU() const;
    01543 #endif
    01544
    01545
    01546   //---------------------------------------------------------------------------
    01547
    01557     void setApplicationData (void * appData);
    01564     void setAuxiliaryInfo(OsiAuxInfo * auxiliaryInfo);
    01565
    01567     void * getApplicationData() const;
    01569     OsiAuxInfo * getAuxiliaryInfo() const;
    01571   //---------------------------------------------------------------------------
    01572
    01586   virtual void passInMessageHandler(CoinMessageHandler * handler);
    01588   void newLanguage(CoinMessages::Language language);
    01589   inline void setLanguage(CoinMessages::Language language)
    01590   {newLanguage(language);}
    01592   inline CoinMessageHandler * messageHandler() const
    01593   {return handler_;}
    01595   inline CoinMessages messages()
    01596   {return messages_;}
    01598   inline CoinMessages * messagesPointer()
    01599   {return &messages_;}
    01601   inline bool defaultHandler() const
    01602   { return defaultHandler_;}
    01604   //---------------------------------------------------------------------------
    01619     void findIntegers(bool justCount);
    01630     virtual int findIntegersAndSOS(bool justCount);
    01632     inline int numberObjects() const { return numberObjects_;}
    01634     inline void setNumberObjects(int number)
    01635     {  numberObjects_=number;}
    01636
    01638     inline OsiObject ** objects() const { return object_;}
    01639
    01641     const inline OsiObject * object(int which) const { return object_[which];}
    01643     inline OsiObject * modifiableObject(int which) const { return object_[which];}
    01644
    01646     void deleteObjects();
    01647
    01652     void addObjects(int numberObjects, OsiObject ** objects);
    01657     double forceFeasible();
    01659   //---------------------------------------------------------------------------
    01660
    01669     virtual void activateRowCutDebugger (const char * modelName);
    01670
    01676     virtual void activateRowCutDebugger( const double * solution);
    01686     const OsiRowCutDebugger * getRowCutDebugger() const;
    01688     const OsiRowCutDebugger * getRowCutDebuggerAlways() const;
    01689
    01691
    01700
    01711   virtual int canDoSimplexInterface() const ;
    01713
    01721
    01730   virtual void enableFactorization() const ;
    01731
    01733   virtual void disableFactorization() const ;
    01734
    01745   virtual bool basisIsAvailable() const ;
    01746
    01748   inline bool optimalBasisIsAvailable() const { return basisIsAvailable() ; }
    01749
    01773   virtual void getBasisStatus(int* cstat, int* rstat) const ;
    01774
    01789   virtual int setBasisStatus(const int* cstat, const int* rstat) ;
    01790
    01796   virtual void getReducedGradient(double* columnReducedCosts,
    01797                                   double* duals, const double* c) const ;
    01798
    01804   virtual void getBInvARow(int row, double* z, double* slack = NULL) const ;
    01805
    01807   virtual void getBInvRow(int row, double* z) const ;
    01808
    01810   virtual void getBInvACol(int col, double* vec) const ;
    01811
    01813   virtual void getBInvCol(int col, double* vec) const ;
    01814
    01822   virtual void getBasics(int* index) const ;
    01823
    01825
    01833
    01840   virtual void enableSimplexInterface(bool doingPrimal) ;
    01841
    01843   virtual void disableSimplexInterface() ;
    01851   virtual int pivot(int colIn, int colOut, int outStatus) ;
    01852
    01864   virtual int primalPivotResult(int colIn, int sign,
    01865                                 int& colOut, int& outStatus,
    01866                                 double& t, CoinPackedVector* dx);
    01867
    01874   virtual int dualPivotResult(int& colIn, int& sign,
    01875                               int colOut, int outStatus,
    01876                               double& t, CoinPackedVector* dx) ;
    01878
    01879   //---------------------------------------------------------------------------
    01880
    01882
    01883
    01884     OsiSolverInterface();
    01885
    01891     virtual OsiSolverInterface * clone(bool copyData = true) const = 0;
    01892
    01894     OsiSolverInterface(const OsiSolverInterface &);
    01895
    01897     OsiSolverInterface & operator=(const OsiSolverInterface& rhs);
    01898
    01900     virtual ~OsiSolverInterface ();
    01901
    01908     virtual void reset();
    01910
    01911   //---------------------------------------------------------------------------
    01912
    01913 protected:
    01915
    01916
    01917     virtual void applyRowCut( const OsiRowCut & rc ) = 0;
    01918
    01920     virtual void applyColCut( const OsiColCut & cc ) = 0;
    01921
    01924     inline void
    01925     convertBoundToSense(const double lower, const double upper,
    01926                         char& sense, double& right, double& range) const;
    01929     inline void
    01930     convertSenseToBound(const char sense, const double right,
    01931                         const double range,
    01932                         double& lower, double& upper) const;
    01935     template <class T> inline T
    01936     forceIntoRange(const T value, const T lower, const T upper) const {
    01937       return value < lower ? lower : (value > upper ? upper : value);
    01938     }
    01945     void setInitialData();
    01947
    01949
    01950
    01951     OsiRowCutDebugger * rowCutDebugger_;
    01952    // Why not just make useful stuff protected?
    01954   CoinMessageHandler * handler_;
    01960   bool defaultHandler_;
    01962   CoinMessages messages_;
    01964   int numberIntegers_;
    01966   int numberObjects_;
    01967
    01969   OsiObject ** object_;
    01975   mutable char * columnType_;
    01976
    01978
    01979   //---------------------------------------------------------------------------
    01980
    01981 private:
    01983
    01984
    01985     OsiAuxInfo * appDataEtc_;
    01987     int intParam_[OsiLastIntParam];
    01989     double dblParam_[OsiLastDblParam];
    01991     std::string strParam_[OsiLastStrParam];
    01993     bool hintParam_[OsiLastHintParam];
    01995     OsiHintStrength hintStrength_[OsiLastHintParam];
    01998     CoinWarmStart* ws_;
    02000     std::vector<double> strictColSolution_;
    02001
    02003     OsiNameVec rowNames_ ;
    02005     OsiNameVec colNames_ ;
    02007     std::string objName_ ;
    02008
    02010 };
    02011
    02012 //#############################################################################
    02020 int
    02021 OsiSolverInterfaceCommonUnitTest(
    02022    const OsiSolverInterface* emptySi,
    02023    const std::string & mpsDir,
    02024    const std::string & netlibDir);
    02025
    02026 //#############################################################################
    02029 int
    02030 OsiSolverInterfaceMpsUnitTest(
    02031    const std::vector<OsiSolverInterface*> & vecSiP,
    02032    const std::string & mpsDir);
    02033
    02034 //#############################################################################
    02037 inline void
    02038 OsiSolverInterface::convertBoundToSense(const double lower, const double upper,
    02039                                         char& sense, double& right,
    02040                                         double& range) const
    02041 {
    02042   double inf = getInfinity();
    02043   range = 0.0;
    02044   if (lower > -inf) {
    02045     if (upper < inf) {
    02046       right = upper;
    02047       if (upper==lower) {
    02048         sense = 'E';
    02049       } else {
    02050         sense = 'R';
    02051         range = upper - lower;
    02052       }
    02053     } else {
    02054       sense = 'G';
    02055       right = lower;
    02056     }
    02057   } else {
    02058     if (upper < inf) {
    02059       sense = 'L';
    02060       right = upper;
    02061     } else {
    02062       sense = 'N';
    02063       right = 0.0;
    02064     }
    02065   }
    02066 }
    02067
    02068 //-----------------------------------------------------------------------------
    02071 inline void
    02072 OsiSolverInterface::convertSenseToBound(const char sense, const double right,
    02073                                         const double range,
    02074                                         double& lower, double& upper) const
    02075 {
    02076   double inf=getInfinity();
    02077   switch (sense) {
    02078   case 'E':
    02079     lower = upper = right;
    02080     break;
    02081   case 'L':
    02082     lower = -inf;
    02083     upper = right;
    02084     break;
    02085   case 'G':
    02086     lower = right;
    02087     upper = inf;
    02088     break;
    02089   case 'R':
    02090     lower = right - range;
    02091     upper = right;
    02092     break;
    02093   case 'N':
    02094     lower = -inf;
    02095     upper = inf;
    02096     break;
    02097   }
    02098 }
    02099
    02100 #endif