00001 /* $Id: CbcHeuristicDive.hpp 1252 2009-10-20 09:22:24Z stefan $ */ 00002 // Copyright (C) 2008, International Business Machines 00003 // Corporation and others. All Rights Reserved. 00004 #ifndef CbcHeuristicDive_H 00005 #define CbcHeuristicDive_H 00006 00007 #include "CbcHeuristic.hpp" 00008 struct PseudoReducedCost { 00009 int var; 00010 double pseudoRedCost; 00011 }; 00012 00013 00017 class CbcHeuristicDive : public CbcHeuristic { 00018 public: 00019 00020 // Default Constructor 00021 CbcHeuristicDive (); 00022 00023 // Constructor with model - assumed before cuts 00024 CbcHeuristicDive (CbcModel & model); 00025 00026 // Copy constructor 00027 CbcHeuristicDive ( const CbcHeuristicDive &); 00028 00029 // Destructor 00030 ~CbcHeuristicDive (); 00031 00033 virtual CbcHeuristicDive * clone() const = 0; 00034 00036 CbcHeuristicDive & operator=(const CbcHeuristicDive& rhs); 00037 00039 virtual void generateCpp( FILE * ) {} 00040 00042 void generateCpp( FILE * fp, const char * heuristic); 00043 00045 virtual void resetModel(CbcModel * model); 00046 00048 virtual void setModel(CbcModel * model); 00049 00050 // REMLOVE using CbcHeuristic::solution ; 00057 virtual int solution(double & objectiveValue, 00058 double * newSolution); 00059 00061 virtual void validate(); 00062 00064 void selectBinaryVariables(); 00065 00067 void setPercentageToFix(double value) { 00068 percentageToFix_ = value; 00069 } 00070 00072 void setMaxIterations(int value) { 00073 maxIterations_ = value; 00074 } 00075 00077 void setMaxSimplexIterations(int value) { 00078 maxSimplexIterations_ = value; 00079 } 00080 00082 void setMaxSimplexIterationsAtRoot(int value) { 00083 maxSimplexIterationsAtRoot_ = value; 00084 } 00085 00087 void setMaxTime(double value) { 00088 maxTime_ = value; 00089 } 00090 00092 virtual bool canHeuristicRun(); 00093 00100 virtual bool selectVariableToBranch(OsiSolverInterface* solver, 00101 const double* newSolution, 00102 int& bestColumn, 00103 int& bestRound) = 0; 00106 virtual void initializeData() {} 00107 00109 int reducedCostFix (OsiSolverInterface* solver); 00111 virtual int fixOtherVariables(OsiSolverInterface * solver, 00112 const double * solution, 00113 PseudoReducedCost * candidate, 00114 const double * random); 00115 00116 protected: 00117 // Data 00118 00119 // Original matrix by column 00120 CoinPackedMatrix matrix_; 00121 00122 // Original matrix by 00123 CoinPackedMatrix matrixByRow_; 00124 00125 // Down locks 00126 unsigned short * downLocks_; 00127 00128 // Up locks 00129 unsigned short * upLocks_; 00130 00132 double * downArray_; 00133 00135 double * upArray_; 00136 00137 // Indexes of binary variables with 0 objective coefficient 00138 // and in variable bound constraints 00139 std::vector<int> binVarIndex_; 00140 00141 // Indexes of variable bound rows for each binary variable 00142 std::vector<int> vbRowIndex_; 00143 00144 // Percentage of integer variables to fix at bounds 00145 double percentageToFix_; 00146 00147 // Maximum number of major iterations 00148 int maxIterations_; 00149 00150 // Maximum number of simplex iterations 00151 int maxSimplexIterations_; 00152 00153 // Maximum number of simplex iterations at root node 00154 int maxSimplexIterationsAtRoot_; 00155 00156 // Maximum time allowed 00157 double maxTime_; 00158 00159 }; 00160 #endif 00161