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;
177 bool exitNow(
double bestObjective)
const;
180 feasibilityPumpOptions_ = value;
184 return feasibilityPumpOptions_;
194 fractionSmall_ = value;
198 return fractionSmall_;
202 return numberSolutionsFound_;
206 numberSolutionsFound_++;
218 int smallBranchAndBound(OsiSolverInterface * solver,
int numberNodes,
219 double * newSolution,
double & newSolutionValue,
220 double cutoff , std::string name)
const;
224 void generateCpp( FILE * fp,
const char * heuristic) ;
231 return heuristicName_.c_str();
235 heuristicName_ = name;
238 void setSeed(
int value);
243 decayFactor_ = value;
246 void setInputSolution(
const double * solution,
double objValue);
268 shallowDepth_ = value;
272 howOftenShallow_ = value;
278 minDistanceToRun_ = value;
289 virtual bool shouldHeurRun(
int whereFrom);
291 bool shouldHeurRun_randomChoice();
293 void printDistanceToNodes();
311 OsiSolverInterface * cloneBut(
int type);
398 double * lowerBoundLastNode_;
401 double * upperBoundLastNode_;
428 virtual void generateCpp( FILE * fp) ;
431 virtual void resetModel(
CbcModel * model);
434 virtual void setModel(
CbcModel * model);
442 virtual int solution(
double & objectiveValue,
443 double * newSolution);
450 virtual int solution(
double & objectiveValue,
451 double * newSolution,
452 double solutionValue);
454 virtual void validate();
513 virtual void generateCpp( FILE * fp) ;
516 virtual void resetModel(
CbcModel * model);
519 virtual void setModel(
CbcModel * model);
527 virtual int solution(
double & objectiveValue,
528 double * newSolution);
530 virtual void validate();
535 fixPriority_ = value;
539 virtual bool shouldHeurRun(
int whereFrom);
574 virtual void generateCpp( FILE * fp) ;
577 virtual void setModel(
CbcModel * model);
590 virtual int solution(
double & objectiveValue,
591 double * newSolution);
593 virtual void resetModel(
CbcModel * model);
623 virtual void generateCpp( FILE * fp) ;
631 virtual int solution(
double & objectiveValue,
632 double * newSolution);
634 virtual void resetModel(
CbcModel * model);
637 virtual void setModel(
CbcModel * model);
652 virtual void validate();
654 void addHeuristic(
const CbcHeuristic * heuristic,
double probability);
656 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)