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

- File List
- File Members

# /home/coin/svn-release/Bcps-0.93.10/Osi/src/Osi/OsiSolverInterface.hpp

Go to the documentation of this file.

    00001 // Copyright (C) 2000, International Business Machines
    00002 // Corporation and others.  All Rights Reserved.
    00003 // This code is licensed under the terms of the Eclipse Public License (EPL).
    00004
    00005 #ifndef OsiSolverInterface_H
    00006 #define OsiSolverInterface_H
    00007
    00008 #include <cstdlib>
    00009 #include <string>
    00010 #include <vector>
    00011
    00012 #include "CoinTypes.hpp"
    00013 #include "CoinMessageHandler.hpp"
    00014 #include "CoinPackedVectorBase.hpp"
    00015 #include "CoinPackedMatrix.hpp"
    00016 #include "CoinWarmStart.hpp"
    00017 #include "CoinFinite.hpp"
    00018 #include "CoinError.hpp"
    00019
    00020 #include "OsiCollections.hpp"
    00021 #include "OsiSolverParameters.hpp"
    00022
    00023 class CoinSnapshot;
    00024 class CoinLpIO;
    00025 class CoinMpsIO;
    00026
    00027 class OsiCuts;
    00028 class OsiAuxInfo;
    00029 class OsiRowCut;
    00030 class OsiRowCutDebugger;
    00031 class CoinSet;
    00032 class CoinBuild;
    00033 class CoinModel;
    00034 class OsiSolverBranch;
    00035 class OsiSolverResult;
    00036 class OsiObject;
    00037
    00038
    00039 //#############################################################################
    00040
    00062 class OsiSolverInterface  {
    00063    friend void OsiSolverInterfaceCommonUnitTest(
    00064       const OsiSolverInterface* emptySi,
    00065       const std::string & mpsDir,
    00066       const std::string & netlibDir);
    00067    friend void OsiSolverInterfaceMpsUnitTest(
    00068       const std::vector<OsiSolverInterface*> & vecSiP,
    00069       const std::string & mpsDir);
    00070
    00071 public:
    00072
    00074   class ApplyCutsReturnCode {
    00075     friend class OsiSolverInterface;
    00076     friend class OsiClpSolverInterface;
    00077     friend class OsiGrbSolverInterface;
    00078
    00079   public:
    00081
    00082
    00083       ApplyCutsReturnCode():
    00084          intInconsistent_(0),
    00085          extInconsistent_(0),
    00086          infeasible_(0),
    00087          ineffective_(0),
    00088          applied_(0) {}
    00090       ApplyCutsReturnCode(const ApplyCutsReturnCode & rhs):
    00091          intInconsistent_(rhs.intInconsistent_),
    00092          extInconsistent_(rhs.extInconsistent_),
    00093          infeasible_(rhs.infeasible_),
    00094          ineffective_(rhs.ineffective_),
    00095          applied_(rhs.applied_) {}
    00097       ApplyCutsReturnCode & operator=(const ApplyCutsReturnCode& rhs)
    00098       {
    00099         if (this != &rhs) {
    00100           intInconsistent_ = rhs.intInconsistent_;
    00101           extInconsistent_ = rhs.extInconsistent_;
    00102           infeasible_      = rhs.infeasible_;
    00103           ineffective_     = rhs.ineffective_;
    00104           applied_         = rhs.applied_;
    00105         }
    00106         return *this;
    00107       }
    00109       ~ApplyCutsReturnCode(){}
    00111
    00114
    00115       inline int getNumInconsistent() const
    00116       {return intInconsistent_;}
    00118       inline int getNumInconsistentWrtIntegerModel() const
    00119       {return extInconsistent_;}
    00121       inline int getNumInfeasible() const
    00122       {return infeasible_;}
    00124       inline int getNumIneffective() const
    00125       {return ineffective_;}
    00127       inline int getNumApplied() const
    00128       {return applied_;}
    00130
    00131   private:
    00134
    00135       inline void incrementInternallyInconsistent(){intInconsistent_++;}
    00137       inline void incrementExternallyInconsistent(){extInconsistent_++;}
    00139       inline void incrementInfeasible(){infeasible_++;}
    00141       inline void incrementIneffective(){ineffective_++;}
    00143       inline void incrementApplied(){applied_++;}
    00145
    00147
    00148
    00149       int intInconsistent_;
    00151       int extInconsistent_;
    00153       int infeasible_;
    00155       int ineffective_;
    00157       int applied_;
    00159   };
    00160
    00161   //---------------------------------------------------------------------------
    00162
    00164
    00165
    00166     virtual void initialSolve() = 0;
    00167
    00173     virtual void resolve() = 0;
    00174
    00176     virtual void branchAndBound() = 0;
    00177
    00178 #ifdef CBC_NEXT_VERSION
    00179     /*
    00180       Would it make sense to collect all of these routines in a `MIP Helper'
    00181       section? It'd make it easier for users and implementors to find them.
    00182     */
    00200     virtual int solveBranches(int depth,const OsiSolverBranch * branch,
    00201                               OsiSolverResult * result,
    00202                               int & numberSolves, int & numberIterations,
    00203                               bool forceBranch=false);
    00204 #endif
    00205
    00206
    00207   //---------------------------------------------------------------------------
    00265
    00266     virtual bool setIntParam(OsiIntParam key, int value) {
    00267       if (key == OsiLastIntParam) return (false) ;
    00268       intParam_[key] = value;
    00269       return true;
    00270     }
    00272     virtual bool setDblParam(OsiDblParam key, double value) {
    00273       if (key == OsiLastDblParam) return (false) ;
    00274       dblParam_[key] = value;
    00275       return true;
    00276     }
    00278     virtual bool setStrParam(OsiStrParam key, const std::string & value) {
    00279       if (key == OsiLastStrParam) return (false) ;
    00280       strParam_[key] = value;
    00281       return true;
    00282     }
    00294     virtual bool setHintParam(OsiHintParam key, bool yesNo=true,
    00295                               OsiHintStrength strength=OsiHintTry,
    00296                               void * /*otherInformation*/ = NULL) {
    00297       if (key==OsiLastHintParam)
    00298         return false;
    00299       hintParam_[key] = yesNo;
    00300       hintStrength_[key] = strength;
    00301       if (strength == OsiForceDo)
    00302         throw CoinError("OsiForceDo illegal",
    00303                         "setHintParam", "OsiSolverInterface");
    00304       return true;
    00305     }
    00307     virtual bool getIntParam(OsiIntParam key, int& value) const {
    00308       if (key == OsiLastIntParam) return (false) ;
    00309       value = intParam_[key];
    00310       return true;
    00311     }
    00313     virtual bool getDblParam(OsiDblParam key, double& value) const {
    00314       if (key == OsiLastDblParam) return (false) ;
    00315       value = dblParam_[key];
    00316       return true;
    00317     }
    00319     virtual bool getStrParam(OsiStrParam key, std::string& value) const {
    00320       if (key == OsiLastStrParam) return (false) ;
    00321       value = strParam_[key];
    00322       return true;
    00323     }
    00333     virtual bool getHintParam(OsiHintParam key, bool& yesNo,
    00334                               OsiHintStrength& strength,
    00335                               void *& otherInformation) const {
    00336       if (key==OsiLastHintParam)
    00337         return false;
    00338       yesNo = hintParam_[key];
    00339       strength = hintStrength_[key];
    00340       otherInformation=NULL;
    00341       return true;
    00342     }
    00347     virtual bool getHintParam(OsiHintParam key, bool& yesNo,
    00348                               OsiHintStrength& strength) const {
    00349       if (key==OsiLastHintParam)
    00350         return false;
    00351       yesNo = hintParam_[key];
    00352       strength = hintStrength_[key];
    00353       return true;
    00354     }
    00359     virtual bool getHintParam(OsiHintParam key, bool& yesNo) const {
    00360       if (key==OsiLastHintParam)
    00361         return false;
    00362       yesNo = hintParam_[key];
    00363       return true;
    00364     }
    00371     void copyParameters(OsiSolverInterface & rhs);
    00372
    00386     inline double getIntegerTolerance() const
    00387     { return dblParam_[OsiPrimalTolerance];}
    00389
    00390   //---------------------------------------------------------------------------
    00392
    00393
    00394     virtual bool isAbandoned() const = 0;
    00396     virtual bool isProvenOptimal() const = 0;
    00398     virtual bool isProvenPrimalInfeasible() const = 0;
    00400     virtual bool isProvenDualInfeasible() const = 0;
    00402     virtual bool isPrimalObjectiveLimitReached() const;
    00404     virtual bool isDualObjectiveLimitReached() const;
    00406     virtual bool isIterationLimitReached() const = 0;
    00408
    00409   //---------------------------------------------------------------------------
    00427     virtual CoinWarmStart *getEmptyWarmStart () const = 0 ;
    00428
    00435     virtual CoinWarmStart* getWarmStart() const = 0;
    00444     virtual CoinWarmStart* getPointerToWarmStart(bool & mustDelete) ;
    00445
    00454     virtual bool setWarmStart(const CoinWarmStart* warmstart) = 0;
    00456
    00457   //---------------------------------------------------------------------------
    00478
    00479     virtual void markHotStart();
    00481     virtual void solveFromHotStart();
    00483     virtual void unmarkHotStart();
    00485
    00486   //---------------------------------------------------------------------------
    00497
    00498     virtual int getNumCols() const = 0;
    00499
    00501     virtual int getNumRows() const = 0;
    00502
    00504     virtual int getNumElements() const = 0;
    00505
    00507     virtual int getNumIntegers() const ;
    00508
    00510     virtual const double * getColLower() const = 0;
    00511
    00513     virtual const double * getColUpper() const = 0;
    00514
    00525     virtual const char * getRowSense() const = 0;
    00526
    00540     virtual const double * getRightHandSide() const = 0;
    00541
    00551     virtual const double * getRowRange() const = 0;
    00552
    00554     virtual const double * getRowLower() const = 0;
    00555
    00557     virtual const double * getRowUpper() const = 0;
    00558
    00562     virtual const double * getObjCoefficients() const = 0;
    00563
    00569     virtual double getObjSense() const = 0;
    00570
    00572     virtual bool isContinuous(int colIndex) const = 0;
    00573
    00575     virtual bool isBinary(int colIndex) const;
    00576
    00581     virtual bool isInteger(int colIndex) const;
    00582
    00584     virtual bool isIntegerNonBinary(int colIndex) const;
    00585
    00587     virtual bool isFreeBinary(int colIndex) const;
    00588
    00593     inline const char *columnType(bool refresh=false) const
    00594     { return getColType(refresh); }
    00595
    00607     virtual const char * getColType(bool refresh=false) const;
    00608
    00610     virtual const CoinPackedMatrix * getMatrixByRow() const = 0;
    00611
    00613     virtual const CoinPackedMatrix * getMatrixByCol() const = 0;
    00614
    00620     virtual CoinPackedMatrix * getMutableMatrixByRow() const {return NULL;}
    00621
    00627     virtual CoinPackedMatrix * getMutableMatrixByCol() const {return NULL;}
    00628
    00630     virtual double getInfinity() const = 0;
    00632
    00635
    00636     virtual const double * getColSolution() const = 0;
    00637
    00641     virtual const double * getStrictColSolution();
    00642
    00644     virtual const double * getRowPrice() const = 0;
    00645
    00647     virtual const double * getReducedCost() const = 0;
    00648
    00654     virtual const double * getRowActivity() const = 0;
    00655
    00657     virtual double getObjValue() const = 0;
    00658
    00662     virtual int getIterationCount() const = 0;
    00663
    00686     virtual std::vector<double*> getDualRays(int maxNumRays,
    00687                                              bool fullRay = false) const = 0;
    00688
    00704     virtual std::vector<double*> getPrimalRays(int maxNumRays) const = 0;
    00705
    00708     virtual OsiVectorInt getFractionalIndices(const double etol=1.e-05)
    00709       const;
    00711
    00712   //-------------------------------------------------------------------------
    00725     virtual void setObjCoeff( int elementIndex, double elementValue ) = 0;
    00726
    00728     virtual void setObjCoeffSet(const int* indexFirst,
    00729                                 const int* indexLast,
    00730                                 const double* coeffList);
    00731
    00737     virtual void setObjective(const double * array);
    00738
    00749     virtual void setObjSense(double s) = 0;
    00750
    00751
    00754     virtual void setColLower( int elementIndex, double elementValue ) = 0;
    00755
    00761     virtual void setColLower(const double * array);
    00762
    00765     virtual void setColUpper( int elementIndex, double elementValue ) = 0;
    00766
    00772     virtual void setColUpper(const double * array);
    00773
    00774
    00778     virtual void setColBounds( int elementIndex,
    00779                                double lower, double upper ) {
    00780        setColLower(elementIndex, lower);
    00781        setColUpper(elementIndex, upper);
    00782     }
    00783
    00790     virtual void setColSetBounds(const int* indexFirst,
    00791                                  const int* indexLast,
    00792                                  const double* boundList);
    00793
    00796     virtual void setRowLower( int elementIndex, double elementValue ) = 0;
    00797
    00800     virtual void setRowUpper( int elementIndex, double elementValue ) = 0;
    00801
    00805     virtual void setRowBounds( int elementIndex,
    00806                                double lower, double upper ) {
    00807        setRowLower(elementIndex, lower);
    00808        setRowUpper(elementIndex, upper);
    00809     }
    00810
    00817     virtual void setRowSetBounds(const int* indexFirst,
    00818                                  const int* indexLast,
    00819                                  const double* boundList);
    00820
    00821
    00823     virtual void setRowType(int index, char sense, double rightHandSide,
    00824                             double range) = 0;
    00825
    00830     virtual void setRowSetTypes(const int* indexFirst,
    00831                                 const int* indexLast,
    00832                                 const char* senseList,
    00833                                 const double* rhsList,
    00834                                 const double* rangeList);
    00835
    00845     virtual void setColSolution(const double *colsol) = 0;
    00846
    00856     virtual void setRowPrice(const double * rowprice) = 0;
    00857
    00866     virtual int reducedCostFix(double gap, bool justInteger=true);
    00868
    00869   //-------------------------------------------------------------------------
    00873     virtual void setContinuous(int index) = 0;
    00875     virtual void setInteger(int index) = 0;
    00878     virtual void setContinuous(const int* indices, int len);
    00881     virtual void setInteger(const int* indices, int len);
    00883   //-------------------------------------------------------------------------
    00884
    00885   //-------------------------------------------------------------------------
    00886
    00888     typedef std::vector<std::string> OsiNameVec ;
    00889
    00910
    00920     virtual std::string dfltRowColName(char rc,
    00921                                  int ndx, unsigned digits = 7) const ;
    00922
    00925   virtual std::string getObjName (unsigned maxLen = static_cast<unsigned>(std::string::npos)) const ;
    00926
    00929     virtual inline void setObjName (std::string name)
    00930     { objName_ = name ; }
    00931
    00938     virtual std::string getRowName(int rowIndex,
    00939                                    unsigned maxLen = static_cast<unsigned>(std::string::npos)) const ;
    00940
    00952     virtual const OsiNameVec &getRowNames() ;
    00953
    00959     virtual void setRowName(int ndx, std::string name) ;
    00960
    00967     virtual void setRowNames(OsiNameVec &srcNames,
    00968                      int srcStart, int len, int tgtStart) ;
    00969
    00975     virtual void deleteRowNames(int tgtStart, int len) ;
    00976
    00983     virtual std::string getColName(int colIndex,
    00984                                    unsigned maxLen = static_cast<unsigned>(std::string::npos)) const ;
    00985
    00995     virtual const OsiNameVec &getColNames() ;
    00996
    01002     virtual void setColName(int ndx, std::string name) ;
    01003
    01010     virtual void setColNames(OsiNameVec &srcNames,
    01011                      int srcStart, int len, int tgtStart) ;
    01012
    01018     virtual void deleteColNames(int tgtStart, int len) ;
    01019
    01020
    01027     void setRowColNames(const CoinMpsIO &mps) ;
    01028
    01034     void setRowColNames(CoinModel &mod) ;
    01035
    01042     void setRowColNames(CoinLpIO &mod) ;
    01043
    01045   //-------------------------------------------------------------------------
    01046
    01047   //-------------------------------------------------------------------------
    01053
    01055     virtual void addCol(const CoinPackedVectorBase& vec,
    01056                         const double collb, const double colub,
    01057                         const double obj) = 0;
    01058
    01064     virtual void addCol(const CoinPackedVectorBase& vec,
    01065                         const double collb, const double colub,
    01066                         const double obj, std::string name) ;
    01067
    01069     virtual void addCol(int numberElements,
    01070                         const int* rows, const double* elements,
    01071                         const double collb, const double colub,
    01072                         const double obj) ;
    01073
    01079     virtual void addCol(int numberElements,
    01080                         const int* rows, const double* elements,
    01081                         const double collb, const double colub,
    01082                         const double obj, std::string name) ;
    01083
    01089     virtual void addCols(const int numcols,
    01090                          const CoinPackedVectorBase * const * cols,
    01091                          const double* collb, const double* colub,
    01092                          const double* obj);
    01093
    01099     virtual void addCols(const int numcols, const int* columnStarts,
    01100                          const int* rows, const double* elements,
    01101                          const double* collb, const double* colub,
    01102                          const double* obj);
    01103
    01105     void addCols(const CoinBuild & buildObject);
    01106
    01112     int addCols(CoinModel & modelObject);
    01113
    01114 #if 0
    01115
    01116     virtual void addCols(const CoinPackedMatrix& matrix,
    01117                          const double* collb, const double* colub,
    01118                          const double* obj);
    01119 #endif
    01120
    01127     virtual void deleteCols(const int num, const int * colIndices) = 0;
    01128
    01130     virtual void addRow(const CoinPackedVectorBase& vec,
    01131                         const double rowlb, const double rowub) = 0;
    01132
    01138     virtual void addRow(const CoinPackedVectorBase& vec,
    01139                         const double rowlb, const double rowub,
    01140                         std::string name) ;
    01141
    01143     virtual void addRow(const CoinPackedVectorBase& vec,
    01144                         const char rowsen, const double rowrhs,
    01145                         const double rowrng) = 0;
    01146
    01152     virtual void addRow(const CoinPackedVectorBase& vec,
    01153                         const char rowsen, const double rowrhs,
    01154                         const double rowrng, std::string name) ;
    01155
    01160     virtual void addRow(int numberElements,
    01161                         const int *columns, const double *element,
    01162                         const double rowlb, const double rowub) ;
    01163
    01169     virtual void addRows(const int numrows,
    01170                          const CoinPackedVectorBase * const * rows,
    01171                          const double* rowlb, const double* rowub);
    01172
    01178     virtual void addRows(const int numrows,
    01179                          const CoinPackedVectorBase * const * rows,
    01180                          const char* rowsen, const double* rowrhs,
    01181                          const double* rowrng);
    01182
    01188     virtual void addRows(const int numrows, const int *rowStarts,
    01189                          const int *columns, const double *element,
    01190                          const double *rowlb, const double *rowub);
    01191
    01193     void addRows(const CoinBuild &buildObject);
    01194
    01203     int addRows(CoinModel &modelObject);
    01204
    01205 #if 0
    01206
    01207     virtual void addRows(const CoinPackedMatrix& matrix,
    01208                          const double* rowlb, const double* rowub);
    01210     virtual void addRows(const CoinPackedMatrix& matrix,
    01211                          const char* rowsen, const double* rowrhs,
    01212                          const double* rowrng);
    01213 #endif
    01214
    01220     virtual void deleteRows(const int num, const int * rowIndices) = 0;
    01221
    01228     virtual void replaceMatrixOptional(const CoinPackedMatrix & ) {}
    01229
    01234     virtual void replaceMatrix(const CoinPackedMatrix & ) {abort();}
    01235
    01240     virtual void saveBaseModel() {}
    01241
    01255     virtual void restoreBaseModel(int numberRows);
    01256     //-----------------------------------------------------------------------
    01279     virtual ApplyCutsReturnCode applyCuts(const OsiCuts & cs,
    01280                                           double effectivenessLb = 0.0);
    01281
    01286     virtual void applyRowCuts(int numberCuts, const OsiRowCut * cuts);
    01287
    01291     virtual void applyRowCuts(int numberCuts, const OsiRowCut ** cuts);
    01292
    01294     void deleteBranchingInfo(int numberDeleted, const int * which);
    01295
    01297
    01298   //---------------------------------------------------------------------------
    01299
    01317     virtual void loadProblem (const CoinPackedMatrix& matrix,
    01318                               const double* collb, const double* colub,
    01319                               const double* obj,
    01320                               const double* rowlb, const double* rowub) = 0;
    01321
    01331     virtual void assignProblem (CoinPackedMatrix*& matrix,
    01332                                 double*& collb, double*& colub, double*& obj,
    01333                                 double*& rowlb, double*& rowub) = 0;
    01334
    01351     virtual void loadProblem (const CoinPackedMatrix& matrix,
    01352                               const double* collb, const double* colub,
    01353                               const double* obj,
    01354                               const char* rowsen, const double* rowrhs,
    01355                               const double* rowrng) = 0;
    01356
    01366     virtual void assignProblem (CoinPackedMatrix*& matrix,
    01367                                 double*& collb, double*& colub, double*& obj,
    01368                                 char*& rowsen, double*& rowrhs,
    01369                                 double*& rowrng) = 0;
    01370
    01383     virtual void loadProblem (const int numcols, const int numrows,
    01384                               const CoinBigIndex * start, const int* index,
    01385                               const double* value,
    01386                               const double* collb, const double* colub,
    01387                               const double* obj,
    01388                               const double* rowlb, const double* rowub) = 0;
    01389
    01402     virtual void loadProblem (const int numcols, const int numrows,
    01403                               const CoinBigIndex * start, const int* index,
    01404                               const double* value,
    01405                               const double* collb, const double* colub,
    01406                               const double* obj,
    01407                               const char* rowsen, const double* rowrhs,
    01408                               const double* rowrng) = 0;
    01409
    01416     virtual int loadFromCoinModel (CoinModel & modelObject,
    01417                                    bool keepSolution=false);
    01418
    01424     virtual int readMps (const char *filename,
    01425                          const char *extension = "mps") ;
    01426
    01433     virtual int readMps (const char *filename, const char*extension,
    01434                         int & numberSets, CoinSet ** & sets);
    01435
    01441     virtual int readGMPL (const char *filename, const char *dataname=NULL);
    01442
    01449     virtual void writeMps (const char *filename,
    01450                            const char *extension = "mps",
    01451                            double objSense=0.0) const = 0;
    01452
    01466     int writeMpsNative (const char *filename,
    01467                         const char ** rowNames, const char ** columnNames,
    01468                         int formatType=0,int numberAcross=2,
    01469                         double objSense=0.0, int numberSOS=0,
    01470                         const CoinSet * setInfo=NULL) const ;
    01471
    01472 /***********************************************************************/
    01473 // Lp files
    01474
    01494   virtual void writeLp(const char *filename,
    01495                const char *extension = "lp",
    01496                 double epsilon = 1e-5,
    01497                 int numberAcross = 10,
    01498                 int decimals = 5,
    01499                 double objSense = 0.0,
    01500                 bool useRowNames = true) const;
    01501
    01506   virtual void writeLp(FILE *fp,
    01507                 double epsilon = 1e-5,
    01508                 int numberAcross = 10,
    01509                 int decimals = 5,
    01510                 double objSense = 0.0,
    01511                 bool useRowNames = true) const;
    01512
    01531   int writeLpNative(const char *filename,
    01532                     char const * const * const rowNames,
    01533                     char const * const * const columnNames,
    01534                     const double epsilon = 1.0e-5,
    01535                     const int numberAcross = 10,
    01536                     const int decimals = 5,
    01537                     const double objSense = 0.0,
    01538                     const bool useRowNames = true) const;
    01539
    01544   int writeLpNative(FILE *fp,
    01545                     char const * const * const rowNames,
    01546                     char const * const * const columnNames,
    01547                     const double epsilon = 1.0e-5,
    01548                     const int numberAcross = 10,
    01549                     const int decimals = 5,
    01550                     const double objSense = 0.0,
    01551                     const bool useRowNames = true) const;
    01552
    01555   virtual int readLp(const char *filename, const double epsilon = 1e-5);
    01556
    01559   int readLp(FILE *fp, const double epsilon = 1e-5);
    01560
    01562
    01563   //---------------------------------------------------------------------------
    01564
    01567 #ifdef COIN_SNAPSHOT
    01569   virtual CoinSnapshot * snapshot(bool createArrays=true) const;
    01570 #endif
    01571 #ifdef COIN_FACTORIZATION_INFO
    01573   virtual CoinBigIndex getSizeL() const;
    01575   virtual CoinBigIndex getSizeU() const;
    01576 #endif
    01577
    01578
    01579   //---------------------------------------------------------------------------
    01580
    01590     void setApplicationData (void * appData);
    01597     void setAuxiliaryInfo(OsiAuxInfo * auxiliaryInfo);
    01598
    01600     void * getApplicationData() const;
    01602     OsiAuxInfo * getAuxiliaryInfo() const;
    01604   //---------------------------------------------------------------------------
    01605
    01619   virtual void passInMessageHandler(CoinMessageHandler * handler);
    01621   void newLanguage(CoinMessages::Language language);
    01622   inline void setLanguage(CoinMessages::Language language)
    01623   {newLanguage(language);}
    01625   inline CoinMessageHandler * messageHandler() const
    01626   {return handler_;}
    01628   inline CoinMessages messages()
    01629   {return messages_;}
    01631   inline CoinMessages * messagesPointer()
    01632   {return &messages_;}
    01634   inline bool defaultHandler() const
    01635   { return defaultHandler_;}
    01637   //---------------------------------------------------------------------------
    01652     void findIntegers(bool justCount);
    01663     virtual int findIntegersAndSOS(bool justCount);
    01665     inline int numberObjects() const { return numberObjects_;}
    01667     inline void setNumberObjects(int number)
    01668     {  numberObjects_=number;}
    01669
    01671     inline OsiObject ** objects() const { return object_;}
    01672
    01674     const inline OsiObject * object(int which) const { return object_[which];}
    01676     inline OsiObject * modifiableObject(int which) const { return object_[which];}
    01677
    01679     void deleteObjects();
    01680
    01685     void addObjects(int numberObjects, OsiObject ** objects);
    01690     double forceFeasible();
    01692   //---------------------------------------------------------------------------
    01693
    01705     virtual void activateRowCutDebugger (const char *modelName);
    01706
    01720     virtual void activateRowCutDebugger(const double *solution,
    01721                                         bool enforceOptimality = true);
    01722
    01734     const OsiRowCutDebugger *getRowCutDebugger() const;
    01735
    01743     OsiRowCutDebugger * getRowCutDebuggerAlways() const;
    01745
    01754
    01765   virtual int canDoSimplexInterface() const ;
    01767
    01775
    01784   virtual void enableFactorization() const ;
    01785
    01787   virtual void disableFactorization() const ;
    01788
    01799   virtual bool basisIsAvailable() const ;
    01800
    01802   inline bool optimalBasisIsAvailable() const { return basisIsAvailable() ; }
    01803
    01827   virtual void getBasisStatus(int* cstat, int* rstat) const ;
    01828
    01843   virtual int setBasisStatus(const int* cstat, const int* rstat) ;
    01844
    01850   virtual void getReducedGradient(double* columnReducedCosts,
    01851                                   double* duals, const double* c) const ;
    01852
    01858   virtual void getBInvARow(int row, double* z, double* slack = NULL) const ;
    01859
    01861   virtual void getBInvRow(int row, double* z) const ;
    01862
    01864   virtual void getBInvACol(int col, double* vec) const ;
    01865
    01867   virtual void getBInvCol(int col, double* vec) const ;
    01868
    01876   virtual void getBasics(int* index) const ;
    01877
    01879
    01887
    01894   virtual void enableSimplexInterface(bool doingPrimal) ;
    01895
    01897   virtual void disableSimplexInterface() ;
    01905   virtual int pivot(int colIn, int colOut, int outStatus) ;
    01906
    01918   virtual int primalPivotResult(int colIn, int sign,
    01919                                 int& colOut, int& outStatus,
    01920                                 double& t, CoinPackedVector* dx);
    01921
    01928   virtual int dualPivotResult(int& colIn, int& sign,
    01929                               int colOut, int outStatus,
    01930                               double& t, CoinPackedVector* dx) ;
    01932
    01933   //---------------------------------------------------------------------------
    01934
    01936
    01937
    01938     OsiSolverInterface();
    01939
    01945     virtual OsiSolverInterface * clone(bool copyData = true) const = 0;
    01946
    01948     OsiSolverInterface(const OsiSolverInterface &);
    01949
    01951     OsiSolverInterface & operator=(const OsiSolverInterface& rhs);
    01952
    01954     virtual ~OsiSolverInterface ();
    01955
    01962     virtual void reset();
    01964
    01965   //---------------------------------------------------------------------------
    01966
    01967 protected:
    01969
    01970
    01971     virtual void applyRowCut( const OsiRowCut & rc ) = 0;
    01972
    01974     virtual void applyColCut( const OsiColCut & cc ) = 0;
    01975
    01978     inline void
    01979     convertBoundToSense(const double lower, const double upper,
    01980                         char& sense, double& right, double& range) const;
    01983     inline void
    01984     convertSenseToBound(const char sense, const double right,
    01985                         const double range,
    01986                         double& lower, double& upper) const;
    01989     template <class T> inline T
    01990     forceIntoRange(const T value, const T lower, const T upper) const {
    01991       return value < lower ? lower : (value > upper ? upper : value);
    01992     }
    01999     void setInitialData();
    02001
    02003
    02004
    02009     mutable OsiRowCutDebugger * rowCutDebugger_;
    02010    // Why not just make useful stuff protected?
    02012   CoinMessageHandler * handler_;
    02018   bool defaultHandler_;
    02020   CoinMessages messages_;
    02022   int numberIntegers_;
    02024   int numberObjects_;
    02025
    02027   OsiObject ** object_;
    02033   mutable char * columnType_;
    02034
    02036
    02037   //---------------------------------------------------------------------------
    02038
    02039 private:
    02041
    02042
    02043     OsiAuxInfo * appDataEtc_;
    02045     int intParam_[OsiLastIntParam];
    02047     double dblParam_[OsiLastDblParam];
    02049     std::string strParam_[OsiLastStrParam];
    02051     bool hintParam_[OsiLastHintParam];
    02053     OsiHintStrength hintStrength_[OsiLastHintParam];
    02056     CoinWarmStart* ws_;
    02058     std::vector<double> strictColSolution_;
    02059
    02061     OsiNameVec rowNames_ ;
    02063     OsiNameVec colNames_ ;
    02065     std::string objName_ ;
    02066
    02068 };
    02069
    02070 //#############################################################################
    02073 inline void
    02074 OsiSolverInterface::convertBoundToSense(const double lower, const double upper,
    02075                                         char& sense, double& right,
    02076                                         double& range) const
    02077 {
    02078   double inf = getInfinity();
    02079   range = 0.0;
    02080   if (lower > -inf) {
    02081     if (upper < inf) {
    02082       right = upper;
    02083       if (upper==lower) {
    02084         sense = 'E';
    02085       } else {
    02086         sense = 'R';
    02087         range = upper - lower;
    02088       }
    02089     } else {
    02090       sense = 'G';
    02091       right = lower;
    02092     }
    02093   } else {
    02094     if (upper < inf) {
    02095       sense = 'L';
    02096       right = upper;
    02097     } else {
    02098       sense = 'N';
    02099       right = 0.0;
    02100     }
    02101   }
    02102 }
    02103
    02104 //-----------------------------------------------------------------------------
    02107 inline void
    02108 OsiSolverInterface::convertSenseToBound(const char sense, const double right,
    02109                                         const double range,
    02110                                         double& lower, double& upper) const
    02111 {
    02112   double inf=getInfinity();
    02113   switch (sense) {
    02114   case 'E':
    02115     lower = upper = right;
    02116     break;
    02117   case 'L':
    02118     lower = -inf;
    02119     upper = right;
    02120     break;
    02121   case 'G':
    02122     lower = right;
    02123     upper = inf;
    02124     break;
    02125   case 'R':
    02126     lower = right - range;
    02127     upper = right;
    02128     break;
    02129   case 'N':
    02130     lower = -inf;
    02131     upper = inf;
    02132     break;
    02133   }
    02134 }
    02135
    02136 #endif