Scippy

SCIP

Solving Constraint Integer Programs

cons_xor.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-2022 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 scipopt.org. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file cons_xor.h
17  * @ingroup CONSHDLRS
18  * @brief Constraint handler for XOR constraints, \f$rhs = x_1 \oplus x_2 \oplus \dots \oplus x_n\f$
19  * @author Tobias Achterberg
20  * @author Stefan Heinz
21  * @author Michael Winkler
22  *
23  */
24 
25 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
26 
27 #ifndef __SCIP_CONS_XOR_H__
28 #define __SCIP_CONS_XOR_H__
29 
30 
31 #include "scip/def.h"
32 #include "scip/type_cons.h"
33 #include "scip/type_retcode.h"
34 #include "scip/type_scip.h"
35 #include "scip/type_var.h"
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 /** creates the handler for xor constraints and includes it in SCIP
42  *
43  * @ingroup ConshdlrIncludes
44  * */
45 SCIP_EXPORT
47  SCIP* scip /**< SCIP data structure */
48  );
49 
50 /**@addtogroup CONSHDLRS
51  *
52  * @{
53  *
54  * @name XOR Constraints
55  *
56  * @{
57  *
58  * This constraint handler deals with "xor" constraint. These are constraint of the form:
59  *
60  * \f[
61  * rhs = x_1 \oplus x_2 \oplus \dots \oplus x_n
62  * \f]
63  *
64  * where \f$x_i\f$ is a binary variable for all \f$i\f$ and \f$rhs\f$ is bool. The variables \f$x\f$'s are called
65  * operators. This constraint is satisfied if \f$rhs\f$ is TRUE and an odd number of the operators are TRUE or if the
66  * \f$rhs\f$ is FALSE and a even number of operators are TRUE. Hence, if the sum of \f$rhs\f$ and operators is even.
67  */
68 
69 /** creates and captures an xor constraint
70  *
71  * @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
72  */
73 SCIP_EXPORT
75  SCIP* scip, /**< SCIP data structure */
76  SCIP_CONS** cons, /**< pointer to hold the created constraint */
77  const char* name, /**< name of constraint */
78  SCIP_Bool rhs, /**< right hand side of the constraint */
79  int nvars, /**< number of operator variables in the constraint */
80  SCIP_VAR** vars, /**< array with operator variables of constraint */
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 modifiable, /**< is constraint modifiable (subject to column generation)?
94  * Usually set to FALSE. In column generation applications, set to TRUE if pricing
95  * adds coefficients to this constraint. */
96  SCIP_Bool dynamic, /**< is constraint subject to aging?
97  * Usually set to FALSE. Set to TRUE for own cuts which
98  * are separated as constraints. */
99  SCIP_Bool removable, /**< should the relaxation be removed from the LP due to aging or cleanup?
100  * Usually set to FALSE. Set to TRUE for 'lazy constraints' and 'user cuts'. */
101  SCIP_Bool stickingatnode /**< should the constraint always be kept at the node where it was added, even
102  * if it may be moved to a more global node?
103  * Usually set to FALSE. Set to TRUE to for constraints that represent node data. */
104  );
105 
106 /** creates and captures an xor constraint
107  * in its most basic version, i. e., all constraint flags are set to their basic value as explained for the
108  * method SCIPcreateConsXor(); all flags can be set via SCIPsetConsFLAGNAME-methods in scip.h
109  *
110  * @see SCIPcreateConsXor() for information about the basic constraint flag configuration
111  *
112  * @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
113  */
114 SCIP_EXPORT
116  SCIP* scip, /**< SCIP data structure */
117  SCIP_CONS** cons, /**< pointer to hold the created constraint */
118  const char* name, /**< name of constraint */
119  SCIP_Bool rhs, /**< right hand side of the constraint */
120  int nvars, /**< number of operator variables in the constraint */
121  SCIP_VAR** vars /**< array with operator variables of constraint */
122  );
123 
124 /** gets number of variables in xor constraint */
125 SCIP_EXPORT
126 int SCIPgetNVarsXor(
127  SCIP* scip, /**< SCIP data structure */
128  SCIP_CONS* cons /**< constraint data */
129  );
130 
131 /** gets array of variables in xor constraint */
132 SCIP_EXPORT
134  SCIP* scip, /**< SCIP data structure */
135  SCIP_CONS* cons /**< constraint data */
136  );
137 
138 /** gets integer variable in xor constraint */
139 SCIP_EXPORT
141  SCIP* scip, /**< SCIP data structure */
142  SCIP_CONS* cons /**< constraint data */
143  );
144 
145 /** gets the right hand side of the xor constraint */
146 SCIP_EXPORT
148  SCIP* scip, /**< SCIP data structure */
149  SCIP_CONS* cons /**< constraint data */
150  );
151 
152 /** @} */
153 
154 /** @} */
155 
156 #ifdef __cplusplus
157 }
158 #endif
159 
160 #endif
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:54
SCIP_RETCODE SCIPincludeConshdlrXor(SCIP *scip)
Definition: cons_xor.c:5755
SCIP_RETCODE SCIPcreateConsXor(SCIP *scip, SCIP_CONS **cons, const char *name, SCIP_Bool rhs, int nvars, SCIP_VAR **vars, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool modifiable, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode)
Definition: cons_xor.c:5842
type definitions for return codes for SCIP methods
SCIP_RETCODE SCIPcreateConsBasicXor(SCIP *scip, SCIP_CONS **cons, const char *name, SCIP_Bool rhs, int nvars, SCIP_VAR **vars)
Definition: cons_xor.c:5900
type definitions for SCIP&#39;s main datastructure
type definitions for problem variables
#define SCIP_Bool
Definition: def.h:84
SCIP_Bool SCIPgetRhsXor(SCIP *scip, SCIP_CONS *cons)
Definition: cons_xor.c:5985
SCIP_VAR ** SCIPgetVarsXor(SCIP *scip, SCIP_CONS *cons)
Definition: cons_xor.c:5939
int SCIPgetNVarsXor(SCIP *scip, SCIP_CONS *cons)
Definition: cons_xor.c:5916
common defines and data types used in all packages of SCIP
SCIP_VAR * SCIPgetIntVarXor(SCIP *scip, SCIP_CONS *cons)
Definition: cons_xor.c:5962
type definitions for constraints and constraint handlers