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-2018 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_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/def.h"
31 #include "scip/type_cons.h"
32 #include "scip/type_misc.h"
33 #include "scip/type_retcode.h"
34 #include "scip/type_scip.h"
35 #include "scip/type_sol.h"
36 #include "scip/type_var.h"
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
42 /** creates the handler for SOS1 constraints and includes it in SCIP
43  *
44  * @ingroup ConshdlrIncludes
45  * */
46 extern
48  SCIP* scip /**< SCIP data structure */
49  );
50 
51 /**@addtogroup CONSHDLRS
52  *
53  * @{
54  *
55  * @name Specially Ordered Set (SOS) Type 1 Constraints
56  *
57  * @{
58  *
59  * A specially ordered set of type 1 (SOS1) is a sequence of variables such that at most one
60  * variable is nonzero. The special case of two variables arises, for instance, from equilibrium or
61  * complementary conditions like \f$x \cdot y = 0\f$. Note that it is in principle allowed that a
62  * variable appears twice, but it then can be fixed to 0.
63  */
64 
65 /** creates and captures an SOS1 constraint
66  *
67  * We set the constraint to not be modifable. If the weights are non
68  * NULL, the variables are ordered according to these weights (in
69  * ascending order).
70  *
71  * @note The constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons().
72  */
73 extern
75  SCIP* scip, /**< SCIP data structure */
76  SCIP_CONS** cons, /**< pointer to hold the created constraint */
77  const char* name, /**< name of constraint */
78  int nvars, /**< number of variables in the constraint */
79  SCIP_VAR** vars, /**< array with variables of constraint entries */
80  SCIP_Real* weights, /**< weights determining the variable order, or NULL if natural order should be used */
81  SCIP_Bool initial, /**< should the LP relaxation of constraint be in the initial LP?
82  * Usually set to TRUE. Set to FALSE for 'lazy constraints'. */
83  SCIP_Bool separate, /**< should the constraint be separated during LP processing?
84  * Usually set to TRUE. */
85  SCIP_Bool enforce, /**< should the constraint be enforced during node processing?
86  * TRUE for model constraints, FALSE for additional, redundant constraints. */
87  SCIP_Bool check, /**< should the constraint be checked for feasibility?
88  * TRUE for model constraints, FALSE for additional, redundant constraints. */
89  SCIP_Bool propagate, /**< should the constraint be propagated during node processing?
90  * Usually set to TRUE. */
91  SCIP_Bool local, /**< is constraint only valid locally?
92  * Usually set to FALSE. Has to be set to TRUE, e.g., for branching constraints. */
93  SCIP_Bool dynamic, /**< is constraint subject to aging?
94  * Usually set to FALSE. Set to TRUE for own cuts which
95  * are separated as constraints. */
96  SCIP_Bool removable, /**< should the relaxation be removed from the LP due to aging or cleanup?
97  * Usually set to FALSE. Set to TRUE for 'lazy constraints' and 'user cuts'. */
98  SCIP_Bool stickingatnode /**< should the constraint always be kept at the node where it was added, even
99  * if it may be moved to a more global node?
100  * Usually set to FALSE. Set to TRUE to for constraints that represent node data. */
101  );
102 
103 /** creates and captures an SOS1 constraint
104  * in its most basic variant, i. e., with all constraint flags set to their default values, which can be set
105  * afterwards using SCIPsetConsFLAGNAME() in scip.h
106  *
107  * @see SCIPcreateConsSOS1() for the default constraint flag configuration
108  *
109  * @warning Do NOT set the constraint to be modifiable manually, because this might lead
110  * to wrong results as the variable array will not be resorted
111  *
112  * @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
113  */
114 extern
116  SCIP* scip, /**< SCIP data structure */
117  SCIP_CONS** cons, /**< pointer to hold the created constraint */
118  const char* name, /**< name of constraint */
119  int nvars, /**< number of variables in the constraint */
120  SCIP_VAR** vars, /**< array with variables of constraint entries */
121  SCIP_Real* weights /**< weights determining the variable order, or NULL if natural order should be used */
122  );
123 
124 /** adds variable to SOS1 constraint, the position is determined by the given weight */
125 extern
127  SCIP* scip, /**< SCIP data structure */
128  SCIP_CONS* cons, /**< constraint */
129  SCIP_VAR* var, /**< variable to add to the constraint */
130  SCIP_Real weight /**< weight determining position of variable */
131  );
132 
133 /** appends variable to SOS1 constraint */
134 extern
136  SCIP* scip, /**< SCIP data structure */
137  SCIP_CONS* cons, /**< constraint */
138  SCIP_VAR* var /**< variable to add to the constraint */
139  );
140 
141 /** gets number of variables in SOS1 constraint */
142 extern
143 int SCIPgetNVarsSOS1(
144  SCIP* scip, /**< SCIP data structure */
145  SCIP_CONS* cons /**< constraint */
146  );
147 
148 /** gets array of variables in SOS1 constraint */
149 extern
151  SCIP* scip, /**< SCIP data structure */
152  SCIP_CONS* cons /**< constraint data */
153  );
154 
155 /** gets array of weights in SOS1 constraint (or NULL if not existent) */
156 extern
158  SCIP* scip, /**< SCIP data structure */
159  SCIP_CONS* cons /**< constraint data */
160  );
161 
162 /** gets conflict graph of SOS1 constraints (or NULL if not existent)
163  *
164  * @note The conflict graph is globally valid; local changes are not taken into account.
165  */
166 extern
168  SCIP_CONSHDLR* conshdlr /**< SOS1 constraint handler */
169  );
170 
171 /** gets number of problem variables that are part of the SOS1 conflict graph */
172 extern
173 int SCIPgetNSOS1Vars(
174  SCIP_CONSHDLR* conshdlr /**< SOS1 constraint handler */
175  );
176 
177 /** returns whether variable is part of the SOS1 conflict graph */
178 extern
180  SCIP_CONSHDLR* conshdlr, /**< SOS1 constraint handler */
181  SCIP_VAR* var /**< variable */
182  );
183 
184 /** returns node of variable in the conflict graph or -1 if variable is not part of the SOS1 conflict graph */
185 extern
187  SCIP_CONSHDLR* conshdlr, /**< SOS1 constraint handler */
188  SCIP_VAR* var /**< variable */
189  );
190 
191 /** returns variable that belongs to a given node from the conflict graph */
192 extern
194  SCIP_DIGRAPH* conflictgraph, /**< conflict graph */
195  int node /**< node from the conflict graph */
196  );
197 
198 /** based on solution values of the variables, fixes variables to zero to turn all SOS1 constraints feasible */
199 extern
201  SCIP* scip, /**< SCIP pointer */
202  SCIP_CONSHDLR* conshdlr, /**< SOS1 constraint handler */
203  SCIP_SOL* sol, /**< solution */
204  SCIP_Bool* changed, /**< pointer to store whether the solution has been changed */
205  SCIP_Bool* success /**< pointer to store whether SOS1 constraints have been turned feasible and
206  * solution was good enough */
207  );
208 
209 /* @} */
210 
211 /* @} */
212 
213 #ifdef __cplusplus
214 }
215 #endif
216 
217 #endif
type definitions for miscellaneous datastructures
SCIP_VAR ** SCIPgetVarsSOS1(SCIP *scip, SCIP_CONS *cons)
Definition: cons_sos1.c:10596
SCIP_Real * SCIPgetWeightsSOS1(SCIP *scip, SCIP_CONS *cons)
Definition: cons_sos1.c:10621
SCIP_RETCODE SCIPmakeSOS1sFeasible(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_SOL *sol, SCIP_Bool *changed, SCIP_Bool *success)
Definition: cons_sos1.c:10773
int SCIPgetNSOS1Vars(SCIP_CONSHDLR *conshdlr)
Definition: cons_sos1.c:10671
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
SCIP_RETCODE SCIPincludeConshdlrSOS1(SCIP *scip)
Definition: cons_sos1.c:10152
type definitions for return codes for SCIP methods
int SCIPvarGetNodeSOS1(SCIP_CONSHDLR *conshdlr, SCIP_VAR *var)
Definition: cons_sos1.c:10717
SCIP_RETCODE SCIPaddVarSOS1(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_Real weight)
Definition: cons_sos1.c:10504
type definitions for SCIP&#39;s main datastructure
type definitions for problem variables
SCIP_DIGRAPH * SCIPgetConflictgraphSOS1(SCIP_CONSHDLR *conshdlr)
Definition: cons_sos1.c:10649
SCIP_Bool SCIPvarIsSOS1(SCIP_CONSHDLR *conshdlr, SCIP_VAR *var)
Definition: cons_sos1.c:10693
SCIP_RETCODE SCIPappendVarSOS1(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var)
Definition: cons_sos1.c:10538
#define SCIP_Bool
Definition: def.h:62
int SCIPgetNVarsSOS1(SCIP *scip, SCIP_CONS *cons)
Definition: cons_sos1.c:10571
SCIP_VAR * SCIPnodeGetVarSOS1(SCIP_DIGRAPH *conflictgraph, int node)
Definition: cons_sos1.c:10748
type definitions for storing primal CIP solutions
SCIP_RETCODE SCIPcreateConsBasicSOS1(SCIP *scip, SCIP_CONS **cons, const char *name, int nvars, SCIP_VAR **vars, SCIP_Real *weights)
Definition: cons_sos1.c:10488
#define SCIP_Real
Definition: def.h:150
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:10367
common defines and data types used in all packages of SCIP
type definitions for constraints and constraint handlers