Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members

OsiOslSolverInterface.hpp

00001 // Copyright (C) 2000, International Business Machines
00002 // Corporation and others.  All Rights Reserved.
00003 
00004 #ifndef _OsiOslSolverInterface_hpp_
00005 #define _OsiOslSolverInterface_hpp_
00006 
00007 #if (defined(__MINGW32__) || defined(__CYGWIN32__)) && !defined(OSLMSDLL)
00008 #  define OSLMSDLL
00009 #endif
00010 
00011 #include <string>
00012 #include <ekk_c_api.h>
00013 
00014 #include "OsiSolverInterface.hpp"
00015 #include "CoinPackedMatrix.hpp"
00016 #include "CoinWarmStartBasis.hpp"
00017 
00018 //#############################################################################
00019 
00025 class OsiOslSolverInterface : public OsiSolverInterface {
00026    friend void OsiOslSolverInterfaceUnitTest(const std::string & mpsDir, const std::string & netlibDir);
00027 
00028 public:
00029   //---------------------------------------------------------------------------
00032 
00033     virtual void initialSolve();
00034 
00036     virtual void resolve();
00037 
00039     virtual void branchAndBound();
00041   
00042   //---------------------------------------------------------------------------
00058     // Set an integer parameter
00059     bool setIntParam(OsiIntParam key, int value);
00060     // Set an double parameter
00061     bool setDblParam(OsiDblParam key, double value);
00062     // Set a string parameter
00063     bool setStrParam(OsiStrParam key, const std::string & value);
00064     // Get an integer parameter
00065     bool getIntParam(OsiIntParam key, int& value) const;
00066     // Get an double parameter
00067     bool getDblParam(OsiDblParam key, double& value) const;
00068     // Get a string parameter
00069     bool getStrParam(OsiStrParam key, std::string& value) const;
00071 
00072   //---------------------------------------------------------------------------
00074 
00075 
00076     virtual bool isAbandoned() const;
00078     virtual bool isProvenOptimal() const;
00080     virtual bool isProvenPrimalInfeasible() const;
00082     virtual bool isProvenDualInfeasible() const;
00084     virtual bool isPrimalObjectiveLimitReached() const;
00086     virtual bool isDualObjectiveLimitReached() const;
00088     virtual bool isIterationLimitReached() const;
00090 
00091   //---------------------------------------------------------------------------
00094 
00095     inline CoinWarmStart *getEmptyWarmStart () const
00096     { return (dynamic_cast<CoinWarmStart *>(new CoinWarmStartBasis())) ; }
00098     virtual CoinWarmStart* getWarmStart() const;
00101     virtual bool setWarmStart(const CoinWarmStart* warmstart);
00103 
00104   //---------------------------------------------------------------------------
00111 
00112     virtual void markHotStart();
00114     virtual void solveFromHotStart();
00116     virtual void unmarkHotStart();
00118 
00119   //---------------------------------------------------------------------------
00134 
00135       virtual int getNumCols() const;
00136   
00138       virtual int getNumRows() const;
00139   
00141       virtual int getNumElements() const;
00142   
00144       virtual const double * getColLower() const;
00145   
00147       virtual const double * getColUpper() const;
00148   
00158       virtual const char * getRowSense() const;
00159   
00168       virtual const double * getRightHandSide() const;
00169   
00178       virtual const double * getRowRange() const;
00179   
00181       virtual const double * getRowLower() const;
00182   
00184       virtual const double * getRowUpper() const;
00185   
00187       virtual const double * getObjCoefficients() const;
00188   
00190       virtual double getObjSense() const;
00191 
00193       virtual bool isContinuous(int colNumber) const;
00194 
00195 #if 0
00196 
00197       virtual bool isBinary(int columnNumber) const;
00198   
00203       virtual bool isInteger(int columnNumber) const;
00204   
00206       virtual bool isIntegerNonBinary(int columnNumber) const;
00207   
00209       virtual bool isFreeBinary(int columnNumber) const;
00210 #endif
00211   
00213       virtual const CoinPackedMatrix * getMatrixByRow() const;
00214   
00216       virtual const CoinPackedMatrix * getMatrixByCol() const;
00217   
00219       virtual double getInfinity() const;
00221     
00224 
00225       virtual const double * getColSolution() const;
00226   
00228       virtual const double * getRowPrice() const;
00229   
00231       virtual const double * getReducedCost() const;
00232   
00235       virtual const double * getRowActivity() const;
00236   
00238       virtual double getObjValue() const;
00239   
00242       virtual int getIterationCount() const;
00243   
00255       virtual std::vector<double*> getDualRays(int maxNumRays) const;
00267       virtual std::vector<double*> getPrimalRays(int maxNumRays) const;
00268   
00269 #if 0
00270 
00272       virtual OsiVectorInt getFractionalIndices(const double etol=1.e-05)
00273         const;
00274 #endif
00275 
00276 
00277 
00278   //---------------------------------------------------------------------------
00279 
00282     //-------------------------------------------------------------------------
00286       virtual void setObjCoeff( int elementIndex, double elementValue );
00287 
00290       virtual void setColLower( int elementIndex, double elementValue );
00291       
00294       virtual void setColUpper( int elementIndex, double elementValue );
00295       
00296 #if 0
00297       // The default implementation is OK.
00301       virtual void setColBounds( int elementIndex,
00302                                  double lower, double upper ) {
00303          setColLower(elementIndex, lower);
00304          setColUpper(elementIndex, upper);
00305       }
00306 #endif
00307 
00315       virtual void setColSetBounds(const int* indexFirst,
00316                                    const int* indexLast,
00317                                    const double* boundList);
00318       
00321       virtual void setRowLower( int elementIndex, double elementValue );
00322       
00325       virtual void setRowUpper( int elementIndex, double elementValue );
00326     
00330       virtual void setRowBounds( int elementIndex,
00331                                  double lower, double upper );
00332     
00334       virtual void setRowType(int index, char sense, double rightHandSide,
00335                               double range);
00336     
00345       virtual void setRowSetBounds(const int* indexFirst,
00346                                    const int* indexLast,
00347                                    const double* boundList);
00348     
00359       virtual void setRowSetTypes(const int* indexFirst,
00360                                   const int* indexLast,
00361                                   const char* senseList,
00362                                   const double* rhsList,
00363                                   const double* rangeList);
00365     
00366     //-------------------------------------------------------------------------
00370       virtual void setContinuous(int index);
00372       virtual void setInteger(int index);
00375       virtual void setContinuous(const int* indices, int len);
00378       virtual void setInteger(const int* indices, int len);
00380     
00381     //-------------------------------------------------------------------------
00383     virtual void setObjSense(double s );
00384     
00395     virtual void setColSolution(const double * colsol);
00396     
00407     virtual void setRowPrice(const double * rowprice);
00408 
00409     //-------------------------------------------------------------------------
00415       virtual void addCol(const CoinPackedVectorBase& vec,
00416                              const double collb, const double colub,   
00417                              const double obj);
00419       virtual void addCols(const int numcols,
00420                            const CoinPackedVectorBase * const * cols,
00421                            const double* collb, const double* colub,   
00422                            const double* obj);
00423 #if 0
00424 
00425       virtual void addCols(const CoinPackedMatrix& matrix,
00426                               const double* collb, const double* colub,   
00427                               const double* obj);
00428 #endif
00429 
00430       virtual void deleteCols(const int num, const int * colIndices);
00431     
00433       virtual void addRow(const CoinPackedVectorBase& vec,
00434                           const double rowlb, const double rowub);
00436       virtual void addRow(const CoinPackedVectorBase& vec,
00437                           const char rowsen, const double rowrhs,   
00438                           const double rowrng);
00440       virtual void addRows(const int numrows,
00441                            const CoinPackedVectorBase * const * rows,
00442                            const double* rowlb, const double* rowub);
00444       virtual void addRows(const int numrows,
00445                            const CoinPackedVectorBase * const * rows,
00446                            const char* rowsen, const double* rowrhs,   
00447                            const double* rowrng);
00448 #if 0
00449 
00450       virtual void addRows(const CoinPackedMatrix& matrix,
00451                            const double* rowlb, const double* rowub);
00453       virtual void addRows(const CoinPackedMatrix& matrix,
00454                            const char* rowsen, const double* rowrhs,   
00455                            const double* rowrng);
00456 #endif
00457 
00458       virtual void deleteRows(const int num, const int * rowIndices);
00459     
00460       //-----------------------------------------------------------------------
00461 #if 0
00462 
00483       virtual ApplyCutsReturnCode applyCuts(const OsiCuts & cs,
00484                                             double effectivenessLb = 0.0);
00485 #endif
00486 
00487 
00488 
00489   //---------------------------------------------------------------------------
00490 
00504     virtual void loadProblem(const CoinPackedMatrix& matrix,
00505                              const double* collb, const double* colub,   
00506                              const double* obj,
00507                              const double* rowlb, const double* rowub);
00508                             
00516     virtual void assignProblem(CoinPackedMatrix*& matrix,
00517                                double*& collb, double*& colub, double*& obj,
00518                                double*& rowlb, double*& rowub);
00519 
00532     virtual void loadProblem(const CoinPackedMatrix& matrix,
00533                              const double* collb, const double* colub,
00534                              const double* obj,
00535                              const char* rowsen, const double* rowrhs,   
00536                              const double* rowrng);
00537 
00545     virtual void assignProblem(CoinPackedMatrix*& matrix,
00546                                double*& collb, double*& colub, double*& obj,
00547                                char*& rowsen, double*& rowrhs,
00548                                double*& rowrng);
00549 
00552     virtual void loadProblem(const int numcols, const int numrows,
00553                              const int* start, const int* index,
00554                              const double* value,
00555                              const double* collb, const double* colub,   
00556                              const double* obj,
00557                              const double* rowlb, const double* rowub);
00558 
00561     virtual void loadProblem(const int numcols, const int numrows,
00562                              const int* start, const int* index,
00563                              const double* value,
00564                              const double* collb, const double* colub,   
00565                              const double* obj,
00566                              const char* rowsen, const double* rowrhs,   
00567                              const double* rowrng);
00568 
00571     virtual int readMps(const char *filename,
00572                         const char *extension = "mps");
00573 
00578     virtual void writeMps(const char *filename,
00579                           const char *extension = "mps",
00580                           double objSense=0.0) const;
00582 
00583   //---------------------------------------------------------------------------
00584 
00587 
00588     EKKModel * getModelPtr(); 
00589 
00600       static void incrementInstanceCounter(); 
00601 
00610       static void decrementInstanceCounter();
00611 
00614       static unsigned int getNumInstances();
00616 
00617 
00620 
00621     OsiOslSolverInterface(); 
00622       
00624     virtual OsiSolverInterface * clone(bool copyData = true) const;
00625  
00627     OsiOslSolverInterface (const OsiOslSolverInterface &);
00628   
00630     OsiOslSolverInterface &    
00631     operator=(const OsiOslSolverInterface& rhs);
00632   
00634     virtual ~OsiOslSolverInterface ();
00635 
00637     virtual void reset();
00639 
00640 protected:
00641 
00645     virtual void applyRowCut( const OsiRowCut & rc );
00646 
00648     virtual void applyColCut( const OsiColCut & cc );
00650     
00651 private:
00652   
00655 
00656     static EKKContext * getContextPtr();
00658   
00661 
00662     static EKKContext * contextPtr_;
00664     static unsigned int numInstances_;
00666   
00667   
00673     EKKModel * getMutableModelPtr() const;
00674   
00676     void gutsOfDestructor();
00677   
00679     void freeCachedResults();
00680 
00682     void extractSenseRhsRange() const;
00684   
00687 
00688      mutable EKKModel * modelPtr_;
00689 
00692 
00693       mutable char    *rowsense_;
00694   
00696       mutable double  *rhs_;
00697   
00701      mutable double  *rowrange_;
00702 
00705      CoinWarmStartBasis* ws_;
00707      int itlimOrig_;
00708   
00710      mutable CoinPackedMatrix *matrixByRow_;  
00712      mutable CoinPackedMatrix *matrixByColumn_;  
00714 
00715 
00716 };
00717 
00718 //#############################################################################
00726 void
00727 OsiOslSolverInterfaceUnitTest(const std::string & mpsDir, const std::string & netlibDir);
00728 
00729 #endif

Generated on Wed Dec 3 14:35:32 2003 for Osi by doxygen 1.3.5