00001
00002
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
00021 CbcHeuristic ();
00022
00023
00024 CbcHeuristic (CbcModel & model);
00025
00026 virtual ~CbcHeuristic();
00027
00029 virtual void setModel(CbcModel * model);
00030
00032 virtual CbcHeuristic * clone() const=0;
00033
00035 virtual void resetModel(CbcModel * model)=0;
00036
00042 virtual int solution(double & objectiveValue,
00043 double * newSolution)=0;
00044
00052 virtual int solution(double & objectiveValue,
00053 double * newSolution,
00054 OsiCuts & cs) {return 0;};
00055
00057 virtual void validate() {};
00058
00063 inline void setWhen(int value)
00064 { when_=value;};
00066 inline int when() const
00067 { return when_;};
00068
00070 int smallBranchAndBound(OsiSolverInterface * solver,int numberNodes,
00071 double * newSolution, double & newSolutionValue,
00072 double cutoff , std::string name) const;
00074 virtual void generateCpp( FILE * fp) {};
00075
00076 protected:
00077
00079 CbcModel * model_;
00081 int when_;
00082 private:
00083
00085 CbcHeuristic & operator=(const CbcHeuristic& rhs);
00086
00087 };
00088
00092 class CbcRounding : public CbcHeuristic {
00093 public:
00094
00095
00096 CbcRounding ();
00097
00098
00099 CbcRounding (CbcModel & model);
00100
00101
00102 CbcRounding ( const CbcRounding &);
00103
00104
00105 ~CbcRounding ();
00106
00108 virtual CbcHeuristic * clone() const;
00110 virtual void generateCpp( FILE * fp) ;
00111
00113 virtual void resetModel(CbcModel * model);
00114
00116 virtual void setModel(CbcModel * model);
00117
00123 virtual int solution(double & objectiveValue,
00124 double * newSolution);
00126 virtual void validate();
00127
00128
00130 void setSeed(int value)
00131 { seed_ = value;};
00132
00133 protected:
00134
00135
00136
00137 CoinPackedMatrix matrix_;
00138
00139
00140 CoinPackedMatrix matrixByRow_;
00141
00142
00143 int seed_;
00144
00145 private:
00147 CbcRounding & operator=(const CbcRounding& rhs);
00148 };
00149
00154 class CbcSerendipity : public CbcHeuristic {
00155 public:
00156
00157
00158 CbcSerendipity ();
00159
00160
00161
00162 CbcSerendipity (CbcModel & model);
00163
00164
00165 CbcSerendipity ( const CbcSerendipity &);
00166
00167
00168 ~CbcSerendipity ();
00169
00171 virtual CbcHeuristic * clone() const;
00173 virtual void generateCpp( FILE * fp) ;
00174
00176 virtual void setModel(CbcModel * model);
00177
00188 virtual int solution(double & objectiveValue,
00189 double * newSolution);
00191 virtual void resetModel(CbcModel * model);
00192
00193 protected:
00194 private:
00196 CbcSerendipity & operator=(const CbcSerendipity& rhs);
00197 };
00198
00199 #endif