/home/coin/SVN-release/Cbc-2.0.0/Cbc/src/CbcHeuristic.hpp

Go to the documentation of this file.
00001 // Copyright (C) 2002, International Business Machines
00002 // Corporation and others.  All Rights Reserved.
00003 #ifndef CbcHeuristic_H
00004 #define CbcHeuristic_H
00005 
00006 #include <string>
00007 #include <vector>
00008 #include "CoinPackedMatrix.hpp"
00009 #include "OsiCuts.hpp"
00010 
00011 class OsiSolverInterface;
00012 
00013 class CbcModel;
00014 
00015 //#############################################################################
00018 class CbcHeuristic {
00019 public:
00020   // Default Constructor 
00021   CbcHeuristic ();
00022 
00023   // Constructor with model - assumed before cuts
00024   CbcHeuristic (CbcModel & model);
00025 
00026   // Copy constructor 
00027   CbcHeuristic ( const CbcHeuristic &);
00028    
00029   virtual ~CbcHeuristic();
00030 
00032   virtual CbcHeuristic * clone() const=0;
00033 
00035   CbcHeuristic & operator=(const CbcHeuristic& rhs);
00036 
00038   virtual void setModel(CbcModel * model);
00039   
00041   virtual void resetModel(CbcModel * model)=0;
00042 
00048   virtual int solution(double & objectiveValue,
00049                        double * newSolution)=0;
00050 
00058   virtual int solution(double & objectiveValue,
00059                        double * newSolution,
00060                        OsiCuts & cs) {return 0;}
00061 
00063   virtual void validate() {}
00064 
00069   inline void setWhen(int value)
00070   { when_=value;}
00072   inline int when() const
00073   { return when_;}
00074 
00076   inline void setNumberNodes(int value)
00077   { numberNodes_=value;}
00079   inline int numberNodes() const
00080   { return numberNodes_;}
00082   inline void setModelOnly(CbcModel * model)
00083   { model_ = model;}
00084   
00085 
00087   inline void setFractionSmall(double value)
00088   { fractionSmall_=value;}
00090   inline double fractionSmall() const
00091   { return fractionSmall_;}
00092 
00100   int smallBranchAndBound(OsiSolverInterface * solver,int numberNodes,
00101                           double * newSolution, double & newSolutionValue,
00102                           double cutoff , std::string name) const;
00104   virtual void generateCpp( FILE * fp) {}
00106   void generateCpp( FILE * fp,const char * heuristic) ;
00108   virtual bool canDealWithOdd() const
00109   { return false;}
00111   inline const char *heuristicName() const
00112   { return heuristicName_.c_str();}
00114   inline void setHeuristicName(const char *name)
00115   { heuristicName_ = name;}
00116 
00117 protected:
00118 
00120   CbcModel * model_;
00122   int when_;
00124   int numberNodes_;
00126   double fractionSmall_;
00128   std::string heuristicName_;
00129   
00130 };
00134 class CbcRounding : public CbcHeuristic {
00135 public:
00136 
00137   // Default Constructor 
00138   CbcRounding ();
00139 
00140   // Constructor with model - assumed before cuts
00141   CbcRounding (CbcModel & model);
00142   
00143   // Copy constructor 
00144   CbcRounding ( const CbcRounding &);
00145    
00146   // Destructor 
00147   ~CbcRounding ();
00148   
00150   CbcRounding & operator=(const CbcRounding& rhs);
00151 
00153   virtual CbcHeuristic * clone() const;
00155   virtual void generateCpp( FILE * fp) ;
00156 
00158   virtual void resetModel(CbcModel * model);
00159 
00161   virtual void setModel(CbcModel * model);
00162   
00163   using CbcHeuristic::solution ;
00169   virtual int solution(double & objectiveValue,
00170                        double * newSolution);
00172   virtual void validate();
00173 
00174 
00176   void setSeed(int value)
00177   { seed_ = value;}
00178 
00179 protected:
00180   // Data
00181 
00182   // Original matrix by column
00183   CoinPackedMatrix matrix_;
00184 
00185   // Original matrix by 
00186   CoinPackedMatrix matrixByRow_;
00187 
00188   // Seed for random stuff
00189   int seed_;
00190 };
00191 
00196 class CbcSerendipity : public CbcHeuristic {
00197 public:
00198 
00199   // Default Constructor 
00200   CbcSerendipity ();
00201 
00202   /* Constructor with model
00203   */
00204   CbcSerendipity (CbcModel & model);
00205   
00206   // Copy constructor 
00207   CbcSerendipity ( const CbcSerendipity &);
00208    
00209   // Destructor 
00210   ~CbcSerendipity ();
00211   
00213   CbcSerendipity & operator=(const CbcSerendipity& rhs);
00214 
00216   virtual CbcHeuristic * clone() const;
00218   virtual void generateCpp( FILE * fp) ;
00219 
00221   virtual void setModel(CbcModel * model);
00222   
00223   using CbcHeuristic::solution ;
00234   virtual int solution(double & objectiveValue,
00235                        double * newSolution);
00237   virtual void resetModel(CbcModel * model);
00238 
00239 protected:
00240 };
00241 
00242 #endif

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