Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

SbbCutGenerator Class Reference

#include <SbbCutGenerator.hpp>

List of all members.

Public Member Functions

Generate Cuts
bool generateCuts (OsiCuts &cs, bool fullScan)
Constructors and destructors
 SbbCutGenerator ()
 Default constructor.

 SbbCutGenerator (SbbModel *model, CglCutGenerator *generator, int howOften=1, const char *name=NULL, bool normal=true, bool atSolution=false, bool infeasible=false)
 Normal constructor.

 SbbCutGenerator (const SbbCutGenerator &)
 Copy constructor.

SbbCutGeneratoroperator= (const SbbCutGenerator &rhs)
 Assignment operator.

 ~SbbCutGenerator ()
 Destructor.

Gets and sets
void refreshModel (SbbModel *model)
const char * cutGeneratorName () const
 return name of generator

void setHowOften (int value)
int howOften () const
 Get the cut generation interval.

bool normal () const
 Get whether the cut generator should be called in the normal place.

void setNormal (bool value)
 Set whether the cut generator should be called in the normal place.

bool atSolution () const
 Get whether the cut generator should be called when a solution is found.

void setAtSolution (bool value)
 Set whether the cut generator should be called when a solution is found.

bool whenInfeasible () const
void setWhenInfeasible (bool value)
CglCutGeneratorgenerator () const
 Get the CglCutGenerator bound to this SbbCutGenerator.


Private Attributes

SbbModelmodel_
 The client model.

CglCutGeneratorgenerator_
int whenCutGenerator_
char * generatorName_
 Name of generator.

bool normal_
 Whether to call the generator in the normal place.

bool atSolution_
 Whether to call the generator when a new solution is found.

bool whenInfeasible_
 Whether to call generator when a subproblem is found to be infeasible.


Detailed Description

Interface between Sbb and Cut Generation Library.

SbbCutGenerator is intended to provide an intelligent interface between Sbb and the cutting plane algorithms in the CGL. A SbbCutGenerator is bound to a CglCutGenerator and to an SbbModel. It contains parameters which control when and how the generateCuts method of the CglCutGenerator will be called.

The builtin decision criteria available to use when deciding whether to generate cuts are limited: every X nodes, when a solution is found, and when a subproblem is found to be infeasible. The idea is that the class will grow more intelligent with time.

Todo:
Add a pointer to function member which will allow a client to install their own decision algorithm to decide whether or not to call the CGL generateCuts method. Create a default decision method that looks at the builtin criteria.

It strikes me as not good that generateCuts contains code specific to individual CGL algorithms. Another set of pointer to function members, so that the client can specify the cut generation method as well as pre- and post-generation methods? Taken a bit further, should this class contain a bunch of pointer to function members, one for each of the places where the cut generator might be referenced? Initialization, root node, search tree node, discovery of solution, and termination all come to mind. Initialization and termination would also be useful for instrumenting sbb.

Definition at line 45 of file SbbCutGenerator.hpp.


Member Function Documentation

bool SbbCutGenerator::generateCuts OsiCuts cs,
bool  fullScan
 

Generate cuts for the client model.

Evaluate the state of the client model and decide whether to generate cuts. The generated cuts are inserted into and returned in the collection of cuts cs.

If fullScan is true, the generator is obliged to call the CGL generateCuts routine. Otherwise, it is free to make a local decision. The current implementation uses whenCutGenerator_ to decide.

The routine returns true if reoptimisation is needed (because the state of the solver interface has been modified).

Definition at line 100 of file SbbCutGenerator.cpp.

References CglCutGenerator::generateCuts(), CglProbing::generateCutsAndModify(), generator(), OsiSolverInterface::getColLower(), OsiSolverInterface::getColSolution(), OsiSolverInterface::getColUpper(), SbbModel::getNodeCount(), OsiSolverInterface::getNumCols(), howOften(), model_, OsiSolverInterface::setColLower(), OsiSolverInterface::setColUpper(), SbbModel::solver(), CglProbing::tightLower(), CglProbing::tightUpper(), and whenCutGenerator_.

Referenced by SbbModel::setBestSolution(), and SbbModel::solveWithCuts().

00101 {
00102   int howOften = whenCutGenerator_;
00103   if (howOften==-100)
00104     return false;
00105   if (howOften>0)
00106     howOften = howOften % 1000000;
00107   else 
00108     howOften=1;
00109   if (!howOften)
00110     howOften=1;
00111   bool returnCode=false;
00112   OsiSolverInterface * solver = model_->solver();
00113   if (fullScan||(model_->getNodeCount()%howOften)==0) {
00114     CglProbing* generator =
00115       dynamic_cast<CglProbing*>(generator_);
00116     if (!generator) {
00117       generator_->generateCuts(*solver,cs);
00118     } else {
00119       // Probing - return tight column bounds
00120       generator->generateCutsAndModify(*solver,cs);
00121       const double * tightLower = generator->tightLower();
00122       const double * lower = solver->getColLower();
00123       const double * tightUpper = generator->tightUpper();
00124       const double * upper = solver->getColUpper();
00125       const double * solution = solver->getColSolution();
00126       int j;
00127       int numberColumns = solver->getNumCols();
00128       double primalTolerance = 1.0e-8;
00129       for (j=0;j<numberColumns;j++) {
00130         if (tightUpper[j]==tightLower[j]&&
00131             upper[j]>lower[j]) {
00132           // fix
00133           solver->setColLower(j,tightLower[j]);
00134           solver->setColUpper(j,tightUpper[j]);
00135           if (tightLower[j]>solution[j]+primalTolerance||
00136               tightUpper[j]<solution[j]-primalTolerance)
00137             returnCode=true;
00138         }
00139       }
00140     }
00141   }
00142   return returnCode;
00143 }

void SbbCutGenerator::refreshModel SbbModel model  ) 
 

Set the client model.

In addition to setting the client model, refreshModel also calls the refreshSolver method of the CglCutGenerator object.

Definition at line 90 of file SbbCutGenerator.cpp.

References model_, CglCutGenerator::refreshSolver(), and SbbModel::solver().

Referenced by SbbModel::synchronizeModel().

00091 {
00092   model_=model;
00093   generator_->refreshSolver(model_->solver());
00094 }

void SbbCutGenerator::setHowOften int  value  ) 
 

Set the cut generation interval

Set the number of nodes evaluated between calls to the Cgl object's generateCuts routine.

If value is positive, cuts will always be generated at the specified interval. If value is negative, cuts will initially be generated at the specified interval, but Sbb may adjust the value depending on the success of cuts produced by this generator.

A value of -100 disables the generator, while a value of -99 means just at root.

Definition at line 145 of file SbbCutGenerator.cpp.

References generator(), and whenCutGenerator_.

Referenced by SbbModel::tightenVubs().

00146 {
00147   
00148   if (howOften>=1000000) {
00149     // leave Probing every 10
00150     howOften = howOften % 1000000;
00151     CglProbing* generator =
00152       dynamic_cast<CglProbing*>(generator_);
00153     
00154     if (generator&&howOften>10) 
00155       howOften=10+1000000;
00156   }
00157   whenCutGenerator_ = howOften;
00158 }

void SbbCutGenerator::setWhenInfeasible bool  value  )  [inline]
 

Set whether the cut generator should be called when the subproblem is found to be infeasible.

Definition at line 142 of file SbbCutGenerator.hpp.

References whenInfeasible_.

00143   { whenInfeasible_=value;};

bool SbbCutGenerator::whenInfeasible  )  const [inline]
 

Get whether the cut generator should be called when the subproblem is found to be infeasible.

Definition at line 137 of file SbbCutGenerator.hpp.

References whenInfeasible_.

00138   { return whenInfeasible_;};


Member Data Documentation

int SbbCutGenerator::whenCutGenerator_ [private]
 

Number of nodes between calls to the CglCutGenerator::generateCuts routine.

Definition at line 159 of file SbbCutGenerator.hpp.

Referenced by generateCuts(), howOften(), operator=(), SbbCutGenerator(), and setHowOften().


The documentation for this class was generated from the following files:
Generated on Wed Dec 3 14:36:23 2003 for Sbb by doxygen 1.3.5