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 '''
141 cdef Conshdlr getPyConshdlr(SCIP_CONSHDLR* conshdlr):
142 cdef SCIP_CONSHDLRDATA* conshdlrdata
144 return <Conshdlr>conshdlrdata
146 cdef Constraint getPyCons(SCIP_CONS* cons):
147 cdef SCIP_CONSDATA* consdata
149 return <Constraint>consdata
153 cdef SCIP_RETCODE PyConshdlrCopy (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_Bool* valid)
with gil:
156 cdef SCIP_RETCODE PyConsFree (SCIP* scip, SCIP_CONSHDLR* conshdlr)
with gil:
157 PyConshdlr = getPyConshdlr(conshdlr)
158 PyConshdlr.consfree()
159 Py_DECREF(PyConshdlr)
162 cdef SCIP_RETCODE PyConsInit (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS** conss, int nconss)
with gil:
163 PyConshdlr = getPyConshdlr(conshdlr)
164 cdef constraints = []
165 for i
in range(nconss):
166 constraints.append(getPyCons(conss[i]))
167 PyConshdlr.consinit(constraints)
170 cdef SCIP_RETCODE PyConsExit (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS** conss, int nconss)
with gil:
171 PyConshdlr = getPyConshdlr(conshdlr)
172 cdef constraints = []
173 for i
in range(nconss):
174 constraints.append(getPyCons(conss[i]))
175 PyConshdlr.consexit(constraints)
178 cdef SCIP_RETCODE PyConsInitpre (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS** conss, int nconss)
with gil:
179 PyConshdlr = getPyConshdlr(conshdlr)
180 cdef constraints = []
181 for i
in range(nconss):
182 constraints.append(getPyCons(conss[i]))
183 PyConshdlr.consinitpre(constraints)
186 cdef SCIP_RETCODE PyConsExitpre (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS** conss, int nconss)
with gil:
187 PyConshdlr = getPyConshdlr(conshdlr)
188 cdef constraints = []
189 for i
in range(nconss):
190 constraints.append(getPyCons(conss[i]))
191 PyConshdlr.consexitpre(constraints)
194 cdef SCIP_RETCODE PyConsInitsol (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS** conss, int nconss)
with gil:
195 PyConshdlr = getPyConshdlr(conshdlr)
196 cdef constraints = []
197 for i
in range(nconss):
198 constraints.append(getPyCons(conss[i]))
199 PyConshdlr.consinitsol(constraints)
202 cdef SCIP_RETCODE PyConsExitsol (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS** conss, int nconss, SCIP_Bool restart)
with gil:
203 PyConshdlr = getPyConshdlr(conshdlr)
204 cdef constraints = []
205 for i
in range(nconss):
206 constraints.append(getPyCons(conss[i]))
207 PyConshdlr.consexitsol(constraints, restart)
210 cdef SCIP_RETCODE PyConsDelete (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS* cons, SCIP_CONSDATA** consdata)
with gil:
211 PyConshdlr = getPyConshdlr(conshdlr)
212 PyCons = getPyCons(cons)
213 assert <Constraint>consdata[0] == PyCons
214 PyConshdlr.consdelete(PyCons)
219 cdef SCIP_RETCODE PyConsTrans (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS* sourcecons, SCIP_CONS** targetcons)
with gil:
220 cdef Constraint PyTargetCons
221 PyConshdlr = getPyConshdlr(conshdlr)
222 PySourceCons = getPyCons(sourcecons)
223 result_dict = PyConshdlr.constrans(PySourceCons)
227 if "targetcons" in result_dict:
228 PyTargetCons = result_dict.get(
"targetcons")
229 targetcons[0] = PyTargetCons.scip_cons
230 Py_INCREF(PyTargetCons)
233 PySourceCons.isInitial(), PySourceCons.isSeparated(), PySourceCons.isEnforced(), PySourceCons.isChecked(),
234 PySourceCons.isPropagated(), PySourceCons.isLocal(), PySourceCons.isModifiable(), PySourceCons.isDynamic(),
235 PySourceCons.isRemovable(), PySourceCons.isStickingAtNode()))
238 cdef SCIP_RETCODE PyConsInitlp (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS** conss, int nconss, SCIP_Bool* infeasible)
with gil:
239 PyConshdlr = getPyConshdlr(conshdlr)
240 cdef constraints = []
241 for i
in range(nconss):
242 constraints.append(getPyCons(conss[i]))
243 result_dict = PyConshdlr.consinitlp(constraints)
244 infeasible[0] = result_dict.get(
"infeasible", infeasible[0])
247 cdef SCIP_RETCODE PyConsSepalp (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS** conss, int nconss, int nusefulconss, SCIP_RESULT* result)
with gil:
248 PyConshdlr = getPyConshdlr(conshdlr)
249 cdef constraints = []
250 for i
in range(nconss):
251 constraints.append(getPyCons(conss[i]))
252 result_dict = PyConshdlr.conssepalp(constraints, nusefulconss)
253 result[0] = result_dict.get(
"result", <SCIP_RESULT>result[0])
256 cdef SCIP_RETCODE PyConsSepasol (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS** conss, int nconss, int nusefulconss,
257 SCIP_SOL* sol, SCIP_RESULT* result)
with gil:
258 PyConshdlr = getPyConshdlr(conshdlr)
259 cdef constraints = []
260 for i
in range(nconss):
261 constraints.append(getPyCons(conss[i]))
262 solution = Solution.create(scip, sol)
263 result_dict = PyConshdlr.conssepasol(constraints, nusefulconss, solution)
264 result[0] = result_dict.get(
"result", <SCIP_RESULT>result[0])
267 cdef SCIP_RETCODE PyConsEnfolp (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS** conss, int nconss, int nusefulconss,
268 SCIP_Bool solinfeasible, SCIP_RESULT* result)
with gil:
269 PyConshdlr = getPyConshdlr(conshdlr)
270 cdef constraints = []
271 for i
in range(nconss):
272 constraints.append(getPyCons(conss[i]))
273 result_dict = PyConshdlr.consenfolp(constraints, nusefulconss, solinfeasible)
274 result[0] = result_dict.get(
"result", <SCIP_RESULT>result[0])
277 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)
with gil:
278 PyConshdlr = getPyConshdlr(conshdlr)
279 cdef constraints = []
280 for i
in range(nconss):
281 constraints.append(getPyCons(conss[i]))
282 solution = Solution.create(scip, sol)
283 result_dict = PyConshdlr.consenforelax(solution, constraints, nusefulconss, solinfeasible)
284 result[0] = result_dict.get(
"result", <SCIP_RESULT>result[0])
287 cdef SCIP_RETCODE PyConsEnfops (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS** conss, int nconss, int nusefulconss,
288 SCIP_Bool solinfeasible, SCIP_Bool objinfeasible, SCIP_RESULT* result)
with gil:
289 PyConshdlr = getPyConshdlr(conshdlr)
290 cdef constraints = []
291 for i
in range(nconss):
292 constraints.append(getPyCons(conss[i]))
293 result_dict = PyConshdlr.consenfops(constraints, nusefulconss, solinfeasible, objinfeasible)
294 result[0] = result_dict.get(
"result", <SCIP_RESULT>result[0])
297 cdef SCIP_RETCODE PyConsCheck (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS** conss, int nconss, SCIP_SOL* sol, SCIP_Bool checkintegrality,
298 SCIP_Bool checklprows, SCIP_Bool printreason, SCIP_Bool completely, SCIP_RESULT* result)
with gil:
299 PyConshdlr = getPyConshdlr(conshdlr)
300 cdef constraints = []
301 for i
in range(nconss):
302 constraints.append(getPyCons(conss[i]))
303 solution = Solution.create(scip, sol)
304 result_dict = PyConshdlr.conscheck(constraints, solution, checkintegrality, checklprows, printreason, completely)
305 result[0] = result_dict.get(
"result", <SCIP_RESULT>result[0])
308 cdef SCIP_RETCODE PyConsProp (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS** conss, int nconss, int nusefulconss, int nmarkedconss,
309 SCIP_PROPTIMING proptiming, SCIP_RESULT* result)
with gil:
310 PyConshdlr = getPyConshdlr(conshdlr)
311 cdef constraints = []
312 for i
in range(nconss):
313 constraints.append(getPyCons(conss[i]))
314 result_dict = PyConshdlr.consprop(constraints, nusefulconss, nmarkedconss, proptiming)
315 result[0] = result_dict.get(
"result", <SCIP_RESULT>result[0])
318 cdef SCIP_RETCODE PyConsPresol (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS** conss, int nconss, int nrounds, SCIP_PRESOLTIMING presoltiming,
319 int nnewfixedvars, int nnewaggrvars, int nnewchgvartypes, int nnewchgbds, int nnewholes,
320 int nnewdelconss, int nnewaddconss, int nnewupgdconss, int nnewchgcoefs, int nnewchgsides,
321 int* nfixedvars, int* naggrvars, int* nchgvartypes, int* nchgbds, int* naddholes,
322 int* ndelconss, int* naddconss, int* nupgdconss, int* nchgcoefs, int* nchgsides, SCIP_RESULT* result)
with gil:
323 PyConshdlr = getPyConshdlr(conshdlr)
324 cdef constraints = []
325 for i
in range(nconss):
326 constraints.append(getPyCons(conss[i]))
329 result_dict[
"nfixedvars"] = nfixedvars[0]
330 result_dict[
"naggrvars"] = naggrvars[0]
331 result_dict[
"nchgvartypes"] = nchgvartypes[0]
332 result_dict[
"nchgbds"] = nchgbds[0]
333 result_dict[
"naddholes"] = naddholes[0]
334 result_dict[
"ndelconss"] = ndelconss[0]
335 result_dict[
"naddconss"] = naddconss[0]
336 result_dict[
"nupgdconss"] = nupgdconss[0]
337 result_dict[
"nchgcoefs"] = nchgcoefs[0]
338 result_dict[
"nchgsides"] = nchgsides[0]
339 result_dict[
"result"] = result[0]
340 PyConshdlr.conspresol(constraints, nrounds, presoltiming,
341 nnewfixedvars, nnewaggrvars, nnewchgvartypes, nnewchgbds, nnewholes,
342 nnewdelconss, nnewaddconss, nnewupgdconss, nnewchgcoefs, nnewchgsides, result_dict)
343 result[0] = result_dict[
"result"]
344 nfixedvars[0] = result_dict[
"nfixedvars"]
345 naggrvars[0] = result_dict[
"naggrvars"]
346 nchgvartypes[0] = result_dict[
"nchgvartypes"]
347 nchgbds[0] = result_dict[
"nchgbds"]
348 naddholes[0] = result_dict[
"naddholes"]
349 ndelconss[0] = result_dict[
"ndelconss"]
350 naddconss[0] = result_dict[
"naddconss"]
351 nupgdconss[0] = result_dict[
"nupgdconss"]
352 nchgcoefs[0] = result_dict[
"nchgcoefs"]
353 nchgsides[0] = result_dict[
"nchgsides"]
356 cdef SCIP_RETCODE PyConsResprop (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS* cons, SCIP_VAR* infervar, int inferinfo,
357 SCIP_BOUNDTYPE boundtype, SCIP_BDCHGIDX* bdchgidx, SCIP_Real relaxedbd, SCIP_RESULT* result)
with gil:
358 PyConshdlr = getPyConshdlr(conshdlr)
359 PyConshdlr.consresprop()
362 cdef SCIP_RETCODE PyConsLock (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS* cons, SCIP_LOCKTYPE locktype, int nlockspos, int nlocksneg)
with gil:
363 PyConshdlr = getPyConshdlr(conshdlr)
365 PyConshdlr.conslock(
None, locktype, nlockspos, nlocksneg)
367 PyCons = getPyCons(cons)
368 PyConshdlr.conslock(PyCons, locktype, nlockspos, nlocksneg)
371 cdef SCIP_RETCODE PyConsActive (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS* cons)
with gil:
372 PyConshdlr = getPyConshdlr(conshdlr)
373 PyCons = getPyCons(cons)
374 PyConshdlr.consactive(PyCons)
377 cdef SCIP_RETCODE PyConsDeactive (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS* cons)
with gil:
378 PyConshdlr = getPyConshdlr(conshdlr)
379 PyCons = getPyCons(cons)
380 PyConshdlr.consdeactive(PyCons)
383 cdef SCIP_RETCODE PyConsEnable (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS* cons)
with gil:
384 PyConshdlr = getPyConshdlr(conshdlr)
385 PyCons = getPyCons(cons)
386 PyConshdlr.consenable(PyCons)
389 cdef SCIP_RETCODE PyConsDisable (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS* cons)
with gil:
390 PyConshdlr = getPyConshdlr(conshdlr)
391 PyCons = getPyCons(cons)
392 PyConshdlr.consdisable(PyCons)
395 cdef SCIP_RETCODE PyConsDelvars (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS** conss, int nconss)
with gil:
396 PyConshdlr = getPyConshdlr(conshdlr)
397 cdef constraints = []
398 for i
in range(nconss):
399 constraints.append(getPyCons(conss[i]))
400 PyConshdlr.consdelvars(constraints)
403 cdef SCIP_RETCODE PyConsPrint (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS* cons, FILE* file)
with gil:
404 PyConshdlr = getPyConshdlr(conshdlr)
405 PyCons = getPyCons(cons)
407 PyConshdlr.consprint(PyCons)
410 cdef SCIP_RETCODE PyConsCopy (SCIP* scip, SCIP_CONS** cons, const char* name, SCIP* sourcescip, SCIP_CONSHDLR* sourceconshdlr,
411 SCIP_CONS* sourcecons, SCIP_HASHMAP* varmap, SCIP_HASHMAP* consmap, SCIP_Bool initial,
412 SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local,
413 SCIP_Bool modifiable, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode,
414 SCIP_Bool isglobal, SCIP_Bool* valid)
with gil:
416 PyConshdlr = getPyConshdlr(sourceconshdlr)
417 PyConshdlr.conscopy()
421 cdef SCIP_RETCODE PyConsParse (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS** cons, const char* name, const char* str,
422 SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate,
423 SCIP_Bool local, SCIP_Bool modifiable, SCIP_Bool dynamic, SCIP_Bool removable,
424 SCIP_Bool stickingatnode, SCIP_Bool* success)
with gil:
426 PyConshdlr = getPyConshdlr(conshdlr)
427 PyConshdlr.consparse()
431 cdef SCIP_RETCODE PyConsGetvars (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS* cons, SCIP_VAR** vars, int varssize, SCIP_Bool* success)
with gil:
433 PyConshdlr = getPyConshdlr(conshdlr)
434 PyCons = getPyCons(cons)
435 PyConshdlr.consgetvars(PyCons)
439 cdef SCIP_RETCODE PyConsGetnvars (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS* cons, int* nvars, SCIP_Bool* success)
with gil:
440 PyConshdlr = getPyConshdlr(conshdlr)
441 PyCons = getPyCons(cons)
442 result_dict = PyConshdlr.consgetnvars(PyCons)
443 nvars[0] = result_dict.get(
"nvars", 0)
444 success[0] = result_dict.get(
"success",
False)
447 cdef SCIP_RETCODE PyConsGetdivebdchgs (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_DIVESET* diveset, SCIP_SOL* sol,
448 SCIP_Bool* success, SCIP_Bool* infeasible)
with gil:
450 PyConshdlr = getPyConshdlr(conshdlr)
451 PyConshdlr.consgetdivebdchgs()
453 infeasible[0] =
False