PySCIPOpt  5.1.1
Python Interface for the SCIP Optimization Suite
event.pxi
Go to the documentation of this file.
1 
3 cdef class Eventhdlr:
4  cdef public Model model
5  cdef public str name
6 
7  def eventcopy(self):
8  '''sets copy callback for all events of this event handler '''
9  pass
10 
11  def eventfree(self):
12  '''calls destructor and frees memory of event handler '''
13  pass
14 
15  def eventinit(self):
16  '''initializes event handler'''
17  pass
18 
19  def eventexit(self):
20  '''calls exit method of event handler'''
21  pass
22 
23  def eventinitsol(self):
24  '''informs event handler that the branch and bound process is being started '''
25  pass
26 
27  def eventexitsol(self):
28  '''informs event handler that the branch and bound process data is being freed '''
29  pass
30 
31  def eventdelete(self):
32  '''sets callback to free specific event data'''
33  pass
34 
35  def eventexec(self, event):
36  '''calls execution method of event handler '''
37  print("python error in eventexec: this method needs to be implemented")
38  return {}
39 
40 
41 # local helper functions for the interface
42 cdef Eventhdlr getPyEventhdlr(SCIP_EVENTHDLR* eventhdlr) noexcept with gil:
43  cdef SCIP_EVENTHDLRDATA* eventhdlrdata
44  eventhdlrdata = SCIPeventhdlrGetData(eventhdlr)
45  return <Eventhdlr>eventhdlrdata
46 
47 cdef SCIP_RETCODE PyEventCopy (SCIP* scip, SCIP_EVENTHDLR* eventhdlr) noexcept with gil:
48  PyEventhdlr = getPyEventhdlr(eventhdlr)
49  PyEventhdlr.eventcopy()
50  return SCIP_OKAY
51 
52 cdef SCIP_RETCODE PyEventFree (SCIP* scip, SCIP_EVENTHDLR* eventhdlr) noexcept with gil:
53  PyEventhdlr = getPyEventhdlr(eventhdlr)
54  PyEventhdlr.eventfree()
55  Py_DECREF(PyEventhdlr)
56  return SCIP_OKAY
57 
58 cdef SCIP_RETCODE PyEventInit (SCIP* scip, SCIP_EVENTHDLR* eventhdlr) noexcept with gil:
59  PyEventhdlr = getPyEventhdlr(eventhdlr)
60  PyEventhdlr.eventinit()
61  return SCIP_OKAY
62 
63 cdef SCIP_RETCODE PyEventExit (SCIP* scip, SCIP_EVENTHDLR* eventhdlr) noexcept with gil:
64  PyEventhdlr = getPyEventhdlr(eventhdlr)
65  PyEventhdlr.eventexit()
66  return SCIP_OKAY
67 
68 cdef SCIP_RETCODE PyEventInitsol (SCIP* scip, SCIP_EVENTHDLR* eventhdlr) noexcept with gil:
69  PyEventhdlr = getPyEventhdlr(eventhdlr)
70  PyEventhdlr.eventinitsol()
71  return SCIP_OKAY
72 
73 cdef SCIP_RETCODE PyEventExitsol (SCIP* scip, SCIP_EVENTHDLR* eventhdlr) noexcept with gil:
74  PyEventhdlr = getPyEventhdlr(eventhdlr)
75  PyEventhdlr.eventexitsol()
76  return SCIP_OKAY
77 
78 cdef SCIP_RETCODE PyEventDelete (SCIP* scip, SCIP_EVENTHDLR* eventhdlr, SCIP_EVENTDATA** eventdata) noexcept with gil:
79  PyEventhdlr = getPyEventhdlr(eventhdlr)
80  PyEventhdlr.eventdelete()
81  return SCIP_OKAY
82 
83 cdef SCIP_RETCODE PyEventExec (SCIP* scip, SCIP_EVENTHDLR* eventhdlr, SCIP_EVENT* event, SCIP_EVENTDATA* eventdata) noexcept with gil:
84  PyEventhdlr = getPyEventhdlr(eventhdlr)
85  PyEvent = Event()
86  PyEvent.event = event
87  PyEventhdlr.eventexec(PyEvent)
88  return SCIP_OKAY
SCIPeventhdlrGetData
SCIP_EVENTHDLRDATA * SCIPeventhdlrGetData(SCIP_EVENTHDLR *eventhdlr)
pyscipopt.event.Eventhdlr.eventexec
def eventexec(self, event)
Definition: event.pxi:35
pyscipopt.event.Eventhdlr.eventfree
def eventfree(self)
Definition: event.pxi:11
pyscipopt.event.Eventhdlr.eventdelete
def eventdelete(self)
Definition: event.pxi:31
pyscipopt.event.Eventhdlr.eventinit
def eventinit(self)
Definition: event.pxi:15
pyscipopt.event.Eventhdlr.eventexitsol
def eventexitsol(self)
Definition: event.pxi:27
pyscipopt.event.Eventhdlr.eventcopy
def eventcopy(self)
Definition: event.pxi:7
pyscipopt.event.Eventhdlr.eventexit
def eventexit(self)
Definition: event.pxi:19
pyscipopt.event.Eventhdlr
Definition: event.pxi:3
pyscipopt.event.Eventhdlr.eventinitsol
def eventinitsol(self)
Definition: event.pxi:23