PySCIPOpt
Python Interface to the SCIP Optimization Suite
branchrule.pxi
Go to the documentation of this file.
1 ##@file branchrule.pxi
2 #@brief Base class of the Branchrule Plugin
3 cdef class Branchrule:
4  cdef public Model model
5 
6  def branchfree(self):
7  '''frees memory of branching rule'''
8  pass
9 
10  def branchinit(self):
11  '''initializes branching rule'''
12  pass
13 
14  def branchexit(self):
15  '''deinitializes branching rule'''
16  pass
17 
18  def branchinitsol(self):
19  '''informs branching rule that the branch and bound process is being started '''
20  pass
21 
22  def branchexitsol(self):
23  '''informs branching rule that the branch and bound process data is being freed'''
24  pass
25 
26  def branchexeclp(self, allowaddcons):
27  '''executes branching rule for fractional LP solution'''
28  # this method needs to be implemented by the user
29  return {}
30 
31  def branchexecext(self, allowaddcons):
32  '''executes branching rule for external branching candidates '''
33  # this method needs to be implemented by the user
34  return {}
35 
36  def branchexecps(self, allowaddcons):
37  '''executes branching rule for not completely fixed pseudo solution '''
38  # this method needs to be implemented by the user
39  return {}
40 
41 
42 
43 cdef SCIP_RETCODE PyBranchruleCopy (SCIP* scip, SCIP_BRANCHRULE* branchrule):
44  return SCIP_OKAY
45 
46 cdef SCIP_RETCODE PyBranchruleFree (SCIP* scip, SCIP_BRANCHRULE* branchrule):
47  cdef SCIP_BRANCHRULEDATA* branchruledata
48  branchruledata = SCIPbranchruleGetData(branchrule)
49  PyBranchrule = <Branchrule>branchruledata
50  PyBranchrule.branchfree()
51  Py_DECREF(PyBranchrule)
52  return SCIP_OKAY
53 
54 cdef SCIP_RETCODE PyBranchruleInit (SCIP* scip, SCIP_BRANCHRULE* branchrule):
55  cdef SCIP_BRANCHRULEDATA* branchruledata
56  branchruledata = SCIPbranchruleGetData(branchrule)
57  PyBranchrule = <Branchrule>branchruledata
58  PyBranchrule.branchinit()
59  return SCIP_OKAY
60 
61 cdef SCIP_RETCODE PyBranchruleExit (SCIP* scip, SCIP_BRANCHRULE* branchrule):
62  cdef SCIP_BRANCHRULEDATA* branchruledata
63  branchruledata = SCIPbranchruleGetData(branchrule)
64  PyBranchrule = <Branchrule>branchruledata
65  PyBranchrule.branchexit()
66  return SCIP_OKAY
67 
68 cdef SCIP_RETCODE PyBranchruleInitsol (SCIP* scip, SCIP_BRANCHRULE* branchrule):
69  cdef SCIP_BRANCHRULEDATA* branchruledata
70  branchruledata = SCIPbranchruleGetData(branchrule)
71  PyBranchrule = <Branchrule>branchruledata
72  PyBranchrule.branchinitsol()
73  return SCIP_OKAY
74 
75 cdef SCIP_RETCODE PyBranchruleExitsol (SCIP* scip, SCIP_BRANCHRULE* branchrule):
76  cdef SCIP_BRANCHRULEDATA* branchruledata
77  branchruledata = SCIPbranchruleGetData(branchrule)
78  PyBranchrule = <Branchrule>branchruledata
79  PyBranchrule.branchexitsol()
80  return SCIP_OKAY
81 
82 cdef SCIP_RETCODE PyBranchruleExeclp (SCIP* scip, SCIP_BRANCHRULE* branchrule, SCIP_Bool allowaddcons, SCIP_RESULT* result):
83  cdef SCIP_BRANCHRULEDATA* branchruledata
84  branchruledata = SCIPbranchruleGetData(branchrule)
85  PyBranchrule = <Branchrule>branchruledata
86  result_dict = PyBranchrule.branchexeclp(allowaddcons)
87  result[0] = result_dict.get("result", <SCIP_RESULT>result[0])
88  return SCIP_OKAY
89 
90 cdef SCIP_RETCODE PyBranchruleExecext(SCIP* scip, SCIP_BRANCHRULE* branchrule, SCIP_Bool allowaddcons, SCIP_RESULT* result):
91  cdef SCIP_BRANCHRULEDATA* branchruledata
92  branchruledata = SCIPbranchruleGetData(branchrule)
93  PyBranchrule = <Branchrule>branchruledata
94  result_dict = PyBranchrule.branchexecext(allowaddcons)
95  result[0] = result_dict.get("result", <SCIP_RESULT>result[0])
96  return SCIP_OKAY
97 
98 cdef SCIP_RETCODE PyBranchruleExecps(SCIP* scip, SCIP_BRANCHRULE* branchrule, SCIP_Bool allowaddcons, SCIP_RESULT* result):
99  cdef SCIP_BRANCHRULEDATA* branchruledata
100  branchruledata = SCIPbranchruleGetData(branchrule)
101  PyBranchrule = <Branchrule>branchruledata
102  result_dict = PyBranchrule.branchexecps(allowaddcons)
103  result[0] = result_dict.get("result", <SCIP_RESULT>result[0])
104  return SCIP_OKAY
SCIP_BRANCHRULEDATA * SCIPbranchruleGetData(SCIP_BRANCHRULE *branchrule)