Scippy

SCIP

Solving Constraint Integer Programs

pub_cons.h
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-2014 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 email to scip@zib.de. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file pub_cons.h
17  * @ingroup PUBLICMETHODS
18  * @brief public methods for managing constraints
19  * @author Tobias Achterberg
20  */
21 
22 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
23 
24 #ifndef __SCIP_PUB_CONS_H__
25 #define __SCIP_PUB_CONS_H__
26 
27 
28 #include "scip/def.h"
29 #include "scip/type_misc.h"
30 #include "scip/type_cons.h"
31 
32 #ifdef NDEBUG
33 #include "scip/struct_cons.h"
34 #endif
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 /*
41  * Constraint handler methods
42  */
43 
44 /** compares two constraint handlers w. r. to their separation priority */
45 extern
46 SCIP_DECL_SORTPTRCOMP(SCIPconshdlrCompSepa);
47 
48 /** compares two constraint handlers w. r. to their enforcing priority */
49 extern
50 SCIP_DECL_SORTPTRCOMP(SCIPconshdlrCompEnfo);
51 
52 /** compares two constraint handlers w. r. to their feasibility check priority */
53 extern
54 SCIP_DECL_SORTPTRCOMP(SCIPconshdlrCompCheck);
55 
56 /** gets name of constraint handler */
57 extern
58 const char* SCIPconshdlrGetName(
59  SCIP_CONSHDLR* conshdlr /**< constraint handler */
60  );
61 
62 /** gets description of constraint handler */
63 extern
64 const char* SCIPconshdlrGetDesc(
65  SCIP_CONSHDLR* conshdlr /**< constraint handler */
66  );
67 
68 /** gets user data of constraint handler */
69 extern
71  SCIP_CONSHDLR* conshdlr /**< constraint handler */
72  );
73 
74 /** sets user data of constraint handler; user has to free old data in advance! */
75 extern
77  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
78  SCIP_CONSHDLRDATA* conshdlrdata /**< new constraint handler user data */
79  );
80 
81 /** sets all separation related callbacks of the constraint handler */
82 extern
84  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
85  SCIP_DECL_CONSSEPALP ((*conssepalp)), /**< separate cutting planes for LP solution */
86  SCIP_DECL_CONSSEPASOL ((*conssepasol)), /**< separate cutting planes for arbitrary primal solution */
87  int sepafreq, /**< frequency for separating cuts; zero means to separate only in the root node */
88  int sepapriority, /**< priority of the constraint handler for separation */
89  SCIP_Bool delaysepa /**< should separation method be delayed, if other separators found cuts? */
90  );
91 
92 /** sets both the propagation callback and the propagation frequency of the constraint handler */
93 extern
95  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
96  SCIP_DECL_CONSPROP ((*consprop)), /**< propagate variable domains */
97  int propfreq, /**< frequency for propagating domains; zero means only preprocessing propagation */
98  SCIP_Bool delayprop, /**< should propagation method be delayed, if other propagators found reductions? */
99  SCIP_PROPTIMING timingmask /**< positions in the node solving loop where propagators should be executed */
100  );
101 
102 /** gets array with constraints of constraint handler; the first SCIPconshdlrGetNActiveConss() entries are the active
103  * constraints, the last SCIPconshdlrGetNConss() - SCIPconshdlrGetNActiveConss() constraints are deactivated
104  *
105  * @note A constraint is active if it is global and was not removed or it was added locally (in that case the local
106  * flag is TRUE) and the current node belongs to the corresponding sub tree.
107  */
108 extern
110  SCIP_CONSHDLR* conshdlr /**< constraint handler */
111  );
112 
113 /** gets array with enforced constraints of constraint handler; this is local information */
114 extern
116  SCIP_CONSHDLR* conshdlr /**< constraint handler */
117  );
118 
119 /** gets array with checked constraints of constraint handler; this is local information */
120 extern
122  SCIP_CONSHDLR* conshdlr /**< constraint handler */
123  );
124 
125 /** gets total number of existing transformed constraints of constraint handler */
126 extern
128  SCIP_CONSHDLR* conshdlr /**< constraint handler */
129  );
130 
131 /** gets number of enforced constraints of constraint handler; this is local information */
132 extern
134  SCIP_CONSHDLR* conshdlr /**< constraint handler */
135  );
136 
137 /** gets number of checked constraints of constraint handler; this is local information */
138 extern
140  SCIP_CONSHDLR* conshdlr /**< constraint handler */
141  );
142 
143 /** gets number of active constraints of constraint handler
144  *
145  * @note A constraint is active if it is global and was not removed or it was added locally (in that case the local
146  * flag is TRUE) and the current node belongs to the corresponding sub tree.
147  */
148 extern
150  SCIP_CONSHDLR* conshdlr /**< constraint handler */
151  );
152 
153 /** gets number of enabled constraints of constraint handler */
154 extern
156  SCIP_CONSHDLR* conshdlr /**< constraint handler */
157  );
158 
159 /** gets time in seconds used for setting up this constraint handler for new stages */
160 extern
162  SCIP_CONSHDLR* conshdlr /**< constraint handler */
163  );
164 
165 /** gets time in seconds used for presolving in this constraint handler */
166 extern
168  SCIP_CONSHDLR* conshdlr /**< constraint handler */
169  );
170 
171 /** gets time in seconds used for separation in this constraint handler */
172 extern
174  SCIP_CONSHDLR* conshdlr /**< constraint handler */
175  );
176 
177 /** gets time in seconds used for LP enforcement in this constraint handler */
178 extern
180  SCIP_CONSHDLR* conshdlr /**< constraint handler */
181  );
182 
183 /** gets time in seconds used for pseudo enforcement in this constraint handler */
184 extern
186  SCIP_CONSHDLR* conshdlr /**< constraint handler */
187  );
188 
189 /** gets time in seconds used for propagation in this constraint handler */
190 extern
192  SCIP_CONSHDLR* conshdlr /**< constraint handler */
193  );
194 
195 /** gets time in seconds used for propagation in this constraint handler during strong branching */
196 extern
198  SCIP_CONSHDLR* conshdlr /**< constraint handler */
199  );
200 
201 /** gets time in seconds used for feasibility checking in this constraint handler */
202 extern
204  SCIP_CONSHDLR* conshdlr /**< constraint handler */
205  );
206 
207 /** gets time in seconds used for resolving propagation in this constraint handler */
208 extern
210  SCIP_CONSHDLR* conshdlr /**< constraint handler */
211  );
212 
213 /** gets number of calls to the constraint handler's separation method */
214 extern
216  SCIP_CONSHDLR* conshdlr /**< constraint handler */
217  );
218 
219 /** gets number of calls to the constraint handler's LP enforcing method */
220 extern
222  SCIP_CONSHDLR* conshdlr /**< constraint handler */
223  );
224 
225 /** gets number of calls to the constraint handler's pseudo enforcing method */
226 extern
228  SCIP_CONSHDLR* conshdlr /**< constraint handler */
229  );
230 
231 /** gets number of calls to the constraint handler's propagation method */
232 extern
234  SCIP_CONSHDLR* conshdlr /**< constraint handler */
235  );
236 
237 /** gets number of calls to the constraint handler's checking method */
238 extern
240  SCIP_CONSHDLR* conshdlr /**< constraint handler */
241  );
242 
243 /** gets number of calls to the constraint handler's resolve propagation method */
244 extern
246  SCIP_CONSHDLR* conshdlr /**< constraint handler */
247  );
248 
249 /** gets total number of times, this constraint handler detected a cutoff */
250 extern
252  SCIP_CONSHDLR* conshdlr /**< constraint handler */
253  );
254 
255 /** gets total number of cuts found by this constraint handler */
256 extern
258  SCIP_CONSHDLR* conshdlr /**< constraint handler */
259  );
260 
261 /** gets total number of cuts found by this constraint handler applied to lp */
262 extern
264  SCIP_CONSHDLR* conshdlr /**< constraint handler */
265  );
266 
267 /** gets total number of additional constraints added by this constraint handler */
268 extern
270  SCIP_CONSHDLR* conshdlr /**< constraint handler */
271  );
272 
273 /** gets total number of domain reductions found by this constraint handler */
274 extern
276  SCIP_CONSHDLR* conshdlr /**< constraint handler */
277  );
278 
279 /** gets number of children created by this constraint handler */
280 extern
282  SCIP_CONSHDLR* conshdlr /**< constraint handler */
283  );
284 
285 /** gets maximum number of active constraints of constraint handler existing at the same time */
286 extern
288  SCIP_CONSHDLR* conshdlr /**< constraint handler */
289  );
290 
291 /** gets initial number of active constraints of constraint handler */
292 extern
294  SCIP_CONSHDLR* conshdlr /**< constraint handler */
295  );
296 
297 /** gets number of variables fixed in presolving method of constraint handler */
298 extern
300  SCIP_CONSHDLR* conshdlr /**< constraint handler */
301  );
302 
303 /** gets number of variables aggregated in presolving method of constraint handler */
304 extern
306  SCIP_CONSHDLR* conshdlr /**< constraint handler */
307  );
308 
309 /** gets number of variable types changed in presolving method of constraint handler */
310 extern
312  SCIP_CONSHDLR* conshdlr /**< constraint handler */
313  );
314 
315 /** gets number of bounds changed in presolving method of constraint handler */
316 extern
318  SCIP_CONSHDLR* conshdlr /**< constraint handler */
319  );
320 
321 /** gets number of holes added to domains of variables in presolving method of constraint handler */
322 extern
324  SCIP_CONSHDLR* conshdlr /**< constraint handler */
325  );
326 
327 /** gets number of constraints deleted in presolving method of constraint handler */
328 extern
330  SCIP_CONSHDLR* conshdlr /**< constraint handler */
331  );
332 
333 /** gets number of constraints added in presolving method of constraint handler */
334 extern
336  SCIP_CONSHDLR* conshdlr /**< constraint handler */
337  );
338 
339 /** gets number of constraints upgraded in presolving method of constraint handler */
340 extern
342  SCIP_CONSHDLR* conshdlr /**< constraint handler */
343  );
344 
345 /** gets number of coefficients changed in presolving method of constraint handler */
346 extern
348  SCIP_CONSHDLR* conshdlr /**< constraint handler */
349  );
350 
351 /** gets number of constraint sides changed in presolving method of constraint handler */
352 extern
354  SCIP_CONSHDLR* conshdlr /**< constraint handler */
355  );
356 
357 /** gets number of times the presolving method of the constraint handler was called and tried to find reductions */
358 extern
360  SCIP_CONSHDLR* conshdlr /**< constraint handler */
361  );
362 
363 /** gets separation priority of constraint handler */
364 extern
366  SCIP_CONSHDLR* conshdlr /**< constraint handler */
367  );
368 
369 /** gets enforcing priority of constraint handler */
370 extern
372  SCIP_CONSHDLR* conshdlr /**< constraint handler */
373  );
374 
375 /** gets checking priority of constraint handler */
376 extern
378  SCIP_CONSHDLR* conshdlr /**< constraint handler */
379  );
380 
381 /** gets separation frequency of constraint handler */
382 extern
384  SCIP_CONSHDLR* conshdlr /**< constraint handler */
385  );
386 
387 /** gets propagation frequency of constraint handler */
388 extern
390  SCIP_CONSHDLR* conshdlr /**< constraint handler */
391  );
392 
393 /** gets frequency of constraint handler for eager evaluations in separation, propagation and enforcement */
394 extern
396  SCIP_CONSHDLR* conshdlr /**< constraint handler */
397  );
398 
399 /** needs constraint handler a constraint to be called? */
400 extern
402  SCIP_CONSHDLR* conshdlr /**< constraint handler */
403  );
404 
405 /** does the constraint handler perform presolving? */
406 extern
408  SCIP_CONSHDLR* conshdlr /**< constraint handler */
409  );
410 
411 /** should separation method be delayed, if other separators found cuts? */
412 extern
414  SCIP_CONSHDLR* conshdlr /**< constraint handler */
415  );
416 
417 /** should propagation method be delayed, if other propagators found reductions? */
418 extern
420  SCIP_CONSHDLR* conshdlr /**< constraint handler */
421  );
422 
423 /** should presolving method be delayed, if other presolvers found reductions? */
424 extern
426  SCIP_CONSHDLR* conshdlr /**< constraint handler */
427  );
428 
429 /** was LP separation method delayed at the last call? */
430 extern
432  SCIP_CONSHDLR* conshdlr /**< constraint handler */
433  );
434 
435 /** was primal solution separation method delayed at the last call? */
436 extern
438  SCIP_CONSHDLR* conshdlr /**< constraint handler */
439  );
440 
441 /** was propagation method delayed at the last call? */
442 extern
444  SCIP_CONSHDLR* conshdlr /**< constraint handler */
445  );
446 
447 /** was presolving method delayed at the last call? */
448 extern
450  SCIP_CONSHDLR* conshdlr /**< constraint handler */
451  );
452 
453 /** is constraint handler initialized? */
454 extern
456  SCIP_CONSHDLR* conshdlr /**< constraint handler */
457  );
458 
459 /** does the constraint handler have a copy function? */
460 extern
462  SCIP_CONSHDLR* conshdlr /**< constraint handler */
463  );
464 
465 /** returns the timing mask of the propagation method of the constraint handler */
466 extern
468  SCIP_CONSHDLR* conshdlr /**< constraint handler */
469  );
470 
471 
472 
473 /*
474  * Constraint methods
475  */
476 
477 /** returns the name of the constraint
478  *
479  * @note to change the name of a constraint, use SCIPchgConsName() from scip.h
480  */
481 extern
482 const char* SCIPconsGetName(
483  SCIP_CONS* cons /**< constraint */
484  );
485 
486 /** returns the position of constraint in the corresponding handler's conss array */
487 extern
488 int SCIPconsGetPos(
489  SCIP_CONS* cons /**< constraint */
490  );
491 
492 /** returns the constraint handler of the constraint */
493 extern
495  SCIP_CONS* cons /**< constraint */
496  );
497 
498 /** returns the constraint data field of the constraint */
499 extern
501  SCIP_CONS* cons /**< constraint */
502  );
503 
504 /** gets number of times, the constraint is currently captured */
505 extern
506 int SCIPconsGetNUses(
507  SCIP_CONS* cons /**< constraint */
508  );
509 
510 /** for an active constraint, returns the depth in the tree at which the constraint was activated */
511 extern
513  SCIP_CONS* cons /**< constraint */
514  );
515 
516 /** returns the depth in the tree at which the constraint is valid; returns INT_MAX, if the constraint is local
517  * and currently not active
518  */
519 extern
521  SCIP_CONS* cons /**< constraint */
522  );
523 
524 /** returns TRUE iff constraint is active in the current node */
525 extern
527  SCIP_CONS* cons /**< constraint */
528  );
529 
530 /** returns TRUE iff constraint is enabled in the current node */
531 extern
533  SCIP_CONS* cons /**< constraint */
534  );
535 
536 /** returns TRUE iff constraint's separation is enabled in the current node */
537 extern
539  SCIP_CONS* cons /**< constraint */
540  );
541 
542 /** returns TRUE iff constraint's propagation is enabled in the current node */
543 extern
545  SCIP_CONS* cons /**< constraint */
546  );
547 
548 /** returns TRUE iff constraint is deleted or marked to be deleted */
549 extern
551  SCIP_CONS* cons /**< constraint */
552  );
553 
554 /** returns TRUE iff constraint is marked obsolete */
555 extern
557  SCIP_CONS* cons /**< constraint */
558  );
559 
560 /** gets age of constraint */
561 extern
563  SCIP_CONS* cons /**< constraint */
564  );
565 
566 /** returns TRUE iff the LP relaxation of constraint should be in the initial LP */
567 extern
569  SCIP_CONS* cons /**< constraint */
570  );
571 
572 /** returns TRUE iff constraint should be separated during LP processing */
573 extern
575  SCIP_CONS* cons /**< constraint */
576  );
577 
578 /** returns TRUE iff constraint should be enforced during node processing */
579 extern
581  SCIP_CONS* cons /**< constraint */
582  );
583 
584 /** returns TRUE iff constraint should be checked for feasibility */
585 extern
587  SCIP_CONS* cons /**< constraint */
588  );
589 
590 /** returns whether the constraint is marked for propagation */
591 extern
593  SCIP_CONS* cons /**< constraint */
594  );
595 
596 /** returns TRUE iff constraint should be propagated during node processing */
597 extern
599  SCIP_CONS* cons /**< constraint */
600  );
601 
602 /** returns TRUE iff constraint is globally valid */
603 extern
605  SCIP_CONS* cons /**< constraint */
606  );
607 
608 /** returns TRUE iff constraint is only locally valid or not added to any (sub)problem */
609 extern
611  SCIP_CONS* cons /**< constraint */
612  );
613 
614 /** returns TRUE iff constraint is modifiable (subject to column generation) */
615 extern
617  SCIP_CONS* cons /**< constraint */
618  );
619 
620 /** returns TRUE iff constraint is subject to aging */
621 extern
623  SCIP_CONS* cons /**< constraint */
624  );
625 
626 /** returns TRUE iff constraint's relaxation should be removed from the LP due to aging or cleanup */
627 extern
629  SCIP_CONS* cons /**< constraint */
630  );
631 
632 /** returns TRUE iff constraint's relaxation should be removed from the LP due to aging or cleanup */
633 extern
635  SCIP_CONS* cons /**< constraint */
636  );
637 
638 /** returns TRUE iff constraint belongs to the global problem */
639 extern
641  SCIP_CONS* cons /**< constraint */
642  );
643 
644 /** returns TRUE iff constraint is belonging to original space */
645 extern
647  SCIP_CONS* cons /**< constraint */
648  );
649 
650 /** returns TRUE iff constraint is belonging to transformed space */
651 extern
653  SCIP_CONS* cons /**< constraint */
654  );
655 
656 /** returns TRUE iff roundings for variables in constraint are locked */
657 extern
659  SCIP_CONS* cons /**< constraint */
660  );
661 
662 /** returns TRUE iff roundings for variables in constraint's negation are locked */
663 extern
665  SCIP_CONS* cons /**< constraint */
666  );
667 
668 /** returns TRUE iff roundings for variables in constraint or in constraint's negation are locked */
669 extern
671  SCIP_CONS* cons /**< constraint */
672  );
673 
674 /** get number of times the roundings for variables in constraint are locked */
675 extern
677  SCIP_CONS* cons /**< constraint */
678  );
679 
680 /** get number of times the roundings for variables in constraint's negation are locked */
681 extern
683  SCIP_CONS* cons /**< constraint */
684  );
685 
686 /** returns if the constraint was already added to a SCIP instance */
687 extern
689  SCIP_CONS* cons /**< constraint */
690  );
691 
692 /** adds locks to (dis-)allow upgrading of constraint */
693 extern
695  SCIP_CONS* cons, /**< constraint to add locks */
696  int nlocks /**< number of locks to add */
697  );
698 
699 /** gets number of locks against upgrading the constraint, 0 means this constraint can be upgraded */
700 extern
702  SCIP_CONS* cons /**< constraint */
703  );
704 
705 #ifdef NDEBUG
706 
707 /* In optimized mode, the function calls are overwritten by defines to reduce the number of function calls and
708  * speed up the algorithms.
709  */
710 
711 #define SCIPconsGetName(cons) (cons)->name
712 #define SCIPconsGetPos(cons) (cons)->consspos
713 #define SCIPconsGetHdlr(cons) (cons)->conshdlr
714 #define SCIPconsGetData(cons) (cons)->consdata
715 #define SCIPconsGetNUses(cons) (cons)->nuses
716 #define SCIPconsGetActiveDepth(cons) (cons)->activedepth
717 #define SCIPconsGetValidDepth(cons) (!(cons)->local ? 0 \
718  : !SCIPconsIsActive(cons) ? INT_MAX \
719  : (cons)->validdepth == -1 ? SCIPconsGetActiveDepth(cons) \
720  : (cons)->validdepth)
721 #define SCIPconsIsActive(cons) ((cons)->updateactivate || ((cons)->active && !(cons)->updatedeactivate))
722 #define SCIPconsIsEnabled(cons) ((cons)->updateenable || ((cons)->enabled && !(cons)->updatedisable))
723 #define SCIPconsIsSeparationEnabled(cons) \
724  (SCIPconsIsEnabled(cons) && ((cons)->updatesepaenable || ((cons)->sepaenabled && !(cons)->updatesepadisable)))
725 #define SCIPconsIsPropagationEnabled(cons) \
726  (SCIPconsIsEnabled(cons) && ((cons)->updatepropenable || ((cons)->propenabled && !(cons)->updatepropdisable)))
727 #define SCIPconsIsDeleted(cons) ((cons)->deleted)
728 #define SCIPconsIsObsolete(cons) ((cons)->updateobsolete || (cons)->obsolete)
729 #define SCIPconsGetAge(cons) (cons)->age
730 #define SCIPconsIsInitial(cons) (cons)->initial
731 #define SCIPconsIsSeparated(cons) (cons)->separate
732 #define SCIPconsIsEnforced(cons) (cons)->enforce
733 #define SCIPconsIsChecked(cons) (cons)->check
734 #define SCIPconsIsMarkedPropagate(cons) (cons)->markpropagate
735 #define SCIPconsIsPropagated(cons) (cons)->propagate
736 #define SCIPconsIsGlobal(cons) !(cons)->local
737 #define SCIPconsIsLocal(cons) (cons)->local
738 #define SCIPconsIsModifiable(cons) (cons)->modifiable
739 #define SCIPconsIsDynamic(cons) (cons)->dynamic
740 #define SCIPconsIsRemovable(cons) (cons)->removable
741 #define SCIPconsIsStickingAtNode(cons) (cons)->stickingatnode
742 #define SCIPconsIsInProb(cons) ((cons)->addconssetchg == NULL && (cons)->addarraypos >= 0)
743 #define SCIPconsIsOriginal(cons) (cons)->original
744 #define SCIPconsIsTransformed(cons) !(cons)->original
745 #define SCIPconsIsLockedPos(cons) ((cons)->nlockspos > 0)
746 #define SCIPconsIsLockedNeg(cons) ((cons)->nlocksneg > 0)
747 #define SCIPconsIsLocked(cons) ((cons)->nlockspos > 0 || (cons)->nlocksneg > 0)
748 #define SCIPconsGetNLocksPos(cons) ((cons)->nlockspos)
749 #define SCIPconsGetNLocksNeg(cons) ((cons)->nlocksneg)
750 #define SCIPconsIsAdded(cons) ((cons)->addarraypos >= 0)
751 #define SCIPconsGetNUpgradeLocks(cons) ((cons)->nupgradelocks)
752 
753 #endif
754 
755 #ifdef __cplusplus
756 }
757 #endif
758 
759 #endif
760