PySCIPOpt  5.1.1
Python Interface for the SCIP Optimization Suite
propagator.pxi
Go to the documentation of this file.
1 
3 cdef class Prop:
4  cdef public Model model
5 
6  def propfree(self):
7  '''calls destructor and frees memory of propagator'''
8  pass
9 
10  def propinit(self):
11  '''initializes propagator'''
12  pass
13 
14  def propexit(self):
15  '''calls exit method of propagator'''
16  pass
17 
18  def propinitsol(self):
19  '''informs propagator that the prop and bound process is being started'''
20  pass
21 
22  def propexitsol(self, restart):
23  '''informs propagator that the prop and bound process data is being freed'''
24  pass
25 
26  def propinitpre(self):
27  '''informs propagator that the presolving process is being started'''
28  pass
29 
30  def propexitpre(self):
31  '''informs propagator that the presolving process is finished'''
32  pass
33 
34  def proppresol(self, nrounds, presoltiming, result_dict):
35  '''executes presolving method of propagator'''
36  pass
37 
38  def propexec(self, proptiming):
39  '''calls execution method of propagator'''
40  print("python error in propexec: this method needs to be implemented")
41  return {}
42 
43  def propresprop(self, confvar, inferinfo, bdtype, relaxedbd):
44  '''resolves the given conflicting bound, that was reduced by the given propagator'''
45  print("python error in propresprop: this method needs to be implemented")
46  return {}
47 
48 
49 
50 cdef SCIP_RETCODE PyPropCopy (SCIP* scip, SCIP_PROP* prop) noexcept with gil:
51  return SCIP_OKAY
52 
53 cdef SCIP_RETCODE PyPropFree (SCIP* scip, SCIP_PROP* prop) noexcept with gil:
54  cdef SCIP_PROPDATA* propdata
55  propdata = SCIPpropGetData(prop)
56  PyProp = <Prop>propdata
57  PyProp.propfree()
58  Py_DECREF(PyProp)
59  return SCIP_OKAY
60 
61 cdef SCIP_RETCODE PyPropInit (SCIP* scip, SCIP_PROP* prop) noexcept with gil:
62  cdef SCIP_PROPDATA* propdata
63  propdata = SCIPpropGetData(prop)
64  PyProp = <Prop>propdata
65  PyProp.propinit()
66  return SCIP_OKAY
67 
68 cdef SCIP_RETCODE PyPropExit (SCIP* scip, SCIP_PROP* prop) noexcept with gil:
69  cdef SCIP_PROPDATA* propdata
70  propdata = SCIPpropGetData(prop)
71  PyProp = <Prop>propdata
72  PyProp.propexit()
73  return SCIP_OKAY
74 
75 cdef SCIP_RETCODE PyPropInitpre (SCIP* scip, SCIP_PROP* prop) noexcept with gil:
76  cdef SCIP_PROPDATA* propdata
77  propdata = SCIPpropGetData(prop)
78  PyProp = <Prop>propdata
79  PyProp.propinitpre()
80  return SCIP_OKAY
81 
82 cdef SCIP_RETCODE PyPropExitpre (SCIP* scip, SCIP_PROP* prop) noexcept with gil:
83  cdef SCIP_PROPDATA* propdata
84  propdata = SCIPpropGetData(prop)
85  PyProp = <Prop>propdata
86  PyProp.propexitpre()
87  return SCIP_OKAY
88 
89 cdef SCIP_RETCODE PyPropInitsol (SCIP* scip, SCIP_PROP* prop) noexcept with gil:
90  cdef SCIP_PROPDATA* propdata
91  propdata = SCIPpropGetData(prop)
92  PyProp = <Prop>propdata
93  PyProp.propinitsol()
94  return SCIP_OKAY
95 
96 cdef SCIP_RETCODE PyPropExitsol (SCIP* scip, SCIP_PROP* prop, SCIP_Bool restart) noexcept with gil:
97  cdef SCIP_PROPDATA* propdata
98  propdata = SCIPpropGetData(prop)
99  PyProp = <Prop>propdata
100  PyProp.propexitsol(restart)
101  return SCIP_OKAY
102 
103 cdef SCIP_RETCODE PyPropPresol (SCIP* scip, SCIP_PROP* prop, int nrounds, SCIP_PRESOLTIMING presoltiming,
104  int nnewfixedvars, int nnewaggrvars, int nnewchgvartypes, int nnewchgbds, int nnewholes,
105  int nnewdelconss, int nnewaddconss, int nnewupgdconss, int nnewchgcoefs, int nnewchgsides,
106  int* nfixedvars, int* naggrvars, int* nchgvartypes, int* nchgbds, int* naddholes,
107  int* ndelconss, int* naddconss, int* nupgdconss, int* nchgcoefs, int* nchgsides, SCIP_RESULT* result) noexcept with gil:
108  cdef SCIP_PROPDATA* propdata
109  propdata = SCIPpropGetData(prop)
110  PyProp = <Prop>propdata
111  # dictionary for input/output parameters
112  result_dict = {}
113  result_dict["nfixedvars"] = nfixedvars[0]
114  result_dict["naggrvars"] = naggrvars[0]
115  result_dict["nchgvartypes"] = nchgvartypes[0]
116  result_dict["nchgbds"] = nchgbds[0]
117  result_dict["naddholes"] = naddholes[0]
118  result_dict["ndelconss"] = ndelconss[0]
119  result_dict["naddconss"] = naddconss[0]
120  result_dict["nupgdconss"] = nupgdconss[0]
121  result_dict["nchgcoefs"] = nchgcoefs[0]
122  result_dict["nchgsides"] = nchgsides[0]
123  result_dict["result"] = result[0]
124  PyProp.proppresol(nrounds, presoltiming,
125  nnewfixedvars, nnewaggrvars, nnewchgvartypes, nnewchgbds, nnewholes,
126  nnewdelconss, nnewaddconss, nnewupgdconss, nnewchgcoefs, nnewchgsides, result_dict)
127  result[0] = result_dict["result"]
128  nfixedvars[0] = result_dict["nfixedvars"]
129  naggrvars[0] = result_dict["naggrvars"]
130  nchgvartypes[0] = result_dict["nchgvartypes"]
131  nchgbds[0] = result_dict["nchgbds"]
132  naddholes[0] = result_dict["naddholes"]
133  ndelconss[0] = result_dict["ndelconss"]
134  naddconss[0] = result_dict["naddconss"]
135  nupgdconss[0] = result_dict["nupgdconss"]
136  nchgcoefs[0] = result_dict["nchgcoefs"]
137  nchgsides[0] = result_dict["nchgsides"]
138  return SCIP_OKAY
139 
140 cdef SCIP_RETCODE PyPropExec (SCIP* scip, SCIP_PROP* prop, SCIP_PROPTIMING proptiming, SCIP_RESULT* result) noexcept with gil:
141  cdef SCIP_PROPDATA* propdata
142  propdata = SCIPpropGetData(prop)
143  PyProp = <Prop>propdata
144  returnvalues = PyProp.propexec(proptiming)
145  result_dict = returnvalues
146  result[0] = result_dict.get("result", <SCIP_RESULT>result[0])
147  return SCIP_OKAY
148 
149 cdef SCIP_RETCODE PyPropResProp (SCIP* scip, SCIP_PROP* prop, SCIP_VAR* infervar, int inferinfo,
150  SCIP_BOUNDTYPE boundtype, SCIP_BDCHGIDX* bdchgidx, SCIP_Real relaxedbd, SCIP_RESULT* result) noexcept with gil:
151  cdef SCIP_PROPDATA* propdata
152  cdef SCIP_VAR* tmp
153  tmp = infervar
154  propdata = SCIPpropGetData(prop)
155  confvar = Variable.create(tmp)
156 
157  #TODO: parse bdchgidx?
158 
159  PyProp = <Prop>propdata
160  returnvalues = PyProp.propresprop(confvar, inferinfo, boundtype, relaxedbd)
161  result_dict = returnvalues
162  result[0] = result_dict.get("result", <SCIP_RESULT>result[0])
163  return SCIP_OKAY
pyscipopt.propagator.propexitpre
def propexitpre(self)
Definition: propagator.pxi:30
pyscipopt.propagator.Prop
Definition: propagator.pxi:3
pyscipopt.propagator.propexit
def propexit(self)
Definition: propagator.pxi:14
pyscipopt.propagator.propinit
def propinit(self)
Definition: propagator.pxi:10
pyscipopt.propagator.proppresol
def proppresol(self, nrounds, presoltiming, result_dict)
Definition: propagator.pxi:34
pyscipopt.propagator.propexec
def propexec(self, proptiming)
Definition: propagator.pxi:38
pyscipopt.propagator.propinitpre
def propinitpre(self)
Definition: propagator.pxi:26
pyscipopt.propagator.propexitsol
def propexitsol(self, restart)
Definition: propagator.pxi:22
pyscipopt.propagator.propinitsol
def propinitsol(self)
Definition: propagator.pxi:18
pyscipopt.propagator.propresprop
def propresprop(self, confvar, inferinfo, bdtype, relaxedbd)
Definition: propagator.pxi:43
SCIPpropGetData
SCIP_PROPDATA * SCIPpropGetData(SCIP_PROP *prop)
pyscipopt.propagator.propfree
def propfree(self)
Definition: propagator.pxi:6