Go to the documentation of this file.
11 #include "CoinPackedMatrix.hpp"
12 #include "OsiCuts.hpp"
13 #include "CoinHelperFunctions.hpp"
14 #include "OsiBranchingObject.hpp"
17 class OsiSolverInterface;
21 #include "OsiClpSolverInterface.hpp"
53 const double threshold)
const;
63 std::vector< CbcHeuristicNode * >
nodes_;
79 return static_cast< int >(
nodes_.size());
120 virtual int solution(
double &objectiveValue,
195 bool exitNow(
double bestObjective)
const;
243 double *newSolution,
double &newSolutionValue,
244 double cutoff, std::string name)
const;
347 const OsiClpSolverInterface *clpSolver
348 =
dynamic_cast< const OsiClpSolverInterface *
>(solver);
350 return clpSolver->isHeuristicInteger(iColumn);
352 return solver->isInteger(iColumn);
357 return solver->isInteger(iColumn);
368 OsiSolverInterface *
cloneBut(
int type);
454 double *lowerBoundLastNode_;
457 double *upperBoundLastNode_;
497 virtual int solution(
double &objectiveValue,
498 double *newSolution);
505 virtual int solution(
double &objectiveValue,
507 double solutionValue);
590 virtual int solution(
double &objectiveValue,
591 double *newSolution);
652 virtual int solution(
double &objectiveValue,
653 double *newSolution);
692 virtual int solution(
double &objectiveValue,
693 double *newSolution);
const char * heuristicName() const
return name of heuristic
virtual CbcHeuristic * clone() const
Clone.
virtual void generateCpp(FILE *fp)
Create C++ lines to get to current state.
std::vector< CbcHeuristicNode * > nodes_
virtual bool shouldHeurRun(int whereFrom)
Check whether the heuristic should run at all 0 - before cuts at root node (or from doHeuristics) 1 -...
virtual void setModel(CbcModel *model)
update model (This is needed if cliques update matrix etc)
void append(CbcHeuristicNode *&node)
int numInvocationsInShallow_
How many invocations happened within the same node when in a shallow part of the tree.
void setSeed(int value)
Set random number generator seed.
virtual void validate()
Validate model i.e. sets when_ to 0 if necessary (may be NULL)
CbcHeuristicPartial & operator=(const CbcHeuristicPartial &rhs)
Assignment operator.
virtual void setModel(CbcModel *model)
update model
int numObjects_
The number of branching decisions made.
void setWhereFrom(int value)
int switches() const
Switches (does not apply equally to all heuristics) 1 bit - stop once allowable gap on objective reac...
CbcHeuristicNodeList runNodes_
The description of the nodes where this heuristic has been applied.
int moreSpecialOptions2() const
Get more special options2.
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...
void setDecayFactor(double value)
Sets decay factor (for howOften) on failure.
virtual bool canDealWithOdd() const
Returns true if can deal with "odd" problems e.g. sos type 2.
void setModelOnly(CbcModel *model)
Just set model - do not do anything else.
void setNumberNodes(int value)
Sets number of nodes in subtree (default 200)
virtual bool selectVariableToBranch(OsiSolverInterface *, const double *, int &, int &)
Selects the next variable to branch on.
void setSeed(int value)
Set seed.
void setShallowDepth(int value)
Upto this depth we call the tree shallow and the heuristic can be called multiple times.
CbcHeuristicNodeList & operator=(const CbcHeuristicNodeList &rhs)
int minDistanceToRun_
How "far" should this node be from every other where the heuristic was run in order to allow the heur...
const CbcHeuristicNode * node(int i) const
int smallBranchAndBound(OsiSolverInterface *solver, int numberNodes, double *newSolution, double &newSolutionValue, double cutoff, std::string name) const
Do mini branch and bound - return 0 not finished - no solution 1 not finished - solution 2 finished -...
int numberSolutionsFound_
How many solutions the heuristic thought it got.
int numberSolutionsFound() const
Get how many solutions the heuristic thought it got.
int howOftenShallow_
How often to invoke the heuristics in the shallow part of the tree.
void gutsOfCopy(const CbcHeuristic &rhs)
OsiSolverInterface * cloneBut(int type)
Clone, but ...
virtual CbcHeuristic * clone() const
Clone.
void setFeasibilityPumpOptions(int value)
Sets feasibility pump options (-1 is off)
int feasibilityPumpOptions_
Feasibility pump options , -1 is off >=0 for feasibility pump itself -2 quick proximity search -3 lon...
virtual void resetModel(CbcModel *model)
Resets stuff if model changes.
heuristic - just picks up any good solution found by solver - see OsiBabSolver
int numCouldRun() const
How many times the heuristic could run.
virtual CbcHeuristic * clone() const =0
Clone.
CbcHeuristicJustOne & operator=(const CbcHeuristicJustOne &rhs)
Assignment operator.
Simple Branch and bound class.
void addHeuristic(const CbcHeuristic *heuristic, double probability)
Adds an heuristic with probability.
double trueObjValue(double value) const
Return objective function value with sign corrected.
void normalizeProbabilities()
Normalize probabilities.
CbcHeuristic ** heuristic_
virtual CbcHeuristicJustOne * clone() const
Clone.
int numberNodesDone_
How many nodes the heuristic did this go.
int lastRunDeep_
After how many deep invocations was the heuristic run last time.
bool isHeuristicInteger(const OsiSolverInterface *solver, int iColumn)
Is it integer for heuristics?
virtual void validate()
Validate model i.e. sets when_ to 0 if necessary (may be NULL)
void setFixPriority(int value)
Set priority level.
void incrementNumberSolutionsFound()
Increment how many solutions the heuristic thought it got.
void setSwitches(int value)
Switches (does not apply equally to all heuristics) 1 bit - stop once allowable gap on objective reac...
Abstract branching object base class Now just difference with OsiBranchingObject.
int switches_
Switches (does not apply equally to all heuristics) 1 bit - stop once allowable gap on objective reac...
virtual int solution(double &objectiveValue, double *newSolution)
returns 0 if no solution, 1 if valid solution.
CbcRounding & operator=(const CbcRounding &rhs)
Assignment operator.
void setHowOftenShallow(int value)
How often to invoke the heuristics in the shallow part of the tree.
void setInputSolution(const double *solution, double objValue)
Set input solution.
CbcSerendipity & operator=(const CbcSerendipity &rhs)
Assignment operator.
virtual bool shouldHeurRun(int whereFrom)
Check whether the heuristic should run at all 0 - before cuts at root node (or from doHeuristics) 1 -...
double decayFactor_
How much to increase how often.
virtual void generateCpp(FILE *fp)
Create C++ lines to get to current state.
int numberNodes_
Number of nodes in any sub tree.
double fractionSmall_
Fraction of new(rows+columns)/old(rows+columns) before doing small branch and bound.
CbcHeuristicNode & operator=(const CbcHeuristicNode &)
void setMinDistanceToRun(int value)
How "far" should this node be from every other where the heuristic was run in order to allow the heur...
virtual bool shouldHeurRun(int whereFrom)
Check whether the heuristic should run at all.
std::string heuristicName_
Name for printing.
virtual void setModel(CbcModel *model)
update model (This is needed if cliques update matrix etc)
virtual CbcHeuristic * clone() const
Clone.
void setWhen(int value)
Sets "when" flag - 0 off, 1 at root, 2 other than root, 3 always.
int numRuns_
how many times the heuristic has actually run
int numberNodes() const
Gets number of nodes in a subtree (default 200)
virtual void generateCpp(FILE *fp)
Create C++ lines to get to current state.
int numRuns() const
how many times the heuristic has actually run
void gutsOfCopy(const CbcHeuristicNodeList &rhs)
bool shouldHeurRun_randomChoice()
Check whether the heuristic should run this time.
virtual int solution(double &objectiveValue, double *newSolution)=0
returns 0 if no solution, 1 if valid solution with better objective value than one passed in Sets sol...
CoinPackedMatrix matrixByRow_
Partial solution class If user knows a partial solution this tries to get an integer solution it uses...
void setHeuristicName(const char *name)
set name of heuristic
int howOften_
How often to do (code can change)
virtual void setModel(CbcModel *model)
update model (This is needed if cliques update matrix etc)
virtual int solution2(double &, double *, OsiCuts &)
returns 0 if no solution, 1 if valid solution, -1 if just returning an estimate of best possible solu...
int feasibilityPumpOptions() const
Gets feasibility pump options (-1 is off)
int getSeed() const
Get random number generator seed.
int numCouldRun_
How many times the heuristic could run.
double avgDistance(const CbcHeuristicNodeList &nodeList) const
int numInvocationsInDeep_
How many invocations happened when in the deep part of the tree.
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...
virtual void validate()
Validate model i.e. sets when_ to 0 if necessary (may be NULL)
bool minDistanceIsSmall(const CbcHeuristicNodeList &nodeList, const double threshold) const
int when_
When flag - 0 off, 1 at root, 2 other than root, 3 always.
virtual void resetModel(CbcModel *model)
Resets stuff if model changes.
A class describing the branching decisions that were made to get to the node where a heuristic was in...
int shallowDepth_
Upto this depth we call the tree shallow and the heuristic can be called multiple times.
double distance(const CbcHeuristicNode *node) const
void setFractionSmall(double value)
Sets fraction of new(rows+columns)/old(rows+columns) before doing small branch and bound (default 1....
double minDistance(const CbcHeuristicNodeList &nodeList) const
int when() const
Gets "when" flag - 0 off, 1 at root, 2 other than root, 3 always.
virtual void resetModel(CbcModel *model)=0
Resets stuff if model changes.
void gutsOfConstructor(CbcModel &model)
virtual void generateCpp(FILE *fp)
Create C++ lines to get to current state.
CbcBranchingObject ** brObj_
The indices of the branching objects.
CbcHeuristic & operator=(const CbcHeuristic &rhs)
Assignment operator.
virtual void generateCpp(FILE *)
Create C++ lines to get to current state.
virtual void setModel(CbcModel *model)
update model (This is needed if cliques update matrix etc)
bool exitNow(double bestObjective) const
Whether to exit at once on gap.
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...
Just One class - this chooses one at random.
CoinThreadRandom randomNumberGenerator_
Thread specific random number generator.
virtual void validate()
Validate model i.e. sets when_ to 0 if necessary (may be NULL)
void printDistanceToNodes()
virtual void resetModel(CbcModel *model)
Resets stuff if model changes.
virtual void resetModel(CbcModel *model)
Resets stuff if model changes.
double fractionSmall() const
Gets fraction of new(rows+columns)/old(rows+columns) before doing small branch and bound (default 1....