5 cdef public Model model
9 '''calls destructor and frees memory of constraint handler ''' 12 def consinit(self, constraints):
13 '''calls initialization method of constraint handler ''' 16 def consexit(self, constraints):
17 '''calls exit method of constraint handler ''' 20 def consinitpre(self, constraints):
21 '''informs constraint handler that the presolving process is being started ''' 24 def consexitpre(self, constraints):
25 '''informs constraint handler that the presolving is finished ''' 28 def consinitsol(self, constraints):
29 '''informs constraint handler that the branch and bound process is being started ''' 32 def consexitsol(self, constraints, restart):
33 '''informs constraint handler that the branch and bound process data is being freed ''' 36 def consdelete(self, constraint):
37 '''sets method of constraint handler to free specific constraint data ''' 40 def constrans(self, sourceconstraint):
41 '''sets method of constraint handler to transform constraint data into data belonging to the transformed problem ''' 44 def consinitlp(self, constraints):
45 '''calls LP initialization method of constraint handler to separate all initial active constraints ''' 48 def conssepalp(self, constraints, nusefulconss):
49 '''calls separator method of constraint handler to separate LP solution ''' 52 def conssepasol(self, constraints, nusefulconss, 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 ''' 80 def conspresol(self, constraints, nrounds, presoltiming,
81 nnewfixedvars, nnewaggrvars, nnewchgvartypes, nnewchgbds, nnewholes,
82 nnewdelconss, nnewaddconss, nnewupgdconss, nnewchgcoefs, nnewchgsides, result_dict):
83 '''calls presolving method of constraint handler ''' 86 def consresprop(self):
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")
95 def consactive(self, constraint):
96 '''sets activation notification method of constraint handler ''' 99 def consdeactive(self, constraint):
100 '''sets deactivation notification method of constraint handler ''' 103 def consenable(self, constraint):
104 '''sets enabling notification method of constraint handler ''' 107 def consdisable(self, constraint):
108 '''sets disabling notification method of constraint handler ''' 111 def consdelvars(self, constraints):
112 '''calls variable deletion method of constraint handler''' 115 def consprint(self, constraint):
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 ''' 127 def consgetvars(self, constraint):
128 '''sets constraint variable getter method of constraint handler''' 131 def consgetnvars(self, constraint):
132 '''sets constraint variable number getter method of constraint handler ''' 135 def consgetdivebdchgs(self):
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):
156 cdef SCIP_RETCODE PyConsFree (SCIP* scip, SCIP_CONSHDLR* conshdlr):
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):
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):
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):
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):
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):
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):
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):
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):
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.cons
230 Py_INCREF(PyTargetCons)
232 PY_SCIP_CALL(
SCIPcreateCons(scip, targetcons, str_conversion(PySourceCons.name), conshdlr, <SCIP_CONSDATA*>PySourceCons,
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):
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):
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):
258 PyConshdlr = getPyConshdlr(conshdlr)
259 cdef constraints = []
260 for i
in range(nconss):
261 constraints.append(getPyCons(conss[i]))
262 solution = Solution()
264 result_dict = PyConshdlr.conssepasol(constraints, nusefulconss, solution)
265 result[0] = result_dict.get(
"result", <SCIP_RESULT>result[0])
268 cdef SCIP_RETCODE PyConsEnfolp (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS** conss, int nconss, int nusefulconss,
269 SCIP_Bool solinfeasible, SCIP_RESULT* result):
270 PyConshdlr = getPyConshdlr(conshdlr)
271 cdef constraints = []
272 for i
in range(nconss):
273 constraints.append(getPyCons(conss[i]))
274 result_dict = PyConshdlr.consenfolp(constraints, nusefulconss, solinfeasible)
275 result[0] = result_dict.get(
"result", <SCIP_RESULT>result[0])
278 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):
279 PyConshdlr = getPyConshdlr(conshdlr)
280 cdef constraints = []
281 for i
in range(nconss):
282 constraints.append(getPyCons(conss[i]))
283 solution = Solution()
285 result_dict = PyConshdlr.consenforelax(solution, constraints, nusefulconss, solinfeasible)
286 result[0] = result_dict.get(
"result", <SCIP_RESULT>result[0])
289 cdef SCIP_RETCODE PyConsEnfops (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS** conss, int nconss, int nusefulconss,
290 SCIP_Bool solinfeasible, SCIP_Bool objinfeasible, SCIP_RESULT* result):
291 PyConshdlr = getPyConshdlr(conshdlr)
292 cdef constraints = []
293 for i
in range(nconss):
294 constraints.append(getPyCons(conss[i]))
295 result_dict = PyConshdlr.consenfops(constraints, nusefulconss, solinfeasible, objinfeasible)
296 result[0] = result_dict.get(
"result", <SCIP_RESULT>result[0])
299 cdef SCIP_RETCODE PyConsCheck (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS** conss, int nconss, SCIP_SOL* sol, SCIP_Bool checkintegrality,
300 SCIP_Bool checklprows, SCIP_Bool printreason, SCIP_Bool completely, SCIP_RESULT* result):
301 PyConshdlr = getPyConshdlr(conshdlr)
302 cdef constraints = []
303 for i
in range(nconss):
304 constraints.append(getPyCons(conss[i]))
305 solution = Solution()
307 result_dict = PyConshdlr.conscheck(constraints, solution, checkintegrality, checklprows, printreason, completely)
308 result[0] = result_dict.get(
"result", <SCIP_RESULT>result[0])
311 cdef SCIP_RETCODE PyConsProp (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS** conss, int nconss, int nusefulconss, int nmarkedconss,
312 SCIP_PROPTIMING proptiming, SCIP_RESULT* result):
313 PyConshdlr = getPyConshdlr(conshdlr)
314 cdef constraints = []
315 for i
in range(nconss):
316 constraints.append(getPyCons(conss[i]))
317 result_dict = PyConshdlr.consprop(constraints, nusefulconss, nmarkedconss, proptiming)
318 result[0] = result_dict.get(
"result", <SCIP_RESULT>result[0])
321 cdef SCIP_RETCODE PyConsPresol (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS** conss, int nconss, int nrounds, SCIP_PRESOLTIMING presoltiming,
322 int nnewfixedvars, int nnewaggrvars, int nnewchgvartypes, int nnewchgbds, int nnewholes,
323 int nnewdelconss, int nnewaddconss, int nnewupgdconss, int nnewchgcoefs, int nnewchgsides,
324 int* nfixedvars, int* naggrvars, int* nchgvartypes, int* nchgbds, int* naddholes,
325 int* ndelconss, int* naddconss, int* nupgdconss, int* nchgcoefs, int* nchgsides, SCIP_RESULT* result):
326 PyConshdlr = getPyConshdlr(conshdlr)
327 cdef constraints = []
328 for i
in range(nconss):
329 constraints.append(getPyCons(conss[i]))
332 result_dict[
"nfixedvars"] = nfixedvars[0]
333 result_dict[
"naggrvars"] = naggrvars[0]
334 result_dict[
"nchgvartypes"] = nchgvartypes[0]
335 result_dict[
"nchgbds"] = nchgbds[0]
336 result_dict[
"naddholes"] = naddholes[0]
337 result_dict[
"ndelconss"] = ndelconss[0]
338 result_dict[
"naddconss"] = naddconss[0]
339 result_dict[
"nupgdconss"] = nupgdconss[0]
340 result_dict[
"nchgcoefs"] = nchgcoefs[0]
341 result_dict[
"nchgsides"] = nchgsides[0]
342 result_dict[
"result"] = result[0]
343 PyConshdlr.conspresol(constraints, nrounds, presoltiming,
344 nnewfixedvars, nnewaggrvars, nnewchgvartypes, nnewchgbds, nnewholes,
345 nnewdelconss, nnewaddconss, nnewupgdconss, nnewchgcoefs, nnewchgsides, result_dict)
346 result[0] = result_dict[
"result"]
347 nfixedvars[0] = result_dict[
"nfixedvars"]
348 naggrvars[0] = result_dict[
"naggrvars"]
349 nchgvartypes[0] = result_dict[
"nchgvartypes"]
350 nchgbds[0] = result_dict[
"nchgbds"]
351 naddholes[0] = result_dict[
"naddholes"]
352 ndelconss[0] = result_dict[
"ndelconss"]
353 naddconss[0] = result_dict[
"naddconss"]
354 nupgdconss[0] = result_dict[
"nupgdconss"]
355 nchgcoefs[0] = result_dict[
"nchgcoefs"]
356 nchgsides[0] = result_dict[
"nchgsides"]
359 cdef SCIP_RETCODE PyConsResprop (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS* cons, SCIP_VAR* infervar, int inferinfo,
360 SCIP_BOUNDTYPE boundtype, SCIP_BDCHGIDX* bdchgidx, SCIP_Real relaxedbd, SCIP_RESULT* result):
361 PyConshdlr = getPyConshdlr(conshdlr)
362 PyConshdlr.consresprop()
365 cdef SCIP_RETCODE PyConsLock (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS* cons, SCIP_LOCKTYPE locktype, int nlockspos, int nlocksneg):
366 PyConshdlr = getPyConshdlr(conshdlr)
368 PyConshdlr.conslock(
None, locktype, nlockspos, nlocksneg)
370 PyCons = getPyCons(cons)
371 PyConshdlr.conslock(PyCons, locktype, nlockspos, nlocksneg)
374 cdef SCIP_RETCODE PyConsActive (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS* cons):
375 PyConshdlr = getPyConshdlr(conshdlr)
376 PyCons = getPyCons(cons)
377 PyConshdlr.consactive(PyCons)
380 cdef SCIP_RETCODE PyConsDeactive (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS* cons):
381 PyConshdlr = getPyConshdlr(conshdlr)
382 PyCons = getPyCons(cons)
383 PyConshdlr.consdeactive(PyCons)
386 cdef SCIP_RETCODE PyConsEnable (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS* cons):
387 PyConshdlr = getPyConshdlr(conshdlr)
388 PyCons = getPyCons(cons)
389 PyConshdlr.consenable(PyCons)
392 cdef SCIP_RETCODE PyConsDisable (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS* cons):
393 PyConshdlr = getPyConshdlr(conshdlr)
394 PyCons = getPyCons(cons)
395 PyConshdlr.consdisable(PyCons)
398 cdef SCIP_RETCODE PyConsDelvars (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS** conss, int nconss):
399 PyConshdlr = getPyConshdlr(conshdlr)
400 cdef constraints = []
401 for i
in range(nconss):
402 constraints.append(getPyCons(conss[i]))
403 PyConshdlr.consdelvars(constraints)
406 cdef SCIP_RETCODE PyConsPrint (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS* cons, FILE* file):
407 PyConshdlr = getPyConshdlr(conshdlr)
408 PyCons = getPyCons(cons)
410 PyConshdlr.consprint(PyCons)
413 cdef SCIP_RETCODE PyConsCopy (SCIP* scip, SCIP_CONS** cons, const char* name, SCIP* sourcescip, SCIP_CONSHDLR* sourceconshdlr,
414 SCIP_CONS* sourcecons, SCIP_HASHMAP* varmap, SCIP_HASHMAP* consmap, SCIP_Bool initial,
415 SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local,
416 SCIP_Bool modifiable, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode,
417 SCIP_Bool isglobal, SCIP_Bool* valid):
419 PyConshdlr = getPyConshdlr(sourceconshdlr)
420 PyConshdlr.conscopy()
424 cdef SCIP_RETCODE PyConsParse (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS** cons, const char* name, const char* str,
425 SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate,
426 SCIP_Bool local, SCIP_Bool modifiable, SCIP_Bool dynamic, SCIP_Bool removable,
427 SCIP_Bool stickingatnode, SCIP_Bool* success):
429 PyConshdlr = getPyConshdlr(conshdlr)
430 PyConshdlr.consparse()
434 cdef SCIP_RETCODE PyConsGetvars (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS* cons, SCIP_VAR** vars, int varssize, SCIP_Bool* success):
436 PyConshdlr = getPyConshdlr(conshdlr)
437 PyCons = getPyCons(cons)
438 PyConshdlr.consgetvars(PyCons)
442 cdef SCIP_RETCODE PyConsGetnvars (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS* cons, int* nvars, SCIP_Bool* success):
443 PyConshdlr = getPyConshdlr(conshdlr)
444 PyCons = getPyCons(cons)
445 result_dict = PyConshdlr.consgetnvars(PyCons)
446 nvars[0] = result_dict.get(
"nvars", 0)
447 success[0] = result_dict.get(
"success",
False)
450 cdef SCIP_RETCODE PyConsGetdivebdchgs (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_DIVESET* diveset, SCIP_SOL* sol,
451 SCIP_Bool* success, SCIP_Bool* infeasible):
453 PyConshdlr = getPyConshdlr(conshdlr)
454 PyConshdlr.consgetdivebdchgs()
456 infeasible[0] =
False SCIP_CONSHDLRDATA * SCIPconshdlrGetData(SCIP_CONSHDLR *conshdlr)
SCIP_RETCODE SCIPcreateCons(SCIP *scip, SCIP_CONS **cons, const char *name, SCIP_CONSHDLR *conshdlr, SCIP_CONSDATA *consdata, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool modifiable, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode)
SCIP_CONSDATA * SCIPconsGetData(SCIP_CONS *cons)