00001 // Copyright (C) 2008, International Business Machines 00002 // Corporation and others. All Rights Reserved. 00003 #ifndef CbcHeuristicDive_H 00004 #define CbcHeuristicDive_H 00005 00006 #include "CbcHeuristic.hpp" 00007 00011 class CbcHeuristicDive : public CbcHeuristic { 00012 public: 00013 00014 // Default Constructor 00015 CbcHeuristicDive (); 00016 00017 // Constructor with model - assumed before cuts 00018 CbcHeuristicDive (CbcModel & model); 00019 00020 // Copy constructor 00021 CbcHeuristicDive ( const CbcHeuristicDive &); 00022 00023 // Destructor 00024 ~CbcHeuristicDive (); 00025 00027 virtual CbcHeuristicDive * clone() const = 0; 00028 00030 CbcHeuristicDive & operator=(const CbcHeuristicDive& rhs); 00031 00033 virtual void generateCpp( FILE * fp) {} 00034 00036 void generateCpp( FILE * fp,const char * heuristic); 00037 00039 virtual void resetModel(CbcModel * model); 00040 00042 virtual void setModel(CbcModel * model); 00043 00044 // REMLOVE using CbcHeuristic::solution ; 00051 virtual int solution(double & objectiveValue, 00052 double * newSolution); 00053 00055 virtual void validate(); 00056 00058 void selectBinaryVariables(); 00059 00061 void setPercentageToFix(double value) 00062 { percentageToFix_ = value; } 00063 00065 void setMaxIterations(int value) 00066 { maxIterations_ = value; } 00067 00069 void setMaxSimplexIterations(int value) 00070 { maxSimplexIterations_ = value; } 00071 00073 void setMaxSimplexIterationsAtRoot(int value) 00074 { maxSimplexIterationsAtRoot_ = value; } 00075 00077 void setMaxTime(double value) 00078 { maxTime_ = value; } 00079 00081 virtual bool canHeuristicRun(); 00082 00084 00089 virtual bool selectVariableToBranch(OsiSolverInterface* solver, 00090 const double* newSolution, 00091 int& bestColumn, 00092 int& bestRound) = 0; 00093 00095 int reducedCostFix (OsiSolverInterface* solver); 00096 00097 protected: 00098 // Data 00099 00100 // Original matrix by column 00101 CoinPackedMatrix matrix_; 00102 00103 // Original matrix by 00104 CoinPackedMatrix matrixByRow_; 00105 00106 // Down locks 00107 unsigned short * downLocks_; 00108 00109 // Up locks 00110 unsigned short * upLocks_; 00111 00112 // Indexes of binary variables with 0 objective coefficient 00113 // and in variable bound constraints 00114 std::vector<int> binVarIndex_; 00115 00116 // Indexes of variable bound rows for each binary variable 00117 std::vector<int> vbRowIndex_; 00118 00119 // Percentage of integer variables to fix at bounds 00120 double percentageToFix_; 00121 00122 // Maximum number of major iterations 00123 int maxIterations_; 00124 00125 // Maximum number of simplex iterations 00126 int maxSimplexIterations_; 00127 00128 // Maximum number of simplex iterations at root node 00129 int maxSimplexIterationsAtRoot_; 00130 00131 // Maximum time allowed 00132 double maxTime_; 00133 00134 }; 00135 #endif