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