Scippy

SCIP

Solving Constraint Integer Programs

cons_sos2.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_sos2.h
17  * @ingroup CONSHDLRS
18  * @brief constraint handler for SOS type 2 constraints
19  * @author Marc Pfetsch
20  *
21  */
22 
23 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
24 
25 #ifndef __SCIP_CONS_SOS2_H__
26 #define __SCIP_CONS_SOS2_H__
27 
28 
29 #include "scip/scip.h"
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 /** creates the handler for SOS2 constraints and includes it in SCIP
36  *
37  * @ingroup ConshdlrIncludes
38  * */
39 extern
41  SCIP* scip /**< SCIP data structure */
42  );
43 
44 /**@addtogroup CONSHDLRS
45  *
46  * @{
47  *
48  * @name Specially Ordered Set (SOS) Type 2 Constraints
49  *
50  * @{
51  *
52  * A specially ordered set of type 2 (SOS2) is a sequence of variables such that at most two
53  * variables are nonzero and if two variables are nonzero they must be adjacent in the specified
54  * sequence. Note that it is in principle allowed that a variable appears twice, but it then can be
55  * fixed to 0 if it is at least two apart in the sequence.
56  */
57 
58 /** creates and captures an SOS2 constraint
59  *
60  * We set the constraint to not be modifable. If the weights are non
61  * NULL, the variables are ordered according to these weights (in
62  * ascending order).
63  *
64  * @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
65  */
66 extern
68  SCIP* scip, /**< SCIP data structure */
69  SCIP_CONS** cons, /**< pointer to hold the created constraint */
70  const char* name, /**< name of constraint */
71  int nvars, /**< number of variables in the constraint */
72  SCIP_VAR** vars, /**< array with variables of constraint entries */
73  SCIP_Real* weights, /**< weights determining the variable order, or NULL if natural order should be used */
74  SCIP_Bool initial, /**< should the LP relaxation of constraint be in the initial LP?
75  * Usually set to TRUE. Set to FALSE for 'lazy constraints'. */
76  SCIP_Bool separate, /**< should the constraint be separated during LP processing?
77  * Usually set to TRUE. */
78  SCIP_Bool enforce, /**< should the constraint be enforced during node processing?
79  * TRUE for model constraints, FALSE for additional, redundant constraints. */
80  SCIP_Bool check, /**< should the constraint be checked for feasibility?
81  * TRUE for model constraints, FALSE for additional, redundant constraints. */
82  SCIP_Bool propagate, /**< should the constraint be propagated during node processing?
83  * Usually set to TRUE. */
84  SCIP_Bool local, /**< is constraint only valid locally?
85  * Usually set to FALSE. Has to be set to TRUE, e.g., for branching constraints. */
86  SCIP_Bool dynamic, /**< is constraint subject to aging?
87  * Usually set to FALSE. Set to TRUE for own cuts which
88  * are separated as constraints. */
89  SCIP_Bool removable, /**< should the relaxation be removed from the LP due to aging or cleanup?
90  * Usually set to FALSE. Set to TRUE for 'lazy constraints' and 'user cuts'. */
91  SCIP_Bool stickingatnode /**< should the constraint always be kept at the node where it was added, even
92  * if it may be moved to a more global node?
93  * Usually set to FALSE. Set to TRUE to for constraints that represent node data. */
94  );
95 
96 /** creates and captures a SOS2 constraint with all constraint flags set to their default values.
97  *
98  * @warning Do NOT set the constraint to be modifiable manually, because this might lead
99  * to wrong results as the variable array will not be resorted
100  *
101  * @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
102  */
103 extern
105  SCIP* scip, /**< SCIP data structure */
106  SCIP_CONS** cons, /**< pointer to hold the created constraint */
107  const char* name, /**< name of constraint */
108  int nvars, /**< number of variables in the constraint */
109  SCIP_VAR** vars, /**< array with variables of constraint entries */
110  SCIP_Real* weights /**< weights determining the variable order, or NULL if natural order should be used */
111  );
112 
113 /** adds variable to SOS2 constraint, the position is determined by the given weight */
114 extern
116  SCIP* scip, /**< SCIP data structure */
117  SCIP_CONS* cons, /**< constraint */
118  SCIP_VAR* var, /**< variable to add to the constraint */
119  SCIP_Real weight /**< weight determining position of variable */
120  );
121 
122 /** appends variable to SOS2 constraint */
123 extern
125  SCIP* scip, /**< SCIP data structure */
126  SCIP_CONS* cons, /**< constraint */
127  SCIP_VAR* var /**< variable to add to the constraint */
128  );
129 
130 /** gets number of variables in SOS2 constraint */
131 extern
132 int SCIPgetNVarsSOS2(
133  SCIP* scip, /**< SCIP data structure */
134  SCIP_CONS* cons /**< constraint */
135  );
136 
137 /** gets array of variables in SOS2 constraint */
138 extern
140  SCIP* scip, /**< SCIP data structure */
141  SCIP_CONS* cons /**< constraint data */
142  );
143 
144 /** gets array of weights in SOS2 constraint (or NULL if not existent) */
145 extern
147  SCIP* scip, /**< SCIP data structure */
148  SCIP_CONS* cons /**< constraint data */
149  );
150 
151 /* @} */
152 
153 /* @} */
154 
155 #ifdef __cplusplus
156 }
157 #endif
158 
159 #endif
SCIP_RETCODE SCIPaddVarSOS2(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_Real weight)
Definition: cons_sos2.c:2394
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
int SCIPgetNVarsSOS2(SCIP *scip, SCIP_CONS *cons)
Definition: cons_sos2.c:2445
SCIP_VAR ** SCIPgetVarsSOS2(SCIP *scip, SCIP_CONS *cons)
Definition: cons_sos2.c:2470
SCIP_RETCODE SCIPincludeConshdlrSOS2(SCIP *scip)
Definition: cons_sos2.c:2240
SCIP_RETCODE SCIPcreateConsBasicSOS2(SCIP *scip, SCIP_CONS **cons, const char *name, int nvars, SCIP_VAR **vars, SCIP_Real *weights)
Definition: cons_sos2.c:2378
#define SCIP_Bool
Definition: def.h:61
SCIP_Real * SCIPgetWeightsSOS2(SCIP *scip, SCIP_CONS *cons)
Definition: cons_sos2.c:2495
#define SCIP_Real
Definition: def.h:149
SCIP_RETCODE SCIPcreateConsSOS2(SCIP *scip, SCIP_CONS **cons, const char *name, int nvars, SCIP_VAR **vars, SCIP_Real *weights, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode)
Definition: cons_sos2.c:2295
SCIP_RETCODE SCIPappendVarSOS2(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var)
Definition: cons_sos2.c:2420
SCIP callable library.