Cbc 2.10.12
Loading...
Searching...
No Matches
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$
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
54class CbcModel;
55
56/*
57 cvs/svn: $Id$
58*/
59
83
84public:
114
138
141 typedef std::map< CbcEvent, CbcAction > eaMapPair;
142
145
152 virtual CbcAction event(CbcEvent whichEvent);
153
160 virtual CbcAction event(CbcEvent whichEvent, void *data);
161
163
166
169 CbcEventHandler(CbcModel *model = 0 /* was NULL but 4.6 complains */);
170
174
178
181 virtual CbcEventHandler *clone() const;
182
186
188
191
194 inline void setModel(CbcModel *model)
195 {
196 model_ = model;
197 }
198
201 inline const CbcModel *getModel() const
202 {
203 return model_;
204 }
205
208 inline void setDfltAction(CbcAction action)
209 {
210 dfltAction_ = action;
211 }
212
215 inline void setAction(CbcEvent event, CbcAction action)
216 {
217 if (eaMap_ == 0) {
218 eaMap_ = new eaMapPair;
219 }
220 (*eaMap_)[event] = action;
221 }
222
224
225protected:
231
235
239
243
245};
246
247#endif
248
249/* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
250*/
Base class for Cbc event handling.
void setDfltAction(CbcAction action)
Set the default action.
std::map< CbcEvent, CbcAction > eaMapPair
Data type for event/action pairs.
CbcAction
Action codes returned by the event handler.
@ restartRoot
RestartRoot — undo root node and start branch-and-cut afresh.
@ noAction
Continue — no action required.
@ takeAction
Take action on modified data.
@ restart
Restart — restart branch-and-cut search; do not undo root node processing.
@ killSolution
Pretend solution never happened.
@ stop
Stop — abort the current run at the next opportunity.
@ addCuts
Add special cuts.
void setAction(CbcEvent event, CbcAction action)
Set the action code associated with an event.
virtual CbcEventHandler * clone() const
Clone (virtual) constructor.
virtual ~CbcEventHandler()
Destructor.
CbcEventHandler(CbcModel *model=0)
Default constructor.
const CbcModel * getModel() const
Get model.
virtual CbcAction event(CbcEvent whichEvent, void *data)
Return the action to be taken for an event - and modify data.
CbcEventHandler(const CbcEventHandler &orig)
Copy constructor.
void setModel(CbcModel *model)
Set model.
CbcEvent
Events known to cbc.
@ beforeSolution1
A solution will be found unless user takes action (first check).
@ afterHeuristic
After failed heuristic.
@ smallBranchAndBound
On entry to small branch and bound.
@ node
Processing of the current node is complete.
@ solution
A solution has been found.
@ convertToCuts
When converting constraints to cuts.
@ afterRootCuts
Just before starting branching i.e.
@ beforeSolution2
A solution will be found unless user takes action (thorough check).
@ endSearch
End of search.
@ treeStatus
A tree status interval has arrived.
@ heuristicSolution
A heuristic solution has been found.
@ generatedCuts
Having generated cuts, allows user to think.
@ heuristicPass
After a pass of heuristic.
virtual CbcAction event(CbcEvent whichEvent)
Return the action to be taken for an event.
CbcAction dfltAction_
Default action.
CbcEventHandler & operator=(const CbcEventHandler &rhs)
Assignment.
eaMapPair * eaMap_
Pointer to a map that holds non-default event/action pairs.
CbcModel * model_
Pointer to associated CbcModel.
Simple Branch and bound class.
Definition CbcModel.hpp:100