Cbc  2.10.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CbcHeuristicDive.hpp
Go to the documentation of this file.
1 /* $Id: CbcHeuristicDive.hpp 2467 2019-01-03 21:26:29Z unxusr $ */
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 
21 public:
22  // Default Constructor
24 
25  // Constructor with model - assumed before cuts
26  CbcHeuristicDive(CbcModel &model);
27 
28  // Copy constructor
30 
31  // Destructor
33 
35  virtual CbcHeuristicDive *clone() const = 0;
36 
39 
41  virtual void generateCpp(FILE *) {}
42 
44  void generateCpp(FILE *fp, const char *heuristic);
45 
47  virtual void resetModel(CbcModel *model);
48 
50  virtual void setModel(CbcModel *model);
51 
52  // REMLOVE using CbcHeuristic::solution ;
59  virtual int solution(double &objectiveValue,
60  double *newSolution);
62  int solution(double &objectiveValue, int &numberNodes,
63  int &numberCuts, OsiRowCut **cuts,
64  CbcSubProblem **&nodes,
65  double *newSolution);
71  int fathom(CbcModel *model, int &numberNodes, CbcSubProblem **&nodes);
72 
74  virtual void validate();
75 
77  void setPriorities();
78 
80  void selectBinaryVariables();
81 
83  void setPercentageToFix(double value)
84  {
85  percentageToFix_ = value;
86  }
87 
89  void setMaxIterations(int value)
90  {
91  maxIterations_ = value;
92  }
93 
95  void setMaxSimplexIterations(int value)
96  {
97  maxSimplexIterations_ = value;
98  }
100  inline int maxSimplexIterations() const
101  {
102  return maxSimplexIterations_;
103  }
104 
107  {
109  }
110 
112  void setMaxTime(double value)
113  {
114  maxTime_ = value;
115  }
116 
118  virtual bool canHeuristicRun();
119 
126  virtual bool selectVariableToBranch(OsiSolverInterface *solver,
127  const double *newSolution,
128  int &bestColumn,
129  int &bestRound)
130  = 0;
133  virtual void initializeData() {}
134 
136  int reducedCostFix(OsiSolverInterface *solver);
138  virtual int fixOtherVariables(OsiSolverInterface *solver,
139  const double *solution,
140  PseudoReducedCost *candidate,
141  const double *random);
142 
143 protected:
144  // Data
145 
146  // Original matrix by column
148 
149  // Original matrix by
151 
152  // Down locks
153  unsigned short *downLocks_;
154 
155  // Up locks
156  unsigned short *upLocks_;
157 
159  double *downArray_;
160 
162  double *upArray_;
163 
165  typedef struct {
166  unsigned int direction : 3; // 0 bit off, 1 bit (0 down first, 1 up first) 2 bit non zero don't try other way
167  unsigned int priority : 29;
168  } PriorityType;
170  // Indexes of binary variables with 0 objective coefficient
171  // and in variable bound constraints
172  std::vector< int > binVarIndex_;
173 
174  // Indexes of variable bound rows for each binary variable
175  std::vector< int > vbRowIndex_;
176 
177  // Percentage of integer variables to fix at bounds
179 
180  // Maximum time allowed
181  double maxTime_;
182 
183  // Small objective (i.e. treat zero objective as this)
185 
186  // Maximum number of major iterations
188 
189  // Maximum number of simplex iterations
191 
192  // Maximum number of simplex iterations at root node
194 };
195 #endif
196 
197 /* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
198 */
void setMaxIterations(int value)
Set maximum number of iterations.
void selectBinaryVariables()
Select candidate binary variables for fixing.
PriorityType * priority_
std::vector< int > vbRowIndex_
CoinPackedMatrix matrixByRow_
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.
Abstract Base Class for describing an interface to a solver.
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.
Row Cut Class.
Definition: OsiRowCut.hpp:29
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.
Sparse Matrix Base Class.
void setPriorities()
Sets priorities if any.
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)