/home/coin/SVN-release/Cbc-2.0.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;
00109   inline CbcModel * model() 
00110   { return &model_;}
00112   inline int numberUserFunctions() const
00113   { return numberUserFunctions_;}
00115   inline CbcUser ** userFunctionArray() const
00116   { return userFunction_;}
00118   inline OsiClpSolverInterface * originalSolver() const
00119   { return originalSolver_;}
00121   inline CoinModel * originalCoinModel() const
00122   { return originalCoinModel_;}
00124   void setOriginalSolver(OsiClpSolverInterface * originalSolver);
00126   void setOriginalCoinModel(CoinModel * originalCoinModel);
00128   inline int numberCutGenerators() const
00129   { return numberCutGenerators_;}
00131   inline CglCutGenerator ** cutGeneratorArray() const
00132   { return cutGenerator_;}
00134   inline double startTime() const
00135   { return startTime_;}
00137   inline void setPrinting(bool onOff)
00138   { noPrinting_= !onOff;}
00140   inline void setReadMode(int value)
00141   { readMode_ = value;}
00143 private:
00145 
00146   
00148   CbcModel model_;
00149   
00151   CbcModel * babModel_;
00152   
00154   CbcUser ** userFunction_;
00161   int * statusUserFunction_;
00163   OsiClpSolverInterface * originalSolver_;
00165   CoinModel * originalCoinModel_;
00167   CglCutGenerator ** cutGenerator_;
00169   int numberUserFunctions_;
00171   int numberCutGenerators_;
00173   CbcStopNow * callBack_;
00175   double startTime_;
00177   CbcOrClpParam * parameters_;
00179   int numberParameters_ ;
00181   bool doMiplib_;
00183   bool noPrinting_;
00185   int readMode_;
00187 };
00188 //#############################################################################
00190 typedef struct {
00191   // Priorities
00192   int * priorities_;
00193   // SOS priorities
00194   int * sosPriority_;
00195   // Direction to branch first
00196   int * branchDirection_;
00197   // Input solution
00198   double * primalSolution_;
00199   // Down pseudo costs
00200   double * pseudoDown_; 
00201   // Up pseudo costs
00202   double * pseudoUp_; 
00203 } CbcSolverUsefulData;
00207 class CbcUser  {
00208   
00209 public:
00211 
00212 
00217   virtual int importData(CbcSolver * model, int & argc, char * argv[]) {return -1;}
00219   virtual void exportSolution(CbcSolver * model, int mode,const char * message=NULL) {}
00221   virtual void exportData(CbcSolver * model) {}
00223   virtual void fillInformation(CbcSolver * model,
00224                                CbcSolverUsefulData & info) {}
00225 
00227 
00228 
00229 
00230   inline CoinModel * coinModel() const
00231   { return coinModel_;}
00233   virtual void * stuff() {return NULL;}
00235   inline std::string name() const
00236   { return userName_;}
00238   virtual void solve(CbcSolver * model, const char * options) = 0;
00240   virtual bool canDo(const char * options) = 0;
00242 
00243 
00244 
00245   CbcUser(); 
00246   
00249   CbcUser(const CbcUser & rhs);
00250   
00252   CbcUser & operator=(const CbcUser& rhs);
00253 
00255   virtual CbcUser * clone() const = 0;
00256   
00258   virtual ~CbcUser ();
00260   
00261 protected:
00263 
00264   
00266   CoinModel * coinModel_;
00267   
00269   std::string userName_;
00270 
00272 };
00273 //#############################################################################
00274 
00278 class CbcStopNow  {
00279   
00280 public:
00282 
00283 
00284 
00293   virtual int callBack(CbcModel * currentSolver, int whereFrom) {return 0;}
00295 
00296 
00297 
00298   CbcStopNow(); 
00299   
00302   CbcStopNow(const CbcStopNow & rhs);
00303   
00305   CbcStopNow & operator=(const CbcStopNow& rhs);
00306 
00308   virtual CbcStopNow * clone() const;
00309   
00311   virtual ~CbcStopNow ();
00313   
00314 private:
00316 
00317 
00318 };
00319 #endif

Generated on Thu May 15 22:07:39 2008 by  doxygen 1.4.7