Cbc 2.10.5
CbcHeuristicDive.hpp
Go to the documentation of this file.
1/* $Id$ */
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"
10class CbcSubProblem;
11class OsiRowCut;
13 int var;
15};
16
21public:
22 // Default Constructor
24
25 // Constructor with model - assumed before cuts
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
78
81
83 void setPercentageToFix(double value)
84 {
85 percentageToFix_ = value;
86 }
87
89 void setMaxIterations(int value)
90 {
91 maxIterations_ = value;
92 }
93
96 {
98 }
100 inline int maxSimplexIterations() const
101 {
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
143protected:
144 // Data
145
146 // Original matrix by column
147 CoinPackedMatrix matrix_;
148
149 // Original matrix by
150 CoinPackedMatrix matrixByRow_;
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 setPriorities()
Sets priorities if any.
virtual void resetModel(CbcModel *model)
Resets stuff if model changes.
int reducedCostFix(OsiSolverInterface *solver)
Perform reduced cost fixing on integer variables.
std::vector< int > binVarIndex_
void setPercentageToFix(double value)
Set percentage of integer variables to fix at bounds.
int solution(double &objectiveValue, int &numberNodes, int &numberCuts, OsiRowCut **cuts, CbcSubProblem **&nodes, double *newSolution)
inner part of dive
void setMaxIterations(int value)
Set maximum number of iterations.
CoinPackedMatrix matrix_
void selectBinaryVariables()
Select candidate binary variables for fixing.
unsigned short * downLocks_
std::vector< int > vbRowIndex_
virtual void setModel(CbcModel *model)
update model (This is needed if cliques update matrix etc)
CbcHeuristicDive(CbcModel &model)
virtual CbcHeuristicDive * clone() const =0
Clone.
double * downArray_
Extra down array (number Integers long)
int maxSimplexIterations() const
Get maximum number of simplex iterations.
void setMaxSimplexIterations(int value)
Set maximum number of simplex iterations.
virtual void validate()
Validate model i.e. sets when_ to 0 if necessary (may be NULL)
CbcHeuristicDive(const CbcHeuristicDive &)
unsigned short * upLocks_
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...
CbcHeuristicDive & operator=(const CbcHeuristicDive &rhs)
Assignment operator.
void generateCpp(FILE *fp, const char *heuristic)
Create C++ lines to get to current state - does work for base class.
void setMaxTime(double value)
Set maximum time allowed.
PriorityType * priority_
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.
virtual void initializeData()
Initializes any data which is going to be used repeatedly in selectVariableToBranch.
CoinPackedMatrix matrixByRow_
virtual bool canHeuristicRun()
Tests if the heuristic can run.
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...
double * upArray_
Extra up array (number Integers long)
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 ...
virtual int fixOtherVariables(OsiSolverInterface *solver, const double *solution, PseudoReducedCost *candidate, const double *random)
Fix other variables at bounds.
Heuristic base class.
int numberNodes() const
Gets number of nodes in a subtree (default 200)
Simple Branch and bound class.
Definition: CbcModel.hpp:100