CbcHeuristicDive.hpp
Go to the documentation of this file.
1 /* $Id: CbcHeuristicDive.hpp 1252 2009-10-20 09:22:24Z stefan $ */
2 // Copyright (C) 2008, International Business Machines
3 // Corporation and others. All Rights Reserved.
4 #ifndef CbcHeuristicDive_H
5 #define CbcHeuristicDive_H
6 
7 #include "CbcHeuristic.hpp"
8 struct PseudoReducedCost {
9  int var;
10  double pseudoRedCost;
11 };
12 
13 
17 class CbcHeuristicDive : public CbcHeuristic {
18 public:
19 
20  // Default Constructor
22 
23  // Constructor with model - assumed before cuts
24  CbcHeuristicDive (CbcModel & model);
25 
26  // Copy constructor
28 
29  // Destructor
31 
33  virtual CbcHeuristicDive * clone() const = 0;
34 
37 
39  virtual void generateCpp( FILE * ) {}
40 
42  void generateCpp( FILE * fp, const char * heuristic);
43 
45  virtual void resetModel(CbcModel * model);
46 
48  virtual void setModel(CbcModel * model);
49 
50  // REMLOVE using CbcHeuristic::solution ;
57  virtual int solution(double & objectiveValue,
58  double * newSolution);
59 
61  virtual void validate();
62 
64  void selectBinaryVariables();
65 
67  void setPercentageToFix(double value) {
68  percentageToFix_ = value;
69  }
70 
72  void setMaxIterations(int value) {
73  maxIterations_ = value;
74  }
75 
77  void setMaxSimplexIterations(int value) {
78  maxSimplexIterations_ = value;
79  }
80 
84  }
85 
87  void setMaxTime(double value) {
88  maxTime_ = value;
89  }
90 
92  virtual bool canHeuristicRun();
93 
100  virtual bool selectVariableToBranch(OsiSolverInterface* solver,
101  const double* newSolution,
102  int& bestColumn,
103  int& bestRound) = 0;
106  virtual void initializeData() {}
107 
109  int reducedCostFix (OsiSolverInterface* solver);
111  virtual int fixOtherVariables(OsiSolverInterface * solver,
112  const double * solution,
113  PseudoReducedCost * candidate,
114  const double * random);
115 
116 protected:
117  // Data
118 
119  // Original matrix by column
120  CoinPackedMatrix matrix_;
121 
122  // Original matrix by
123  CoinPackedMatrix matrixByRow_;
124 
125  // Down locks
126  unsigned short * downLocks_;
127 
128  // Up locks
129  unsigned short * upLocks_;
130 
132  double * downArray_;
133 
135  double * upArray_;
136 
137  // Indexes of binary variables with 0 objective coefficient
138  // and in variable bound constraints
139  std::vector<int> binVarIndex_;
140 
141  // Indexes of variable bound rows for each binary variable
142  std::vector<int> vbRowIndex_;
143 
144  // Percentage of integer variables to fix at bounds
145  double percentageToFix_;
146 
147  // Maximum number of major iterations
148  int maxIterations_;
149 
150  // Maximum number of simplex iterations
152 
153  // Maximum number of simplex iterations at root node
155 
156  // Maximum time allowed
157  double maxTime_;
158 
159 };
160 #endif
161 
CoinPackedMatrix matrixByRow_
virtual void setModel(CbcModel *model)
update model (This is needed if cliques update matrix etc)
virtual CbcHeuristicDive * clone() const =0
Clone.
unsigned short * downLocks_
void setMaxTime(double value)
Set maximum time allowed.
double * upArray_
Extra up array (number Integers long)
virtual bool canHeuristicRun()
Tests if the heuristic can run.
virtual void resetModel(CbcModel *model)
Resets stuff if model changes.
virtual void generateCpp(FILE *)
Create C++ lines to get to current state.
void setMaxSimplexIterationsAtRoot(int value)
Set maximum number of simplex iterations at root node.
CbcHeuristicDive & operator=(const CbcHeuristicDive &rhs)
Assignment operator.
void setMaxSimplexIterations(int value)
Set maximum number of simplex iterations.
virtual int solution(double &objectiveValue, double *newSolution)
returns 0 if no solution, 1 if valid solution with better objective value than one passed in Sets sol...
virtual void initializeData()
Initializes any data which is going to be used repeatedly in selectVariableToBranch.
std::vector< int > vbRowIndex_
void selectBinaryVariables()
Select candidate binary variables for fixing.
virtual bool selectVariableToBranch(OsiSolverInterface *solver, const double *newSolution, int &bestColumn, int &bestRound)=0
Selects the next variable to branch on Returns true if all the fractional variables can be trivially ...
int reducedCostFix(OsiSolverInterface *solver)
Perform reduced cost fixing on integer variables.
virtual int fixOtherVariables(OsiSolverInterface *solver, const double *solution, PseudoReducedCost *candidate, const double *random)
Fix other variables at bounds.
Heuristic base class.
void setPercentageToFix(double value)
Set percentage of integer variables to fix at bounds.
double * downArray_
Extra down array (number Integers long)
void setMaxIterations(int value)
Set maximum number of iterations.
unsigned short * upLocks_
std::vector< int > binVarIndex_
CoinPackedMatrix matrix_
virtual void validate()
Validate model i.e. sets when_ to 0 if necessary (may be NULL)
Simple Branch and bound class.
Definition: CbcModel.hpp:98