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 virtual void selectVariableToBranch(OsiSolverInterface* solver, 00077 const double* newSolution, 00078 int& bestColumn, 00079 int& bestRound) = 0; 00080 00081 protected: 00082 // Data 00083 00084 // Original matrix by column 00085 CoinPackedMatrix matrix_; 00086 00087 // Original matrix by 00088 CoinPackedMatrix matrixByRow_; 00089 00090 // Down locks 00091 unsigned short * downLocks_; 00092 00093 // Up locks 00094 unsigned short * upLocks_; 00095 00096 // Indexes of binary variables with 0 objective coefficient 00097 // and in variable bound constraints 00098 std::vector<int> binVarIndex_; 00099 00100 // Indexes of variable bound rows for each binary variable 00101 std::vector<int> vbRowIndex_; 00102 00103 // Percentage of integer variables to fix at bounds 00104 double percentageToFix_; 00105 00106 // Maximum number of iterations 00107 int maxIterations_; 00108 00109 // Maximum time allowed 00110 double maxTime_; 00111 00112 }; 00113 00114 #endif