1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /*                                                                           */
3 /*                  This file is part of the program and library             */
4 /*         SCIP --- Solving Constraint Integer Programs                      */
5 /*                                                                           */
6 /*    Copyright (C) 2002-2021 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_logicor.h
17  * @ingroup CONSHDLRS
18  * @brief  Constraint handler for logicor constraints \f$1^T x \ge 1\f$ (equivalent to set covering, but algorithms are suited for depth first search).
19  * @author Tobias Achterberg
20  * @author Michael Winkler
21  *
22  */
23 
24 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
25 
26 #ifndef __SCIP_CONS_LOGICOR_H__
27 #define __SCIP_CONS_LOGICOR_H__
28 
29 
30 #include "scip/def.h"
31 #include "scip/type_cons.h"
32 #include "scip/type_lp.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 logic or constraints and includes it in SCIP
42  *
43  * @ingroup ConshdlrIncludes
44  * */
45 SCIP_EXPORT
46 SCIP_RETCODE SCIPincludeConshdlrLogicor(
47    SCIP*                 scip                /**< SCIP data structure */
48    );
49 
50 /**@addtogroup CONSHDLRS
51  *
52  * @{
53  *
54  * @name Logicor Constraints
55  *
56  * @{
57  *
58  * This constraint handler handles a special type of linear constraints, namely
59  * logic or constraints. These are equivalent to set covering constraints, but
60  * are handled by special algorithms which are better suited for depth first search.
61  * For a set of binary variables \f$x_i, i=1,\dots,n\f$, a logic or constraint has the form
62  * \f[
63  *   \sum_{i=1}^n x_i \ge 1.
64  * \f]
65  */
66 
67 /** creates and captures a logic or constraint
68  *
69  *  @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
70  */
71 SCIP_EXPORT
72 SCIP_RETCODE SCIPcreateConsLogicor(
73    SCIP*                 scip,               /**< SCIP data structure */
74    SCIP_CONS**           cons,               /**< pointer to hold the created constraint */
75    const char*           name,               /**< name of constraint */
76    int                   nvars,              /**< number of variables in the constraint */
77    SCIP_VAR**            vars,               /**< array with variables of constraint entries */
78    SCIP_Bool             initial,            /**< should the LP relaxation of constraint be in the initial LP?
79                                               *   Usually set to TRUE. Set to FALSE for 'lazy constraints'. */
80    SCIP_Bool             separate,           /**< should the constraint be separated during LP processing?
81                                               *   Usually set to TRUE. */
82    SCIP_Bool             enforce,            /**< should the constraint be enforced during node processing?
83                                               *   TRUE for model constraints, FALSE for additional, redundant constraints. */
84    SCIP_Bool             check,              /**< should the constraint be checked for feasibility?
85                                               *   TRUE for model constraints, FALSE for additional, redundant constraints. */
86    SCIP_Bool             propagate,          /**< should the constraint be propagated during node processing?
87                                               *   Usually set to TRUE. */
88    SCIP_Bool             local,              /**< is constraint only valid locally?
89                                               *   Usually set to FALSE. Has to be set to TRUE, e.g., for branching constraints. */
90    SCIP_Bool             modifiable,         /**< is constraint modifiable (subject to column generation)?
91                                               *   Usually set to FALSE. In column generation applications, set to TRUE if pricing
92                                               *   adds coefficients to this constraint. */
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 a logicor constraint
104  *  in its most basic version, i. e., all constraint flags are set to their basic value as explained for the
105  *  method SCIPcreateConsLogicor(); all flags can be set via SCIPsetConsFLAGNAME-methods in scip.h
106  *
107  *  @see SCIPcreateConsLogicor() for information about the basic constraint flag configuration
108  *
109  *  @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
110  */
111 SCIP_EXPORT
112 SCIP_RETCODE SCIPcreateConsBasicLogicor(
113    SCIP*                 scip,               /**< SCIP data structure */
114    SCIP_CONS**           cons,               /**< pointer to hold the created constraint */
115    const char*           name,               /**< name of constraint */
116    int                   nvars,              /**< number of variables in the constraint */
117    SCIP_VAR**            vars                /**< array with variables of constraint entries */
118    );
119 
120 /** adds coefficient in logic or constraint */
121 SCIP_EXPORT
122 SCIP_RETCODE SCIPaddCoefLogicor(
123    SCIP*                 scip,               /**< SCIP data structure */
124    SCIP_CONS*            cons,               /**< logicor constraint */
125    SCIP_VAR*             var                 /**< variable to add to the constraint */
126    );
127 
128 /** gets number of variables in logic or constraint */
129 SCIP_EXPORT
130 int SCIPgetNVarsLogicor(
131    SCIP*                 scip,               /**< SCIP data structure */
132    SCIP_CONS*            cons                /**< constraint data */
133    );
134 
135 /** gets array of variables in logic or constraint */
136 SCIP_EXPORT
137 SCIP_VAR** SCIPgetVarsLogicor(
138    SCIP*                 scip,               /**< SCIP data structure */
139    SCIP_CONS*            cons                /**< constraint data */
140    );
141 
142 /** gets the dual solution of the logic or constraint in the current LP */
143 SCIP_EXPORT
144 SCIP_Real SCIPgetDualsolLogicor(
145    SCIP*                 scip,               /**< SCIP data structure */
146    SCIP_CONS*            cons                /**< constraint data */
147    );
148 
149 /** gets the dual Farkas value of the logic or constraint in the current infeasible LP */
150 SCIP_EXPORT
151 SCIP_Real SCIPgetDualfarkasLogicor(
152    SCIP*                 scip,               /**< SCIP data structure */
153    SCIP_CONS*            cons                /**< constraint data */
154    );
155 
156 /** returns the linear relaxation of the given logic or constraint; may return NULL if no LP row was yet created;
157  *  the user must not modify the row!
158  */
159 SCIP_EXPORT
160 SCIP_ROW* SCIPgetRowLogicor(
161    SCIP*                 scip,               /**< SCIP data structure */
162    SCIP_CONS*            cons                /**< constraint data */
163    );
164 
165 /** cleans up (multi-)aggregations and fixings from logicor constraints */
166 SCIP_EXPORT
167 SCIP_RETCODE SCIPcleanupConssLogicor(
168    SCIP*                 scip,               /**< SCIP data structure */
169    SCIP_Bool             onlychecked,        /**< should only checked constraints be cleaned up? */
170    int*                  naddconss,          /**< pointer to count number of added (linear) constraints */
171    int*                  ndelconss,          /**< pointer to count number of deleted (logicor) constraints */
172    int*                  nchgcoefs           /**< pointer to count number of changed coefficients */
173    );
174 
175 /** @} */
176 
177 /** @} */
178 
179 #ifdef __cplusplus
180 }
181 #endif
182 
183 #endif
184