Cbc  2.9.9
CbcEventHandler.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2006, International Business Machines Corporation and others.
3  All Rights Reserved.
4 
5  This code is licensed under the terms of the Eclipse Public License (EPL).
6 
7  $Id: CbcEventHandler.hpp 1987 2013-11-29 17:27:29Z forrest $
8 */
9 
10 #ifndef CbcEventHandler_H
11 #define CbcEventHandler_H
12 
49 #include <cstddef>
50 #include <map>
51 
52 /* May well already be declared, but can't hurt. */
53 
54 class CbcModel ;
55 
56 /*
57  cvs/svn: $Id: CbcEventHandler.hpp 1987 2013-11-29 17:27:29Z forrest $
58 */
59 
83 
84 public:
85 
88  enum CbcEvent {
89  node = 200,
109  endSearch
110  } ;
111 
117  enum CbcAction {
118  noAction = -1,
120  stop = 0,
132  takeAction
133 
134  } ;
135 
138  typedef std::map<CbcEvent, CbcAction> eaMapPair ;
139 
140 
143 
150  virtual CbcAction event(CbcEvent whichEvent) ;
151 
158  virtual CbcAction event(CbcEvent whichEvent, void * data) ;
159 
161 
162 
165 
168  CbcEventHandler(CbcModel *model = 0 /* was NULL but 4.6 complains */) ;
169 
173 
177 
180  virtual CbcEventHandler* clone() const ;
181 
184  virtual ~CbcEventHandler() ;
185 
187 
190 
193  inline void setModel(CbcModel *model) {
194  model_ = model ;
195  }
196 
199  inline const CbcModel* getModel() const {
200  return model_ ;
201  }
202 
205  inline void setDfltAction(CbcAction action) {
206  dfltAction_ = action ;
207  }
208 
211  inline void setAction(CbcEvent event, CbcAction action) {
212  if (eaMap_ == 0) {
213  eaMap_ = new eaMapPair ;
214  }
215  (*eaMap_)[event] = action ;
216  }
217 
219 
220 
221 protected:
222 
228 
232 
236 
240 
242 } ;
243 
244 #endif
245 
CbcEventHandler::setAction
void setAction(CbcEvent event, CbcAction action)
Set the action code associated with an event.
Definition: CbcEventHandler.hpp:211
CbcEventHandler::smallBranchAndBound
@ smallBranchAndBound
On entry to small branch and bound.
Definition: CbcEventHandler.hpp:103
CbcEventHandler::takeAction
@ takeAction
Take action on modified data.
Definition: CbcEventHandler.hpp:132
CbcEventHandler::event
virtual CbcAction event(CbcEvent whichEvent)
Return the action to be taken for an event.
CbcEventHandler::eaMapPair
std::map< CbcEvent, CbcAction > eaMapPair
Data type for event/action pairs.
Definition: CbcEventHandler.hpp:138
CbcEventHandler::clone
virtual CbcEventHandler * clone() const
Clone (virtual) constructor.
CbcEventHandler::CbcEventHandler
CbcEventHandler(CbcModel *model=0)
Default constructor.
CbcEventHandler::operator=
CbcEventHandler & operator=(const CbcEventHandler &rhs)
Assignment.
CbcEventHandler::killSolution
@ killSolution
Pretend solution never happened.
Definition: CbcEventHandler.hpp:130
CbcEventHandler::setModel
void setModel(CbcModel *model)
Set model.
Definition: CbcEventHandler.hpp:193
CbcEventHandler::model_
CbcModel * model_
Pointer to associated CbcModel.
Definition: CbcEventHandler.hpp:231
CbcEventHandler::eaMap_
eaMapPair * eaMap_
Pointer to a map that holds non-default event/action pairs.
Definition: CbcEventHandler.hpp:239
CbcEventHandler::endSearch
@ endSearch
End of search.
Definition: CbcEventHandler.hpp:109
CbcEventHandler::restartRoot
@ restartRoot
RestartRoot — undo root node and start branch-and-cut afresh.
Definition: CbcEventHandler.hpp:126
CbcModel
Simple Branch and bound class.
Definition: CbcModel.hpp:101
CbcEventHandler::treeStatus
@ treeStatus
A tree status interval has arrived.
Definition: CbcEventHandler.hpp:91
CbcEventHandler
Base class for Cbc event handling.
Definition: CbcEventHandler.hpp:82
CbcEventHandler::~CbcEventHandler
virtual ~CbcEventHandler()
Destructor.
CbcEventHandler::heuristicPass
@ heuristicPass
After a pass of heuristic.
Definition: CbcEventHandler.hpp:105
CbcEventHandler::CbcAction
CbcAction
Action codes returned by the event handler.
Definition: CbcEventHandler.hpp:117
CbcEventHandler::CbcEventHandler
CbcEventHandler(const CbcEventHandler &orig)
Copy constructor.
CbcEventHandler::event
virtual CbcAction event(CbcEvent whichEvent, void *data)
Return the action to be taken for an event - and modify data.
CbcEventHandler::restart
@ restart
Restart — restart branch-and-cut search; do not undo root node processing.
Definition: CbcEventHandler.hpp:124
CbcEventHandler::addCuts
@ addCuts
Add special cuts.
Definition: CbcEventHandler.hpp:128
CbcEventHandler::dfltAction_
CbcAction dfltAction_
Default action.
Definition: CbcEventHandler.hpp:235
CbcEventHandler::beforeSolution2
@ beforeSolution2
A solution will be found unless user takes action (thorough check).
Definition: CbcEventHandler.hpp:99
CbcEventHandler::node
@ node
Processing of the current node is complete.
Definition: CbcEventHandler.hpp:89
CbcEventHandler::afterHeuristic
@ afterHeuristic
After failed heuristic.
Definition: CbcEventHandler.hpp:101
CbcEventHandler::CbcEvent
CbcEvent
Events known to cbc.
Definition: CbcEventHandler.hpp:88
CbcEventHandler::convertToCuts
@ convertToCuts
When converting constraints to cuts.
Definition: CbcEventHandler.hpp:107
CbcEventHandler::beforeSolution1
@ beforeSolution1
A solution will be found unless user takes action (first check).
Definition: CbcEventHandler.hpp:97
CbcEventHandler::heuristicSolution
@ heuristicSolution
A heuristic solution has been found.
Definition: CbcEventHandler.hpp:95
CbcEventHandler::stop
@ stop
Stop — abort the current run at the next opportunity.
Definition: CbcEventHandler.hpp:120
CbcEventHandler::setDfltAction
void setDfltAction(CbcAction action)
Set the default action.
Definition: CbcEventHandler.hpp:205
CbcEventHandler::noAction
@ noAction
Continue — no action required.
Definition: CbcEventHandler.hpp:118
CbcEventHandler::getModel
const CbcModel * getModel() const
Get model.
Definition: CbcEventHandler.hpp:199
CbcEventHandler::solution
@ solution
A solution has been found.
Definition: CbcEventHandler.hpp:93