Cbc  2.9.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | List of all members
CbcEventHandler Class Reference

Base class for Cbc event handling. More...

#include <CbcEventHandler.hpp>

+ Collaboration diagram for CbcEventHandler:

Public Types

enum  CbcEvent {
  node = 200, treeStatus, solution, heuristicSolution,
  beforeSolution1, beforeSolution2, afterHeuristic, smallBranchAndBound,
  heuristicPass, convertToCuts, endSearch
}
 Events known to cbc. More...
 
enum  CbcAction {
  noAction = -1, stop = 0, restart, restartRoot,
  addCuts, killSolution, takeAction
}
 Action codes returned by the event handler. More...
 
typedef std::map< CbcEvent,
CbcAction
eaMapPair
 Data type for event/action pairs. More...
 

Public Member Functions

Event Processing
virtual CbcAction event (CbcEvent whichEvent)
 Return the action to be taken for an event. More...
 
virtual CbcAction event (CbcEvent whichEvent, void *data)
 Return the action to be taken for an event - and modify data. More...
 
Constructors and destructors
 CbcEventHandler (CbcModel *model=0)
 Default constructor. More...
 
 CbcEventHandler (const CbcEventHandler &orig)
 Copy constructor. More...
 
CbcEventHandleroperator= (const CbcEventHandler &rhs)
 Assignment. More...
 
virtual CbcEventHandlerclone () const
 Clone (virtual) constructor. More...
 
virtual ~CbcEventHandler ()
 Destructor. More...
 
Set/Get methods
void setModel (CbcModel *model)
 Set model. More...
 
const CbcModelgetModel () const
 Get model. More...
 
void setDfltAction (CbcAction action)
 Set the default action. More...
 
void setAction (CbcEvent event, CbcAction action)
 Set the action code associated with an event. More...
 

Protected Attributes

Data members

Protected (as opposed to private) to allow access by derived classes.

CbcModelmodel_
 Pointer to associated CbcModel. More...
 
CbcAction dfltAction_
 Default action. More...
 
eaMapPaireaMap_
 Pointer to a map that holds non-default event/action pairs. More...
 

Detailed Description

Base class for Cbc event handling.

Up front: We're not talking about unanticipated events here. We're talking about anticipated events, in the sense that the code is going to make a call to event() and is prepared to obey the return value that it receives.

The general pattern for usage is as follows:

  1. Create a CbcEventHandler object. This will be initialised with a set of default actions for every recognised event.

  2. Attach the event handler to the CbcModel object.

  3. When execution reaches the point where an event occurs, call the event handler as CbcEventHandler::event(the event). The return value will specify what the code should do in response to the event.

The return value associated with an event can be changed at any time.

Definition at line 82 of file CbcEventHandler.hpp.

Member Typedef Documentation

Data type for event/action pairs.

Definition at line 138 of file CbcEventHandler.hpp.

Member Enumeration Documentation

Events known to cbc.

Enumerator
node 

Processing of the current node is complete.

treeStatus 

A tree status interval has arrived.

solution 

A solution has been found.

heuristicSolution 

A heuristic solution has been found.

beforeSolution1 

A solution will be found unless user takes action (first check).

beforeSolution2 

A solution will be found unless user takes action (thorough check).

afterHeuristic 

After failed heuristic.

smallBranchAndBound 

On entry to small branch and bound.

heuristicPass 

After a pass of heuristic.

convertToCuts 

When converting constraints to cuts.

endSearch 

End of search.

Definition at line 88 of file CbcEventHandler.hpp.

Action codes returned by the event handler.

Specific values are chosen to match ClpEventHandler return codes.

Enumerator
noAction 

Continue — no action required.

stop 

Stop — abort the current run at the next opportunity.

restart 

Restart — restart branch-and-cut search; do not undo root node processing.

restartRoot 

RestartRoot — undo root node and start branch-and-cut afresh.

addCuts 

Add special cuts.

killSolution 

Pretend solution never happened.

takeAction 

Take action on modified data.

Definition at line 117 of file CbcEventHandler.hpp.

Constructor & Destructor Documentation

CbcEventHandler::CbcEventHandler ( CbcModel model = 0)

Default constructor.

CbcEventHandler::CbcEventHandler ( const CbcEventHandler orig)

Copy constructor.

virtual CbcEventHandler::~CbcEventHandler ( )
virtual

Destructor.

Member Function Documentation

virtual CbcAction CbcEventHandler::event ( CbcEvent  whichEvent)
virtual

Return the action to be taken for an event.

Return the action that should be taken in response to the event passed as the parameter. The default implementation simply reads a return code from a map.

virtual CbcAction CbcEventHandler::event ( CbcEvent  whichEvent,
void data 
)
virtual

Return the action to be taken for an event - and modify data.

Return the action that should be taken in response to the event passed as the parameter. The default implementation simply reads a return code from a map.

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

Assignment.

virtual CbcEventHandler* CbcEventHandler::clone ( ) const
virtual

Clone (virtual) constructor.

void CbcEventHandler::setModel ( CbcModel model)
inline

Set model.

Definition at line 193 of file CbcEventHandler.hpp.

const CbcModel* CbcEventHandler::getModel ( ) const
inline

Get model.

Definition at line 199 of file CbcEventHandler.hpp.

void CbcEventHandler::setDfltAction ( CbcAction  action)
inline

Set the default action.

Definition at line 205 of file CbcEventHandler.hpp.

void CbcEventHandler::setAction ( CbcEvent  event,
CbcAction  action 
)
inline

Set the action code associated with an event.

Definition at line 211 of file CbcEventHandler.hpp.

Member Data Documentation

CbcModel* CbcEventHandler::model_
protected

Pointer to associated CbcModel.

Definition at line 231 of file CbcEventHandler.hpp.

CbcAction CbcEventHandler::dfltAction_
protected

Default action.

Definition at line 235 of file CbcEventHandler.hpp.

eaMapPair* CbcEventHandler::eaMap_
protected

Pointer to a map that holds non-default event/action pairs.

Definition at line 239 of file CbcEventHandler.hpp.


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