00001 /* $Id: CbcHeuristicLocal.hpp 1943 2013-07-21 09:05:45Z forrest $ */ 00002 // Copyright (C) 2002, International Business Machines 00003 // Corporation and others. All Rights Reserved. 00004 // This code is licensed under the terms of the Eclipse Public License (EPL). 00005 00006 #ifndef CbcHeuristicLocal_H 00007 #define CbcHeuristicLocal_H 00008 00009 #include "CbcHeuristic.hpp" 00013 class CbcHeuristicLocal : public CbcHeuristic { 00014 public: 00015 00016 // Default Constructor 00017 CbcHeuristicLocal (); 00018 00019 /* Constructor with model - assumed before cuts 00020 Initial version does not do Lps 00021 */ 00022 CbcHeuristicLocal (CbcModel & model); 00023 00024 // Copy constructor 00025 CbcHeuristicLocal ( const CbcHeuristicLocal &); 00026 00027 // Destructor 00028 ~CbcHeuristicLocal (); 00029 00031 virtual CbcHeuristic * clone() const; 00032 00034 CbcHeuristicLocal & operator=(const CbcHeuristicLocal& rhs); 00035 00037 virtual void generateCpp( FILE * fp) ; 00038 00040 virtual void resetModel(CbcModel * model); 00041 00043 virtual void setModel(CbcModel * model); 00044 00045 using CbcHeuristic::solution ; 00057 virtual int solution(double & objectiveValue, 00058 double * newSolution); 00060 int solutionFix(double & objectiveValue, 00061 double * newSolution, 00062 const int * keep); 00063 00065 inline void setSearchType(int value) { 00066 swap_ = value; 00067 } 00069 inline int * used() const { 00070 return used_; 00071 } 00072 00073 protected: 00074 // Data 00075 00076 // Original matrix by column 00077 CoinPackedMatrix matrix_; 00078 00079 // Number of solutions so we only do after new solution 00080 int numberSolutions_; 00081 // Type of search 0=normal, 1=BAB 00082 int swap_; 00084 int * used_; 00085 }; 00086 00089 class CbcHeuristicFPump; 00090 class CbcHeuristicProximity : public CbcHeuristic { 00091 public: 00092 00093 // Default Constructor 00094 CbcHeuristicProximity (); 00095 00096 /* Constructor with model - assumed before cuts 00097 */ 00098 CbcHeuristicProximity (CbcModel & model); 00099 00100 // Copy constructor 00101 CbcHeuristicProximity ( const CbcHeuristicProximity &); 00102 00103 // Destructor 00104 ~CbcHeuristicProximity (); 00105 00107 virtual CbcHeuristic * clone() const; 00108 00110 CbcHeuristicProximity & operator=(const CbcHeuristicProximity& rhs); 00111 00113 virtual void generateCpp( FILE * fp) ; 00114 00116 virtual void resetModel(CbcModel * model); 00117 00119 virtual void setModel(CbcModel * model); 00120 00121 using CbcHeuristic::solution ; 00125 virtual int solution(double & objectiveValue, 00126 double * newSolution); 00128 inline void setIncrement(double value) 00129 { increment_ = value;} 00131 inline int * used() const { 00132 return used_; 00133 } 00134 00135 protected: 00136 // Data 00138 double increment_; 00140 CbcHeuristicFPump * feasibilityPump_; 00142 int numberSolutions_; 00144 int * used_; 00145 }; 00146 00147 00154 class CbcHeuristicNaive : public CbcHeuristic { 00155 public: 00156 00157 // Default Constructor 00158 CbcHeuristicNaive (); 00159 00160 /* Constructor with model - assumed before cuts 00161 Initial version does not do Lps 00162 */ 00163 CbcHeuristicNaive (CbcModel & model); 00164 00165 // Copy constructor 00166 CbcHeuristicNaive ( const CbcHeuristicNaive &); 00167 00168 // Destructor 00169 ~CbcHeuristicNaive (); 00170 00172 virtual CbcHeuristic * clone() const; 00173 00175 CbcHeuristicNaive & operator=(const CbcHeuristicNaive& rhs); 00176 00178 virtual void generateCpp( FILE * fp) ; 00179 00181 virtual void resetModel(CbcModel * model); 00182 00184 virtual void setModel(CbcModel * model); 00185 00186 using CbcHeuristic::solution ; 00190 virtual int solution(double & objectiveValue, 00191 double * newSolution); 00192 00194 inline void setLargeValue(double value) { 00195 large_ = value; 00196 } 00198 inline double largeValue() const { 00199 return large_; 00200 } 00201 00202 protected: 00205 double large_; 00206 }; 00207 00211 class CbcHeuristicCrossover : public CbcHeuristic { 00212 public: 00213 00214 // Default Constructor 00215 CbcHeuristicCrossover (); 00216 00217 /* Constructor with model - assumed before cuts 00218 Initial version does not do Lps 00219 */ 00220 CbcHeuristicCrossover (CbcModel & model); 00221 00222 // Copy constructor 00223 CbcHeuristicCrossover ( const CbcHeuristicCrossover &); 00224 00225 // Destructor 00226 ~CbcHeuristicCrossover (); 00227 00229 virtual CbcHeuristic * clone() const; 00230 00232 CbcHeuristicCrossover & operator=(const CbcHeuristicCrossover& rhs); 00233 00235 virtual void generateCpp( FILE * fp) ; 00236 00238 virtual void resetModel(CbcModel * model); 00239 00241 virtual void setModel(CbcModel * model); 00242 00243 using CbcHeuristic::solution ; 00249 virtual int solution(double & objectiveValue, 00250 double * newSolution); 00251 00253 inline void setNumberSolutions(int value) { 00254 if (value > 0 && value <= 10) 00255 useNumber_ = value; 00256 } 00257 00258 protected: 00259 // Data 00261 std::vector <double> attempts_; 00263 double random_[10]; 00265 int numberSolutions_; 00267 int useNumber_; 00268 }; 00269 00270 #endif 00271