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 setMaxTime(double value) 00070 { maxTime_ = value; } 00071 00073 virtual bool canHeuristicRun(); 00074 00076 00081 virtual bool selectVariableToBranch(OsiSolverInterface* solver, 00082 const double* newSolution, 00083 int& bestColumn, 00084 int& bestRound) = 0; 00085 00087 int reducedCostFix (OsiSolverInterface* solver); 00088 00089 protected: 00090 // Data 00091 00092 // Original matrix by column 00093 CoinPackedMatrix matrix_; 00094 00095 // Original matrix by 00096 CoinPackedMatrix matrixByRow_; 00097 00098 // Down locks 00099 unsigned short * downLocks_; 00100 00101 // Up locks 00102 unsigned short * upLocks_; 00103 00104 // Indexes of binary variables with 0 objective coefficient 00105 // and in variable bound constraints 00106 std::vector<int> binVarIndex_; 00107 00108 // Indexes of variable bound rows for each binary variable 00109 std::vector<int> vbRowIndex_; 00110 00111 // Percentage of integer variables to fix at bounds 00112 double percentageToFix_; 00113 00114 // Maximum number of major iterations 00115 int maxIterations_; 00116 00117 // Maximum number of simplex iterations 00118 int maxSimplexIterations_; 00119 00120 // Maximum time allowed 00121 double maxTime_; 00122 00123 }; 00124 #endif