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