Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
|
#include <gscip_event_handler.h>
Public Member Functions | |
GScipEventHandler (const GScipEventHandlerDescription &description) | |
GScipEventHandler (const GScipEventHandler &)=delete | |
GScipEventHandler & | operator= (const GScipEventHandler &)=delete |
virtual | ~GScipEventHandler ()=default |
absl::Status | Register (GScip *gscip) |
virtual SCIP_RETCODE | Init (GScip *gscip) |
virtual SCIP_RETCODE | Execute (GScipEventHandlerContext context) |
virtual SCIP_RETCODE | Exit (GScip *gscip) |
Protected Member Functions | |
SCIP_RETCODE | CatchEvent (SCIP_EVENTTYPE event_type) |
Friends | |
SCIP_RETCODE | DropAllEvents (GScipEventHandler &handler) |
Inherit from this to implement the callback and override Init() to call CatchEvent() for the events you want to listen to.
Usage:
class MyHandler : public GScipEventHandler { public: MyHandler() : GScipEventHandler({ .name = "my handler", .description = "something"}) {}
};
std::unique_ptr<GScip> gscip = ...;
MyHandler handler; handler.Register(gscip.get());
Definition at line 93 of file gscip_event_handler.h.
|
inlineexplicit |
Definition at line 95 of file gscip_event_handler.h.
|
delete |
|
virtualdefault |
|
protected |
Catches a global event (i.e. not a variable or row dependent one) based on the input event_type mask.
This method must only be called after the problem is transformed; typically it is called in the Init() virtual method.
Caught events will be automatically dropped when the handler will be called on EXIT (before calling the corresponding Exit() member function).
See scip/type_event.h for the list of possible events. This function corresponds to SCIPcatchEvent().
Definition at line 121 of file gscip_event_handler.cc.
|
inlinevirtual |
Called when a caught event is emitted.
Return SCIP_OKAY, or use SCIP_CALL macro to wraps SCIP calls to properly propagate errors.
Definition at line 126 of file gscip_event_handler.h.
|
inlinevirtual |
Deinitialization of the event handler.
Called before the transformed problem is freed and after all the events specified in CatchEvent() have been dropped (thus there is no need to implement this function to drop these events since this would have already been done).
Return SCIP_OKAY, or use SCIP_CALL macro to wraps SCIP calls to properly propagate errors.
Definition at line 139 of file gscip_event_handler.h.
|
inlinevirtual |
Initialization of the event handler. Called after the problem was transformed.
The implementation should use the CatchEvent() method to register to global events.
Return SCIP_OKAY, or use SCIP_CALL macro to wraps SCIP calls to properly propagate errors.
Definition at line 120 of file gscip_event_handler.h.
|
delete |
absl::Status operations_research::GScipEventHandler::Register | ( | GScip * | gscip | ) |
Registers this event handler to the given GScip.
This function returns an internal Status error if this handler has already been registered.
The given GScip won't own this handler but will keep a pointer to it that will be used during the solve.
event_handler_data is freed in EventFree.
This is only defensive: SCIP should return a SCIP error above instead.
Definition at line 92 of file gscip_event_handler.cc.
|
friend |
Calls SCIPdropEvent() for all events in caught_events_ and clear this collection.
This is not a member function since it needs to be visible to the SCIP Exit callback function.
Definition at line 133 of file gscip_event_handler.cc.