Cbc  2.8.12
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CbcHeuristicDive.hpp
Go to the documentation of this file.
1 /* $Id: CbcHeuristicDive.hpp 1902 2013-04-10 16:58:16Z stefan $ */
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 selectBinaryVariables();
80 
82  void setPercentageToFix(double value) {
83  percentageToFix_ = value;
84  }
85 
87  void setMaxIterations(int value) {
88  maxIterations_ = value;
89  }
90 
92  void setMaxSimplexIterations(int value) {
93  maxSimplexIterations_ = value;
94  }
96  inline int maxSimplexIterations() const {
97  return maxSimplexIterations_;
98  }
99 
103  }
104 
106  void setMaxTime(double value) {
107  maxTime_ = value;
108  }
109 
111  virtual bool canHeuristicRun();
112 
119  virtual bool selectVariableToBranch(OsiSolverInterface* solver,
120  const double* newSolution,
121  int& bestColumn,
122  int& bestRound) = 0;
125  virtual void initializeData() {}
126 
128  int reducedCostFix (OsiSolverInterface* solver);
130  virtual int fixOtherVariables(OsiSolverInterface * solver,
131  const double * solution,
132  PseudoReducedCost * candidate,
133  const double * random);
134 
135 protected:
136  // Data
137 
138  // Original matrix by column
139  CoinPackedMatrix matrix_;
140 
141  // Original matrix by
142  CoinPackedMatrix matrixByRow_;
143 
144  // Down locks
145  unsigned short * downLocks_;
146 
147  // Up locks
148  unsigned short * upLocks_;
149 
151  double * downArray_;
152 
154  double * upArray_;
155 
156  // Indexes of binary variables with 0 objective coefficient
157  // and in variable bound constraints
158  std::vector<int> binVarIndex_;
159 
160  // Indexes of variable bound rows for each binary variable
161  std::vector<int> vbRowIndex_;
162 
163  // Percentage of integer variables to fix at bounds
165 
166  // Maximum number of major iterations
168 
169  // Maximum number of simplex iterations
171 
172  // Maximum number of simplex iterations at root node
174 
175  // Maximum time allowed
176  double maxTime_;
177 
178 };
179 #endif
180 
void setMaxIterations(int value)
Set maximum number of iterations.
void selectBinaryVariables()
Select candidate binary variables for fixing.
CoinPackedMatrix matrixByRow_
std::vector< int > vbRowIndex_
CoinPackedMatrix matrix_
std::vector< int > binVarIndex_
virtual void setModel(CbcModel *model)
update model (This is needed if cliques update matrix etc)
virtual CbcHeuristicDive * clone() const =0
Clone.
void setPercentageToFix(double value)
Set percentage of integer variables to fix at bounds.
unsigned short * upLocks_
virtual bool canHeuristicRun()
Tests if the heuristic can run.
virtual void initializeData()
Initializes any data which is going to be used repeatedly in selectVariableToBranch.
int numberNodes() const
Gets number of nodes in a subtree (default 200)
void setMaxSimplexIterationsAtRoot(int value)
Set maximum number of simplex iterations at root node.
virtual int fixOtherVariables(OsiSolverInterface *solver, const double *solution, PseudoReducedCost *candidate, const double *random)
Fix other variables at bounds.
virtual void generateCpp(FILE *)
Create C++ lines to get to current state.
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...
Heuristic base class.
void setMaxSimplexIterations(int value)
Set maximum number of simplex iterations.
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.
CbcHeuristicDive & operator=(const CbcHeuristicDive &rhs)
Assignment operator.
virtual void resetModel(CbcModel *model)
Resets stuff if model changes.
unsigned short * downLocks_
Simple Branch and bound class.
Definition: CbcModel.hpp:100
double * downArray_
Extra down array (number Integers long)
virtual void validate()
Validate model i.e. sets when_ to 0 if necessary (may be NULL)
void setMaxTime(double value)
Set maximum time allowed.
int maxSimplexIterations() const
Get maximum number of simplex iterations.
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 ret...
double * upArray_
Extra up array (number Integers long)