All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
type_cons.h
Go to the documentation of this file.
29 /*+1+2+3+4+5+6+7+8+9+0+1+2*/
46 typedef struct SCIP_Conshdlr SCIP_CONSHDLR; /**< constraint handler for a specific constraint type */
49 typedef struct SCIP_ConsData SCIP_CONSDATA; /**< locally defined constraint type specific data */
50 typedef struct SCIP_ConsSetChg SCIP_CONSSETCHG; /**< tracks additions and removals of the set of active constraints */
54 * If the copy process was a one to one the valid pointer can set to TRUE. Otherwise, you have to set this pointer to
55 * FALSE. In case all problem defining objects (constraint handlers and variable pricers) return a valid TRUE for all
56 * their copying calls, SCIP assumes that it is a overall one to one copy of the original instance. In this case any
57 * reductions made in the copied SCIP instance can be transfer to the original SCIP instance. If the valid pointer is
58 * set to TRUE and it was not one to one copy, it might happen that optimal solutions are cut off.
65 #define SCIP_DECL_CONSHDLRCOPY(x) SCIP_RETCODE x (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_Bool* valid)
67 /** destructor of constraint handler to free constraint handler data (called when SCIP is exiting)
83 #define SCIP_DECL_CONSINIT(x) SCIP_RETCODE x (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS** conss, int nconss)
93 #define SCIP_DECL_CONSEXIT(x) SCIP_RETCODE x (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS** conss, int nconss)
95 /** presolving initialization method of constraint handler (called when presolving is about to begin)
97 * This method is called when the presolving process is about to begin, even if presolving is turned off.
100 * Necessary modifications that have to be performed even if presolving is turned off should be done here or in the
103 * @note Note that the constraint array might contain constraints that were created but not added to the problem.
104 * Constraints that are not added, i.e., for which SCIPconsIsAdded() returns FALSE, cannot be used for problem
113 #define SCIP_DECL_CONSINITPRE(x) SCIP_RETCODE x (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS** conss, int nconss)
115 /** presolving deinitialization method of constraint handler (called after presolving has been finished)
117 * This method is called after the presolving has been finished, even if presolving is turned off.
120 * Necessary modifications that have to be performed even if presolving is turned off should be done here or in the
123 * Besides necessary modifications and clean up, no time consuming operations should be performed, especially if the
124 * problem has already been solved. Use the method SCIPgetStatus(), which in this case returns SCIP_STATUS_OPTIMAL,
127 * @note Note that the constraint array might contain constraints that were created but not added to the problem.
128 * Constraints that are not added, i.e., for which SCIPconsIsAdded() returns FALSE, cannot be used for problem
137 #define SCIP_DECL_CONSEXITPRE(x) SCIP_RETCODE x (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS** conss, int nconss)
139 /** solving process initialization method of constraint handler (called when branch and bound process is about to begin)
141 * This method is called when the presolving was finished and the branch and bound process is about to begin.
144 * Besides necessary modifications and clean up, no time consuming operations should be performed, especially if the
145 * problem has already been solved. Use the method SCIPgetStatus(), which in this case returns SCIP_STATUS_OPTIMAL,
148 * @note Note that the constraint array might contain constraints that were created but not added to the problem.
149 * Constraints that are not added, i.e., for which SCIPconsIsAdded() returns FALSE, cannot be used for problem
158 #define SCIP_DECL_CONSINITSOL(x) SCIP_RETCODE x (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS** conss, int nconss)
160 /** solving process deinitialization method of constraint handler (called before branch and bound process data is freed)
163 * The constraint handler should use this call to clean up its branch and bound data, in particular to release
173 #define SCIP_DECL_CONSEXITSOL(x) SCIP_RETCODE x (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS** conss, int nconss, SCIP_Bool restart)
177 * @warning There may exist unprocessed events. For example, a variable's bound may have been already changed, but the
186 #define SCIP_DECL_CONSDELETE(x) SCIP_RETCODE x (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS* cons, SCIP_CONSDATA** consdata)
196 #define SCIP_DECL_CONSTRANS(x) SCIP_RETCODE x (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS* sourcecons, SCIP_CONS** targetcons)
198 /** LP initialization method of constraint handler (called before the initial LP relaxation at a node is solved)
200 * Puts the LP relaxations of all "initial" constraints into the LP. The method should put a canonic LP relaxation
209 #define SCIP_DECL_CONSINITLP(x) SCIP_RETCODE x (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS** conss, int nconss)
213 * Separates all constraints of the constraint handler. The method is called in the LP solution loop,
216 * The first nusefulconss constraints are the ones, that are identified to likely be violated. The separation
217 * method should process only the useful constraints in most runs, and only occasionally the remaining
228 * possible return values for *result (if more than one applies, the first in the list should be used):
233 *  SCIP_NEWROUND : a cutting plane was generated and a new separation round should immediately start
234 *  SCIP_DIDNOTFIND : the separator searched, but did not find domain reductions, cutting planes, or cut constraints
238 #define SCIP_DECL_CONSSEPALP(x) SCIP_RETCODE x (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS** conss, \
243 * Separates all constraints of the constraint handler. The method is called outside the LP solution loop (e.g., by
247 * The first nusefulconss constraints are the ones, that are identified to likely be violated. The separation
248 * method should process only the useful constraints in most runs, and only occasionally the remaining
260 * possible return values for *result (if more than one applies, the first in the list should be used):
265 *  SCIP_NEWROUND : a cutting plane was generated and a new separation round should immediately start
266 *  SCIP_DIDNOTFIND : the separator searched, but did not find domain reductions, cutting planes, or cut constraints
270 #define SCIP_DECL_CONSSEPASOL(x) SCIP_RETCODE x (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS** conss, \
275 * The method is called at the end of the node processing loop for a node where the LP was solved.
276 * The LP solution has to be checked for feasibility. If possible, an infeasibility should be resolved by
277 * branching, reducing a variable's domain to exclude the solution or separating the solution with a valid
280 * The enforcing methods of the active constraint handlers are called in decreasing order of their enforcing
281 * priorities until the first constraint handler returned with the value SCIP_CUTOFF, SCIP_SEPARATED,
283 * The integrality constraint handler has an enforcing priority of zero. A constraint handler which can
284 * (or wants) to enforce its constraints only for integral solutions should have a negative enforcing priority
286 * A constraint handler which wants to incorporate its own branching strategy even on nonintegral
287 * solutions must have an enforcing priority greater than zero (e.g. the SOSconstraint incorporates
290 * The first nusefulconss constraints are the ones, that are identified to likely be violated. The enforcing
291 * method should process the useful constraints first. The other nconss  nusefulconss constraints should only
303 * possible return values for *result (if more than one applies, the first in the list should be used):
308 *  SCIP_BRANCHED : no changes were made to the problem, but a branching was applied to resolve an infeasibility
312 #define SCIP_DECL_CONSENFOLP(x) SCIP_RETCODE x (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS** conss, int nconss, int nusefulconss, \
317 * The method is called at the end of the node processing loop for a node where the LP was not solved.
318 * The pseudo solution has to be checked for feasibility. If possible, an infeasibility should be resolved by
319 * branching, reducing a variable's domain to exclude the solution or adding an additional constraint.
320 * Separation is not possible, since the LP is not processed at the current node. All LP informations like
323 * Like in the enforcing method for LP solutions, the enforcing methods of the active constraint handlers are
324 * called in decreasing order of their enforcing priorities until the first constraint handler returned with
327 * The first nusefulconss constraints are the ones, that are identified to likely be violated. The enforcing
328 * method should process the useful constraints first. The other nconss  nusefulconss constraints should only
331 * If the pseudo solution's objective value is lower than the lower bound of the node, it cannot be feasible
332 * and the enforcing method may skip it's check and set *result to SCIP_DIDNOTRUN. However, it can also process
345 * possible return values for *result (if more than one applies, the first in the list should be used):
349 *  SCIP_BRANCHED : no changes were made to the problem, but a branching was applied to resolve an infeasibility
350 *  SCIP_SOLVELP : at least one constraint is infeasible, and this can only be resolved by solving the LP
355 #define SCIP_DECL_CONSENFOPS(x) SCIP_RETCODE x (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS** conss, int nconss, int nusefulconss, \
362 * The check methods of the active constraint handlers are called in decreasing order of their check
364 * The integrality constraint handler has a check priority of zero. A constraint handler which can
365 * (or wants) to check its constraints only for integral solutions should have a negative check priority
367 * A constraint handler which wants to check feasibility even on nonintegral solutions must have a
368 * check priority greater than zero (e.g. if the check is much faster than testing all variables for
371 * In some cases, integrality conditions or rows of the current LP don't have to be checked, because their
390 #define SCIP_DECL_CONSCHECK(x) SCIP_RETCODE x (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS** conss, int nconss, SCIP_SOL* sol, \
395 * The first nusefulconss constraints are the ones, that are identified to likely be violated. The propagation
396 * method should process only the useful constraints in most runs, and only occasionally the remaining
416 #define SCIP_DECL_CONSPROP(x) SCIP_RETCODE x (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS** conss, int nconss, int nusefulconss, int nmarkedconss, \
432 *  nnewchgvartypes : number of variable type changes since the last call to the presolving method
433 *  nnewchgbds : number of variable bounds tightened since the last call to the presolving method
439 *  nnewchgsides : number of changed left or right hand sides since the last call to the presolving method
441 * @note the counters state the changes since the last call including the changes of this presolving method during its
454 *  nchgsides : pointer to count total number of changed left/right hand sides of all presolvers
463 *  SCIP_UNBOUNDED : at least one variable is not bounded by any constraint in obj. direction > problem is unbounded
464 *  SCIP_CUTOFF : at least one constraint is infeasible in the variable's bounds > problem is infeasible
470 #define SCIP_DECL_CONSPRESOL(x) SCIP_RETCODE x (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS** conss, int nconss, int nrounds, \
474 int* ndelconss, int* naddconss, int* nupgdconss, int* nchgcoefs, int* nchgsides, SCIP_RESULT* result)
478 * This method is called during conflict analysis. If the constraint handler wants to support conflict analysis,
479 * it should call SCIPinferVarLbCons() or SCIPinferVarUbCons() in domain propagation instead of SCIPchgVarLb() or
481 * In the SCIPinferVarLbCons() and SCIPinferVarUbCons() calls, the handler provides the constraint, that deduced the
483 * The propagation conflict resolving method can then be implemented, to provide a "reasons" for the bound
484 * changes, i.e. the bounds of variables at the time of the propagation, that forced the constraint to set the
485 * conflict variable's bound to its current value. It can use the "inferinfo" tag to identify its own propagation
486 * rule and thus identify the "reason" bounds. The bounds that form the reason of the assignment must then be provided
487 * by calls to SCIPaddConflictLb(), SCIPaddConflictUb(), SCIPaddConflictBd(), SCIPaddConflictRelaxedLb(),
488 * SCIPaddConflictRelaxedUb(), SCIPaddConflictRelaxedBd(), and/or SCIPaddConflictBinvar() in the propagation conflict
491 * For example, the logicor constraint c = "x or y or z" fixes variable z to TRUE (i.e. changes the lower bound of z
492 * to 1.0), if both, x and y, are assigned to FALSE (i.e. if the upper bounds of these variables are 0.0). It uses
493 * SCIPinferVarLbCons(scip, z, 1.0, c, 0) to apply this assignment (an inference information tag is not needed by the
495 * In the conflict analysis, the constraint handler may be asked to resolve the lower bound change on z with
497 * With a call to SCIPvarGetLbAtIndex(z, bdchgidx, TRUE), the handler can find out, that the lower bound of
498 * variable z was set to 1.0 at the given point of time, and should call SCIPaddConflictUb(scip, x, bdchgidx) and
499 * SCIPaddConflictUb(scip, y, bdchgidx) to tell SCIP, that the upper bounds of x and y at this point of time were
507 *  inferinfo : the user information passed to the corresponding SCIPinferVarLbCons() or SCIPinferVarUbCons() call
509 *  bdchgidx : the index of the bound change, representing the point of time where the change took place
516 *  SCIP_SUCCESS : the conflicting bound change has been successfully resolved by adding all reason bounds
517 *  SCIP_DIDNOTFIND : the conflicting bound change could not be resolved and has to be put into the conflict set
521 #define SCIP_DECL_CONSRESPROP(x) SCIP_RETCODE x (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS* cons, \
522 SCIP_VAR* infervar, int inferinfo, SCIP_BOUNDTYPE boundtype, SCIP_BDCHGIDX* bdchgidx, SCIP_Real relaxedbd, \
528 * It should update the rounding locks of all associated variables with calls to SCIPaddVarLocks(),
531 * SCIPaddVarLocks(scip, var, nlockspos, nlocksneg), saying that rounding down is potentially rendering the
532 * (positive) constraint infeasible and rounding up is potentially rendering the negation of the constraint
535 * SCIPaddVarLocks(scip, var, nlocksneg, nlockspos), saying that rounding up is potentially rendering the
536 * constraint's negation infeasible and rounding up is potentially rendering the constraint itself
538 *  If the constraint may get violated by changing the variable in any direction, it should call
541 * Consider the linear constraint "3x 5y +2z <= 7" as an example. The variable rounding lock method of the
543 * SCIPaddVarLocks(scip, y, nlockspos, nlocksneg) and SCIPaddVarLocks(scip, z, nlocksneg, nlockspos) to tell SCIP,
544 * that rounding up of x and z and rounding down of y can destroy the feasibility of the constraint, while rounding
545 * down of x and z and rounding up of y can destroy the feasibility of the constraint's negation "3x 5y +2z > 7".
547 * SCIPaddVarLocks(scip, ..., nlockspos + nlocksneg, nlockspos + nlocksneg) on all variables, since rounding in both
548 * directions of each variable can destroy both the feasibility of the constraint and it's negation
551 * If the constraint itself contains other constraints as sub constraints (e.g. the "or" constraint concatenation
552 * "c(x) or d(x)"), the rounding lock methods of these constraints should be called in a proper way.
554 * SCIPaddConsLocks(scip, c, nlockspos, nlocksneg), saying that infeasibility of c may lead to infeasibility of
555 * the (positive) constraint, and infeasibility of c's negation (i.e. feasibility of c) may lead to infeasibility
557 *  If the constraint may get violated by the feasibility of the sub constraint c, it should call
558 * SCIPaddConsLocks(scip, c, nlocksneg, nlockspos), saying that infeasibility of c may lead to infeasibility of
559 * the constraint's negation (i.e. feasibility of the constraint), and infeasibility of c's negation (i.e. feasibility
561 *  If the constraint may get violated by any change in the feasibility of the sub constraint c, it should call
564 * Consider the or concatenation "c(x) or d(x)". The variable rounding lock method of the or constraint handler
565 * should call SCIPaddConsLocks(scip, c, nlockspos, nlocksneg) and SCIPaddConsLocks(scip, d, nlockspos, nlocksneg)
568 * As a second example, consider the equivalence constraint "y <> c(x)" with variable y and constraint c. The
569 * constraint demands, that y == 1 if and only if c(x) is satisfied. The variable lock method of the corresponding
570 * constraint handler should call SCIPaddVarLocks(scip, y, nlockspos + nlocksneg, nlockspos + nlocksneg) and
571 * SCIPaddConsLocks(scip, c, nlockspos + nlocksneg, nlockspos + nlocksneg), because any modification to the
572 * value of y or to the feasibility of c can alter the feasibility of the equivalence constraint.
577 *  cons : the constraint that should lock rounding of its variables, or NULL if the constraint handler
579 *  nlockspos : number of times, the roundings should be locked for the constraint (may be negative)
580 *  nlocksneg : number of times, the roundings should be locked for the constraint's negation (may be negative)
582 #define SCIP_DECL_CONSLOCK(x) SCIP_RETCODE x (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS* cons, int nlockspos, int nlocksneg)
586 * WARNING! There may exist unprocessed events. For example, a variable's bound may have been already changed, but
589 * This method is always called after a constraint of the constraint handler was activated. The constraint
597 #define SCIP_DECL_CONSACTIVE(x) SCIP_RETCODE x (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS* cons)
601 * WARNING! There may exist unprocessed events. For example, a variable's bound may have been already changed, but
604 * This method is always called before a constraint of the constraint handler is deactivated. The constraint
612 #define SCIP_DECL_CONSDEACTIVE(x) SCIP_RETCODE x (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS* cons)
616 * WARNING! There may exist unprocessed events. For example, a variable's bound may have been already changed, but
619 * This method is always called after a constraint of the constraint handler was enabled. The constraint
627 #define SCIP_DECL_CONSENABLE(x) SCIP_RETCODE x (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS* cons)
631 * WARNING! There may exist unprocessed events. For example, a variable's bound may have been already changed, but
634 * This method is always called before a constraint of the constraint handler is disabled. The constraint
642 #define SCIP_DECL_CONSDISABLE(x) SCIP_RETCODE x (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS* cons)
646 * This method is optinal and only of interest if you are using SCIP as a branchandprice framework. That means, you
647 * are generating new variables during the search. If you are not doing that just define the function pointer to be
650 * If this method gets implemented you should iterate over all constraints of the constraint handler and delete all
659 #define SCIP_DECL_CONSDELVARS(x) SCIP_RETCODE x (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS** conss, int nconss)
663 * The constraint handler can store a representation of the constraint into the given text file. Use the method
666 * @note There are several methods which help to display variables. These are SCIPwriteVarName(), SCIPwriteVarsList(),
669 * input:  scip : SCIP main data structure  conshdlr : the constraint handler itself  cons : the constraint that
673 #define SCIP_DECL_CONSPRINT(x) SCIP_RETCODE x (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS* cons, FILE* file)
677 * The constraint handler can provide a copy method which copies a constraint from one SCIP data structure into a other
678 * SCIP data structure. If a copy of a constraint is created the constraint has to be captured (The capture is usually
681 * If the copy process was a one to one the valid pointer can set to TRUE. Otherwise, you have to set this pointer to
682 * FALSE. In case all problem defining objects (constraint handlers and variable pricers) return a valid TRUE for all
683 * their copying calls, SCIP assumes that it is a overall one to one copy of the original instance. In this case any
684 * reductions made in the copied SCIP instance can be transfer to the original SCIP instance. If the valid pointer is
685 * set to TRUE and it was not one to one copy, it might happen that optimal solutions are cut off.
696 *  varmap : a SCIP_HASHMAP mapping variables of the source SCIP to corresponding variables of the target SCIP
697 *  consmap : a SCIP_HASHMAP mapping constraints of the source SCIP to corresponding constraints of the target SCIP
715 SCIP* sourcescip, SCIP_CONSHDLR* sourceconshdlr, SCIP_CONS* sourcecons, SCIP_HASHMAP* varmap, SCIP_HASHMAP* consmap, \
716 SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, \
717 SCIP_Bool local, SCIP_Bool modifiable, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode, \
722 * The constraint handler can provide a callback to parse the output created by the display method
725 * @note For parsing there are several methods which are handy. Have a look at: SCIPparseVarName(),
726 * SCIPparseVarsList(), SCIPparseVarsLinearsum(), SCIPparseVarsPolynomial(), SCIPstrToRealValue(), and
749 #define SCIP_DECL_CONSPARSE(x) SCIP_RETCODE x (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS** cons, \
751 SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, \
752 SCIP_Bool modifiable, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode, SCIP_Bool* success)
756 * The constraint handler can (this callback is optional) provide this callback to return the variables which are
757 * involved in that particular constraint. If this is possible, the variables should be copyied into the variables
758 * array and the success pointers has to be set to TRUE. Otherwise the success has to be set FALSE or the callback
768 *  varssize : available slots in vars array which is needed to check if the array is large enough
771 #define SCIP_DECL_CONSGETVARS(x) SCIP_RETCODE x (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS* cons, \
776 * The constraint handler can (this callback is optional) provide this callback to return the number variable which are
777 * involved in that particular constraint. If this is not possible, the success pointers has to be set to FALSE or the
787 *  success : pointer to store whether the constraint successfully returned the number of variables
789 #define SCIP_DECL_CONSGETNVARS(x) SCIP_RETCODE x (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS* cons, \
