/home/coin/SVN-release/CoinAll-1.1.0/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 #include "CbcModel.hpp"
00011 #include "CbcOrClpParam.hpp"
00012 class CbcUser;
00013 class CbcStopNow;
00014 class CglCutGenerator;
00015 
00016 //#############################################################################
00017 
00027 class CbcSolver  {
00028   
00029 public:
00031 
00032 
00038   int solve(int argc, const char * argv[], int returnMode); 
00045   int solve(const char * input, int returnMode); 
00047 
00048 
00049 
00050   CbcSolver(); 
00051   
00053   CbcSolver(const OsiClpSolverInterface &);
00054   
00056   CbcSolver(const CbcModel &);
00057   
00060   CbcSolver(const CbcSolver & rhs);
00061   
00063   CbcSolver & operator=(const CbcSolver& rhs);
00064   
00066   ~CbcSolver ();
00068   void fillParameters();
00070   void fillValuesInSolver();
00072   void addUserFunction(CbcUser * function);
00074   void setUserCallBack(CbcStopNow * function);
00076   void addCutGenerator(CglCutGenerator * generator);
00078 
00079 
00080   // analyze model
00081   int * analyze(OsiClpSolverInterface * solverMod, int & numberChanged, double & increment,
00082                 bool changeInt,  CoinMessageHandler * generalMessageHandler);
00088   int doHeuristics(CbcModel * model, int type);
00095   void updateModel(ClpSimplex * model2, int returnMode);
00097 
00098 
00099 
00100   int intValue(CbcOrClpParameterType type) const;
00102   void setIntValue(CbcOrClpParameterType type,int value);
00104   double doubleValue(CbcOrClpParameterType type) const;
00106   void setDoubleValue(CbcOrClpParameterType type,double value);
00108   CbcUser * userFunction(const char * name) const;
00110   inline CbcModel * model() 
00111   { return &model_;}
00113   inline CbcModel * babModel() 
00114   { return babModel_;}
00116   inline int numberUserFunctions() const
00117   { return numberUserFunctions_;}
00119   inline CbcUser ** userFunctionArray() const
00120   { return userFunction_;}
00122   inline OsiClpSolverInterface * originalSolver() const
00123   { return originalSolver_;}
00125   inline CoinModel * originalCoinModel() const
00126   { return originalCoinModel_;}
00128   void setOriginalSolver(OsiClpSolverInterface * originalSolver);
00130   void setOriginalCoinModel(CoinModel * originalCoinModel);
00132   inline int numberCutGenerators() const
00133   { return numberCutGenerators_;}
00135   inline CglCutGenerator ** cutGeneratorArray() const
00136   { return cutGenerator_;}
00138   inline double startTime() const
00139   { return startTime_;}
00141   inline void setPrinting(bool onOff)
00142   { noPrinting_= !onOff;}
00144   inline void setReadMode(int value)
00145   { readMode_ = value;}
00147 private:
00149 
00150   
00152   CbcModel model_;
00153   
00155   CbcModel * babModel_;
00156   
00158   CbcUser ** userFunction_;
00165   int * statusUserFunction_;
00167   OsiClpSolverInterface * originalSolver_;
00169   CoinModel * originalCoinModel_;
00171   CglCutGenerator ** cutGenerator_;
00173   int numberUserFunctions_;
00175   int numberCutGenerators_;
00177   CbcStopNow * callBack_;
00179   double startTime_;
00181   CbcOrClpParam * parameters_;
00183   int numberParameters_ ;
00185   bool doMiplib_;
00187   bool noPrinting_;
00189   int readMode_;
00191 };
00192 //#############################################################################
00194 typedef struct {
00195   // Priorities
00196   int * priorities_;
00197   // SOS priorities
00198   int * sosPriority_;
00199   // Direction to branch first
00200   int * branchDirection_;
00201   // Input solution
00202   double * primalSolution_;
00203   // Down pseudo costs
00204   double * pseudoDown_; 
00205   // Up pseudo costs
00206   double * pseudoUp_; 
00207 } CbcSolverUsefulData;
00211 class CbcUser  {
00212   
00213 public:
00215 
00216 
00221   virtual int importData(CbcSolver * model, int & argc, char * argv[]) {return -1;}
00223   virtual void exportSolution(CbcSolver * model, int mode,const char * message=NULL) {}
00225   virtual void exportData(CbcSolver * model) {}
00227   virtual void fillInformation(CbcSolver * model,
00228                                CbcSolverUsefulData & info) {}
00229 
00231 
00232 
00233 
00234   inline CoinModel * coinModel() const
00235   { return coinModel_;}
00237   virtual void * stuff() {return NULL;}
00239   inline std::string name() const
00240   { return userName_;}
00242   virtual void solve(CbcSolver * model, const char * options) = 0;
00244   virtual bool canDo(const char * options) = 0;
00246 
00247 
00248 
00249   CbcUser(); 
00250   
00253   CbcUser(const CbcUser & rhs);
00254   
00256   CbcUser & operator=(const CbcUser& rhs);
00257 
00259   virtual CbcUser * clone() const = 0;
00260   
00262   virtual ~CbcUser ();
00264   
00265 protected:
00267 
00268   
00270   CoinModel * coinModel_;
00271   
00273   std::string userName_;
00274 
00276 };
00277 //#############################################################################
00278 
00282 class CbcStopNow  {
00283   
00284 public:
00286 
00287 
00288 
00297   virtual int callBack(CbcModel * currentSolver, int whereFrom) {return 0;}
00299 
00300 
00301 
00302   CbcStopNow(); 
00303   
00306   CbcStopNow(const CbcStopNow & rhs);
00307   
00309   CbcStopNow & operator=(const CbcStopNow& rhs);
00310 
00312   virtual CbcStopNow * clone() const;
00313   
00315   virtual ~CbcStopNow ();
00317   
00318 private:
00320 
00321 
00322 };
00323 #endif

Generated on Sun Nov 14 14:06:31 2010 for Coin-All by  doxygen 1.4.7