4 cdef public Model model
6 cdef SCIP_BENDERS* _benders
9 '''calls destructor and frees memory of Benders decomposition '''
13 '''initializes Benders deconposition'''
17 '''calls exit method of Benders decomposition'''
21 '''informs the Benders decomposition that the presolving process is being started '''
25 '''informs the Benders decomposition that the presolving process has been completed'''
29 '''informs Benders decomposition that the branch and bound process is being started '''
33 '''informs Benders decomposition that the branch and bound process data is being freed'''
37 '''creates the subproblems and registers it with the Benders decomposition struct '''
38 print(
"python error in benderscreatesub: this method needs to be implemented")
42 '''sets the pre subproblem solve callback of Benders decomposition '''
46 '''sets convex solve callback of Benders decomposition'''
50 '''sets solve callback of Benders decomposition '''
53 def benderspostsolve(self, solution, enfotype, mergecandidates, npriomergecands, checkint, infeasible):
54 '''sets post-solve callback of Benders decomposition '''
58 '''frees the subproblems'''
62 '''Returns the corresponding master or subproblem variable for the given variable. This provides a call back for the variable mapping between the master and subproblems. '''
63 print(
"python error in bendersgetvar: this method needs to be implemented")
67 cdef Variable getPyVar(SCIP_VAR* var):
68 cdef SCIP_VARDATA* vardata
70 return <Variable>vardata
73 cdef SCIP_RETCODE PyBendersCopy (SCIP* scip, SCIP_BENDERS* benders, SCIP_Bool threadsafe) noexcept
with gil:
76 cdef SCIP_RETCODE PyBendersFree (SCIP* scip, SCIP_BENDERS* benders) noexcept
with gil:
77 cdef SCIP_BENDERSDATA* bendersdata
79 PyBenders = <Benders>bendersdata
80 PyBenders.bendersfree()
84 cdef SCIP_RETCODE PyBendersInit (SCIP* scip, SCIP_BENDERS* benders) noexcept
with gil:
85 cdef SCIP_BENDERSDATA* bendersdata
87 PyBenders = <Benders>bendersdata
88 PyBenders.bendersinit()
91 cdef SCIP_RETCODE PyBendersExit (SCIP* scip, SCIP_BENDERS* benders) noexcept
with gil:
92 cdef SCIP_BENDERSDATA* bendersdata
94 PyBenders = <Benders>bendersdata
95 PyBenders.bendersexit()
98 cdef SCIP_RETCODE PyBendersInitpre (SCIP* scip, SCIP_BENDERS* benders) noexcept
with gil:
99 cdef SCIP_BENDERSDATA* bendersdata
101 PyBenders = <Benders>bendersdata
102 PyBenders.bendersinitpre()
105 cdef SCIP_RETCODE PyBendersExitpre (SCIP* scip, SCIP_BENDERS* benders) noexcept
with gil:
106 cdef SCIP_BENDERSDATA* bendersdata
108 PyBenders = <Benders>bendersdata
109 PyBenders.bendersexitpre()
112 cdef SCIP_RETCODE PyBendersInitsol (SCIP* scip, SCIP_BENDERS* benders) noexcept
with gil:
113 cdef SCIP_BENDERSDATA* bendersdata
115 PyBenders = <Benders>bendersdata
116 PyBenders.bendersinitsol()
119 cdef SCIP_RETCODE PyBendersExitsol (SCIP* scip, SCIP_BENDERS* benders) noexcept
with gil:
120 cdef SCIP_BENDERSDATA* bendersdata
122 PyBenders = <Benders>bendersdata
123 PyBenders.bendersexitsol()
126 cdef SCIP_RETCODE PyBendersCreatesub (SCIP* scip, SCIP_BENDERS* benders, int probnumber) noexcept
with gil:
127 cdef SCIP_BENDERSDATA* bendersdata
129 PyBenders = <Benders>bendersdata
130 PyBenders.benderscreatesub(probnumber)
133 cdef SCIP_RETCODE PyBendersPresubsolve (SCIP* scip, SCIP_BENDERS* benders, SCIP_SOL* sol, SCIP_BENDERSENFOTYPE type, SCIP_Bool checkint, SCIP_Bool* infeasible, SCIP_Bool* auxviol, SCIP_Bool* skipsolve, SCIP_RESULT* result) noexcept
with gil:
134 cdef SCIP_BENDERSDATA* bendersdata
136 PyBenders = <Benders>bendersdata
140 solution = Solution.create(scip, sol)
142 result_dict = PyBenders.benderspresubsolve(solution, enfotype, checkint)
143 infeasible[0] = result_dict.get(
"infeasible",
False)
144 auxviol[0] = result_dict.get(
"auxviol",
False)
145 skipsolve[0] = result_dict.get(
"skipsolve",
False)
146 result[0] = result_dict.get(
"result", <SCIP_RESULT>result[0])
149 cdef SCIP_RETCODE PyBendersSolvesubconvex (SCIP* scip, SCIP_BENDERS* benders, SCIP_SOL* sol, int probnumber, SCIP_Bool onlyconvex, SCIP_Real* objective, SCIP_RESULT* result) noexcept
with gil:
150 cdef SCIP_BENDERSDATA* bendersdata
152 PyBenders = <Benders>bendersdata
156 solution = Solution.create(scip, sol)
157 result_dict = PyBenders.benderssolvesubconvex(solution, probnumber, onlyconvex)
158 objective[0] = result_dict.get(
"objective", 1e+20)
159 result[0] = result_dict.get(
"result", <SCIP_RESULT>result[0])
162 cdef SCIP_RETCODE PyBendersSolvesub (SCIP* scip, SCIP_BENDERS* benders, SCIP_SOL* sol, int probnumber, SCIP_Real* objective, SCIP_RESULT* result) noexcept
with gil:
163 cdef SCIP_BENDERSDATA* bendersdata
165 PyBenders = <Benders>bendersdata
169 solution = Solution.create(scip, sol)
170 result_dict = PyBenders.benderssolvesub(solution, probnumber)
171 objective[0] = result_dict.get(
"objective", 1e+20)
172 result[0] = result_dict.get(
"result", <SCIP_RESULT>result[0])
175 cdef SCIP_RETCODE PyBendersPostsolve (SCIP* scip, SCIP_BENDERS* benders, SCIP_SOL* sol,
176 SCIP_BENDERSENFOTYPE type, int* mergecands, int npriomergecands, int nmergecands, SCIP_Bool checkint,
177 SCIP_Bool infeasible, SCIP_Bool* merged) noexcept
with gil:
178 cdef SCIP_BENDERSDATA* bendersdata
180 PyBenders = <Benders>bendersdata
184 solution = Solution.create(scip, sol)
187 for i
in range(nmergecands):
188 mergecandidates.append(mergecands[i])
189 result_dict = PyBenders.benderspostsolve(solution, enfotype, mergecandidates, npriomergecands, checkint, infeasible)
190 merged[0] = result_dict.get(
"merged",
False)
193 cdef SCIP_RETCODE PyBendersFreesub (SCIP* scip, SCIP_BENDERS* benders, int probnumber) noexcept
with gil:
194 cdef SCIP_BENDERSDATA* bendersdata
196 PyBenders = <Benders>bendersdata
197 PyBenders.bendersfreesub(probnumber)
201 cdef SCIP_RETCODE PyBendersGetvar (SCIP* scip, SCIP_BENDERS* benders, SCIP_VAR* var, SCIP_VAR** mappedvar, int probnumber) noexcept
with gil:
202 cdef SCIP_BENDERSDATA* bendersdata
204 PyBenders = <Benders>bendersdata
205 PyVar = getPyVar(var)
206 result_dict = PyBenders.bendersgetvar(PyVar, probnumber)
207 mappedvariable = <Variable>(result_dict.get(
"mappedvar",
None))
208 if mappedvariable
is None:
211 mappedvar[0] = mappedvariable.scip_var