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 2002-2022 Zuse Institute Berlin */
7 /* */
8 /* Licensed under the Apache License, Version 2.0 (the "License"); */
9 /* you may not use this file except in compliance with the License. */
10 /* You may obtain a copy of the License at */
11 /* */
12 /* http://www.apache.org/licenses/LICENSE-2.0 */
13 /* */
14 /* Unless required by applicable law or agreed to in writing, software */
15 /* distributed under the License is distributed on an "AS IS" BASIS, */
16 /* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
17 /* See the License for the specific language governing permissions and */
18 /* limitations under the License. */
19 /* */
20 /* You should have received a copy of the Apache-2.0 license */
21 /* along with SCIP; see the file LICENSE. If not visit scipopt.org. */
22 /* */
23 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
24 
25 /**@file cons_linking.h
26  * @ingroup CONSHDLRS
27  * @brief constraint handler for linking binary variables to a linking (continuous or integer) variable
28  * @author Stefan Heinz
29  * @author Jens Schulz
30  *
31  */
32 
33 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
34 
35 #ifndef __SCIP_CONS_LINKING_H__
36 #define __SCIP_CONS_LINKING_H__
37 
38 
39 #include "scip/def.h"
40 #include "scip/type_cons.h"
41 #include "scip/type_retcode.h"
42 #include "scip/type_scip.h"
43 #include "scip/type_var.h"
44 
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48 
49 /** creates the handler for linking constraints and includes it in SCIP
50  *
51  * @ingroup ConshdlrIncludes
52  * */
53 SCIP_EXPORT
55  SCIP* scip /**< SCIP data structure */
56  );
57 
58 /**@addtogroup CONSHDLRS
59  *
60  * @{
61  *
62  * @name Linking Constraints
63  *
64  * @{
65  *
66  * The constraints handler stores linking constraints between a linking variable (continuous or integer) and an array of binary variables. Such
67  * a linking constraint has the form:
68  * \f[
69  * y = \sum_{i=1}^n {c_i * x_i}
70  * \f]
71  * with linking variable (continuous or integer) \f$ y \f$, binary variables \f$ x_1, \dots, x_n \f$ and offset \f$b \in Q\f$, and
72  * with the additional side condition that exactly one binary variable has to be one (set partitioning condition).
73  *
74  * This constraint can be created only with the linking variable, if it is an integer variable. In this case the binary variables are only created on
75  * demand. That is, whenever someone asks for the binary variables. Therefore, such constraints can be used to get a
76  * "binary representation" of the domain of the linking variable which will be dynamically created.
77  */
78 
79 /** creates and captures a linking constraint
80  *
81  * @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
82  */
83 SCIP_EXPORT
85  SCIP* scip, /**< SCIP data structure */
86  SCIP_CONS** cons, /**< pointer to hold the created constraint */
87  const char* name, /**< name of constraint */
88  SCIP_VAR* linkvar, /**< linking variable (continuous or integer) which should be linked */
89  SCIP_VAR** binvars, /**< binary variables */
90  SCIP_Real* vals, /**< coefficients of the binary variables */
91  int nbinvars, /**< number of binary starting variables */
92  SCIP_Bool initial, /**< should the LP relaxation of constraint be in the initial LP?
93  * Usually set to TRUE. Set to FALSE for 'lazy constraints'. */
94  SCIP_Bool separate, /**< should the constraint be separated during LP processing?
95  * Usually set to TRUE. */
96  SCIP_Bool enforce, /**< should the constraint be enforced during node processing?
97  * TRUE for model constraints, FALSE for additional, redundant constraints. */
98  SCIP_Bool check, /**< should the constraint be checked for feasibility?
99  * TRUE for model constraints, FALSE for additional, redundant constraints. */
100  SCIP_Bool propagate, /**< should the constraint be propagated during node processing?
101  * Usually set to TRUE. */
102  SCIP_Bool local, /**< is constraint only valid locally?
103  * Usually set to FALSE. Has to be set to TRUE, e.g., for branching constraints. */
104  SCIP_Bool modifiable, /**< is constraint modifiable (subject to column generation)?
105  * Usually set to FALSE. In column generation applications, set to TRUE if pricing
106  * adds coefficients to this constraint. */
107  SCIP_Bool dynamic, /**< is constraint subject to aging?
108  * Usually set to FALSE. Set to TRUE for own cuts which
109  * are separated as constraints. */
110  SCIP_Bool removable, /**< should the relaxation be removed from the LP due to aging or cleanup?
111  * Usually set to FALSE. Set to TRUE for 'lazy constraints' and 'user cuts'. */
112  SCIP_Bool stickingatnode /**< should the constraint always be kept at the node where it was added, even
113  * if it may be moved to a more global node?
114  * Usually set to FALSE. Set to TRUE to for constraints that represent node data. */
115  );
116 
117 /** creates and captures a linking constraint
118  * in its most basic version, i. e., all constraint flags are set to their basic value as explained for the
119  * method SCIPcreateConsLinking(); all flags can be set via SCIPsetConsFLAGNAME-methods in scip.h
120  *
121  * @see SCIPcreateConsLinking() for information about the basic constraint flag configuration
122  *
123  * @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
124  */
125 SCIP_EXPORT
127  SCIP* scip, /**< SCIP data structure */
128  SCIP_CONS** cons, /**< pointer to hold the created constraint */
129  const char* name, /**< name of constraint */
130  SCIP_VAR* linkvar, /**< linking variable (continuous or integer) which should be linked */
131  SCIP_VAR** binvars, /**< binary variables, or NULL */
132  SCIP_Real* vals, /**< coefficients of the binary variables */
133  int nbinvars /**< number of binary variables */
134  );
135 
136 
137 /** checks if for the given linking variable (continuous or integer) a linking constraint exists */
138 SCIP_EXPORT
140  SCIP* scip, /**< SCIP data structure */
141  SCIP_VAR* linkvar /**< linking variable (continuous or integer) which should be linked */
142  );
143 
144 /** returns the linking constraint belonging the given linking variable (continuous or integer) or NULL if it does not exist yet */
145 SCIP_EXPORT
147  SCIP* scip, /**< SCIP data structure */
148  SCIP_VAR* linkvar /**< linking variable (continuous or integer) which should be linked */
149  );
150 
151 /** returns the linking variable (continuous or integer) of the linking constraint */
152 SCIP_EXPORT
154  SCIP* scip, /**< SCIP data structure */
155  SCIP_CONS* cons /**< linking constraint */
156  );
157 
158 /** returns the binary variables of the linking constraint */
159 SCIP_EXPORT
161  SCIP* scip, /**< SCIP data structure */
162  SCIP_CONS* cons, /**< linking constraint */
163  SCIP_VAR*** binvars, /**< pointer to store the binary variables array pointer */
164  int* nbinvars /**< pointer to store the number of returned binary variables */
165  );
166 
167 /** returns the number of binary variables of the linking constraint */
168 SCIP_EXPORT
170  SCIP* scip, /**< SCIP data structure */
171  SCIP_CONS* cons /**< linking constraint */
172  );
173 
174 /** returns the coefficients of the binary variables */
175 SCIP_EXPORT
177  SCIP* scip, /**< SCIP data structure */
178  SCIP_CONS* cons /**< linking constraint */
179  );
180 
181 /** return all binary variable information of the linking constraint */
182 SCIP_EXPORT
184  SCIP_CONS* cons, /**< linking constraint */
185  SCIP_VAR*** binvars, /**< pointer to store binary variables, or NULL */
186  SCIP_Real** vals, /**< pointer to store the binary coefficients, or NULL */
187  int* nbinvars /**< pointer to store the number of binary variables, or NULL */
188  );
189 
190 /** @} */
191 
192 /** @} */
193 
194 #ifdef __cplusplus
195 }
196 #endif
197 
198 #endif
SCIP_RETCODE SCIPincludeConshdlrLinking(SCIP *scip)
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:63
type definitions for return codes for SCIP methods
int SCIPgetNBinvarsLinking(SCIP *scip, SCIP_CONS *cons)
SCIP_Bool SCIPexistsConsLinking(SCIP *scip, SCIP_VAR *linkvar)
SCIP_RETCODE SCIPcreateConsBasicLinking(SCIP *scip, SCIP_CONS **cons, const char *name, SCIP_VAR *linkvar, SCIP_VAR **binvars, SCIP_Real *vals, int nbinvars)
SCIP_Real * SCIPgetValsLinking(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE SCIPgetBinvarsDataLinking(SCIP_CONS *cons, SCIP_VAR ***binvars, SCIP_Real **vals, int *nbinvars)
type definitions for SCIP&#39;s main datastructure
SCIP_RETCODE SCIPcreateConsLinking(SCIP *scip, SCIP_CONS **cons, const char *name, SCIP_VAR *linkvar, SCIP_VAR **binvars, SCIP_Real *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)
type definitions for problem variables
#define SCIP_Bool
Definition: def.h:93
SCIP_RETCODE SCIPgetBinvarsLinking(SCIP *scip, SCIP_CONS *cons, SCIP_VAR ***binvars, int *nbinvars)
SCIP_VAR * SCIPgetLinkvarLinking(SCIP *scip, SCIP_CONS *cons)
#define SCIP_Real
Definition: def.h:186
SCIP_CONS * SCIPgetConsLinking(SCIP *scip, SCIP_VAR *linkvar)
common defines and data types used in all packages of SCIP
type definitions for constraints and constraint handlers