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