forked from scipopt/PySCIPOpt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpresol.pxi
93 lines (77 loc) · 3.37 KB
/
presol.pxi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
##@file presol.pxi
#@brief Base class of the Presolver Plugin
cdef class Presol:
cdef public Model model
def presolfree(self):
'''frees memory of presolver'''
pass
def presolinit(self):
'''initializes presolver'''
pass
def presolexit(self):
'''deinitializes presolver'''
pass
def presolinitpre(self):
'''informs presolver that the presolving process is being started'''
pass
def presolexitpre(self):
'''informs presolver that the presolving process is finished'''
pass
def presolexec(self, nrounds, presoltiming):
'''executes presolver'''
print("python error in presolexec: this method needs to be implemented")
return {}
cdef SCIP_RETCODE PyPresolCopy (SCIP* scip, SCIP_PRESOL* presol):
return SCIP_OKAY
cdef SCIP_RETCODE PyPresolFree (SCIP* scip, SCIP_PRESOL* presol):
cdef SCIP_PRESOLDATA* presoldata
presoldata = SCIPpresolGetData(presol)
PyPresol = <Presol>presoldata
PyPresol.presolfree()
Py_DECREF(PyPresol)
return SCIP_OKAY
cdef SCIP_RETCODE PyPresolInit (SCIP* scip, SCIP_PRESOL* presol):
cdef SCIP_PRESOLDATA* presoldata
presoldata = SCIPpresolGetData(presol)
PyPresol = <Presol>presoldata
PyPresol.presolinit()
return SCIP_OKAY
cdef SCIP_RETCODE PyPresolExit (SCIP* scip, SCIP_PRESOL* presol):
cdef SCIP_PRESOLDATA* presoldata
presoldata = SCIPpresolGetData(presol)
PyPresol = <Presol>presoldata
PyPresol.presolexit()
return SCIP_OKAY
cdef SCIP_RETCODE PyPresolInitpre (SCIP* scip, SCIP_PRESOL* presol):
cdef SCIP_PRESOLDATA* presoldata
presoldata = SCIPpresolGetData(presol)
PyPresol = <Presol>presoldata
PyPresol.presolinitpre()
return SCIP_OKAY
cdef SCIP_RETCODE PyPresolExitpre (SCIP* scip, SCIP_PRESOL* presol):
cdef SCIP_PRESOLDATA* presoldata
presoldata = SCIPpresolGetData(presol)
PyPresol = <Presol>presoldata
PyPresol.presolexitpre()
return SCIP_OKAY
cdef SCIP_RETCODE PyPresolExec (SCIP* scip, SCIP_PRESOL* presol, int nrounds, SCIP_PRESOLTIMING presoltiming,
int nnewfixedvars, int nnewaggrvars, int nnewchgvartypes, int nnewchgbds, int nnewholes,
int nnewdelconss, int nnewaddconss, int nnewupgdconss, int nnewchgcoefs, int nnewchgsides,
int* nfixedvars, int* naggrvars, int* nchgvartypes, int* nchgbds, int* naddholes,
int* ndelconss, int* naddconss, int* nupgdconss, int* nchgcoefs, int* nchgsides, SCIP_RESULT* result):
cdef SCIP_PRESOLDATA* presoldata
presoldata = SCIPpresolGetData(presol)
PyPresol = <Presol>presoldata
result_dict = PyPresol.presolexec(nrounds, presoltiming)
result[0] = result_dict.get("result", <SCIP_RESULT>result[0])
nfixedvars[0] += result_dict.get("nnewfixedvars", 0)
naggrvars[0] += result_dict.get("nnewaggrvars", 0)
nchgvartypes[0] += result_dict.get("nnewchgvartypes", 0)
nchgbds[0] += result_dict.get("nnewchgbds", 0)
naddholes[0] += result_dict.get("nnewaddholes", 0)
ndelconss[0] += result_dict.get("nnewdelconss", 0)
naddconss[0] += result_dict.get("nnewaddconss", 0)
nupgdconss[0] += result_dict.get("nnewupgdconss", 0)
nchgcoefs[0] += result_dict.get("nnewchgcoefs", 0)
nchgsides[0] += result_dict.get("nnewchgsides", 0)
return SCIP_OKAY