00001 /*===========================================================================* 00002 * This file is part of the Bcps Linear Solver (BLIS). * 00003 * * 00004 * BLIS is distributed under the Eclipse Public License as part of the * 00005 * COIN-OR repository (http://www.coin-or.org). * 00006 * * 00007 * Authors: * 00008 * * 00009 * Yan Xu, Lehigh University * 00010 * Ted Ralphs, Lehigh University * 00011 * * 00012 * Conceptual Design: * 00013 * * 00014 * Yan Xu, Lehigh University * 00015 * Ted Ralphs, Lehigh University * 00016 * Laszlo Ladanyi, IBM T.J. Watson Research Center * 00017 * Matthew Saltzman, Clemson University * 00018 * * 00019 * * 00020 * Corporation, Lehigh University, Yan Xu, Ted Ralphs, Matthew Salzman and * 00021 * others. All Rights Reserved. * 00022 *===========================================================================*/ 00023 00024 00025 //############################################################################# 00026 // This file is modified from COIN/Cbc/CbcHeuristic.hpp 00027 //############################################################################# 00028 00029 00030 #ifndef BlisHeuristic_h_ 00031 #define BlisHeuristic_h_ 00032 00033 #include <string> 00034 #include <vector> 00035 00036 #include "CoinPackedMatrix.hpp" 00037 #include "OsiCuts.hpp" 00038 00039 class BlisModel; 00040 00041 00042 //############################################################################# 00043 00044 00046 class BlisHeuristic { 00047 00048 private: 00049 00051 BlisHeuristic & operator = (const BlisHeuristic& rhs); 00052 00053 protected: 00054 00056 BlisModel *model_; 00057 00059 char *name_; 00060 00067 int strategy_; 00068 00070 int numSolutions_; 00071 00073 double time_; 00074 00076 int calls_; 00077 00078 public: 00079 00081 BlisHeuristic() { 00082 model_ = NULL; 00083 name_ = strdup("Unknown"); 00084 strategy_ = 0; 00085 numSolutions_ = 0; 00086 time_ = 0.0; 00087 calls_ = 0; 00088 } 00089 00091 BlisHeuristic(BlisModel *model, const char *name, int strategy) { 00092 model_ = model; 00093 if (name) { 00094 name_ = strdup(name); 00095 } 00096 else { 00097 name_ = strdup("Unknown"); 00098 } 00099 strategy_ = strategy; 00100 numSolutions_ = 0; 00101 time_ = 0.0; 00102 calls_ = 0; 00103 } 00104 00106 virtual ~BlisHeuristic() { if (name_) free(name_); } 00107 00109 BlisHeuristic(const BlisHeuristic & rhs) { 00110 model_ = rhs.model_; 00111 name_ = strdup(rhs.name_); 00112 strategy_ = rhs.strategy_; // What if disabled? 00113 numSolutions_ = 0; 00114 time_ = 0.0; 00115 calls_ = 0; 00116 } 00117 00119 virtual void setModel(BlisModel * model) { model_ = model ;} 00120 00123 virtual void setStrategy(int strategy) { strategy_ = strategy; } 00124 virtual int strategy() { return strategy_; } 00125 //@] 00126 00128 virtual BlisHeuristic * clone() const = 0; 00129 00135 virtual bool searchSolution(double & objectiveValue, 00136 double * newSolution)=0; 00137 00146 virtual int searchSolution(double & objectiveValue, 00147 double * newSolution, 00148 OsiCuts & cs) { return 0; } 00149 00151 int numSolutions() { return numSolutions_; } 00152 00154 inline double time() { return time_; } 00155 00157 inline int calls() { return calls_; } 00158 }; 00159 00160 #endif 00161