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