Dip
0.92.4
|
Base class for Cbc event handling. More...
#include <CbcEventHandler.hpp>
Public Types | |
enum | CbcEvent { node = 200, treeStatus, solution, heuristicSolution, beforeSolution1, beforeSolution2, afterHeuristic, smallBranchAndBound, heuristicPass, convertToCuts, generatedCuts, 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... | |
CbcEventHandler & | operator= (const CbcEventHandler &rhs) |
Assignment. More... | |
virtual CbcEventHandler * | clone () const |
Clone (virtual) constructor. More... | |
virtual | ~CbcEventHandler () |
Destructor. More... | |
Set/Get methods | |
void | setModel (CbcModel *model) |
Set model. More... | |
const CbcModel * | getModel () 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. | |
CbcModel * | model_ |
Pointer to associated CbcModel. More... | |
CbcAction | dfltAction_ |
Default action. More... | |
eaMapPair * | eaMap_ |
Pointer to a map that holds non-default event/action pairs. More... | |
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:
Create a CbcEventHandler object. This will be initialised with a set of default actions for every recognised event.
Attach the event handler to the CbcModel object.
The return value associated with an event can be changed at any time.
Definition at line 82 of file CbcEventHandler.hpp.
typedef std::map< CbcEvent, CbcAction > CbcEventHandler::eaMapPair |
Data type for event/action pairs.
Definition at line 139 of file CbcEventHandler.hpp.
Events known to cbc.
Definition at line 87 of file CbcEventHandler.hpp.
Action codes returned by the event handler.
Specific values are chosen to match ClpEventHandler return codes.
Definition at line 118 of file CbcEventHandler.hpp.
CbcEventHandler::CbcEventHandler | ( | CbcModel * | model = 0 | ) |
Default constructor.
CbcEventHandler::CbcEventHandler | ( | const CbcEventHandler & | orig | ) |
Copy constructor.
|
virtual |
Destructor.
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.
Referenced by setAction().
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 |
Clone (virtual) constructor.
|
inline |
|
inline |
|
inline |
Set the action code associated with an event.
Definition at line 213 of file CbcEventHandler.hpp.
|
protected |
Pointer to associated CbcModel.
Definition at line 232 of file CbcEventHandler.hpp.
Referenced by getModel(), and setModel().
|
protected |
|
protected |
Pointer to a map that holds non-default event/action pairs.
Definition at line 240 of file CbcEventHandler.hpp.
Referenced by setAction().