PySCIPOpt  5.1.1
Python Interface for the SCIP Optimization Suite
nodesel.pxi
Go to the documentation of this file.
1 
3 cdef class Nodesel:
4  cdef public Model model
5 
6  def nodefree(self):
7  '''frees memory of node selector'''
8  pass
9 
10  def nodeinit(self):
11  ''' executed after the problem is transformed. use this call to initialize node selector data.'''
12  pass
13 
14  def nodeexit(self):
15  '''executed before the transformed problem is freed'''
16  pass
17 
18  def nodeinitsol(self):
19  '''executed when the presolving is finished and the branch-and-bound process is about to begin'''
20  pass
21 
22  def nodeexitsol(self):
23  '''executed before the branch-and-bound process is freed'''
24  pass
25 
26  def nodeselect(self):
27  '''first method called in each iteration in the main solving loop. '''
28  # this method needs to be implemented by the user
29  return {}
30 
31  def nodecomp(self, node1, node2):
32  '''
33  compare two leaves of the current branching tree
34 
35  It should return the following values:
36 
37  value < 0, if node 1 comes before (is better than) node 2
38  value = 0, if both nodes are equally good
39  value > 0, if node 1 comes after (is worse than) node 2.
40  '''
41  # this method needs to be implemented by the user
42  return 0
43 
44 
45 cdef SCIP_RETCODE PyNodeselCopy (SCIP* scip, SCIP_NODESEL* nodesel) noexcept with gil:
46  return SCIP_OKAY
47 
48 cdef SCIP_RETCODE PyNodeselFree (SCIP* scip, SCIP_NODESEL* nodesel) noexcept with gil:
49  cdef SCIP_NODESELDATA* nodeseldata
50  nodeseldata = SCIPnodeselGetData(nodesel)
51  PyNodesel = <Nodesel>nodeseldata
52  PyNodesel.nodefree()
53  Py_DECREF(PyNodesel)
54  return SCIP_OKAY
55 
56 cdef SCIP_RETCODE PyNodeselInit (SCIP* scip, SCIP_NODESEL* nodesel) noexcept with gil:
57  cdef SCIP_NODESELDATA* nodeseldata
58  nodeseldata = SCIPnodeselGetData(nodesel)
59  PyNodesel = <Nodesel>nodeseldata
60  PyNodesel.nodeinit()
61  return SCIP_OKAY
62 
63 
64 cdef SCIP_RETCODE PyNodeselExit (SCIP* scip, SCIP_NODESEL* nodesel) noexcept with gil:
65  cdef SCIP_NODESELDATA* nodeseldata
66  nodeseldata = SCIPnodeselGetData(nodesel)
67  PyNodesel = <Nodesel>nodeseldata
68  PyNodesel.nodeexit()
69  return SCIP_OKAY
70 
71 cdef SCIP_RETCODE PyNodeselInitsol (SCIP* scip, SCIP_NODESEL* nodesel) noexcept with gil:
72  cdef SCIP_NODESELDATA* nodeseldata
73  nodeseldata = SCIPnodeselGetData(nodesel)
74  PyNodesel = <Nodesel>nodeseldata
75  PyNodesel.nodeinitsol()
76  return SCIP_OKAY
77 
78 cdef SCIP_RETCODE PyNodeselExitsol (SCIP* scip, SCIP_NODESEL* nodesel) noexcept with gil:
79  cdef SCIP_NODESELDATA* nodeseldata
80  nodeseldata = SCIPnodeselGetData(nodesel)
81  PyNodesel = <Nodesel>nodeseldata
82  PyNodesel.nodeexitsol()
83  return SCIP_OKAY
84 
85 cdef SCIP_RETCODE PyNodeselSelect (SCIP* scip, SCIP_NODESEL* nodesel, SCIP_NODE** selnode) noexcept with gil:
86  cdef SCIP_NODESELDATA* nodeseldata
87  nodeseldata = SCIPnodeselGetData(nodesel)
88  PyNodesel = <Nodesel>nodeseldata
89  result_dict = PyNodesel.nodeselect()
90  selected_node = <Node>(result_dict.get("selnode", None))
91  selnode[0] = selected_node.scip_node
92  return SCIP_OKAY
93 
94 cdef int PyNodeselComp (SCIP* scip, SCIP_NODESEL* nodesel, SCIP_NODE* node1, SCIP_NODE* node2) noexcept with gil:
95  cdef SCIP_NODESELDATA* nodeseldata
96  nodeseldata = SCIPnodeselGetData(nodesel)
97  PyNodesel = <Nodesel>nodeseldata
98  n1 = Node.create(node1)
99  n2 = Node.create(node2)
100  result = PyNodesel.nodecomp(n1, n2) #
101  return result
pyscipopt.nodesel.Nodesel
Definition: nodesel.pxi:3
pyscipopt.nodesel.Nodesel.nodeselect
def nodeselect(self)
Definition: nodesel.pxi:26
pyscipopt.nodesel.Nodesel.nodeinitsol
def nodeinitsol(self)
Definition: nodesel.pxi:18
pyscipopt.nodesel.Nodesel.nodeexit
def nodeexit(self)
Definition: nodesel.pxi:14
pyscipopt.nodesel.Nodesel.nodefree
def nodefree(self)
Definition: nodesel.pxi:6
SCIPnodeselGetData
SCIP_NODESELDATA * SCIPnodeselGetData(SCIP_NODESEL *nodesel)
pyscipopt.nodesel.Nodesel.nodecomp
def nodecomp(self, node1, node2)
Definition: nodesel.pxi:31
pyscipopt.nodesel.Nodesel.nodeexitsol
def nodeexitsol(self)
Definition: nodesel.pxi:22
pyscipopt.nodesel.Nodesel.nodeinit
def nodeinit(self)
Definition: nodesel.pxi:10