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