Dip-All  0.91.0
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
35 
37  virtual CbcHeuristicDive * clone() const = 0;
38 
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 
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
143 
144  // Original matrix by
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 
CoinPackedMatrix matrixByRow_
virtual void setModel(CbcModel *model)
update model (This is needed if cliques update matrix etc)
virtual CbcHeuristicDive * clone() const =0
Clone.
Row Cut Class.
Definition: OsiRowCut.hpp:29
void setMaxTime(double value)
Set maximum time allowed.
std::vector< int > binVarIndex_
virtual bool canHeuristicRun()
Tests if the heuristic can run.
int maxSimplexIterations() const
Get maximum number of simplex iterations.
virtual void resetModel(CbcModel *model)
Resets stuff if model changes.
Sparse Matrix Base Class.
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.
unsigned short * upLocks_
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...
int numberNodes() const
Gets number of nodes in a subtree (default 200)
virtual void initializeData()
Initializes any data which is going to be used repeatedly in selectVariableToBranch.
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 ...
double * upArray_
Extra up array (number Integers long)
PriorityType * priority_
double * downArray_
Extra down array (number Integers long)
int fathom(CbcModel *model, int &numberNodes, CbcSubProblem **&nodes)
returns 0 if no solution, 1 if valid solution with better objective value than one passed in also re...
Abstract Base Class for describing an interface to a solver.
int reducedCostFix(OsiSolverInterface *solver)
Perform reduced cost fixing on integer variables.
#define random(x)
Definition: mcknap.h:41
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.
void setMaxIterations(int value)
Set maximum number of iterations.
unsigned short * downLocks_
std::vector< int > vbRowIndex_
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:101
void setPriorities()
Sets priorities if any.