Scippy

SCIP

Solving Constraint Integer Programs

cons_sos1.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_sos1.h
17  * @ingroup CONSHDLRS
18  * @brief constraint handler for SOS type 1 constraints
19  * @author Tobias Fischer
20  * @author Marc Pfetsch
21  *
22  */
23 
24 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
25 
26 #ifndef __SCIP_CONS_SOS1_H__
27 #define __SCIP_CONS_SOS1_H__
28 
29 
30 #include "scip/scip.h"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 /** creates the handler for SOS1 constraints and includes it in SCIP
37  *
38  * @ingroup ConshdlrIncludes
39  * */
40 extern
42  SCIP* scip /**< SCIP data structure */
43  );
44 
45 /**@addtogroup CONSHDLRS
46  *
47  * @{
48  *
49  * @name Specially Ordered Set (SOS) Type 1 Constraints
50  *
51  * @{
52  *
53  * A specially ordered set of type 1 (SOS1) is a sequence of variables such that at most one
54  * variable is nonzero. The special case of two variables arises, for instance, from equilibrium or
55  * complementary conditions like \f$x \cdot y = 0\f$. Note that it is in principle allowed that a
56  * variable appears twice, but it then can be fixed to 0.
57  */
58 
59 /** creates and captures an SOS1 constraint
60  *
61  * We set the constraint to not be modifable. If the weights are non
62  * NULL, the variables are ordered according to these weights (in
63  * ascending order).
64  *
65  * @note The constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons().
66  */
67 extern
69  SCIP* scip, /**< SCIP data structure */
70  SCIP_CONS** cons, /**< pointer to hold the created constraint */
71  const char* name, /**< name of constraint */
72  int nvars, /**< number of variables in the constraint */
73  SCIP_VAR** vars, /**< array with variables of constraint entries */
74  SCIP_Real* weights, /**< weights determining the variable order, or NULL if natural order should be used */
75  SCIP_Bool initial, /**< should the LP relaxation of constraint be in the initial LP?
76  * Usually set to TRUE. Set to FALSE for 'lazy constraints'. */
77  SCIP_Bool separate, /**< should the constraint be separated during LP processing?
78  * Usually set to TRUE. */
79  SCIP_Bool enforce, /**< should the constraint be enforced during node processing?
80  * TRUE for model constraints, FALSE for additional, redundant constraints. */
81  SCIP_Bool check, /**< should the constraint be checked for feasibility?
82  * TRUE for model constraints, FALSE for additional, redundant constraints. */
83  SCIP_Bool propagate, /**< should the constraint be propagated during node processing?
84  * Usually set to TRUE. */
85  SCIP_Bool local, /**< is constraint only valid locally?
86  * Usually set to FALSE. Has to be set to TRUE, e.g., for branching constraints. */
87  SCIP_Bool dynamic, /**< is constraint subject to aging?
88  * Usually set to FALSE. Set to TRUE for own cuts which
89  * are separated as constraints. */
90  SCIP_Bool removable, /**< should the relaxation be removed from the LP due to aging or cleanup?
91  * Usually set to FALSE. Set to TRUE for 'lazy constraints' and 'user cuts'. */
92  SCIP_Bool stickingatnode /**< should the constraint always be kept at the node where it was added, even
93  * if it may be moved to a more global node?
94  * Usually set to FALSE. Set to TRUE to for constraints that represent node data. */
95  );
96 
97 /** creates and captures an SOS1 constraint
98  * in its most basic variant, i. e., with all constraint flags set to their default values, which can be set
99  * afterwards using SCIPsetConsFLAGNAME() in scip.h
100  *
101  * @see SCIPcreateConsSOS1() for the default constraint flag configuration
102  *
103  * @warning Do NOT set the constraint to be modifiable manually, because this might lead
104  * to wrong results as the variable array will not be resorted
105  *
106  * @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
107  */
108 extern
110  SCIP* scip, /**< SCIP data structure */
111  SCIP_CONS** cons, /**< pointer to hold the created constraint */
112  const char* name, /**< name of constraint */
113  int nvars, /**< number of variables in the constraint */
114  SCIP_VAR** vars, /**< array with variables of constraint entries */
115  SCIP_Real* weights /**< weights determining the variable order, or NULL if natural order should be used */
116  );
117 
118 /** adds variable to SOS1 constraint, the position is determined by the given weight */
119 extern
121  SCIP* scip, /**< SCIP data structure */
122  SCIP_CONS* cons, /**< constraint */
123  SCIP_VAR* var, /**< variable to add to the constraint */
124  SCIP_Real weight /**< weight determining position of variable */
125  );
126 
127 /** appends variable to SOS1 constraint */
128 extern
130  SCIP* scip, /**< SCIP data structure */
131  SCIP_CONS* cons, /**< constraint */
132  SCIP_VAR* var /**< variable to add to the constraint */
133  );
134 
135 /** gets number of variables in SOS1 constraint */
136 extern
137 int SCIPgetNVarsSOS1(
138  SCIP* scip, /**< SCIP data structure */
139  SCIP_CONS* cons /**< constraint */
140  );
141 
142 /** gets array of variables in SOS1 constraint */
143 extern
145  SCIP* scip, /**< SCIP data structure */
146  SCIP_CONS* cons /**< constraint data */
147  );
148 
149 /** gets array of weights in SOS1 constraint (or NULL if not existent) */
150 extern
152  SCIP* scip, /**< SCIP data structure */
153  SCIP_CONS* cons /**< constraint data */
154  );
155 
156 /** gets conflict graph of SOS1 constraints (or NULL if not existent)
157  *
158  * @note The conflict graph is globally valid; local changes are not taken into account.
159  */
160 extern
162  SCIP_CONSHDLR* conshdlr /**< SOS1 constraint handler */
163  );
164 
165 /** gets number of problem variables that are part of the SOS1 conflict graph */
166 extern
167 int SCIPgetNSOS1Vars(
168  SCIP_CONSHDLR* conshdlr /**< SOS1 constraint handler */
169  );
170 
171 /** returns whether variable is part of the SOS1 conflict graph */
172 extern
174  SCIP_CONSHDLR* conshdlr, /**< SOS1 constraint handler */
175  SCIP_VAR* var /**< variable */
176  );
177 
178 /** returns node of variable in the conflict graph or -1 if variable is not part of the SOS1 conflict graph */
179 extern
181  SCIP_CONSHDLR* conshdlr, /**< SOS1 constraint handler */
182  SCIP_VAR* var /**< variable */
183  );
184 
185 /** returns variable that belongs to a given node from the conflict graph */
186 extern
188  SCIP_DIGRAPH* conflictgraph, /**< conflict graph */
189  int node /**< node from the conflict graph */
190  );
191 
192 /** based on solution values of the variables, fixes variables to zero to turn all SOS1 constraints feasible */
193 extern
195  SCIP* scip, /**< SCIP pointer */
196  SCIP_CONSHDLR* conshdlr, /**< SOS1 constraint handler */
197  SCIP_SOL* sol, /**< solution */
198  SCIP_Bool* changed, /**< pointer to store whether the solution has been changed */
199  SCIP_Bool* success /**< pointer to store whether SOS1 constraints have been turned feasible and
200  * solution was good enough */
201  );
202 
203 /* @} */
204 
205 /* @} */
206 
207 #ifdef __cplusplus
208 }
209 #endif
210 
211 #endif
SCIP_VAR ** SCIPgetVarsSOS1(SCIP *scip, SCIP_CONS *cons)
Definition: cons_sos1.c:10569
SCIP_Real * SCIPgetWeightsSOS1(SCIP *scip, SCIP_CONS *cons)
Definition: cons_sos1.c:10594
SCIP_RETCODE SCIPmakeSOS1sFeasible(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_SOL *sol, SCIP_Bool *changed, SCIP_Bool *success)
Definition: cons_sos1.c:10746
int SCIPgetNSOS1Vars(SCIP_CONSHDLR *conshdlr)
Definition: cons_sos1.c:10644
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
SCIP_RETCODE SCIPincludeConshdlrSOS1(SCIP *scip)
Definition: cons_sos1.c:10125
int SCIPvarGetNodeSOS1(SCIP_CONSHDLR *conshdlr, SCIP_VAR *var)
Definition: cons_sos1.c:10690
SCIP_RETCODE SCIPaddVarSOS1(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_Real weight)
Definition: cons_sos1.c:10477
SCIP_DIGRAPH * SCIPgetConflictgraphSOS1(SCIP_CONSHDLR *conshdlr)
Definition: cons_sos1.c:10622
SCIP_Bool SCIPvarIsSOS1(SCIP_CONSHDLR *conshdlr, SCIP_VAR *var)
Definition: cons_sos1.c:10666
SCIP_RETCODE SCIPappendVarSOS1(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var)
Definition: cons_sos1.c:10511
#define SCIP_Bool
Definition: def.h:61
int SCIPgetNVarsSOS1(SCIP *scip, SCIP_CONS *cons)
Definition: cons_sos1.c:10544
SCIP_VAR * SCIPnodeGetVarSOS1(SCIP_DIGRAPH *conflictgraph, int node)
Definition: cons_sos1.c:10721
SCIP_RETCODE SCIPcreateConsBasicSOS1(SCIP *scip, SCIP_CONS **cons, const char *name, int nvars, SCIP_VAR **vars, SCIP_Real *weights)
Definition: cons_sos1.c:10461
#define SCIP_Real
Definition: def.h:149
SCIP_RETCODE SCIPcreateConsSOS1(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_sos1.c:10340
SCIP callable library.