/home/coin/SVN-release/Cbc-2.3.2/Cbc/src/CbcSolver.hpp

Go to the documentation of this file.
00001 // Copyright (C) 2007, International Business Machines
00002 // Corporation and others.  All Rights Reserved.
00003 #ifndef CbcSolver_H
00004 #define CbcSolver_H
00005 #include <string>
00006 #include <vector>
00007 #include "CoinFinite.hpp"
00008 #include "CoinMessageHandler.hpp"
00009 #include "OsiClpSolverInterface.hpp"
00010 #if CBC_OTHER_SOLVER==1
00011 #include "OsiCpxSolverInterface.hpp"
00012 //typedef OsiCpxSolverInterface OsiClpSolverInterface;
00013 #endif
00014 #include "CbcModel.hpp"
00015 #include "CbcOrClpParam.hpp"
00016 class CbcUser;
00017 class CbcStopNow;
00018 class CglCutGenerator;
00019 
00020 //#############################################################################
00021 
00031 class CbcSolver  {
00032   
00033 public:
00035 
00036 
00042   int solve(int argc, const char * argv[], int returnMode); 
00049   int solve(const char * input, int returnMode); 
00051 
00052 
00053 
00054   CbcSolver(); 
00055   
00057   CbcSolver(const OsiClpSolverInterface &);
00058   
00060   CbcSolver(const CbcModel &);
00061   
00064   CbcSolver(const CbcSolver & rhs);
00065   
00067   CbcSolver & operator=(const CbcSolver& rhs);
00068   
00070   ~CbcSolver ();
00072   void fillParameters();
00074   void fillValuesInSolver();
00076   void addUserFunction(CbcUser * function);
00078   void setUserCallBack(CbcStopNow * function);
00080   void addCutGenerator(CglCutGenerator * generator);
00082 
00083 
00084   // analyze model
00085   int * analyze(OsiClpSolverInterface * solverMod, int & numberChanged, double & increment,
00086                 bool changeInt,  CoinMessageHandler * generalMessageHandler);
00092   int doHeuristics(CbcModel * model, int type);
00099   void updateModel(ClpSimplex * model2, int returnMode);
00101 
00102 
00103 
00104   int intValue(CbcOrClpParameterType type) const;
00106   void setIntValue(CbcOrClpParameterType type,int value);
00108   double doubleValue(CbcOrClpParameterType type) const;
00110   void setDoubleValue(CbcOrClpParameterType type,double value);
00112   CbcUser * userFunction(const char * name) const;
00114   inline CbcModel * model() 
00115   { return &model_;}
00117   inline CbcModel * babModel() 
00118   { return babModel_;}
00120   inline int numberUserFunctions() const
00121   { return numberUserFunctions_;}
00123   inline CbcUser ** userFunctionArray() const
00124   { return userFunction_;}
00126   inline OsiClpSolverInterface * originalSolver() const
00127   { return originalSolver_;}
00129   inline CoinModel * originalCoinModel() const
00130   { return originalCoinModel_;}
00132   void setOriginalSolver(OsiClpSolverInterface * originalSolver);
00134   void setOriginalCoinModel(CoinModel * originalCoinModel);
00136   inline int numberCutGenerators() const
00137   { return numberCutGenerators_;}
00139   inline CglCutGenerator ** cutGeneratorArray() const
00140   { return cutGenerator_;}
00142   inline double startTime() const
00143   { return startTime_;}
00145   inline void setPrinting(bool onOff)
00146   { noPrinting_= !onOff;}
00148   inline void setReadMode(int value)
00149   { readMode_ = value;}
00151 private:
00153 
00154   
00156   CbcModel model_;
00157   
00159   CbcModel * babModel_;
00160   
00162   CbcUser ** userFunction_;
00169   int * statusUserFunction_;
00171   OsiClpSolverInterface * originalSolver_;
00173   CoinModel * originalCoinModel_;
00175   CglCutGenerator ** cutGenerator_;
00177   int numberUserFunctions_;
00179   int numberCutGenerators_;
00181   CbcStopNow * callBack_;
00183   double startTime_;
00185   CbcOrClpParam * parameters_;
00187   int numberParameters_ ;
00189   bool doMiplib_;
00191   bool noPrinting_;
00193   int readMode_;
00195 };
00196 //#############################################################################
00198 typedef struct {
00199   // Priorities
00200   int * priorities_;
00201   // SOS priorities
00202   int * sosPriority_;
00203   // Direction to branch first
00204   int * branchDirection_;
00205   // Input solution
00206   double * primalSolution_;
00207   // Down pseudo costs
00208   double * pseudoDown_; 
00209   // Up pseudo costs
00210   double * pseudoUp_; 
00211 } CbcSolverUsefulData;
00215 class CbcUser  {
00216   
00217 public:
00219 
00220 
00225   virtual int importData(CbcSolver * model, int & argc, char * argv[]) {return -1;}
00227   virtual void exportSolution(CbcSolver * model, int mode,const char * message=NULL) {}
00229   virtual void exportData(CbcSolver * model) {}
00231   virtual void fillInformation(CbcSolver * model,
00232                                CbcSolverUsefulData & info) {}
00233 
00235 
00236 
00237 
00238   inline CoinModel * coinModel() const
00239   { return coinModel_;}
00241   virtual void * stuff() {return NULL;}
00243   inline std::string name() const
00244   { return userName_;}
00246   virtual void solve(CbcSolver * model, const char * options) = 0;
00248   virtual bool canDo(const char * options) = 0;
00250 
00251 
00252 
00253   CbcUser(); 
00254   
00257   CbcUser(const CbcUser & rhs);
00258   
00260   CbcUser & operator=(const CbcUser& rhs);
00261 
00263   virtual CbcUser * clone() const = 0;
00264   
00266   virtual ~CbcUser ();
00268   
00269 protected:
00271 
00272   
00274   CoinModel * coinModel_;
00275   
00277   std::string userName_;
00278 
00280 };
00281 //#############################################################################
00282 
00286 class CbcStopNow  {
00287   
00288 public:
00290 
00291 
00292 
00301   virtual int callBack(CbcModel * currentSolver, int whereFrom) {return 0;}
00303 
00304 
00305 
00306   CbcStopNow(); 
00307   
00310   CbcStopNow(const CbcStopNow & rhs);
00311   
00313   CbcStopNow & operator=(const CbcStopNow& rhs);
00314 
00316   virtual CbcStopNow * clone() const;
00317   
00319   virtual ~CbcStopNow ();
00321   
00322 private:
00324 
00325 
00326 };
00327 #endif

Generated on Wed Oct 7 03:01:16 2009 by  doxygen 1.4.7