Base class for Cbc event handling. More...
#include <CbcEventHandler.hpp>
Public Types | |
enum | CbcEvent { node = 200, treeStatus, solution, heuristicSolution } |
Events known to cbc. More... | |
enum | CbcAction { noAction = -1, stop = 0, restart, restartRoot } |
Action codes returned by the event handler. More... | |
typedef std::map< CbcEvent, CbcAction > | eaMapPair |
Data type for event/action pairs. | |
Public Member Functions | |
Event Processing | |
virtual CbcAction | event (CbcEvent whichEvent) |
Return the action to be taken for an event. | |
Constructors and destructors | |
CbcEventHandler (const CbcModel *model=NULL) | |
Default constructor. | |
CbcEventHandler (const CbcEventHandler &orig) | |
Copy constructor. | |
CbcEventHandler & | operator= (const CbcEventHandler &rhs) |
Assignment. | |
virtual CbcEventHandler * | clone () const |
Clone (virtual) constructor. | |
virtual | ~CbcEventHandler () |
Destructor. | |
Set/Get methods | |
void | setModel (CbcModel *model) |
Set model. | |
const CbcModel * | getModel () const |
Get model. | |
void | setDfltAction (CbcAction action) |
Set the default action. | |
void | setAction (CbcEvent event, CbcAction action) |
Set the action code associated with an event. | |
Protected Attributes | |
Data members | |
const CbcModel * | model_ |
Pointer to associated CbcModel. | |
CbcAction | dfltAction_ |
Default action. | |
eaMapPair * | eaMap_ |
Pointer to a map that holds non-default event/action pairs. |
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 77 of file CbcEventHandler.hpp.
typedef std::map<CbcEvent,CbcAction> CbcEventHandler::eaMapPair |
Data type for event/action pairs.
Definition at line 115 of file CbcEventHandler.hpp.
Events known to cbc.
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. |
Definition at line 84 of file CbcEventHandler.hpp.
Action codes returned by the event handler.
Specific values are chosen to match ClpEventHandler return codes.
Definition at line 100 of file CbcEventHandler.hpp.
CbcEventHandler::CbcEventHandler | ( | const CbcModel * | model = NULL |
) |
Default constructor.
CbcEventHandler::CbcEventHandler | ( | const CbcEventHandler & | orig | ) |
Copy constructor.
virtual CbcEventHandler::~CbcEventHandler | ( | ) | [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.
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 162 of file CbcEventHandler.hpp.
const CbcModel* CbcEventHandler::getModel | ( | ) | const [inline] |
Get model.
Definition at line 167 of file CbcEventHandler.hpp.
void CbcEventHandler::setDfltAction | ( | CbcAction | action | ) | [inline] |
Set the default action.
Definition at line 172 of file CbcEventHandler.hpp.
Set the action code associated with an event.
Definition at line 177 of file CbcEventHandler.hpp.
const CbcModel* CbcEventHandler::model_ [protected] |
Pointer to associated CbcModel.
Definition at line 195 of file CbcEventHandler.hpp.
CbcAction CbcEventHandler::dfltAction_ [protected] |
Default action.
Definition at line 199 of file CbcEventHandler.hpp.
eaMapPair* CbcEventHandler::eaMap_ [protected] |
Pointer to a map that holds non-default event/action pairs.
Definition at line 203 of file CbcEventHandler.hpp.