Scippy

SCIP

Solving Constraint Integer Programs

cons_exactlinear.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-2025 Zuse Institute Berlin (ZIB) */
7/* */
8/* Licensed under the Apache License, Version 2.0 (the "License"); */
9/* you may not use this file except in compliance with the License. */
10/* You may obtain a copy of the License at */
11/* */
12/* http://www.apache.org/licenses/LICENSE-2.0 */
13/* */
14/* Unless required by applicable law or agreed to in writing, software */
15/* distributed under the License is distributed on an "AS IS" BASIS, */
16/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
17/* See the License for the specific language governing permissions and */
18/* limitations under the License. */
19/* */
20/* You should have received a copy of the Apache-2.0 license */
21/* along with SCIP; see the file LICENSE. If not visit scipopt.org. */
22/* */
23/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
24
25/**@file cons_exactlinear.h
26 * @ingroup CONSHDLRS
27 * @brief Constraint handler for linear constraints in their most general form, \f$lhs <= a^T x <= rhs\f$.
28 * @author Leon Eifler
29 */
30
31/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
32
33#ifndef __SCIP_CONS_EXACTLINEAR_H__
34#define __SCIP_CONS_EXACTLINEAR_H__
35
36#include "scip/def.h"
37#include "scip/intervalarith.h"
38#include "scip/type_cons.h"
39#include "scip/type_lp.h"
40#include "scip/type_lpexact.h"
41#include "scip/type_misc.h"
42#include "scip/type_retcode.h"
43#include "scip/type_scip.h"
44#include "scip/type_sol.h"
45#include "scip/type_var.h"
47#include "scip/type_rational.h"
48
49#ifdef __cplusplus
50extern "C" {
51#endif
52
53
54
55/*
56 * constraint specific interface methods
57 */
58
59/** creates the handler for linear constraints and includes it in SCIP
60 *
61 * @ingroup ConshdlrIncludes
62 */
63SCIP_EXPORT
65 SCIP* scip /**< SCIP data structure */
66 );
67
68/**@addtogroup CONSHDLRS
69 *
70 * @{
71 *
72 * @name Exact Linear Constraints
73 *
74 * This constraint handler handles linear constraints in their most general form
75 * \f[
76 * lhs \leq \sum_{i=1}^n a_i x_i \leq rhs
77 * \f]
78 * in a numerically exact way, where \f$a_i \in Q, i = 1,\dots,n\f$, \f$lhs\in Q \cup \{-\infty\}\f$, \f$rhs\in Q \cup \{\infty\}\f$,
79 * and \f$x_i, i = 1,\dots,n\f$ which can be binary, integer, or continuous decision variables.
80 *
81 * @{
82 */
83
84/** creates and captures a linear constraint
85 *
86 * @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
87 */
88SCIP_EXPORT
90 SCIP* scip, /**< SCIP data structure */
91 SCIP_CONS** cons, /**< pointer to hold the created constraint */
92 const char* name, /**< name of constraint */
93 int nvars, /**< number of nonzeros in the constraint */
94 SCIP_VAR** vars, /**< array with variables of constraint entries */
95 SCIP_RATIONAL** vals, /**< array with coefficients of constraint entries */
96 SCIP_RATIONAL* lhs, /**< left hand side of constraint */
97 SCIP_RATIONAL* rhs, /**< right hand side of constraint */
98 SCIP_Bool initial, /**< should the LP relaxation of constraint be in the initial LP?
99 * Usually set to TRUE. Set to FALSE for 'lazy constraints'. */
100 SCIP_Bool separate, /**< should the constraint be separated during LP processing?
101 * Usually set to TRUE. */
102 SCIP_Bool enforce, /**< should the constraint be enforced during node processing?
103 * TRUE for model constraints, FALSE for additional, redundant constraints. */
104 SCIP_Bool check, /**< should the constraint be checked for feasibility?
105 * TRUE for model constraints, FALSE for additional, redundant constraints. */
106 SCIP_Bool propagate, /**< should the constraint be propagated during node processing?
107 * Usually set to TRUE. */
108 SCIP_Bool local, /**< is constraint only valid locally?
109 * Usually set to FALSE. Has to be set to TRUE, e.g., for branching constraints. */
110 SCIP_Bool modifiable, /**< is constraint modifiable (subject to column generation)?
111 * Usually set to FALSE. In column generation applications, set to TRUE if pricing
112 * adds coefficients to this constraint. */
113 SCIP_Bool dynamic, /**< is constraint subject to aging?
114 * Usually set to FALSE. Set to TRUE for own cuts which
115 * are separated as constraints. */
116 SCIP_Bool removable, /**< should the relaxation be removed from the LP due to aging or cleanup?
117 * Usually set to FALSE. Set to TRUE for 'lazy constraints' and 'user cuts'. */
118 SCIP_Bool stickingatnode /**< should the constraint always be kept at the node where it was added, even
119 * if it may be moved to a more global node?
120 * Usually set to FALSE. Set to TRUE to for constraints that represent node data. */
121 );
122
123/** creates and captures a linear constraint
124 * in its most basic version, i. e., all constraint flags are set to their basic value as explained for the
125 * method SCIPcreateConsLinear(); all flags can be set via SCIPsetConsFLAGNAME-methods in scip.h
126 *
127 * @see SCIPcreateConsLinear() for information about the basic constraint flag configuration
128 *
129 * @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
130 */
131SCIP_EXPORT
133 SCIP* scip, /**< SCIP data structure */
134 SCIP_CONS** cons, /**< pointer to hold the created constraint */
135 const char* name, /**< name of constraint */
136 int nvars, /**< number of nonzeros in the constraint */
137 SCIP_VAR** vars, /**< array with variables of constraint entries */
138 SCIP_RATIONAL** vals, /**< array with coefficients of constraint entries */
139 SCIP_RATIONAL* lhs, /**< left hand side of constraint */
140 SCIP_RATIONAL* rhs /**< right hand side of constraint */
141 );
142
143/** creates a linear constraint from an exact linear constraint by rounding values to floating-point and captures it */
144SCIP_EXPORT
146 SCIP* scip, /**< target SCIP data structure */
147 SCIP_CONS** cons, /**< pointer to store the created target constraint */
148 SCIP* sourcescip, /**< source SCIP data structure */
149 const char* name, /**< name of constraint */
150 int nvars, /**< number of variables in source variable array */
151 SCIP_VAR** sourcevars, /**< source variables of the linear constraints */
152 SCIP_INTERVAL* sourcecoefs, /**< coefficient array of the linear constraint, or NULL if all coefficients are one */
153 SCIP_Real lhs, /**< left hand side of the linear constraint */
154 SCIP_Real rhs, /**< right hand side of the linear constraint */
155 SCIP_HASHMAP* varmap, /**< a SCIP_HASHMAP mapping variables of the source SCIP to corresponding
156 * variables of the target SCIP */
157 SCIP_HASHMAP* consmap, /**< a hashmap to store the mapping of source constraints to the corresponding
158 * target constraints */
159 SCIP_Bool initial, /**< should the LP relaxation of constraint be in the initial LP? */
160 SCIP_Bool separate, /**< should the constraint be separated during LP processing? */
161 SCIP_Bool enforce, /**< should the constraint be enforced during node processing? */
162 SCIP_Bool check, /**< should the constraint be checked for feasibility? */
163 SCIP_Bool propagate, /**< should the constraint be propagated during node processing? */
164 SCIP_Bool local, /**< is constraint only valid locally? */
165 SCIP_Bool modifiable, /**< is constraint modifiable (subject to column generation)? */
166 SCIP_Bool dynamic, /**< is constraint subject to aging? */
167 SCIP_Bool removable, /**< should the relaxation be removed from the LP due to aging or cleanup? */
168 SCIP_Bool stickingatnode, /**< should the constraint always be kept at the node where it was added, even
169 * if it may be moved to a more global node? */
170 SCIP_Bool global, /**< create a global or a local copy? */
171 SCIP_Bool* valid /**< pointer to store if the copying was valid */
172 );
173
174/** adds coefficient to linear constraint (if it is not zero) */
175SCIP_EXPORT
177 SCIP* scip, /**< SCIP data structure */
178 SCIP_CONS* cons, /**< constraint data */
179 SCIP_VAR* var, /**< variable of constraint entry */
180 SCIP_RATIONAL* val /**< coefficient of constraint entry */
181 );
182
183/** changes coefficient of variable in linear constraint; deletes the variable if coefficient is zero; adds variable if
184 * not yet contained in the constraint
185 *
186 * @note This method may only be called during problem creation stage for an original constraint and variable.
187 *
188 * @note This method requires linear time to search for occurences of the variable in the constraint data.
189 */
190SCIP_EXPORT
192 SCIP* scip, /**< SCIP data structure */
193 SCIP_CONS* cons, /**< constraint data */
194 SCIP_VAR* var, /**< variable of constraint entry */
195 SCIP_RATIONAL* val /**< new coefficient of constraint entry */
196 );
197
198/** deletes variable from linear constraint
199 *
200 * @note This method may only be called during problem creation stage for an original constraint and variable.
201 *
202 * @note This method requires linear time to search for occurences of the variable in the constraint data.
203 */
204SCIP_EXPORT
206 SCIP* scip, /**< SCIP data structure */
207 SCIP_CONS* cons, /**< constraint data */
208 SCIP_VAR* var /**< variable of constraint entry */
209 );
210
211/** gets left hand side of linear constraint */
212SCIP_EXPORT
214 SCIP* scip, /**< SCIP data structure */
215 SCIP_CONS* cons /**< constraint data */
216 );
217
218/** gets right hand side of linear constraint */
219SCIP_EXPORT
221 SCIP* scip, /**< SCIP data structure */
222 SCIP_CONS* cons /**< constraint data */
223 );
224
225/** changes left hand side of linear constraint */
226SCIP_EXPORT
228 SCIP* scip, /**< SCIP data structure */
229 SCIP_CONS* cons, /**< constraint data */
230 SCIP_RATIONAL* lhs /**< new left hand side */
231 );
232
233/** changes right hand side of linear constraint */
234SCIP_EXPORT
236 SCIP* scip, /**< SCIP data structure */
237 SCIP_CONS* cons, /**< constraint data */
238 SCIP_RATIONAL* rhs /**< new right hand side */
239 );
240
241/** gets the number of variables in the linear constraint */
242SCIP_EXPORT
244 SCIP* scip, /**< SCIP data structure */
245 SCIP_CONS* cons /**< constraint data */
246 );
247
248/** gets the array of variables in the linear constraint; the user must not modify this array! */
249SCIP_EXPORT
251 SCIP* scip, /**< SCIP data structure */
252 SCIP_CONS* cons /**< constraint data */
253 );
254
255/** gets the array of coefficient values in the linear constraint; the user must not modify this array! */
256SCIP_EXPORT
258 SCIP* scip, /**< SCIP data structure */
259 SCIP_CONS* cons /**< constraint data */
260 );
261
262/** gets the array of coefficient values in the linear constraint; the user must not modify this array! */
263SCIP_EXPORT
265 SCIP* scip, /**< SCIP data structure */
266 SCIP_CONS* cons /**< constraint data */
267 );
268
269/** gets the activity of the linear constraint in the given solution
270 *
271 * @note if the activity comprises positive and negative infinity contributions, the result is currently undefined
272 */
273SCIP_EXPORT
275 SCIP* scip, /**< SCIP data structure */
276 SCIP_CONS* cons, /**< constraint data */
277 SCIP_SOL* sol, /**< solution, or NULL to use current node's solution */
278 SCIP_RATIONAL* ret /**< pointer to store result */
279 );
280
281/** gets the feasibility of the linear constraint in the given solution */
282SCIP_EXPORT
284 SCIP* scip, /**< SCIP data structure */
285 SCIP_CONS* cons, /**< constraint data */
286 SCIP_SOL* sol, /**< solution, or NULL to use current node's solution */
287 SCIP_RATIONAL* ret /**< pointer to store the result */
288 );
289
290/** gets the dual solution of the linear constraint in the current LP
291 *
292 * @note this method currently returns the value from the floating-point LP
293 */
294SCIP_EXPORT
296 SCIP* scip, /**< SCIP data structure */
297 SCIP_CONS* cons, /**< constraint data */
298 SCIP_RATIONAL* ret /**< pointer to store the result */
299 );
300
301/** gets the dual Farkas value of the linear constraint in the current infeasible LP
302 *
303 * @note this method currently returns the value from the floating-point LP
304 */
305SCIP_EXPORT
307 SCIP* scip, /**< SCIP data structure */
308 SCIP_CONS* cons, /**< constraint data */
309 SCIP_RATIONAL* ret /**< pointer to store the result */
310 );
311
312/** returns the linear relaxation of the given linear constraint; may return NULL if no LP row was yet created;
313 * the user must not modify the row!
314 */
315SCIP_EXPORT
317 SCIP* scip, /**< SCIP data structure */
318 SCIP_CONS* cons /**< constraint data */
319 );
320
321/** returns the exact linear relaxation of the given linear constraint; may return NULL if no LP row was yet created;
322 * the user must not modify the row!
323 */
324SCIP_EXPORT
326 SCIP* scip, /**< SCIP data structure */
327 SCIP_CONS* cons /**< constraint data */
328 );
329
330/** prints the certificate for a given original exact linear constraint */
331SCIP_EXPORT
333 SCIP* scip,
334 SCIP_CONSHDLR* conshdlr,
335 SCIP_CONS* cons
336 );
337
338/** @} */
339/** @} */
340
341#ifdef __cplusplus
342}
343#endif
344
345#endif
common defines and data types used in all packages of SCIP
#define SCIP_Bool
Definition: def.h:91
#define SCIP_Real
Definition: def.h:156
SCIP_RETCODE SCIPchgLhsExactLinear(SCIP *scip, SCIP_CONS *cons, SCIP_RATIONAL *lhs)
SCIP_RATIONAL * SCIPgetLhsExactLinear(SCIP *scip, SCIP_CONS *cons)
void SCIPgetFpDualsolExactLinear(SCIP *scip, SCIP_CONS *cons, SCIP_RATIONAL *ret)
SCIP_RATIONAL * SCIPgetRhsExactLinear(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE SCIPchgRhsExactLinear(SCIP *scip, SCIP_CONS *cons, SCIP_RATIONAL *rhs)
SCIP_RETCODE SCIPcreateConsExactLinear(SCIP *scip, SCIP_CONS **cons, const char *name, int nvars, SCIP_VAR **vars, SCIP_RATIONAL **vals, SCIP_RATIONAL *lhs, SCIP_RATIONAL *rhs, 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)
SCIP_VAR ** SCIPgetVarsExactLinear(SCIP *scip, SCIP_CONS *cons)
void SCIPgetFpDualfarkasExactLinear(SCIP *scip, SCIP_CONS *cons, SCIP_RATIONAL *ret)
SCIP_RETCODE SCIPcopyConsExactLinear(SCIP *scip, SCIP_CONS **cons, SCIP *sourcescip, const char *name, int nvars, SCIP_VAR **sourcevars, SCIP_INTERVAL *sourcecoefs, SCIP_Real lhs, SCIP_Real rhs, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, 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, SCIP_Bool global, SCIP_Bool *valid)
int SCIPgetNVarsExactLinear(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE SCIPaddCoefExactLinear(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_RATIONAL *val)
SCIP_RETCODE SCIPcertifyConsOrigExactLinear(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_CONS *cons)
SCIP_RETCODE SCIPgetActivityExactLinear(SCIP *scip, SCIP_CONS *cons, SCIP_SOL *sol, SCIP_RATIONAL *ret)
SCIP_RETCODE SCIPcreateConsBasicExactLinear(SCIP *scip, SCIP_CONS **cons, const char *name, int nvars, SCIP_VAR **vars, SCIP_RATIONAL **vals, SCIP_RATIONAL *lhs, SCIP_RATIONAL *rhs)
SCIP_ROWEXACT * SCIPgetRowExactExactLinear(SCIP *scip, SCIP_CONS *cons)
SCIP_INTERVAL * SCIPgetValsRealExactLinear(SCIP *scip, SCIP_CONS *cons)
SCIP_RATIONAL ** SCIPgetValsExactLinear(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE SCIPdelCoefExactLinear(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var)
SCIP_ROW * SCIPgetRowExactLinear(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE SCIPgetFeasibilityExactLinear(SCIP *scip, SCIP_CONS *cons, SCIP_SOL *sol, SCIP_RATIONAL *ret)
SCIP_RETCODE SCIPchgCoefExactLinear(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_RATIONAL *val)
SCIP_RETCODE SCIPincludeConshdlrExactLinear(SCIP *scip)
interval arithmetics for provable bounds
static SCIP_RETCODE separate(SCIP *scip, SCIP_SEPA *sepa, SCIP_SOL *sol, SCIP_RESULT *result)
Main separation function.
Definition: sepa_flower.c:1221
type definitions for certificate output
type definitions for constraints and constraint handlers
type definitions for LP management
type definitions for exact LP management
type definitions for miscellaneous datastructures
type definitions for rational numbers
type definitions for return codes for SCIP methods
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:63
type definitions for SCIP's main datastructure
type definitions for storing primal CIP solutions
type definitions for problem variables