OsiXprSolverInterface.hpp

Go to the documentation of this file.
00001 // Copyright (C) 2000, International Business Machines
00002 // Corporation and others.  All Rights Reserved.
00003 
00004 #ifndef OsiXprSolverInterface_H
00005 #define OsiXprSolverInterface_H
00006 
00007 #include <string>
00008 #include <cstdio>
00009 
00010 #include "OsiSolverInterface.hpp"
00011 
00012 typedef struct xo_prob_struct* XPRSprob;
00013 
00014 //#############################################################################
00015 
00020 class OsiXprSolverInterface : virtual public OsiSolverInterface {
00021    friend void OsiXprSolverInterfaceUnitTest(const std::string & mpsDir, const std::string & netlibDir);
00022 public:
00025 
00026     virtual void initialSolve();
00027 
00029     virtual void resolve();
00030 
00032     virtual void branchAndBound();
00034   
00050     // Set an integer parameter
00051     bool setIntParam(OsiIntParam key, int value);
00052     // Set an double parameter
00053     bool setDblParam(OsiDblParam key, double value);
00054     // Set a string parameter
00055     bool setStrParam(OsiStrParam key, const std::string & value);
00056     // Get an integer parameter
00057     bool getIntParam(OsiIntParam key, int& value) const;
00058     // Get an double parameter
00059     bool getDblParam(OsiDblParam key, double& value) const;
00060     // Get a string parameter
00061     bool getStrParam(OsiStrParam key, std::string& value) const;
00063 
00064   //---------------------------------------------------------------------------
00066 
00067 
00068     virtual bool isAbandoned() const;
00070     virtual bool isProvenOptimal() const;
00072     virtual bool isProvenPrimalInfeasible() const;
00074     virtual bool isProvenDualInfeasible() const;
00076     virtual bool isPrimalObjectiveLimitReached() const;
00078     virtual bool isDualObjectiveLimitReached() const;
00080     virtual bool isIterationLimitReached() const;
00082 
00083   //---------------------------------------------------------------------------
00086 
00087     CoinWarmStart *getEmptyWarmStart () const;
00089     virtual CoinWarmStart* getWarmStart() const;
00092     virtual bool setWarmStart(const CoinWarmStart* warmstart);
00094 
00095   //---------------------------------------------------------------------------
00102 
00103     virtual void markHotStart();
00105     virtual void solveFromHotStart();
00107     virtual void unmarkHotStart();
00109 
00110   //---------------------------------------------------------------------------
00125 
00126       virtual int getNumCols() const;
00127   
00129       virtual int getNumRows() const;
00130   
00132       virtual int getNumElements() const;
00133   
00135       virtual const double * getColLower() const;
00136   
00138       virtual const double * getColUpper() const;
00139   
00149       virtual const char * getRowSense() const;
00150   
00159       virtual const double * getRightHandSide() const;
00160   
00169       virtual const double * getRowRange() const;
00170   
00172       virtual const double * getRowLower() const;
00173   
00175       virtual const double * getRowUpper() const;
00176   
00178       virtual const double * getObjCoefficients() const;
00179   
00181       virtual double getObjSense() const;
00182   
00184       virtual bool isContinuous(int colIndex) const;
00185   
00186 #if 0
00188       virtual bool isBinary(int colIndex) const;
00189   
00194       virtual bool isInteger(int colIndex) const;
00195   
00197       virtual bool isIntegerNonBinary(int colIndex) const;
00198   
00200       virtual bool isFreeBinary(int colIndex) const; 
00201 #endif
00203       virtual const CoinPackedMatrix * getMatrixByRow() const;
00204   
00206       virtual const CoinPackedMatrix * getMatrixByCol() const;
00207   
00209       virtual double getInfinity() const;
00211     
00214 
00215       virtual const double * getColSolution() const;
00216   
00218       virtual const double * getRowPrice() const;
00219   
00221       virtual const double * getReducedCost() const;
00222   
00225       virtual const double * getRowActivity() const;
00226   
00228       virtual double getObjValue() const;
00229   
00232       virtual int getIterationCount() const;
00233   
00251       virtual std::vector<double*> getDualRays(int maxNumRays,
00252                                                bool fullRay=false) const;
00264       virtual std::vector<double*> getPrimalRays(int maxNumRays) const;
00265   
00266 #if 0
00267 
00269       virtual OsiVectorInt getFractionalIndices(const double etol=1.e-05)
00270         const;
00271 #endif
00272 
00273 
00274 
00275   //---------------------------------------------------------------------------
00276 
00279     //-------------------------------------------------------------------------
00283       virtual void setObjCoeff( int elementIndex, double elementValue );
00284 
00287       virtual void setColLower( int elementIndex, double elementValue );
00288       
00291       virtual void setColUpper( int elementIndex, double elementValue );
00292       
00296       virtual void setColBounds( int elementIndex,
00297                                  double lower, double upper );
00298     
00307       virtual void setColSetBounds(const int* indexFirst,
00308                                    const int* indexLast,
00309                                    const double* boundList);
00310       
00313       virtual void setRowLower( int elementIndex, double elementValue );
00314       
00317       virtual void setRowUpper( int elementIndex, double elementValue );
00318     
00322       virtual void setRowBounds( int elementIndex,
00323                                  double lower, double upper );
00324     
00326       virtual void setRowType(int index, char sense, double rightHandSide,
00327                               double range);
00328     
00337       virtual void setRowSetBounds(const int* indexFirst,
00338                                    const int* indexLast,
00339                                    const double* boundList);
00340     
00351       virtual void setRowSetTypes(const int* indexFirst,
00352                                   const int* indexLast,
00353                                   const char* senseList,
00354                                   const double* rhsList,
00355                                   const double* rangeList);
00357     
00358     //-------------------------------------------------------------------------
00362       virtual void setContinuous(int index);
00364       virtual void setInteger(int index);
00367       virtual void setContinuous(const int* indices, int len);
00370       virtual void setInteger(const int* indices, int len);
00372     
00373     //-------------------------------------------------------------------------
00375     virtual void setObjSense(double s);
00376     
00387     virtual void setColSolution(const double * colsol);
00388     
00399     virtual void setRowPrice(const double * rowprice);
00400     
00401     //-------------------------------------------------------------------------
00407       virtual void addCol(const CoinPackedVectorBase& vec,
00408                           const double collb, const double colub,   
00409                           const double obj);
00411       virtual void addCols(const int numcols,
00412                            const CoinPackedVectorBase * const * cols,
00413                            const double* collb, const double* colub,   
00414                            const double* obj);
00416       virtual void deleteCols(const int num, const int * colIndices);
00417     
00419       virtual void addRow(const CoinPackedVectorBase& vec,
00420                           const double rowlb, const double rowub);
00422       virtual void addRow(const CoinPackedVectorBase& vec,
00423                           const char rowsen, const double rowrhs,   
00424                           const double rowrng);
00426       virtual void addRows(const int numrows,
00427                            const CoinPackedVectorBase * const * rows,
00428                            const double* rowlb, const double* rowub);
00430       virtual void addRows(const int numrows,
00431                            const CoinPackedVectorBase * const * rows,
00432                            const char* rowsen, const double* rowrhs,   
00433                            const double* rowrng);
00435       virtual void deleteRows(const int num, const int * rowIndices);
00436 #if 0
00437       //-----------------------------------------------------------------------
00459       virtual ApplyCutsReturnCode applyCuts(const OsiCuts & cs,
00460                                             double effectivenessLb = 0.0);
00462 
00463 #endif
00464   //---------------------------------------------------------------------------
00465 
00479     virtual void loadProblem(const CoinPackedMatrix& matrix,
00480                              const double* collb, const double* colub,   
00481                              const double* obj,
00482                              const double* rowlb, const double* rowub);
00483                             
00491     virtual void assignProblem(CoinPackedMatrix*& matrix,
00492                                double*& collb, double*& colub, double*& obj,
00493                                double*& rowlb, double*& rowub);
00494 
00507     virtual void loadProblem(const CoinPackedMatrix& matrix,
00508                              const double* collb, const double* colub,
00509                              const double* obj,
00510                              const char* rowsen, const double* rowrhs,   
00511                              const double* rowrng);
00512 
00520     virtual void assignProblem(CoinPackedMatrix*& matrix,
00521                                double*& collb, double*& colub, double*& obj,
00522                                char*& rowsen, double*& rowrhs,
00523                                double*& rowrng);
00524 
00527     virtual void loadProblem(const int numcols, const int numrows,
00528                              const int* start, const int* index,
00529                              const double* value,
00530                              const double* collb, const double* colub,   
00531                              const double* obj,
00532                              const double* rowlb, const double* rowub);
00533 
00536     virtual void loadProblem(const int numcols, const int numrows,
00537                              const int* start, const int* index,
00538                              const double* value,
00539                              const double* collb, const double* colub,   
00540                              const double* obj,
00541                              const char* rowsen, const double* rowrhs,   
00542                              const double* rowrng);
00543 
00544 
00546     virtual int readMps(const char *filename,
00547                          const char *extension = "mps");
00548 
00549 
00554     virtual void writeMps(const char *filename,
00555                           const char *extension = "mps",
00556                           double objSense=0.0) const;
00558 
00566     void passInMessageHandler(CoinMessageHandler * handler);
00568 
00569   //---------------------------------------------------------------------------
00570 
00584       static  void incrementInstanceCounter();
00585 
00594       static  void decrementInstanceCounter();
00595 
00598       static  unsigned int getNumInstances();
00599       
00601       XPRSprob getLpPtr() { return prob_; }
00603 
00605     static int version();
00606 
00609     static int iXprCallCount_;
00610 
00611 
00613       static FILE * getLogFilePtr();
00616       static void setLogFileName( const char * filename );
00618 
00619 
00622 
00623     OsiXprSolverInterface (int newrows = 50, int newnz = 100);
00624 
00626     virtual OsiSolverInterface * clone(bool copyData = true) const;
00627 
00629     OsiXprSolverInterface (const OsiXprSolverInterface &);
00630 
00632     OsiXprSolverInterface & operator=(const OsiXprSolverInterface& rhs);
00633 
00635     virtual ~OsiXprSolverInterface ();
00637 
00638 protected:
00639 
00642 
00643     virtual void applyRowCut( const OsiRowCut & rc );
00644 
00648     virtual void applyColCut( const OsiColCut & cc );
00650 
00651 private:  
00652   
00655 
00656     static const char * logFileName_;
00657 
00659     static FILE * logFilePtr_;
00660 
00662     static  unsigned int numInstances_;
00663 
00665     static  unsigned int osiSerial_;
00666 
00668 
00671 
00672     void gutsOfCopy( const OsiXprSolverInterface & source );
00673 
00675     void gutsOfConstructor(); 
00676 
00678     void gutsOfDestructor(); 
00679 
00681     void freeSolution();
00682 
00685     void freeCachedResults();
00686 
00688     int getNumIntVars() const;
00689 
00692 
00693       void getVarTypes() const;
00694 
00698       void    activateMe() const;
00699 
00704       bool    isDataLoaded() const;
00706 
00707 
00710 
00713     
00714     mutable XPRSprob prob_;
00715     
00717       mutable std::string  xprProbname_;
00719 
00727       mutable CoinPackedMatrix *matrixByRow_;
00728       mutable CoinPackedMatrix *matrixByCol_;
00729 
00731       mutable double  *colupper_;
00732 
00734       mutable double  *collower_;
00735 
00737       mutable double  *rowupper_;
00738 
00740       mutable double  *rowlower_;
00741 
00743       mutable char    *rowsense_;
00744 
00746       mutable double  *rhs_;
00747 
00751       mutable double  *rowrange_;
00752 
00754       mutable double  *objcoeffs_;
00755 
00757       mutable double  objsense_;
00758 
00760       mutable double  *colsol_;
00761 
00763       mutable double  *rowsol_;
00764 
00766       mutable double  *rowact_;
00767 
00769       mutable double  *rowprice_;
00770 
00772       mutable double  *colprice_;
00773 
00775       mutable int     *ivarind_;
00776 
00785       mutable char    *ivartype_;
00786 
00790       mutable char    *vartype_;
00791 
00793       mutable bool lastsolvewasmip;
00795 
00796 };
00797 
00798 //#############################################################################
00804 void
00805 OsiXprSolverInterfaceUnitTest(const std::string & mpsDir, const std::string & netlibDir);
00806 
00807 #endif

Generated on Tue Jun 14 23:14:05 2011 for Cbc by  doxygen 1.4.7