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-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_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/def.h"
30 #include "scip/type_cons.h"
31 #include "scip/type_retcode.h"
32 #include "scip/type_scip.h"
33 #include "scip/type_var.h"
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
39 /** creates the handler for SOS2 constraints and includes it in SCIP
40  *
41  * @ingroup ConshdlrIncludes
42  * */
45  SCIP* scip /**< SCIP data structure */
46  );
47 
48 /**@addtogroup CONSHDLRS
49  *
50  * @{
51  *
52  * @name Specially Ordered Set (SOS) Type 2 Constraints
53  *
54  * @{
55  *
56  * A specially ordered set of type 2 (SOS2) is a sequence of variables such that at most two
57  * variables are nonzero and if two variables are nonzero they must be adjacent in the specified
58  * sequence. Note that it is in principle allowed that a variable appears twice, but it then can be
59  * fixed to 0 if it is at least two apart in the sequence.
60  */
61 
62 /** creates and captures an SOS2 constraint
63  *
64  * We set the constraint to not be modifable. If the weights are non
65  * NULL, the variables are ordered according to these weights (in
66  * ascending order).
67  *
68  * @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
69  */
72  SCIP* scip, /**< SCIP data structure */
73  SCIP_CONS** cons, /**< pointer to hold the created constraint */
74  const char* name, /**< name of constraint */
75  int nvars, /**< number of variables in the constraint */
76  SCIP_VAR** vars, /**< array with variables of constraint entries */
77  SCIP_Real* weights, /**< weights determining the variable order, or NULL if natural order should be used */
78  SCIP_Bool initial, /**< should the LP relaxation of constraint be in the initial LP?
79  * Usually set to TRUE. Set to FALSE for 'lazy constraints'. */
80  SCIP_Bool separate, /**< should the constraint be separated during LP processing?
81  * Usually set to TRUE. */
82  SCIP_Bool enforce, /**< should the constraint be enforced during node processing?
83  * TRUE for model constraints, FALSE for additional, redundant constraints. */
84  SCIP_Bool check, /**< should the constraint be checked for feasibility?
85  * TRUE for model constraints, FALSE for additional, redundant constraints. */
86  SCIP_Bool propagate, /**< should the constraint be propagated during node processing?
87  * Usually set to TRUE. */
88  SCIP_Bool local, /**< is constraint only valid locally?
89  * Usually set to FALSE. Has to be set to TRUE, e.g., for branching constraints. */
90  SCIP_Bool dynamic, /**< is constraint subject to aging?
91  * Usually set to FALSE. Set to TRUE for own cuts which
92  * are separated as constraints. */
93  SCIP_Bool removable, /**< should the relaxation be removed from the LP due to aging or cleanup?
94  * Usually set to FALSE. Set to TRUE for 'lazy constraints' and 'user cuts'. */
95  SCIP_Bool stickingatnode /**< should the constraint always be kept at the node where it was added, even
96  * if it may be moved to a more global node?
97  * Usually set to FALSE. Set to TRUE to for constraints that represent node data. */
98  );
99 
100 /** creates and captures a SOS2 constraint with all constraint flags set to their default values.
101  *
102  * @warning Do NOT set the constraint to be modifiable manually, because this might lead
103  * to wrong results as the variable array will not be resorted
104  *
105  * @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
106  */
109  SCIP* scip, /**< SCIP data structure */
110  SCIP_CONS** cons, /**< pointer to hold the created constraint */
111  const char* name, /**< name of constraint */
112  int nvars, /**< number of variables in the constraint */
113  SCIP_VAR** vars, /**< array with variables of constraint entries */
114  SCIP_Real* weights /**< weights determining the variable order, or NULL if natural order should be used */
115  );
116 
117 /** adds variable to SOS2 constraint, the position is determined by the given weight */
120  SCIP* scip, /**< SCIP data structure */
121  SCIP_CONS* cons, /**< constraint */
122  SCIP_VAR* var, /**< variable to add to the constraint */
123  SCIP_Real weight /**< weight determining position of variable */
124  );
125 
126 /** appends variable to SOS2 constraint */
129  SCIP* scip, /**< SCIP data structure */
130  SCIP_CONS* cons, /**< constraint */
131  SCIP_VAR* var /**< variable to add to the constraint */
132  );
133 
134 /** gets number of variables in SOS2 constraint */
136 int SCIPgetNVarsSOS2(
137  SCIP* scip, /**< SCIP data structure */
138  SCIP_CONS* cons /**< constraint */
139  );
140 
141 /** gets array of variables in SOS2 constraint */
144  SCIP* scip, /**< SCIP data structure */
145  SCIP_CONS* cons /**< constraint data */
146  );
147 
148 /** gets array of weights in SOS2 constraint (or NULL if not existent) */
151  SCIP* scip, /**< SCIP data structure */
152  SCIP_CONS* cons /**< constraint data */
153  );
154 
155 /* @} */
156 
157 /* @} */
158 
159 #ifdef __cplusplus
160 }
161 #endif
162 
163 #endif
SCIP_EXPORT int SCIPgetNVarsSOS2(SCIP *scip, SCIP_CONS *cons)
Definition: cons_sos2.c:2477
SCIP_EXPORT SCIP_Real * SCIPgetWeightsSOS2(SCIP *scip, SCIP_CONS *cons)
Definition: cons_sos2.c:2527
#define SCIP_EXPORT
Definition: def.h:98
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
SCIP_EXPORT 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:2327
type definitions for return codes for SCIP methods
SCIP_EXPORT SCIP_RETCODE SCIPappendVarSOS2(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var)
Definition: cons_sos2.c:2452
type definitions for SCIP&#39;s main datastructure
SCIP_EXPORT SCIP_RETCODE SCIPcreateConsBasicSOS2(SCIP *scip, SCIP_CONS **cons, const char *name, int nvars, SCIP_VAR **vars, SCIP_Real *weights)
Definition: cons_sos2.c:2410
type definitions for problem variables
#define SCIP_Bool
Definition: def.h:70
SCIP_EXPORT SCIP_RETCODE SCIPaddVarSOS2(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_Real weight)
Definition: cons_sos2.c:2426
SCIP_EXPORT SCIP_RETCODE SCIPincludeConshdlrSOS2(SCIP *scip)
Definition: cons_sos2.c:2272
SCIP_EXPORT SCIP_VAR ** SCIPgetVarsSOS2(SCIP *scip, SCIP_CONS *cons)
Definition: cons_sos2.c:2502
#define SCIP_Real
Definition: def.h:164
common defines and data types used in all packages of SCIP
type definitions for constraints and constraint handlers