Scippy

SCIP

Solving Constraint Integer Programs

cons_linking.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-2017 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 cons_linking.h
17  * @ingroup CONSHDLRS
18  * @brief constraint handler for linking binary variables to an integer variable
19  * @author Stefan Heinz
20  * @author Jens Schulz
21  *
22  */
23 
24 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
25 
26 #ifndef __SCIP_CONS_LINKING_H__
27 #define __SCIP_CONS_LINKING_H__
28 
29 
30 #include "scip/scip.h"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 /** creates the handler for linking constraints and includes it in SCIP
37  *
38  * @ingroup ConshdlrIncludes
39  * */
40 extern
42  SCIP* scip /**< SCIP data structure */
43  );
44 
45 /**@addtogroup CONSHDLRS
46  *
47  * @{
48  *
49  * @name Linking Constraints
50  *
51  * @{
52  *
53  * The constraints handler stores linking constraints between an integer variable and an array of binary variables. Such
54  * a linking constraint has the form:
55  * \f[
56  * y = \sum_{i=1}^n {c_i * x_i}
57  * \f]
58  * with integer variable \f$ y \f$, binary variables \f$ x_1, \dots, x_n \f$ and offset \f$b \in Q\f$, and
59  * with the additional side condition that exactly one binary variable has to be one (set partitioning condition).
60  *
61  * This constraint can be created only with the integer variable. In this case the binary variables are only created on
62  * demand. That is, whenever someone asks for the binary variables. Therefore, such constraints can be used to get a
63  * "binary representation" of the domain of the integer variable which will be dynamically created.
64  */
65 
66 /** creates and captures a linking constraint
67  *
68  * @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
69  */
70 extern
72  SCIP* scip, /**< SCIP data structure */
73  SCIP_CONS** cons, /**< pointer to hold the created constraint */
74  const char* name, /**< name of constraint */
75  SCIP_VAR* intvar, /**< integer variable which should be linked */
76  SCIP_VAR** binvars, /**< binary variables */
77  int* vals, /**< coefficients of the binary variables */
78  int nbinvars, /**< number of binary starting variables */
79  SCIP_Bool initial, /**< should the LP relaxation of constraint be in the initial LP?
80  * Usually set to TRUE. Set to FALSE for 'lazy constraints'. */
81  SCIP_Bool separate, /**< should the constraint be separated during LP processing?
82  * Usually set to TRUE. */
83  SCIP_Bool enforce, /**< should the constraint be enforced during node processing?
84  * TRUE for model constraints, FALSE for additional, redundant constraints. */
85  SCIP_Bool check, /**< should the constraint be checked for feasibility?
86  * TRUE for model constraints, FALSE for additional, redundant constraints. */
87  SCIP_Bool propagate, /**< should the constraint be propagated during node processing?
88  * Usually set to TRUE. */
89  SCIP_Bool local, /**< is constraint only valid locally?
90  * Usually set to FALSE. Has to be set to TRUE, e.g., for branching constraints. */
91  SCIP_Bool modifiable, /**< is constraint modifiable (subject to column generation)?
92  * Usually set to FALSE. In column generation applications, set to TRUE if pricing
93  * adds coefficients to this constraint. */
94  SCIP_Bool dynamic, /**< is constraint subject to aging?
95  * Usually set to FALSE. Set to TRUE for own cuts which
96  * are separated as constraints. */
97  SCIP_Bool removable, /**< should the relaxation be removed from the LP due to aging or cleanup?
98  * Usually set to FALSE. Set to TRUE for 'lazy constraints' and 'user cuts'. */
99  SCIP_Bool stickingatnode /**< should the constraint always be kept at the node where it was added, even
100  * if it may be moved to a more global node?
101  * Usually set to FALSE. Set to TRUE to for constraints that represent node data. */
102  );
103 
104 /** creates and captures a linking constraint
105  * in its most basic version, i. e., all constraint flags are set to their basic value as explained for the
106  * method SCIPcreateConsLinking(); all flags can be set via SCIPsetConsFLAGNAME-methods in scip.h
107  *
108  * @see SCIPcreateConsLinking() for information about the basic constraint flag configuration
109  *
110  * @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
111  */
112 extern
114  SCIP* scip, /**< SCIP data structure */
115  SCIP_CONS** cons, /**< pointer to hold the created constraint */
116  const char* name, /**< name of constraint */
117  SCIP_VAR* intvar, /**< integer variable which should be linked */
118  SCIP_VAR** binvars, /**< binary variables, or NULL */
119  int* vals, /**< coefficients of the binary variables */
120  int nbinvars /**< number of binary variables */
121  );
122 
123 
124 /** checks if for the given integer variable a linking constraint exists */
125 extern
127  SCIP* scip, /**< SCIP data structure */
128  SCIP_VAR* intvar /**< integer variable which should be linked */
129  );
130 
131 /** returns the linking constraint belonging the given integer variable or NULL if it does not exist yet */
132 extern
134  SCIP* scip, /**< SCIP data structure */
135  SCIP_VAR* intvar /**< integer variable which should be linked */
136  );
137 
138 /** returns the integer variable of the linking constraint */
139 extern
141  SCIP* scip, /**< SCIP data structure */
142  SCIP_CONS* cons /**< linking constraint */
143  );
144 
145 /** returns the binary variables of the linking constraint */
146 extern
148  SCIP* scip, /**< SCIP data structure */
149  SCIP_CONS* cons, /**< linking constraint */
150  SCIP_VAR*** binvars, /**< pointer to store the binary variables array pointer */
151  int* nbinvars /**< pointer to store the number of returned binary variables */
152  );
153 
154 /** returns the number of binary variables of the linking constraint */
155 extern
157  SCIP* scip, /**< SCIP data structure */
158  SCIP_CONS* cons /**< linking constraint */
159  );
160 
161 /** returns the coefficients of the binary variables */
162 extern
163 int* SCIPgetValsLinking(
164  SCIP* scip, /**< SCIP data structure */
165  SCIP_CONS* cons /**< linking constraint */
166  );
167 
168 /* @} */
169 
170 /* @} */
171 
172 #ifdef __cplusplus
173 }
174 #endif
175 
176 #endif
SCIP_RETCODE SCIPincludeConshdlrLinking(SCIP *scip)
int * SCIPgetValsLinking(SCIP *scip, SCIP_CONS *cons)
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
SCIP_Bool SCIPexistsConsLinking(SCIP *scip, SCIP_VAR *intvar)
int SCIPgetNBinvarsLinking(SCIP *scip, SCIP_CONS *cons)
SCIP_VAR * SCIPgetIntvarLinking(SCIP *scip, SCIP_CONS *cons)
#define SCIP_Bool
Definition: def.h:61
SCIP_RETCODE SCIPcreateConsLinking(SCIP *scip, SCIP_CONS **cons, const char *name, SCIP_VAR *intvar, SCIP_VAR **binvars, int *vals, int nbinvars, 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_RETCODE SCIPgetBinvarsLinking(SCIP *scip, SCIP_CONS *cons, SCIP_VAR ***binvars, int *nbinvars)
SCIP_CONS * SCIPgetConsLinking(SCIP *scip, SCIP_VAR *intvar)
SCIP_RETCODE SCIPcreateConsBasicLinking(SCIP *scip, SCIP_CONS **cons, const char *name, SCIP_VAR *intvar, SCIP_VAR **binvars, int *vals, int nbinvars)
SCIP callable library.