Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
CbcHeuristicGreedyCover Class Reference

Greedy heuristic classes. More...

#include <CbcHeuristicGreedy.hpp>

Inheritance diagram for CbcHeuristicGreedyCover:
CbcHeuristic CbcHeuristic

Public Member Functions

 CbcHeuristicGreedyCover ()
 CbcHeuristicGreedyCover (CbcModel &model)
 CbcHeuristicGreedyCover (const CbcHeuristicGreedyCover &)
 ~CbcHeuristicGreedyCover ()
virtual CbcHeuristicclone () const
 Clone.
CbcHeuristicGreedyCoveroperator= (const CbcHeuristicGreedyCover &rhs)
 Assignment operator.
virtual void generateCpp (FILE *fp)
 Create C++ lines to get to current state.
virtual void setModel (CbcModel *model)
 update model (This is needed if cliques update matrix etc)
virtual int solution (double &objectiveValue, double *newSolution)
 returns 0 if no solution, 1 if valid solution.
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.
int algorithm () const
void setAlgorithm (int value)
int numberTimes () const
void setNumberTimes (int value)
 CbcHeuristicGreedyCover ()
 CbcHeuristicGreedyCover (CbcModel &model)
 CbcHeuristicGreedyCover (const CbcHeuristicGreedyCover &)
 ~CbcHeuristicGreedyCover ()
virtual CbcHeuristicclone () const
 Clone.
CbcHeuristicGreedyCoveroperator= (const CbcHeuristicGreedyCover &rhs)
 Assignment operator.
virtual void generateCpp (FILE *fp)
 Create C++ lines to get to current state.
virtual void setModel (CbcModel *model)
 update model (This is needed if cliques update matrix etc)
virtual int solution (double &objectiveValue, double *newSolution)
 returns 0 if no solution, 1 if valid solution.
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.
int algorithm () const
void setAlgorithm (int value)
int numberTimes () const
void setNumberTimes (int value)
- Public Member Functions inherited from CbcHeuristic
 CbcHeuristic ()
 CbcHeuristic (CbcModel &model)
 CbcHeuristic (const CbcHeuristic &)
virtual ~CbcHeuristic ()
CbcHeuristicoperator= (const CbcHeuristic &rhs)
 Assignment operator.
virtual int solution2 (double &, double *, OsiCuts &)
 returns 0 if no solution, 1 if valid solution, -1 if just returning an estimate of best possible solution with better objective value than one passed in Sets solution values if good, sets objective value (only if nonzero code) This is called at same time as cut generators - so can add cuts Default is do nothing
void setWhen (int value)
 Sets "when" flag - 0 off, 1 at root, 2 other than root, 3 always.
int when () const
 Gets "when" flag - 0 off, 1 at root, 2 other than root, 3 always.
void setNumberNodes (int value)
 Sets number of nodes in subtree (default 200)
int numberNodes () const
 Gets number of nodes in a subtree (default 200)
void setSwitches (int value)
 Switches (does not apply equally to all heuristics) 1 bit - stop once allowable gap on objective reached 2 bit - always do given number of passes 4 bit - weaken cutoff by 5% every 50 passes? 8 bit - if has cutoff and suminf bobbling for 20 passes then first try halving distance to best possible then try keep halving distance to known cutoff 1024 bit - stop all heuristics on max time.
int switches () const
 Switches (does not apply equally to all heuristics) 1 bit - stop once allowable gap on objective reached 2 bit - always do given number of passes 4 bit - weaken cutoff by 5% every 50 passes? 8 bit - if has cutoff and suminf bobbling for 20 passes then first try halving distance to best possible then try keep halving distance to known cutoff 1024 bit - stop all heuristics on max time.
bool exitNow (double bestObjective) const
 Whether to exit at once on gap.
void setFeasibilityPumpOptions (int value)
 Sets feasibility pump options (-1 is off)
int feasibilityPumpOptions () const
 Gets feasibility pump options (-1 is off)
void setModelOnly (CbcModel *model)
 Just set model - do not do anything else.
void setFractionSmall (double value)
 Sets fraction of new(rows+columns)/old(rows+columns) before doing small branch and bound (default 1.0)
double fractionSmall () const
 Gets fraction of new(rows+columns)/old(rows+columns) before doing small branch and bound (default 1.0)
int numberSolutionsFound () const
 Get how many solutions the heuristic thought it got.
void incrementNumberSolutionsFound ()
 Increment how many solutions the heuristic thought it got.
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 - no solution 3 finished - solution (could add global cut if finished) -1 returned on size -2 time or user event.
void generateCpp (FILE *fp, const char *heuristic)
 Create C++ lines to get to current state - does work for base class.
virtual bool canDealWithOdd () const
 Returns true if can deal with "odd" problems e.g. sos type 2.
const char * heuristicName () const
 return name of heuristic
void setHeuristicName (const char *name)
 set name of heuristic
void setSeed (int value)
 Set random number generator seed.
void setDecayFactor (double value)
 Sets decay factor (for howOften) on failure.
void setInputSolution (const double *solution, double objValue)
 Set input solution.
void setWhereFrom (int value)
void setShallowDepth (int value)
 Upto this depth we call the tree shallow and the heuristic can be called multiple times.
void setHowOftenShallow (int value)
 How often to invoke the heuristics in the shallow part of the tree.
void setMinDistanceToRun (int value)
 How "far" should this node be from every other where the heuristic was run in order to allow the heuristic to run in this node, too.
virtual bool shouldHeurRun (int whereFrom)
 Check whether the heuristic should run at all 0 - before cuts at root node (or from doHeuristics) 1 - during cuts at root 2 - after root node cuts 3 - after cuts at other nodes 4 - during cuts at other nodes 8 added if previous heuristic in loop found solution.
bool shouldHeurRun_randomChoice ()
 Check whether the heuristic should run this time.
void debugNodes ()
void printDistanceToNodes ()
int numRuns () const
 how many times the heuristic has actually run
int numCouldRun () const
 How many times the heuristic could run.
OsiSolverInterface * cloneBut (int type)
 Clone but .
 CbcHeuristic ()
 CbcHeuristic (CbcModel &model)
 CbcHeuristic (const CbcHeuristic &)
virtual ~CbcHeuristic ()
CbcHeuristicoperator= (const CbcHeuristic &rhs)
 Assignment operator.
virtual int solution2 (double &, double *, OsiCuts &)
 returns 0 if no solution, 1 if valid solution, -1 if just returning an estimate of best possible solution with better objective value than one passed in Sets solution values if good, sets objective value (only if nonzero code) This is called at same time as cut generators - so can add cuts Default is do nothing
void setWhen (int value)
 Sets "when" flag - 0 off, 1 at root, 2 other than root, 3 always.
int when () const
 Gets "when" flag - 0 off, 1 at root, 2 other than root, 3 always.
void setNumberNodes (int value)
 Sets number of nodes in subtree (default 200)
int numberNodes () const
 Gets number of nodes in a subtree (default 200)
void setSwitches (int value)
 Switches (does not apply equally to all heuristics) 1 bit - stop once allowable gap on objective reached 2 bit - always do given number of passes 4 bit - weaken cutoff by 5% every 50 passes? 8 bit - if has cutoff and suminf bobbling for 20 passes then first try halving distance to best possible then try keep halving distance to known cutoff 1024 bit - stop all heuristics on max time.
int switches () const
 Switches (does not apply equally to all heuristics) 1 bit - stop once allowable gap on objective reached 2 bit - always do given number of passes 4 bit - weaken cutoff by 5% every 50 passes? 8 bit - if has cutoff and suminf bobbling for 20 passes then first try halving distance to best possible then try keep halving distance to known cutoff 1024 bit - stop all heuristics on max time.
bool exitNow (double bestObjective) const
 Whether to exit at once on gap.
void setFeasibilityPumpOptions (int value)
 Sets feasibility pump options (-1 is off)
int feasibilityPumpOptions () const
 Gets feasibility pump options (-1 is off)
void setModelOnly (CbcModel *model)
 Just set model - do not do anything else.
void setFractionSmall (double value)
 Sets fraction of new(rows+columns)/old(rows+columns) before doing small branch and bound (default 1.0)
double fractionSmall () const
 Gets fraction of new(rows+columns)/old(rows+columns) before doing small branch and bound (default 1.0)
int numberSolutionsFound () const
 Get how many solutions the heuristic thought it got.
void incrementNumberSolutionsFound ()
 Increment how many solutions the heuristic thought it got.
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 - no solution 3 finished - solution (could add global cut if finished) -1 returned on size -2 time or user event.
void generateCpp (FILE *fp, const char *heuristic)
 Create C++ lines to get to current state - does work for base class.
virtual bool canDealWithOdd () const
 Returns true if can deal with "odd" problems e.g. sos type 2.
const char * heuristicName () const
 return name of heuristic
void setHeuristicName (const char *name)
 set name of heuristic
void setSeed (int value)
 Set random number generator seed.
void setDecayFactor (double value)
 Sets decay factor (for howOften) on failure.
void setInputSolution (const double *solution, double objValue)
 Set input solution.
void setWhereFrom (int value)
void setShallowDepth (int value)
 Upto this depth we call the tree shallow and the heuristic can be called multiple times.
void setHowOftenShallow (int value)
 How often to invoke the heuristics in the shallow part of the tree.
void setMinDistanceToRun (int value)
 How "far" should this node be from every other where the heuristic was run in order to allow the heuristic to run in this node, too.
virtual bool shouldHeurRun (int whereFrom)
 Check whether the heuristic should run at all 0 - before cuts at root node (or from doHeuristics) 1 - during cuts at root 2 - after root node cuts 3 - after cuts at other nodes 4 - during cuts at other nodes 8 added if previous heuristic in loop found solution.
bool shouldHeurRun_randomChoice ()
 Check whether the heuristic should run this time.
void debugNodes ()
void printDistanceToNodes ()
int numRuns () const
 how many times the heuristic has actually run
int numCouldRun () const
 How many times the heuristic could run.
OsiSolverInterface * cloneBut (int type)
 Clone but .

Protected Member Functions

void gutsOfConstructor (CbcModel *model)
 Guts of constructor from a CbcModel.
void gutsOfConstructor (CbcModel *model)
 Guts of constructor from a CbcModel.

Protected Attributes

CoinPackedMatrix matrix_
int originalNumberRows_
int algorithm_
int numberTimes_
 Do this many times.
- Protected Attributes inherited from CbcHeuristic
CbcModelmodel_
 Model.
int when_
 When flag - 0 off, 1 at root, 2 other than root, 3 always.
int numberNodes_
 Number of nodes in any sub tree.
int feasibilityPumpOptions_
 Feasibility pump options (-1 is off)
double fractionSmall_
 Fraction of new(rows+columns)/old(rows+columns) before doing small branch and bound.
CoinThreadRandom randomNumberGenerator_
 Thread specific random number generator.
std::string heuristicName_
 Name for printing.
int howOften_
 How often to do (code can change)
double decayFactor_
 How much to increase how often.
int switches_
 Switches (does not apply equally to all heuristics) 1 bit - stop once allowable gap on objective reached 2 bit - always do given number of passes 4 bit - weaken cutoff by 5% every 50 passes? 8 bit - if has cutoff and suminf bobbling for 20 passes then first try halving distance to best possible then try keep halving distance to known cutoff 1024 bit - stop all heuristics on max time.
int whereFrom_
int shallowDepth_
 Upto this depth we call the tree shallow and the heuristic can be called multiple times.
int howOftenShallow_
 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.
int numInvocationsInDeep_
 How many invocations happened when in the deep part of the tree.
int lastRunDeep_
 After how many deep invocations was the heuristic run last time.
int numRuns_
 how many times the heuristic has actually run
int minDistanceToRun_
 How "far" should this node be from every other where the heuristic was run in order to allow the heuristic to run in this node, too.
CbcHeuristicNodeList runNodes_
 The description of the nodes where this heuristic has been applied.
int numCouldRun_
 How many times the heuristic could run.
int numberSolutionsFound_
 How many solutions the heuristic thought it got.
double * inputSolution_

Detailed Description

Greedy heuristic classes.

Definition at line 11 of file CbcHeuristicGreedy.hpp.

Constructor & Destructor Documentation

CbcHeuristicGreedyCover::CbcHeuristicGreedyCover ( )
CbcHeuristicGreedyCover::CbcHeuristicGreedyCover ( CbcModel model)
CbcHeuristicGreedyCover::CbcHeuristicGreedyCover ( const CbcHeuristicGreedyCover )
CbcHeuristicGreedyCover::~CbcHeuristicGreedyCover ( )
CbcHeuristicGreedyCover::CbcHeuristicGreedyCover ( )
CbcHeuristicGreedyCover::CbcHeuristicGreedyCover ( CbcModel model)
CbcHeuristicGreedyCover::CbcHeuristicGreedyCover ( const CbcHeuristicGreedyCover )
CbcHeuristicGreedyCover::~CbcHeuristicGreedyCover ( )

Member Function Documentation

virtual CbcHeuristic* CbcHeuristicGreedyCover::clone ( ) const
virtual

Clone.

Implements CbcHeuristic.

CbcHeuristicGreedyCover& CbcHeuristicGreedyCover::operator= ( const CbcHeuristicGreedyCover rhs)

Assignment operator.

virtual void CbcHeuristicGreedyCover::generateCpp ( FILE *  fp)
virtual

Create C++ lines to get to current state.

Reimplemented from CbcHeuristic.

virtual void CbcHeuristicGreedyCover::setModel ( CbcModel model)
virtual

update model (This is needed if cliques update matrix etc)

Reimplemented from CbcHeuristic.

virtual int CbcHeuristicGreedyCover::solution ( double &  objectiveValue,
double *  newSolution 
)
virtual

returns 0 if no solution, 1 if valid solution.

Sets solution values if good, sets objective value (only if good) We leave all variables which are at one at this node of the tree to that value and will initially set all others to zero. We then sort all variables in order of their cost divided by the number of entries in rows which are not yet covered. We randomize that value a bit so that ties will be broken in different ways on different runs of the heuristic. We then choose the best one and set it to one and repeat the exercise.

Implements CbcHeuristic.

virtual void CbcHeuristicGreedyCover::validate ( )
virtual

Validate model i.e. sets when_ to 0 if necessary (may be NULL)

Reimplemented from CbcHeuristic.

virtual void CbcHeuristicGreedyCover::resetModel ( CbcModel model)
virtual

Resets stuff if model changes.

Implements CbcHeuristic.

int CbcHeuristicGreedyCover::algorithm ( ) const
inline

Definition at line 61 of file CbcHeuristicGreedy.hpp.

void CbcHeuristicGreedyCover::setAlgorithm ( int  value)
inline

Definition at line 64 of file CbcHeuristicGreedy.hpp.

int CbcHeuristicGreedyCover::numberTimes ( ) const
inline

Definition at line 68 of file CbcHeuristicGreedy.hpp.

void CbcHeuristicGreedyCover::setNumberTimes ( int  value)
inline

Definition at line 71 of file CbcHeuristicGreedy.hpp.

void CbcHeuristicGreedyCover::gutsOfConstructor ( CbcModel model)
protected

Guts of constructor from a CbcModel.

virtual CbcHeuristic* CbcHeuristicGreedyCover::clone ( ) const
virtual

Clone.

Implements CbcHeuristic.

CbcHeuristicGreedyCover& CbcHeuristicGreedyCover::operator= ( const CbcHeuristicGreedyCover rhs)

Assignment operator.

virtual void CbcHeuristicGreedyCover::generateCpp ( FILE *  fp)
virtual

Create C++ lines to get to current state.

Reimplemented from CbcHeuristic.

virtual void CbcHeuristicGreedyCover::setModel ( CbcModel model)
virtual

update model (This is needed if cliques update matrix etc)

Reimplemented from CbcHeuristic.

virtual int CbcHeuristicGreedyCover::solution ( double &  objectiveValue,
double *  newSolution 
)
virtual

returns 0 if no solution, 1 if valid solution.

Sets solution values if good, sets objective value (only if good) We leave all variables which are at one at this node of the tree to that value and will initially set all others to zero. We then sort all variables in order of their cost divided by the number of entries in rows which are not yet covered. We randomize that value a bit so that ties will be broken in different ways on different runs of the heuristic. We then choose the best one and set it to one and repeat the exercise.

Implements CbcHeuristic.

virtual void CbcHeuristicGreedyCover::validate ( )
virtual

Validate model i.e. sets when_ to 0 if necessary (may be NULL)

Reimplemented from CbcHeuristic.

virtual void CbcHeuristicGreedyCover::resetModel ( CbcModel model)
virtual

Resets stuff if model changes.

Implements CbcHeuristic.

int CbcHeuristicGreedyCover::algorithm ( ) const
inline

Definition at line 61 of file CbcHeuristicGreedy.hpp.

void CbcHeuristicGreedyCover::setAlgorithm ( int  value)
inline

Definition at line 64 of file CbcHeuristicGreedy.hpp.

int CbcHeuristicGreedyCover::numberTimes ( ) const
inline

Definition at line 68 of file CbcHeuristicGreedy.hpp.

void CbcHeuristicGreedyCover::setNumberTimes ( int  value)
inline

Definition at line 71 of file CbcHeuristicGreedy.hpp.

void CbcHeuristicGreedyCover::gutsOfConstructor ( CbcModel model)
protected

Guts of constructor from a CbcModel.

Member Data Documentation

CoinPackedMatrix CbcHeuristicGreedyCover::matrix_
protected

Definition at line 81 of file CbcHeuristicGreedy.hpp.

int CbcHeuristicGreedyCover::originalNumberRows_
protected

Definition at line 83 of file CbcHeuristicGreedy.hpp.

int CbcHeuristicGreedyCover::algorithm_
protected

Definition at line 89 of file CbcHeuristicGreedy.hpp.

int CbcHeuristicGreedyCover::numberTimes_
protected

Do this many times.

Definition at line 91 of file CbcHeuristicGreedy.hpp.


The documentation for this class was generated from the following files: