Cbc trunk
|
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 // This code is licensed under the terms of the Eclipse Public License (EPL). 00005 00006 #ifndef CbcHeuristicDive_H 00007 #define CbcHeuristicDive_H 00008 00009 #include "CbcHeuristic.hpp" 00010 struct PseudoReducedCost { 00011 int var; 00012 double pseudoRedCost; 00013 }; 00014 00015 00019 class CbcHeuristicDive : public CbcHeuristic { 00020 public: 00021 00022 // Default Constructor 00023 CbcHeuristicDive (); 00024 00025 // Constructor with model - assumed before cuts 00026 CbcHeuristicDive (CbcModel & model); 00027 00028 // Copy constructor 00029 CbcHeuristicDive ( const CbcHeuristicDive &); 00030 00031 // Destructor 00032 ~CbcHeuristicDive (); 00033 00035 virtual CbcHeuristicDive * clone() const = 0; 00036 00038 CbcHeuristicDive & operator=(const CbcHeuristicDive& rhs); 00039 00041 virtual void generateCpp( FILE * ) {} 00042 00044 void generateCpp( FILE * fp, const char * heuristic); 00045 00047 virtual void resetModel(CbcModel * model); 00048 00050 virtual void setModel(CbcModel * model); 00051 00052 // REMLOVE using CbcHeuristic::solution ; 00059 virtual int solution(double & objectiveValue, 00060 double * newSolution); 00061 00063 virtual void validate(); 00064 00066 void selectBinaryVariables(); 00067 00069 void setPercentageToFix(double value) { 00070 percentageToFix_ = value; 00071 } 00072 00074 void setMaxIterations(int value) { 00075 maxIterations_ = value; 00076 } 00077 00079 void setMaxSimplexIterations(int value) { 00080 maxSimplexIterations_ = value; 00081 } 00082 00084 void setMaxSimplexIterationsAtRoot(int value) { 00085 maxSimplexIterationsAtRoot_ = value; 00086 } 00087 00089 void setMaxTime(double value) { 00090 maxTime_ = value; 00091 } 00092 00094 virtual bool canHeuristicRun(); 00095 00102 virtual bool selectVariableToBranch(OsiSolverInterface* solver, 00103 const double* newSolution, 00104 int& bestColumn, 00105 int& bestRound) = 0; 00108 virtual void initializeData() {} 00109 00111 int reducedCostFix (OsiSolverInterface* solver); 00113 virtual int fixOtherVariables(OsiSolverInterface * solver, 00114 const double * solution, 00115 PseudoReducedCost * candidate, 00116 const double * random); 00117 00118 protected: 00119 // Data 00120 00121 // Original matrix by column 00122 CoinPackedMatrix matrix_; 00123 00124 // Original matrix by 00125 CoinPackedMatrix matrixByRow_; 00126 00127 // Down locks 00128 unsigned short * downLocks_; 00129 00130 // Up locks 00131 unsigned short * upLocks_; 00132 00134 double * downArray_; 00135 00137 double * upArray_; 00138 00139 // Indexes of binary variables with 0 objective coefficient 00140 // and in variable bound constraints 00141 std::vector<int> binVarIndex_; 00142 00143 // Indexes of variable bound rows for each binary variable 00144 std::vector<int> vbRowIndex_; 00145 00146 // Percentage of integer variables to fix at bounds 00147 double percentageToFix_; 00148 00149 // Maximum number of major iterations 00150 int maxIterations_; 00151 00152 // Maximum number of simplex iterations 00153 int maxSimplexIterations_; 00154 00155 // Maximum number of simplex iterations at root node 00156 int maxSimplexIterationsAtRoot_; 00157 00158 // Maximum time allowed 00159 double maxTime_; 00160 00161 }; 00162 #endif 00163