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