Cbc  2.9.8
CbcHeuristicDive.hpp
Go to the documentation of this file.
1 /* $Id: CbcHeuristicDive.hpp 2093 2014-11-06 16:17:38Z forrest $ */
2 // Copyright (C) 2008, International Business Machines
3 // Corporation and others. All Rights Reserved.
4 // This code is licensed under the terms of the Eclipse Public License (EPL).
5 
6 #ifndef CbcHeuristicDive_H
7 #define CbcHeuristicDive_H
8 
9 #include "CbcHeuristic.hpp"
10 class CbcSubProblem;
11 class OsiRowCut;
13  int var;
14  double pseudoRedCost;
15 };
16 
17 
22 public:
23 
24  // Default Constructor
26 
27  // Constructor with model - assumed before cuts
28  CbcHeuristicDive (CbcModel & model);
29 
30  // Copy constructor
32 
33  // Destructor
34  ~CbcHeuristicDive ();
35 
37  virtual CbcHeuristicDive * clone() const = 0;
38 
40  CbcHeuristicDive & operator=(const CbcHeuristicDive& rhs);
41 
43  virtual void generateCpp( FILE * ) {}
44 
46  void generateCpp( FILE * fp, const char * heuristic);
47 
49  virtual void resetModel(CbcModel * model);
50 
52  virtual void setModel(CbcModel * model);
53 
54  // REMLOVE using CbcHeuristic::solution ;
61  virtual int solution(double & objectiveValue,
62  double * newSolution);
64  int solution(double & objectiveValue, int & numberNodes,
65  int & numberCuts, OsiRowCut ** cuts,
66  CbcSubProblem ** & nodes,
67  double * newSolution);
73  int fathom(CbcModel * model, int & numberNodes,CbcSubProblem ** & nodes);
74 
76  virtual void validate();
77 
79  void setPriorities();
80 
82  void selectBinaryVariables();
83 
85  void setPercentageToFix(double value) {
86  percentageToFix_ = value;
87  }
88 
90  void setMaxIterations(int value) {
91  maxIterations_ = value;
92  }
93 
95  void setMaxSimplexIterations(int value) {
96  maxSimplexIterations_ = value;
97  }
99  inline int maxSimplexIterations() const {
100  return maxSimplexIterations_;
101  }
102 
105  maxSimplexIterationsAtRoot_ = value;
106  }
107 
109  void setMaxTime(double value) {
110  maxTime_ = value;
111  }
112 
114  virtual bool canHeuristicRun();
115 
122  virtual bool selectVariableToBranch(OsiSolverInterface* solver,
123  const double* newSolution,
124  int& bestColumn,
125  int& bestRound) = 0;
128  virtual void initializeData() {}
129 
131  int reducedCostFix (OsiSolverInterface* solver);
133  virtual int fixOtherVariables(OsiSolverInterface * solver,
134  const double * solution,
135  PseudoReducedCost * candidate,
136  const double * random);
137 
138 protected:
139  // Data
140 
141  // Original matrix by column
142  CoinPackedMatrix matrix_;
143 
144  // Original matrix by
145  CoinPackedMatrix matrixByRow_;
146 
147  // Down locks
148  unsigned short * downLocks_;
149 
150  // Up locks
151  unsigned short * upLocks_;
152 
154  double * downArray_;
155 
157  double * upArray_;
158 
160  typedef struct {
161  unsigned int direction:3; // 0 bit off, 1 bit (0 down first, 1 up first) 2 bit non zero don't try other way
162  unsigned int priority:29;
163  } PriorityType;
165  // Indexes of binary variables with 0 objective coefficient
166  // and in variable bound constraints
167  std::vector<int> binVarIndex_;
168 
169  // Indexes of variable bound rows for each binary variable
170  std::vector<int> vbRowIndex_;
171 
172  // Percentage of integer variables to fix at bounds
174 
175  // Maximum time allowed
176  double maxTime_;
177 
178  // Small objective (i.e. treat zero objective as this)
180 
181  // Maximum number of major iterations
183 
184  // Maximum number of simplex iterations
186 
187  // Maximum number of simplex iterations at root node
189 
190 };
191 #endif
192 
void setMaxIterations(int value)
Set maximum number of iterations.
PriorityType * priority_
CoinPackedMatrix matrixByRow_
std::vector< int > vbRowIndex_
CoinPackedMatrix matrix_
std::vector< int > binVarIndex_
void setPercentageToFix(double value)
Set percentage of integer variables to fix at bounds.
unsigned short * upLocks_
virtual void initializeData()
Initializes any data which is going to be used repeatedly in selectVariableToBranch.
void setMaxSimplexIterationsAtRoot(int value)
Set maximum number of simplex iterations at root node.
virtual void generateCpp(FILE *)
Create C++ lines to get to current state.
Heuristic base class.
void setMaxSimplexIterations(int value)
Set maximum number of simplex iterations.
int maxSimplexIterations() const
Get maximum number of simplex iterations.
unsigned short * downLocks_
Simple Branch and bound class.
Definition: CbcModel.hpp:101
double * downArray_
Extra down array (number Integers long)
void setMaxTime(double value)
Set maximum time allowed.
double * upArray_
Extra up array (number Integers long)