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

- File List
- File Members

# /home/coin/SVN-release/Bcps-0.91.0/Osi/src/OsiFmp/OsiFmpSolverInterface.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 _OsiFmpSolverInterface_hpp_
    00005 #define _OsiFmpSolverInterface_hpp_
    00006
    00007 #if (defined(__MINGW32__) || defined(__CYGWIN32__)) && !defined(FMPMSDLL)
    00008 #  define FMPMSDLL
    00009 #endif
    00010
    00011 #include <string>
    00012 #include <libhd2.h>
    00013
    00014 #include "OsiSolverInterface.hpp"
    00015 #include "CoinPackedMatrix.hpp"
    00016 #include "CoinWarmStartBasis.hpp"
    00017
    00018 //#############################################################################
    00019
    00025 class OsiFmpSolverInterface : virtual public OsiSolverInterface {
    00026    friend void OsiFmpSolverInterfaceUnitTest(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
    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 CoinBigIndex * 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 CoinBigIndex * 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
    00585
    00588
    00589     OsiFmpSolverInterface();
    00590
    00592     virtual OsiSolverInterface * clone(bool copyData = true) const;
    00593
    00595     OsiFmpSolverInterface (const OsiFmpSolverInterface &);
    00596
    00598     OsiFmpSolverInterface &
    00599     operator=(const OsiFmpSolverInterface& rhs);
    00600
    00602     virtual ~OsiFmpSolverInterface ();
    00603
    00605     virtual void reset();
    00607
    00608 protected:
    00609
    00610         static int CBIterCountP2(int iter,double obj);
    00611
    00612         void AllocSolutionSpace();
    00613
    00617     virtual void applyRowCut( const OsiRowCut & rc );
    00618
    00620     virtual void applyColCut( const OsiColCut & cc );
    00622
    00623 private:
    00624
    00627
    00629     void gutsOfDestructor();
    00630
    00632     void freeCachedResults();
    00633
    00635     void extractSenseRhsRange() const;
    00637
    00643
    00644         int             nr_;
    00646         int             nc_;
    00648         int             nz_;
    00650         int             ns_;
    00652         int             nq_;
    00654         int *send_;
    00655         int *sref_;
    00656         int *sfun_;
    00657         int *sbeg_;
    00659         int             *rowin_;
    00661         int             *colin_;
    00663         double  *aij_;
    00665         int             *mitype_;
    00667         double  *upb_;
    00669   double  *lob_;
    00671         double  *cost_;
    00673         double  *rhs_;
    00675         double  *lhs_;
    00677         int stsl_;
    00679         int *basis_;
    00681         double *sol_;
    00683         double *dsl_;
    00685         double  objconstant_;
    00687         double  obj_;
    00689         std::string modelname_;
    00691         bool isMax_;
    00692
    00693
    00696
    00697      mutable char *rowsense_;
    00698
    00700      mutable double *rowrhs_;
    00701
    00704      mutable double *rowrange_;
    00705
    00707      mutable CoinPackedMatrix *matrixByRow_;
    00709      mutable CoinPackedMatrix *matrixByColumn_;
    00710
    00713      CoinWarmStartBasis* ws_;
    00715      int itlimOrig_;
    00716
    00718
    00719
    00720 };
    00721
    00722
    00723 //#############################################################################
    00731 void
    00732 OsiFmpSolverInterfaceUnitTest(const std::string & mpsDir, const std::string & netlibDir);
    00733
    00734 #endif