11 #include "CoinPackedMatrix.hpp" 12 #include "OsiCuts.hpp" 13 #include "CoinHelperFunctions.hpp" 14 #include "OsiBranchingObject.hpp" 16 class OsiSolverInterface;
30 void gutsOfConstructor(
CbcModel& model);
48 const double threshold)
const;
57 std::vector<CbcHeuristicNode*> nodes_;
70 return static_cast<int>(nodes_.size());
79 void gutsOfDelete() {}
101 virtual void setModel(
CbcModel * model);
104 virtual void resetModel(
CbcModel * model) = 0;
111 virtual int solution(
double & objectiveValue,
112 double * newSolution) = 0;
144 numberNodes_ = value;
178 bool exitNow(
double bestObjective)
const;
181 feasibilityPumpOptions_ = value;
185 return feasibilityPumpOptions_;
195 fractionSmall_ = value;
199 return fractionSmall_;
203 return numberSolutionsFound_;
207 numberSolutionsFound_++;
219 int smallBranchAndBound(OsiSolverInterface * solver,
int numberNodes,
220 double * newSolution,
double & newSolutionValue,
221 double cutoff , std::string name)
const;
225 void generateCpp( FILE * fp,
const char * heuristic) ;
232 return heuristicName_.c_str();
236 heuristicName_ = name;
239 void setSeed(
int value);
244 decayFactor_ = value;
247 void setInputSolution(
const double * solution,
double objValue);
269 shallowDepth_ = value;
273 howOftenShallow_ = value;
279 minDistanceToRun_ = value;
290 virtual bool shouldHeurRun(
int whereFrom);
292 bool shouldHeurRun_randomChoice();
294 void printDistanceToNodes();
312 OsiSolverInterface * cloneBut(
int type);
399 double * lowerBoundLastNode_;
402 double * upperBoundLastNode_;
429 virtual void generateCpp( FILE * fp) ;
432 virtual void resetModel(
CbcModel * model);
435 virtual void setModel(
CbcModel * model);
443 virtual int solution(
double & objectiveValue,
444 double * newSolution);
451 virtual int solution(
double & objectiveValue,
452 double * newSolution,
453 double solutionValue);
455 virtual void validate();
470 virtual bool shouldHeurRun(
int whereFrom);
523 virtual void generateCpp( FILE * fp) ;
526 virtual void resetModel(
CbcModel * model);
529 virtual void setModel(
CbcModel * model);
537 virtual int solution(
double & objectiveValue,
538 double * newSolution);
540 virtual void validate();
545 fixPriority_ = value;
549 virtual bool shouldHeurRun(
int whereFrom);
584 virtual void generateCpp( FILE * fp) ;
587 virtual void setModel(
CbcModel * model);
600 virtual int solution(
double & objectiveValue,
601 double * newSolution);
603 virtual void resetModel(
CbcModel * model);
633 virtual void generateCpp( FILE * fp) ;
641 virtual int solution(
double & objectiveValue,
642 double * newSolution);
644 virtual void resetModel(
CbcModel * model);
647 virtual void setModel(
CbcModel * model);
662 virtual void validate();
664 void addHeuristic(
const CbcHeuristic * heuristic,
double probability);
666 void normalizeProbabilities();
void incrementNumberSolutionsFound()
Increment how many solutions the heuristic thought it got.
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.
int numberNodesDone_
How many nodes the heuristic did this go.
double fractionSmall_
Fraction of new(rows+columns)/old(rows+columns) before doing small branch and bound.
CoinThreadRandom randomNumberGenerator_
Thread specific random number generator.
void setFixPriority(int value)
Set priority level.
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 bool canDealWithOdd() const
Returns true if can deal with "odd" problems e.g. sos type 2.
int feasibilityPumpOptions() const
Gets feasibility pump options (-1 is off)
void setSeed(int value)
Set seed.
int numInvocationsInShallow_
How many invocations happened within the same node when in a shallow part of the tree.
void setShallowDepth(int value)
Upto this depth we call the tree shallow and the heuristic can be called multiple times...
double minDistance(const CbcHeuristicNodeList &nodeList) const
int numInvocationsInDeep_
How many invocations happened when in the deep part of the tree.
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...
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...
void setModelOnly(CbcModel *model)
Just set model - do not do anything else.
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 setHeuristicName(const char *name)
set name of heuristic
const char * heuristicName() const
return name of heuristic
int howOften_
How often to do (code can change)
CbcHeuristic ** heuristic_
Abstract branching object base class Now just difference with OsiBranchingObject. ...
Partial solution class If user knows a partial solution this tries to get an integer solution it uses...
bool minDistanceIsSmall(const CbcHeuristicNodeList &nodeList, const double threshold) const
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.
void setWhereFrom(int value)
int shallowDepth_
Upto this depth we call the tree shallow and the heuristic can be called multiple times...
double distance(const CbcHeuristicNode *node) const
int numberSolutionsFound_
How many solutions the heuristic thought it got.
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.
virtual void generateCpp(FILE *)
Create C++ lines to get to current state.
std::string heuristicName_
Name for printing.
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)
int numCouldRun() const
How many times the heuristic could run.
virtual bool selectVariableToBranch(OsiSolverInterface *, const double *, int &, int &)
Selects the next variable to branch on.
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.
int numberSolutionsFound() const
Get how many solutions the heuristic thought it got.
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)