5 cdef public Model model
9 '''calls destructor and frees memory of constraint handler '''
13 '''calls initialization method of constraint handler '''
17 '''calls exit method of constraint handler '''
21 '''informs constraint handler that the presolving process is being started '''
25 '''informs constraint handler that the presolving is finished '''
29 '''informs constraint handler that the branch and bound process is being started '''
33 '''informs constraint handler that the branch and bound process data is being freed '''
37 '''sets method of constraint handler to free specific constraint data '''
41 '''sets method of constraint handler to transform constraint data into data belonging to the transformed problem '''
45 '''calls LP initialization method of constraint handler to separate all initial active constraints '''
49 '''calls separator method of constraint handler to separate LP solution '''
53 '''calls separator method of constraint handler to separate given primal solution '''
56 def consenfolp(self, constraints, nusefulconss, solinfeasible):
57 '''calls enforcing method of constraint handler for LP solution for all constraints added'''
58 print(
"python error in consenfolp: this method needs to be implemented")
61 def consenforelax(self, solution, constraints, nusefulconss, solinfeasible):
62 '''calls enforcing method of constraint handler for a relaxation solution for all constraints added'''
63 print(
"python error in consenforelax: this method needs to be implemented")
66 def consenfops(self, constraints, nusefulconss, solinfeasible, objinfeasible):
67 '''calls enforcing method of constraint handler for pseudo solution for all constraints added'''
68 print(
"python error in consenfops: this method needs to be implemented")
71 def conscheck(self, constraints, solution, checkintegrality, checklprows, printreason, completely):
72 '''calls feasibility check method of constraint handler '''
73 print(
"python error in conscheck: this method needs to be implemented")
76 def consprop(self, constraints, nusefulconss, nmarkedconss, proptiming):
77 '''calls propagation method of constraint handler '''
81 nnewfixedvars, nnewaggrvars, nnewchgvartypes, nnewchgbds, nnewholes,
82 nnewdelconss, nnewaddconss, nnewupgdconss, nnewchgcoefs, nnewchgsides, result_dict):
83 '''calls presolving method of constraint handler '''
87 '''sets propagation conflict resolving method of constraint handler '''
90 def conslock(self, constraint, locktype, nlockspos, nlocksneg):
91 '''variable rounding lock method of constraint handler'''
92 print(
"python error in conslock: this method needs to be implemented")
96 '''sets activation notification method of constraint handler '''
100 '''sets deactivation notification method of constraint handler '''
104 '''sets enabling notification method of constraint handler '''
108 '''sets disabling notification method of constraint handler '''
112 '''calls variable deletion method of constraint handler'''
116 '''sets constraint display method of constraint handler '''
120 '''sets copy method of both the constraint handler and each associated constraint'''
124 '''sets constraint parsing method of constraint handler '''
128 '''sets constraint variable getter method of constraint handler'''
132 '''sets constraint variable number getter method of constraint handler '''
136 '''calls diving solution enforcement callback of constraint handler, if it exists '''
140 '''permutation symmetry detection graph getter callback, if it exists '''
144 '''signed permutation symmetry detection graph getter callback, if it exists '''
149 cdef Conshdlr getPyConshdlr(SCIP_CONSHDLR* conshdlr):
150 cdef SCIP_CONSHDLRDATA* conshdlrdata
152 return <Conshdlr>conshdlrdata
154 cdef Constraint getPyCons(SCIP_CONS* cons):
155 cdef SCIP_CONSDATA* consdata
157 return <Constraint>consdata
161 cdef SCIP_RETCODE PyConshdlrCopy (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_Bool* valid) noexcept
with gil:
164 cdef SCIP_RETCODE PyConsFree (SCIP* scip, SCIP_CONSHDLR* conshdlr) noexcept
with gil:
165 PyConshdlr = getPyConshdlr(conshdlr)
166 PyConshdlr.consfree()
167 Py_DECREF(PyConshdlr)
170 cdef SCIP_RETCODE PyConsInit (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS** conss, int nconss) noexcept
with gil:
171 PyConshdlr = getPyConshdlr(conshdlr)
172 cdef constraints = []
173 for i
in range(nconss):
174 constraints.append(getPyCons(conss[i]))
175 PyConshdlr.consinit(constraints)
178 cdef SCIP_RETCODE PyConsExit (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS** conss, int nconss) noexcept
with gil:
179 PyConshdlr = getPyConshdlr(conshdlr)
180 cdef constraints = []
181 for i
in range(nconss):
182 constraints.append(getPyCons(conss[i]))
183 PyConshdlr.consexit(constraints)
186 cdef SCIP_RETCODE PyConsInitpre (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS** conss, int nconss) noexcept
with gil:
187 PyConshdlr = getPyConshdlr(conshdlr)
188 cdef constraints = []
189 for i
in range(nconss):
190 constraints.append(getPyCons(conss[i]))
191 PyConshdlr.consinitpre(constraints)
194 cdef SCIP_RETCODE PyConsExitpre (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS** conss, int nconss) noexcept
with gil:
195 PyConshdlr = getPyConshdlr(conshdlr)
196 cdef constraints = []
197 for i
in range(nconss):
198 constraints.append(getPyCons(conss[i]))
199 PyConshdlr.consexitpre(constraints)
202 cdef SCIP_RETCODE PyConsInitsol (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS** conss, int nconss) noexcept
with gil:
203 PyConshdlr = getPyConshdlr(conshdlr)
204 cdef constraints = []
205 for i
in range(nconss):
206 constraints.append(getPyCons(conss[i]))
207 PyConshdlr.consinitsol(constraints)
210 cdef SCIP_RETCODE PyConsExitsol (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS** conss, int nconss, SCIP_Bool restart) noexcept
with gil:
211 PyConshdlr = getPyConshdlr(conshdlr)
212 cdef constraints = []
213 for i
in range(nconss):
214 constraints.append(getPyCons(conss[i]))
215 PyConshdlr.consexitsol(constraints, restart)
218 cdef SCIP_RETCODE PyConsDelete (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS* cons, SCIP_CONSDATA** consdata) noexcept
with gil:
219 PyConshdlr = getPyConshdlr(conshdlr)
220 PyCons = getPyCons(cons)
221 assert <Constraint>consdata[0] == PyCons
222 PyConshdlr.consdelete(PyCons)
227 cdef SCIP_RETCODE PyConsTrans (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS* sourcecons, SCIP_CONS** targetcons) noexcept
with gil:
228 cdef Constraint PyTargetCons
229 PyConshdlr = getPyConshdlr(conshdlr)
230 PySourceCons = getPyCons(sourcecons)
231 result_dict = PyConshdlr.constrans(PySourceCons)
235 if "targetcons" in result_dict:
236 PyTargetCons = result_dict.get(
"targetcons")
237 targetcons[0] = PyTargetCons.scip_cons
238 Py_INCREF(PyTargetCons)
241 PySourceCons.isInitial(), PySourceCons.isSeparated(), PySourceCons.isEnforced(), PySourceCons.isChecked(),
242 PySourceCons.isPropagated(), PySourceCons.isLocal(), PySourceCons.isModifiable(), PySourceCons.isDynamic(),
243 PySourceCons.isRemovable(), PySourceCons.isStickingAtNode()))
246 cdef SCIP_RETCODE PyConsInitlp (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS** conss, int nconss, SCIP_Bool* infeasible) noexcept
with gil:
247 PyConshdlr = getPyConshdlr(conshdlr)
248 cdef constraints = []
249 for i
in range(nconss):
250 constraints.append(getPyCons(conss[i]))
251 result_dict = PyConshdlr.consinitlp(constraints)
252 infeasible[0] = result_dict.get(
"infeasible", infeasible[0])
255 cdef SCIP_RETCODE PyConsSepalp (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS** conss, int nconss, int nusefulconss, SCIP_RESULT* result) noexcept
with gil:
256 PyConshdlr = getPyConshdlr(conshdlr)
257 cdef constraints = []
258 for i
in range(nconss):
259 constraints.append(getPyCons(conss[i]))
260 result_dict = PyConshdlr.conssepalp(constraints, nusefulconss)
261 result[0] = result_dict.get(
"result", <SCIP_RESULT>result[0])
264 cdef SCIP_RETCODE PyConsSepasol (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS** conss, int nconss, int nusefulconss,
265 SCIP_SOL* sol, SCIP_RESULT* result) noexcept
with gil:
266 PyConshdlr = getPyConshdlr(conshdlr)
267 cdef constraints = []
268 for i
in range(nconss):
269 constraints.append(getPyCons(conss[i]))
270 solution = Solution.create(scip, sol)
271 result_dict = PyConshdlr.conssepasol(constraints, nusefulconss, solution)
272 result[0] = result_dict.get(
"result", <SCIP_RESULT>result[0])
275 cdef SCIP_RETCODE PyConsEnfolp (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS** conss, int nconss, int nusefulconss,
276 SCIP_Bool solinfeasible, SCIP_RESULT* result) noexcept
with gil:
277 PyConshdlr = getPyConshdlr(conshdlr)
278 cdef constraints = []
279 for i
in range(nconss):
280 constraints.append(getPyCons(conss[i]))
281 result_dict = PyConshdlr.consenfolp(constraints, nusefulconss, solinfeasible)
282 result[0] = result_dict.get(
"result", <SCIP_RESULT>result[0])
285 cdef SCIP_RETCODE PyConsEnforelax (SCIP* scip, SCIP_SOL* sol, SCIP_CONSHDLR* conshdlr, SCIP_CONS** conss, int nconss, int nusefulconss, SCIP_Bool solinfeasible, SCIP_RESULT* result) noexcept
with gil:
286 PyConshdlr = getPyConshdlr(conshdlr)
287 cdef constraints = []
288 for i
in range(nconss):
289 constraints.append(getPyCons(conss[i]))
290 solution = Solution.create(scip, sol)
291 result_dict = PyConshdlr.consenforelax(solution, constraints, nusefulconss, solinfeasible)
292 result[0] = result_dict.get(
"result", <SCIP_RESULT>result[0])
295 cdef SCIP_RETCODE PyConsEnfops (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS** conss, int nconss, int nusefulconss,
296 SCIP_Bool solinfeasible, SCIP_Bool objinfeasible, SCIP_RESULT* result) noexcept
with gil:
297 PyConshdlr = getPyConshdlr(conshdlr)
298 cdef constraints = []
299 for i
in range(nconss):
300 constraints.append(getPyCons(conss[i]))
301 result_dict = PyConshdlr.consenfops(constraints, nusefulconss, solinfeasible, objinfeasible)
302 result[0] = result_dict.get(
"result", <SCIP_RESULT>result[0])
305 cdef SCIP_RETCODE PyConsCheck (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS** conss, int nconss, SCIP_SOL* sol, SCIP_Bool checkintegrality,
306 SCIP_Bool checklprows, SCIP_Bool printreason, SCIP_Bool completely, SCIP_RESULT* result) noexcept
with gil:
307 PyConshdlr = getPyConshdlr(conshdlr)
308 cdef constraints = []
309 for i
in range(nconss):
310 constraints.append(getPyCons(conss[i]))
311 solution = Solution.create(scip, sol)
312 result_dict = PyConshdlr.conscheck(constraints, solution, checkintegrality, checklprows, printreason, completely)
313 result[0] = result_dict.get(
"result", <SCIP_RESULT>result[0])
316 cdef SCIP_RETCODE PyConsProp (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS** conss, int nconss, int nusefulconss, int nmarkedconss,
317 SCIP_PROPTIMING proptiming, SCIP_RESULT* result) noexcept
with gil:
318 PyConshdlr = getPyConshdlr(conshdlr)
319 cdef constraints = []
320 for i
in range(nconss):
321 constraints.append(getPyCons(conss[i]))
322 result_dict = PyConshdlr.consprop(constraints, nusefulconss, nmarkedconss, proptiming)
323 result[0] = result_dict.get(
"result", <SCIP_RESULT>result[0])
326 cdef SCIP_RETCODE PyConsPresol (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS** conss, int nconss, int nrounds, SCIP_PRESOLTIMING presoltiming,
327 int nnewfixedvars, int nnewaggrvars, int nnewchgvartypes, int nnewchgbds, int nnewholes,
328 int nnewdelconss, int nnewaddconss, int nnewupgdconss, int nnewchgcoefs, int nnewchgsides,
329 int* nfixedvars, int* naggrvars, int* nchgvartypes, int* nchgbds, int* naddholes,
330 int* ndelconss, int* naddconss, int* nupgdconss, int* nchgcoefs, int* nchgsides, SCIP_RESULT* result) noexcept
with gil:
331 PyConshdlr = getPyConshdlr(conshdlr)
332 cdef constraints = []
333 for i
in range(nconss):
334 constraints.append(getPyCons(conss[i]))
337 result_dict[
"nfixedvars"] = nfixedvars[0]
338 result_dict[
"naggrvars"] = naggrvars[0]
339 result_dict[
"nchgvartypes"] = nchgvartypes[0]
340 result_dict[
"nchgbds"] = nchgbds[0]
341 result_dict[
"naddholes"] = naddholes[0]
342 result_dict[
"ndelconss"] = ndelconss[0]
343 result_dict[
"naddconss"] = naddconss[0]
344 result_dict[
"nupgdconss"] = nupgdconss[0]
345 result_dict[
"nchgcoefs"] = nchgcoefs[0]
346 result_dict[
"nchgsides"] = nchgsides[0]
347 result_dict[
"result"] = result[0]
348 PyConshdlr.conspresol(constraints, nrounds, presoltiming,
349 nnewfixedvars, nnewaggrvars, nnewchgvartypes, nnewchgbds, nnewholes,
350 nnewdelconss, nnewaddconss, nnewupgdconss, nnewchgcoefs, nnewchgsides, result_dict)
351 result[0] = result_dict[
"result"]
352 nfixedvars[0] = result_dict[
"nfixedvars"]
353 naggrvars[0] = result_dict[
"naggrvars"]
354 nchgvartypes[0] = result_dict[
"nchgvartypes"]
355 nchgbds[0] = result_dict[
"nchgbds"]
356 naddholes[0] = result_dict[
"naddholes"]
357 ndelconss[0] = result_dict[
"ndelconss"]
358 naddconss[0] = result_dict[
"naddconss"]
359 nupgdconss[0] = result_dict[
"nupgdconss"]
360 nchgcoefs[0] = result_dict[
"nchgcoefs"]
361 nchgsides[0] = result_dict[
"nchgsides"]
364 cdef SCIP_RETCODE PyConsResprop (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS* cons, SCIP_VAR* infervar, int inferinfo,
365 SCIP_BOUNDTYPE boundtype, SCIP_BDCHGIDX* bdchgidx, SCIP_Real relaxedbd, SCIP_RESULT* result) noexcept
with gil:
366 PyConshdlr = getPyConshdlr(conshdlr)
367 PyConshdlr.consresprop()
370 cdef SCIP_RETCODE PyConsLock (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS* cons, SCIP_LOCKTYPE locktype, int nlockspos, int nlocksneg) noexcept
with gil:
371 PyConshdlr = getPyConshdlr(conshdlr)
373 PyConshdlr.conslock(
None, locktype, nlockspos, nlocksneg)
375 PyCons = getPyCons(cons)
376 PyConshdlr.conslock(PyCons, locktype, nlockspos, nlocksneg)
379 cdef SCIP_RETCODE PyConsActive (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS* cons) noexcept
with gil:
380 PyConshdlr = getPyConshdlr(conshdlr)
381 PyCons = getPyCons(cons)
382 PyConshdlr.consactive(PyCons)
385 cdef SCIP_RETCODE PyConsDeactive (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS* cons) noexcept
with gil:
386 PyConshdlr = getPyConshdlr(conshdlr)
387 PyCons = getPyCons(cons)
388 PyConshdlr.consdeactive(PyCons)
391 cdef SCIP_RETCODE PyConsEnable (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS* cons) noexcept
with gil:
392 PyConshdlr = getPyConshdlr(conshdlr)
393 PyCons = getPyCons(cons)
394 PyConshdlr.consenable(PyCons)
397 cdef SCIP_RETCODE PyConsDisable (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS* cons) noexcept
with gil:
398 PyConshdlr = getPyConshdlr(conshdlr)
399 PyCons = getPyCons(cons)
400 PyConshdlr.consdisable(PyCons)
403 cdef SCIP_RETCODE PyConsDelvars (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS** conss, int nconss) noexcept
with gil:
404 PyConshdlr = getPyConshdlr(conshdlr)
405 cdef constraints = []
406 for i
in range(nconss):
407 constraints.append(getPyCons(conss[i]))
408 PyConshdlr.consdelvars(constraints)
411 cdef SCIP_RETCODE PyConsPrint (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS* cons, FILE* file) noexcept
with gil:
412 PyConshdlr = getPyConshdlr(conshdlr)
413 PyCons = getPyCons(cons)
415 PyConshdlr.consprint(PyCons)
418 cdef SCIP_RETCODE PyConsCopy (SCIP* scip, SCIP_CONS** cons, const char* name, SCIP* sourcescip, SCIP_CONSHDLR* sourceconshdlr,
419 SCIP_CONS* sourcecons, SCIP_HASHMAP* varmap, SCIP_HASHMAP* consmap, SCIP_Bool initial,
420 SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local,
421 SCIP_Bool modifiable, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode,
422 SCIP_Bool isglobal, SCIP_Bool* valid) noexcept
with gil:
424 PyConshdlr = getPyConshdlr(sourceconshdlr)
425 PyConshdlr.conscopy()
429 cdef SCIP_RETCODE PyConsParse (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS** cons, const char* name, const char* str,
430 SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate,
431 SCIP_Bool local, SCIP_Bool modifiable, SCIP_Bool dynamic, SCIP_Bool removable,
432 SCIP_Bool stickingatnode, SCIP_Bool* success) noexcept
with gil:
434 PyConshdlr = getPyConshdlr(conshdlr)
435 PyConshdlr.consparse()
439 cdef SCIP_RETCODE PyConsGetvars (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS* cons, SCIP_VAR** vars, int varssize, SCIP_Bool* success) noexcept
with gil:
441 PyConshdlr = getPyConshdlr(conshdlr)
442 PyCons = getPyCons(cons)
443 PyConshdlr.consgetvars(PyCons)
447 cdef SCIP_RETCODE PyConsGetnvars (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS* cons, int* nvars, SCIP_Bool* success) noexcept
with gil:
448 PyConshdlr = getPyConshdlr(conshdlr)
449 PyCons = getPyCons(cons)
450 result_dict = PyConshdlr.consgetnvars(PyCons)
451 nvars[0] = result_dict.get(
"nvars", 0)
452 success[0] = result_dict.get(
"success",
False)
455 cdef SCIP_RETCODE PyConsGetdivebdchgs (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_DIVESET* diveset, SCIP_SOL* sol,
456 SCIP_Bool* success, SCIP_Bool* infeasible) noexcept
with gil:
458 PyConshdlr = getPyConshdlr(conshdlr)
459 PyConshdlr.consgetdivebdchgs()
461 infeasible[0] =
False
464 cdef SCIP_RETCODE PyConsGetPermSymGraph (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS* cons, SYM_GRAPH* graph,
465 SCIP_Bool* success) noexcept
with gil:
467 PyConshdlr = getPyConshdlr(conshdlr)
468 PyConshdlr.consgetpermsymgraph()
472 cdef SCIP_RETCODE PyConsGetSignedPermSymGraph (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS* cons, SYM_GRAPH* graph,
473 SCIP_Bool* success) noexcept
with gil:
475 PyConshdlr = getPyConshdlr(conshdlr)
476 PyConshdlr.consgetsignedpermsymgraph()