Scippy

SCIP

Solving Constraint Integer Programs

objconshdlr.cpp
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the program and library */
4 /* SCIP --- Solving Constraint Integer Programs */
5 /* */
6 /* Copyright (C) 2002-2020 Konrad-Zuse-Zentrum */
7 /* fuer Informationstechnik Berlin */
8 /* */
9 /* SCIP is distributed under the terms of the ZIB Academic License. */
10 /* */
11 /* You should have received a copy of the ZIB Academic License. */
12 /* along with SCIP; see the file COPYING. If not visit scipopt.org. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file objconshdlr.cpp
17  * @brief C++ wrapper for constraint handlers
18  * @author Tobias Achterberg
19  */
20 
21 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
22 
23 #include <cassert>
24 
25 #include "objconshdlr.h"
26 
27 
28 
29 
30 /*
31  * Data structures
32  */
33 
34 /** constraint handler data */
35 struct SCIP_ConshdlrData
36 {
37  scip::ObjConshdlr* objconshdlr; /**< constraint handler object */
38  SCIP_Bool deleteobject; /**< should the constraint handler object be deleted when conshdlr is freed? */
39 };
40 
41 
42 
43 
44 /*
45  * Callback methods of constraint handler
46  */
47 
48 extern "C"
49 {
50 
51 /** copy method for constraint handler plugins (called when SCIP copies plugins) */
52 static
53 SCIP_DECL_CONSHDLRCOPY(conshdlrCopyObj)
54 { /*lint --e{715}*/
55  SCIP_CONSHDLRDATA* conshdlrdata;
56 
57  assert(scip != NULL);
58 
59  conshdlrdata = SCIPconshdlrGetData(conshdlr);
60  assert(conshdlrdata != NULL);
61  assert(conshdlrdata->objconshdlr != NULL);
62  assert(conshdlrdata->objconshdlr->scip_ != scip);
63 
64  if( conshdlrdata->objconshdlr->iscloneable() )
65  {
66  scip::ObjConshdlr* newobjconshdlr;
67  newobjconshdlr = dynamic_cast<scip::ObjConshdlr*> (conshdlrdata->objconshdlr->clone(scip, valid));
68 
69  /* call include method of constraint handler object */
70  SCIP_CALL( SCIPincludeObjConshdlr(scip, newobjconshdlr, TRUE) );
71  }
72 
73  return SCIP_OKAY;
74 }
75 
76 /** destructor of constraint handler to free user data (called when SCIP is exiting) */
77 static
78 SCIP_DECL_CONSFREE(consFreeObj)
79 { /*lint --e{715}*/
80  SCIP_CONSHDLRDATA* conshdlrdata;
81 
82  conshdlrdata = SCIPconshdlrGetData(conshdlr);
83  assert(conshdlrdata != NULL);
84  assert(conshdlrdata->objconshdlr != NULL);
85  assert(conshdlrdata->objconshdlr->scip_ == scip);
86 
87  /* call virtual method of conshdlr object */
88  SCIP_CALL( conshdlrdata->objconshdlr->scip_free(scip, conshdlr) );
89 
90  /* free conshdlr object */
91  if( conshdlrdata->deleteobject )
92  delete conshdlrdata->objconshdlr;
93 
94  /* free conshdlr data */
95  delete conshdlrdata;
96  SCIPconshdlrSetData(conshdlr, NULL); /*lint !e64*/
97 
98  return SCIP_OKAY;
99 }
100 
101 
102 /** initialization method of constraint handler (called after problem was transformed) */
103 static
104 SCIP_DECL_CONSINIT(consInitObj)
105 { /*lint --e{715}*/
106  SCIP_CONSHDLRDATA* conshdlrdata;
107 
108  conshdlrdata = SCIPconshdlrGetData(conshdlr);
109  assert(conshdlrdata != NULL);
110  assert(conshdlrdata->objconshdlr != NULL);
111  assert(conshdlrdata->objconshdlr->scip_ == scip);
112 
113  /* call virtual method of conshdlr object */
114  SCIP_CALL( conshdlrdata->objconshdlr->scip_init(scip, conshdlr, conss, nconss) );
115 
116  return SCIP_OKAY;
117 }
118 
119 
120 /** deinitialization method of constraint handler (called before transformed problem is freed) */
121 static
122 SCIP_DECL_CONSEXIT(consExitObj)
123 { /*lint --e{715}*/
124  SCIP_CONSHDLRDATA* conshdlrdata;
125 
126  conshdlrdata = SCIPconshdlrGetData(conshdlr);
127  assert(conshdlrdata != NULL);
128  assert(conshdlrdata->objconshdlr != NULL);
129 
130  /* call virtual method of conshdlr object */
131  SCIP_CALL( conshdlrdata->objconshdlr->scip_exit(scip, conshdlr, conss, nconss) );
132 
133  return SCIP_OKAY;
134 }
135 
136 
137 /** presolving initialization method of constraint handler (called when presolving is about to begin) */
138 static
139 SCIP_DECL_CONSINITPRE(consInitpreObj)
140 { /*lint --e{715}*/
141  SCIP_CONSHDLRDATA* conshdlrdata;
142 
143  conshdlrdata = SCIPconshdlrGetData(conshdlr);
144  assert(conshdlrdata != NULL);
145  assert(conshdlrdata->objconshdlr != NULL);
146 
147  /* call virtual method of conshdlr object */
148  SCIP_CALL( conshdlrdata->objconshdlr->scip_initpre(scip, conshdlr, conss, nconss) );
149 
150  return SCIP_OKAY;
151 }
152 
153 
154 /** presolving deinitialization method of constraint handler (called after presolving has been finished) */
155 static
156 SCIP_DECL_CONSEXITPRE(consExitpreObj)
157 { /*lint --e{715}*/
158  SCIP_CONSHDLRDATA* conshdlrdata;
159 
160  conshdlrdata = SCIPconshdlrGetData(conshdlr);
161  assert(conshdlrdata != NULL);
162  assert(conshdlrdata->objconshdlr != NULL);
163 
164  /* call virtual method of conshdlr object */
165  SCIP_CALL( conshdlrdata->objconshdlr->scip_exitpre(scip, conshdlr, conss, nconss) );
166 
167  return SCIP_OKAY;
168 }
169 
170 
171 /** solving process initialization method of constraint handler (called when branch and bound process is about to begin) */
172 static
173 SCIP_DECL_CONSINITSOL(consInitsolObj)
174 { /*lint --e{715}*/
175  SCIP_CONSHDLRDATA* conshdlrdata;
176 
177  conshdlrdata = SCIPconshdlrGetData(conshdlr);
178  assert(conshdlrdata != NULL);
179  assert(conshdlrdata->objconshdlr != NULL);
180 
181  /* call virtual method of conshdlr object */
182  SCIP_CALL( conshdlrdata->objconshdlr->scip_initsol(scip, conshdlr, conss, nconss) );
183 
184  return SCIP_OKAY;
185 }
186 
187 
188 /** solving process deinitialization method of constraint handler (called before branch and bound process data is freed) */
189 static
190 SCIP_DECL_CONSEXITSOL(consExitsolObj)
191 { /*lint --e{715}*/
192  SCIP_CONSHDLRDATA* conshdlrdata;
193 
194  conshdlrdata = SCIPconshdlrGetData(conshdlr);
195  assert(conshdlrdata != NULL);
196  assert(conshdlrdata->objconshdlr != NULL);
197 
198  /* call virtual method of conshdlr object */
199  SCIP_CALL( conshdlrdata->objconshdlr->scip_exitsol(scip, conshdlr, conss, nconss, restart) );
200 
201  return SCIP_OKAY;
202 }
203 
204 
205 /** frees specific constraint data */
206 static
207 SCIP_DECL_CONSDELETE(consDeleteObj)
208 { /*lint --e{715}*/
209  SCIP_CONSHDLRDATA* conshdlrdata;
210 
211  conshdlrdata = SCIPconshdlrGetData(conshdlr);
212  assert(conshdlrdata != NULL);
213  assert(conshdlrdata->objconshdlr != NULL);
214 
215  /* call virtual method of conshdlr object */
216  SCIP_CALL( conshdlrdata->objconshdlr->scip_delete(scip, conshdlr, cons, consdata) );
217 
218  return SCIP_OKAY;
219 }
220 
221 
222 /** transforms constraint data into data belonging to the transformed problem */
223 static
224 SCIP_DECL_CONSTRANS(consTransObj)
225 { /*lint --e{715}*/
226  SCIP_CONSHDLRDATA* conshdlrdata;
227 
228  conshdlrdata = SCIPconshdlrGetData(conshdlr);
229  assert(conshdlrdata != NULL);
230  assert(conshdlrdata->objconshdlr != NULL);
231 
232  /* call virtual method of conshdlr object */
233  SCIP_CALL( conshdlrdata->objconshdlr->scip_trans(scip, conshdlr, sourcecons, targetcons) );
234 
235  return SCIP_OKAY;
236 }
237 
238 
239 /** LP initialization method of constraint handler */
240 static
241 SCIP_DECL_CONSINITLP(consInitlpObj)
242 { /*lint --e{715}*/
243  SCIP_CONSHDLRDATA* conshdlrdata;
244 
245  conshdlrdata = SCIPconshdlrGetData(conshdlr);
246  assert(conshdlrdata != NULL);
247  assert(conshdlrdata->objconshdlr != NULL);
248 
249  /* call virtual method of conshdlr object */
250  SCIP_CALL( conshdlrdata->objconshdlr->scip_initlp(scip, conshdlr, conss, nconss, infeasible) );
251 
252  return SCIP_OKAY;
253 }
254 
255 
256 /** separation method of constraint handler for LP solutions */
257 static
258 SCIP_DECL_CONSSEPALP(consSepalpObj)
259 { /*lint --e{715}*/
260  SCIP_CONSHDLRDATA* conshdlrdata;
261 
262  conshdlrdata = SCIPconshdlrGetData(conshdlr);
263  assert(conshdlrdata != NULL);
264  assert(conshdlrdata->objconshdlr != NULL);
265 
266  /* call virtual method of conshdlr object */
267  SCIP_CALL( conshdlrdata->objconshdlr->scip_sepalp(scip, conshdlr, conss, nconss, nusefulconss, result) );
268 
269  return SCIP_OKAY;
270 }
271 
272 
273 /** separation method of constraint handler for arbitrary primal solutions */
274 static
275 SCIP_DECL_CONSSEPASOL(consSepasolObj)
276 { /*lint --e{715}*/
277  SCIP_CONSHDLRDATA* conshdlrdata;
278 
279  conshdlrdata = SCIPconshdlrGetData(conshdlr);
280  assert(conshdlrdata != NULL);
281  assert(conshdlrdata->objconshdlr != NULL);
282 
283  /* call virtual method of conshdlr object */
284  SCIP_CALL( conshdlrdata->objconshdlr->scip_sepasol(scip, conshdlr, conss, nconss, nusefulconss, sol, result) );
285 
286  return SCIP_OKAY;
287 }
288 
289 
290 /** constraint enforcing method of constraint handler for LP solutions */
291 static
292 SCIP_DECL_CONSENFOLP(consEnfolpObj)
293 { /*lint --e{715}*/
294  SCIP_CONSHDLRDATA* conshdlrdata;
295 
296  conshdlrdata = SCIPconshdlrGetData(conshdlr);
297  assert(conshdlrdata != NULL);
298  assert(conshdlrdata->objconshdlr != NULL);
299 
300  /* call virtual method of conshdlr object */
301  SCIP_CALL( conshdlrdata->objconshdlr->scip_enfolp(scip, conshdlr, conss, nconss, nusefulconss, solinfeasible, result) );
302 
303  return SCIP_OKAY;
304 }
305 
306 
307 /** constraint enforcing method of constraint handler for relaxation solutions */
308 static
309 SCIP_DECL_CONSENFORELAX(consEnforelaxObj)
310 { /*lint --e{715}*/
311  SCIP_CONSHDLRDATA* conshdlrdata;
312 
313  conshdlrdata = SCIPconshdlrGetData(conshdlr);
314  assert(conshdlrdata != NULL);
315  assert(conshdlrdata->objconshdlr != NULL);
316 
317  /* call virtual method of conshdlr object */
318  SCIP_CALL( conshdlrdata->objconshdlr->scip_enforelax(scip, sol, conshdlr, conss, nconss, nusefulconss, solinfeasible, result) );
319 
320  return SCIP_OKAY;
321 }
322 
323 
324 /** constraint enforcing method of constraint handler for pseudo solutions */
325 static
326 SCIP_DECL_CONSENFOPS(consEnfopsObj)
327 { /*lint --e{715}*/
328  SCIP_CONSHDLRDATA* conshdlrdata;
329 
330  conshdlrdata = SCIPconshdlrGetData(conshdlr);
331  assert(conshdlrdata != NULL);
332  assert(conshdlrdata->objconshdlr != NULL);
333 
334  /* call virtual method of conshdlr object */
335  SCIP_CALL( conshdlrdata->objconshdlr->scip_enfops(scip, conshdlr, conss, nconss, nusefulconss,
336  solinfeasible, objinfeasible, result) );
337 
338  return SCIP_OKAY;
339 }
340 
341 
342 /** feasibility check method of constraint handler for primal solutions */
343 static
344 SCIP_DECL_CONSCHECK(consCheckObj)
345 { /*lint --e{715}*/
346  SCIP_CONSHDLRDATA* conshdlrdata;
347 
348  conshdlrdata = SCIPconshdlrGetData(conshdlr);
349  assert(conshdlrdata != NULL);
350  assert(conshdlrdata->objconshdlr != NULL);
351 
352  /* call virtual method of conshdlr object */
353  SCIP_CALL( conshdlrdata->objconshdlr->scip_check(scip, conshdlr, conss, nconss, sol,
354  checkintegrality, checklprows, printreason, completely, result) );
355 
356  return SCIP_OKAY;
357 }
358 
359 
360 /** domain propagation method of constraint handler */
361 static
362 SCIP_DECL_CONSPROP(consPropObj)
363 { /*lint --e{715}*/
364  SCIP_CONSHDLRDATA* conshdlrdata;
365 
366  conshdlrdata = SCIPconshdlrGetData(conshdlr);
367  assert(conshdlrdata != NULL);
368  assert(conshdlrdata->objconshdlr != NULL);
369 
370  /* call virtual method of conshdlr object */
371  SCIP_CALL( conshdlrdata->objconshdlr->scip_prop(scip, conshdlr, conss, nconss, nusefulconss, nmarkedconss, proptiming, result) );
372 
373  return SCIP_OKAY;
374 }
375 
376 
377 /** presolving method of constraint handler */
378 static
379 SCIP_DECL_CONSPRESOL(consPresolObj)
380 { /*lint --e{715}*/
381  SCIP_CONSHDLRDATA* conshdlrdata;
382 
383  conshdlrdata = SCIPconshdlrGetData(conshdlr);
384  assert(conshdlrdata != NULL);
385  assert(conshdlrdata->objconshdlr != NULL);
386 
387  /* call virtual method of conshdlr object */
388  SCIP_CALL( conshdlrdata->objconshdlr->scip_presol(scip, conshdlr, conss, nconss, nrounds, presoltiming,
389  nnewfixedvars, nnewaggrvars, nnewchgvartypes, nnewchgbds, nnewholes,
390  nnewdelconss, nnewaddconss, nnewupgdconss, nnewchgcoefs, nnewchgsides,
391  nfixedvars, naggrvars, nchgvartypes, nchgbds, naddholes,
392  ndelconss, naddconss, nupgdconss, nchgcoefs, nchgsides, result) );
393 
394  return SCIP_OKAY;
395 }
396 
397 
398 /** propagation conflict resolving method of constraint handler */
399 static
400 SCIP_DECL_CONSRESPROP(consRespropObj)
401 { /*lint --e{715}*/
402  SCIP_CONSHDLRDATA* conshdlrdata;
403 
404  conshdlrdata = SCIPconshdlrGetData(conshdlr);
405  assert(conshdlrdata != NULL);
406  assert(conshdlrdata->objconshdlr != NULL);
407 
408  /* call virtual method of conshdlr object */
409  SCIP_CALL( conshdlrdata->objconshdlr->scip_resprop(scip, conshdlr, cons, infervar, inferinfo, boundtype, bdchgidx,
410  relaxedbd, result) );
411 
412  return SCIP_OKAY;
413 }
414 
415 
416 /** variable rounding lock method of constraint handler */
417 static
418 SCIP_DECL_CONSLOCK(consLockObj)
419 { /*lint --e{715}*/
420  SCIP_CONSHDLRDATA* conshdlrdata;
421 
422  conshdlrdata = SCIPconshdlrGetData(conshdlr);
423  assert(conshdlrdata != NULL);
424  assert(conshdlrdata->objconshdlr != NULL);
425 
426  /* call virtual method of conshdlr object */
427  SCIP_CALL( conshdlrdata->objconshdlr->scip_lock(scip, conshdlr, cons, locktype, nlockspos, nlocksneg) );
428 
429  return SCIP_OKAY;
430 }
431 
432 
433 /** constraint activation notification method of constraint handler */
434 static
435 SCIP_DECL_CONSACTIVE(consActiveObj)
436 { /*lint --e{715}*/
437  SCIP_CONSHDLRDATA* conshdlrdata;
438 
439  conshdlrdata = SCIPconshdlrGetData(conshdlr);
440  assert(conshdlrdata != NULL);
441  assert(conshdlrdata->objconshdlr != NULL);
442 
443  /* call virtual method of conshdlr object */
444  SCIP_CALL( conshdlrdata->objconshdlr->scip_active(scip, conshdlr, cons) );
445 
446  return SCIP_OKAY;
447 }
448 
449 
450 /** constraint deactivation notification method of constraint handler */
451 static
452 SCIP_DECL_CONSDEACTIVE(consDeactiveObj)
453 { /*lint --e{715}*/
454  SCIP_CONSHDLRDATA* conshdlrdata;
455 
456  conshdlrdata = SCIPconshdlrGetData(conshdlr);
457  assert(conshdlrdata != NULL);
458  assert(conshdlrdata->objconshdlr != NULL);
459 
460  /* call virtual method of conshdlr object */
461  SCIP_CALL( conshdlrdata->objconshdlr->scip_deactive(scip, conshdlr, cons) );
462 
463  return SCIP_OKAY;
464 }
465 
466 
467 /** constraint enabling notification method of constraint handler */
468 static
469 SCIP_DECL_CONSENABLE(consEnableObj)
470 { /*lint --e{715}*/
471  SCIP_CONSHDLRDATA* conshdlrdata;
472 
473  conshdlrdata = SCIPconshdlrGetData(conshdlr);
474  assert(conshdlrdata != NULL);
475  assert(conshdlrdata->objconshdlr != NULL);
476 
477  /* call virtual method of conshdlr object */
478  SCIP_CALL( conshdlrdata->objconshdlr->scip_enable(scip, conshdlr, cons) );
479 
480  return SCIP_OKAY;
481 }
482 
483 
484 /** constraint disabling notification method of constraint handler */
485 static
486 SCIP_DECL_CONSDISABLE(consDisableObj)
487 { /*lint --e{715}*/
488  SCIP_CONSHDLRDATA* conshdlrdata;
489 
490  conshdlrdata = SCIPconshdlrGetData(conshdlr);
491  assert(conshdlrdata != NULL);
492  assert(conshdlrdata->objconshdlr != NULL);
493 
494  /* call virtual method of conshdlr object */
495  SCIP_CALL( conshdlrdata->objconshdlr->scip_disable(scip, conshdlr, cons) );
496 
497  return SCIP_OKAY;
498 }
499 
500 /** variable deletion method of constraint handler */
501 static
502 SCIP_DECL_CONSDELVARS(consDelVarsObj)
503 { /*lint --e{715}*/
504  SCIP_CONSHDLRDATA* conshdlrdata;
505 
506  conshdlrdata = SCIPconshdlrGetData(conshdlr);
507  assert(conshdlrdata != NULL);
508  assert(conshdlrdata->objconshdlr != NULL);
509 
510  /* call virtual method of conshdlr object */
511  SCIP_CALL( conshdlrdata->objconshdlr->scip_delvars(scip, conshdlr, conss, nconss) );
512 
513  return SCIP_OKAY;
514 }
515 
516 /** constraint display method of constraint handler */
517 static
518 SCIP_DECL_CONSPRINT(consPrintObj)
519 { /*lint --e{715}*/
520  SCIP_CONSHDLRDATA* conshdlrdata;
521 
522  conshdlrdata = SCIPconshdlrGetData(conshdlr);
523  assert(conshdlrdata != NULL);
524  assert(conshdlrdata->objconshdlr != NULL);
525 
526  /* call virtual method of conshdlr object */
527  SCIP_CALL( conshdlrdata->objconshdlr->scip_print(scip, conshdlr, cons, file) );
528 
529  return SCIP_OKAY;
530 }
531 
532 /** constraint copying method of constraint handler */
533 static
534 SCIP_DECL_CONSCOPY(consCopyObj)
535 { /*lint --e{715}*/
536  SCIP_CONSHDLRDATA* sourceconshdlrdata;
537 
538  sourceconshdlrdata = SCIPconshdlrGetData(sourceconshdlr);
539  assert(sourceconshdlrdata != NULL);
540  assert(sourceconshdlrdata->objconshdlr != NULL);
541 
542  /* call virtual method of conshdlr object */
543  SCIP_CALL( sourceconshdlrdata->objconshdlr->scip_copy(scip, cons, name, sourcescip, sourceconshdlr, sourcecons, varmap, consmap,
544  initial, separate, enforce, check, propagate, local, modifiable, dynamic, removable, stickingatnode, global, valid) );
545 
546  return SCIP_OKAY;
547 }
548 
549 /** constraint parsing method of constraint handler */
550 static
551 SCIP_DECL_CONSPARSE(consParseObj)
552 { /*lint --e{715}*/
553  SCIP_CONSHDLRDATA* conshdlrdata;
554 
555  conshdlrdata = SCIPconshdlrGetData(conshdlr);
556  assert(conshdlrdata != NULL);
557  assert(conshdlrdata->objconshdlr != NULL);
558 
559  /* call virtual method of conshdlr object */
560  SCIP_CALL( conshdlrdata->objconshdlr->scip_parse(scip, conshdlr, cons, name, str,
561  initial, separate, enforce, check, propagate, local, modifiable, dynamic, removable, stickingatnode, success) );
562 
563  return SCIP_OKAY;
564 }
565 
566 /** constraint method of constraint handler which returns the variables (if possible) */
567 static
568 SCIP_DECL_CONSGETVARS(consGetVarsObj)
569 { /*lint --e{715}*/
570  SCIP_CONSHDLRDATA* conshdlrdata;
571 
572  conshdlrdata = SCIPconshdlrGetData(conshdlr);
573  assert(conshdlrdata != NULL);
574  assert(conshdlrdata->objconshdlr != NULL);
575 
576  /* call virtual method of conshdlr object */
577  SCIP_CALL( conshdlrdata->objconshdlr->scip_getvars(scip, conshdlr, cons, vars, varssize, success) );
578 
579  return SCIP_OKAY;
580 }
581 
582 /** constraint method of constraint handler which returns the number of variables (if possible) */
583 static
584 SCIP_DECL_CONSGETNVARS(consGetNVarsObj)
585 { /*lint --e{715}*/
586  SCIP_CONSHDLRDATA* conshdlrdata;
587 
588  conshdlrdata = SCIPconshdlrGetData(conshdlr);
589  assert(conshdlrdata != NULL);
590  assert(conshdlrdata->objconshdlr != NULL);
591 
592  /* call virtual method of conshdlr object */
593  SCIP_CALL( conshdlrdata->objconshdlr->scip_getnvars(scip, conshdlr, cons, nvars, success) );
594 
595  return SCIP_OKAY;
596 }
597 
598 /** constraint handler method to suggest dive bound changes during the generic diving algorithm */
599 static
600 SCIP_DECL_CONSGETDIVEBDCHGS(consGetDiveBdChgsObj)
601 { /*lint --e{715}*/
602  SCIP_CONSHDLRDATA* conshdlrdata;
603 
604  conshdlrdata = SCIPconshdlrGetData(conshdlr);
605  assert(conshdlrdata != NULL);
606  assert(conshdlrdata->objconshdlr != NULL);
607 
608  /* call virtual method of conshdlr object */
609  SCIP_CALL( conshdlrdata->objconshdlr->scip_getdivebdchgs(scip, conshdlr, diveset, sol, success, infeasible) );
610 
611  return SCIP_OKAY;
612 }
613 }
614 
615 
616 /*
617  * constraint handler specific interface methods
618  */
619 
620 /** creates the constraint handler for the given constraint handler object and includes it in SCIP */
622  SCIP* scip, /**< SCIP data structure */
623  scip::ObjConshdlr* objconshdlr, /**< constraint handler object */
624  SCIP_Bool deleteobject /**< should the constraint handler object be deleted when conshdlr is freed? */
625  )
626 {
627  SCIP_CONSHDLRDATA* conshdlrdata;
628 
629  assert(scip != NULL);
630  assert(objconshdlr != NULL);
631  assert(objconshdlr->scip_ == scip);
632 
633  /* create obj constraint handler data */
634  conshdlrdata = new SCIP_CONSHDLRDATA;
635  conshdlrdata->objconshdlr = objconshdlr;
636  conshdlrdata->deleteobject = deleteobject;
637 
638  /* include constraint handler */
639  SCIP_CALL( SCIPincludeConshdlr(scip, objconshdlr->scip_name_, objconshdlr->scip_desc_,
640  objconshdlr->scip_sepapriority_, objconshdlr->scip_enfopriority_, objconshdlr->scip_checkpriority_,
641  objconshdlr->scip_sepafreq_, objconshdlr->scip_propfreq_, objconshdlr->scip_eagerfreq_,
642  objconshdlr->scip_maxprerounds_,
643  objconshdlr->scip_delaysepa_, objconshdlr->scip_delayprop_,
644  objconshdlr->scip_needscons_, objconshdlr->scip_proptiming_, objconshdlr->scip_presoltiming_,
645  conshdlrCopyObj,
646  consFreeObj, consInitObj, consExitObj,
647  consInitpreObj, consExitpreObj, consInitsolObj, consExitsolObj,
648  consDeleteObj, consTransObj, consInitlpObj,
649  consSepalpObj, consSepasolObj, consEnfolpObj, consEnforelaxObj, consEnfopsObj, consCheckObj,
650  consPropObj, consPresolObj, consRespropObj, consLockObj,
651  consActiveObj, consDeactiveObj,
652  consEnableObj, consDisableObj, consDelVarsObj,
653  consPrintObj, consCopyObj, consParseObj,
654  consGetVarsObj, consGetNVarsObj, consGetDiveBdChgsObj, conshdlrdata) ); /*lint !e429*/
655 
656  return SCIP_OKAY; /*lint !e429*/
657 }
658 
659 /** returns the conshdlr object of the given name, or 0 if not existing */
661  SCIP* scip, /**< SCIP data structure */
662  const char* name /**< name of constraint handler */
663  )
664 {
665  SCIP_CONSHDLR* conshdlr;
666  SCIP_CONSHDLRDATA* conshdlrdata;
667 
668  conshdlr = SCIPfindConshdlr(scip, name);
669  if( conshdlr == NULL )
670  return 0;
671 
672  conshdlrdata = SCIPconshdlrGetData(conshdlr);
673  assert(conshdlrdata != NULL);
674 
675  return conshdlrdata->objconshdlr;
676 }
677 
678 /** returns the conshdlr object for the given constraint handler */
680  SCIP* scip, /**< SCIP data structure */
681  SCIP_CONSHDLR* conshdlr /**< constraint handler */
682  )
683 {
684  SCIP_CONSHDLRDATA* conshdlrdata;
685 
686  assert(scip != NULL);
687  conshdlrdata = SCIPconshdlrGetData(conshdlr);
688  assert(conshdlrdata != NULL);
689 
690  return conshdlrdata->objconshdlr;
691 }
static SCIP_DECL_CONSDISABLE(consDisableObj)
void SCIPconshdlrSetData(SCIP_CONSHDLR *conshdlr, SCIP_CONSHDLRDATA *conshdlrdata)
Definition: cons.c:4209
static SCIP_DECL_CONSPRESOL(consPresolObj)
const SCIP_Bool scip_delaysepa_
Definition: objconshdlr.h:83
SCIP_CONSHDLR * SCIPfindConshdlr(SCIP *scip, const char *name)
Definition: scip_cons.c:877
static SCIP_DECL_CONSEXITPRE(consExitpreObj)
const int scip_eagerfreq_
Definition: objconshdlr.h:77
static SCIP_DECL_CONSINIT(consInitObj)
const SCIP_Bool scip_needscons_
Definition: objconshdlr.h:89
static SCIP_DECL_CONSDEACTIVE(consDeactiveObj)
static SCIP_DECL_CONSRESPROP(consRespropObj)
static SCIP_DECL_CONSCHECK(consCheckObj)
const int scip_propfreq_
Definition: objconshdlr.h:74
static SCIP_DECL_CONSGETDIVEBDCHGS(consGetDiveBdChgsObj)
static SCIP_DECL_CONSGETVARS(consGetVarsObj)
static SCIP_DECL_CONSEXIT(consExitObj)
#define TRUE
Definition: def.h:72
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:54
static SCIP_DECL_CONSINITSOL(consInitsolObj)
static SCIP_DECL_CONSENFOPS(consEnfopsObj)
static SCIP_DECL_CONSLOCK(consLockObj)
static SCIP_DECL_CONSGETNVARS(consGetNVarsObj)
const SCIP_PROPTIMING scip_proptiming_
Definition: objconshdlr.h:92
C++ wrapper for constraint handlers.
static SCIP_DECL_CONSHDLRCOPY(conshdlrCopyObj)
Definition: objconshdlr.cpp:53
SCIP_RETCODE SCIPincludeConshdlr(SCIP *scip, const char *name, const char *desc, int sepapriority, int enfopriority, int chckpriority, int sepafreq, int propfreq, int eagerfreq, int maxprerounds, SCIP_Bool delaysepa, SCIP_Bool delayprop, SCIP_Bool needscons, SCIP_PROPTIMING proptiming, SCIP_PRESOLTIMING presoltiming, SCIP_DECL_CONSHDLRCOPY((*conshdlrcopy)), SCIP_DECL_CONSFREE((*consfree)), SCIP_DECL_CONSINIT((*consinit)), SCIP_DECL_CONSEXIT((*consexit)), SCIP_DECL_CONSINITPRE((*consinitpre)), SCIP_DECL_CONSEXITPRE((*consexitpre)), SCIP_DECL_CONSINITSOL((*consinitsol)), SCIP_DECL_CONSEXITSOL((*consexitsol)), SCIP_DECL_CONSDELETE((*consdelete)), SCIP_DECL_CONSTRANS((*constrans)), SCIP_DECL_CONSINITLP((*consinitlp)), SCIP_DECL_CONSSEPALP((*conssepalp)), SCIP_DECL_CONSSEPASOL((*conssepasol)), SCIP_DECL_CONSENFOLP((*consenfolp)), SCIP_DECL_CONSENFORELAX((*consenforelax)), SCIP_DECL_CONSENFOPS((*consenfops)), SCIP_DECL_CONSCHECK((*conscheck)), SCIP_DECL_CONSPROP((*consprop)), SCIP_DECL_CONSPRESOL((*conspresol)), SCIP_DECL_CONSRESPROP((*consresprop)), SCIP_DECL_CONSLOCK((*conslock)), SCIP_DECL_CONSACTIVE((*consactive)), SCIP_DECL_CONSDEACTIVE((*consdeactive)), SCIP_DECL_CONSENABLE((*consenable)), SCIP_DECL_CONSDISABLE((*consdisable)), SCIP_DECL_CONSDELVARS((*consdelvars)), SCIP_DECL_CONSPRINT((*consprint)), SCIP_DECL_CONSCOPY((*conscopy)), SCIP_DECL_CONSPARSE((*consparse)), SCIP_DECL_CONSGETVARS((*consgetvars)), SCIP_DECL_CONSGETNVARS((*consgetnvars)), SCIP_DECL_CONSGETDIVEBDCHGS((*consgetdivebdchgs)), SCIP_CONSHDLRDATA *conshdlrdata)
Definition: scip_cons.c:73
SCIP_RETCODE SCIPincludeObjConshdlr(SCIP *scip, scip::ObjConshdlr *objconshdlr, SCIP_Bool deleteobject)
scip::ObjConshdlr * SCIPfindObjConshdlr(SCIP *scip, const char *name)
static SCIP_DECL_CONSENABLE(consEnableObj)
const int scip_maxprerounds_
Definition: objconshdlr.h:80
const int scip_sepapriority_
Definition: objconshdlr.h:62
const SCIP_Bool scip_delayprop_
Definition: objconshdlr.h:86
#define NULL
Definition: lpi_spx1.cpp:155
static SCIP_DECL_CONSACTIVE(consActiveObj)
#define SCIP_CALL(x)
Definition: def.h:364
static SCIP_DECL_CONSENFOLP(consEnfolpObj)
#define SCIP_Bool
Definition: def.h:70
static SCIP_DECL_CONSTRANS(consTransObj)
SCIP_CONSHDLRDATA * SCIPconshdlrGetData(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4199
const int scip_sepafreq_
Definition: objconshdlr.h:71
static SCIP_DECL_CONSDELVARS(consDelVarsObj)
static SCIP_DECL_CONSENFORELAX(consEnforelaxObj)
C++ wrapper for constraint handlers.
Definition: objconshdlr.h:47
static SCIP_DECL_CONSINITLP(consInitlpObj)
static SCIP_DECL_CONSPROP(consPropObj)
scip::ObjConshdlr * SCIPgetObjConshdlr(SCIP *scip, SCIP_CONSHDLR *conshdlr)
static SCIP_DECL_CONSEXITSOL(consExitsolObj)
static SCIP_DECL_CONSDELETE(consDeleteObj)
const int scip_checkpriority_
Definition: objconshdlr.h:68
static SCIP_DECL_CONSSEPASOL(consSepasolObj)
static SCIP_DECL_CONSCOPY(consCopyObj)
const SCIP_PRESOLTIMING scip_presoltiming_
Definition: objconshdlr.h:95
static SCIP_DECL_CONSPARSE(consParseObj)
static SCIP_DECL_CONSINITPRE(consInitpreObj)
static SCIP_DECL_CONSFREE(consFreeObj)
Definition: objconshdlr.cpp:78
struct SCIP_ConshdlrData SCIP_CONSHDLRDATA
Definition: type_cons.h:55
static SCIP_DECL_CONSPRINT(consPrintObj)
const int scip_enfopriority_
Definition: objconshdlr.h:65
static SCIP_DECL_CONSSEPALP(consSepalpObj)