Scippy

SCIP

Solving Constraint Integer Programs

pub_matrix.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-2024 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 pub_matrix.h
26 * @ingroup PUBLICCOREAPI
27 * @brief public methods for matrix
28 * @author Dieter Weninger
29 */
30
31/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
32
33#ifndef __SCIP_PUB_MATRIX_H__
34#define __SCIP_PUB_MATRIX_H__
35
36#include "scip/def.h"
37#include "scip/type_var.h"
38#include "scip/type_cons.h"
39#include "scip/type_matrix.h"
40
41#ifdef NDEBUG
42#include "scip/struct_matrix.h"
43#endif
44
45#ifdef __cplusplus
46extern "C" {
47#endif
48
49/*
50 * methods for matrix access
51 */
52
53/** get column based start pointer of values */
54SCIP_EXPORT
56 SCIP_MATRIX* matrix, /**< matrix instance */
57 int col /**< column index */
58 );
59
60/** get column based start pointer of row indices */
61SCIP_EXPORT
63 SCIP_MATRIX* matrix, /**< matrix instance */
64 int col /**< column index */
65 );
66
67/** get the number of non-zero entries of this column */
68SCIP_EXPORT
70 SCIP_MATRIX* matrix, /**< matrix instance */
71 int col /**< column index */
72 );
73
74/** get number of columns of the matrix */
75SCIP_EXPORT
77 SCIP_MATRIX* matrix /**< matrix instance */
78 );
79
80/** get upper bound of column */
81SCIP_EXPORT
83 SCIP_MATRIX* matrix, /**< matrix instance */
84 int col /**< column index */
85 );
86
87/** get lower bound of column */
88SCIP_EXPORT
90 SCIP_MATRIX* matrix, /**< matrix instance */
91 int col /**< column index */
92 );
93
94/** get number of uplocks of column */
95SCIP_EXPORT
97 SCIP_MATRIX* matrix, /**< matrix instance */
98 int col /**< column index */
99 );
100
101/** get number of downlocks of column */
102SCIP_EXPORT
104 SCIP_MATRIX* matrix, /**< matrix instance */
105 int col /**< column index */
106 );
107
108/** get variable pointer of column */
109SCIP_EXPORT
111 SCIP_MATRIX* matrix, /**< matrix instance */
112 int col /**< column index */
113 );
114
115/** get name of column/variable */
116SCIP_EXPORT
117const char* SCIPmatrixGetColName(
118 SCIP_MATRIX* matrix, /**< matrix instance */
119 int col /**< column index */
120 );
121
122/** get row based start pointer of values */
123SCIP_EXPORT
125 SCIP_MATRIX* matrix, /**< matrix instance */
126 int row /**< row index */
127 );
128
129/** get row based start pointer of column indices */
130SCIP_EXPORT
132 SCIP_MATRIX* matrix, /**< matrix instance */
133 int row /**< row index */
134 );
135
136/** get number of non-zeros of this row */
137SCIP_EXPORT
139 SCIP_MATRIX* matrix, /**< matrix instance */
140 int row /**< row index */
141 );
142
143/** get name of row */
144SCIP_EXPORT
145const char* SCIPmatrixGetRowName(
146 SCIP_MATRIX* matrix, /**< matrix instance */
147 int row /**< row index */
148 );
149
150/** get number of rows of the matrix */
151SCIP_EXPORT
153 SCIP_MATRIX* matrix /**< matrix instance */
154 );
155
156/** get left-hand-side of row */
157SCIP_EXPORT
159 SCIP_MATRIX* matrix, /**< matrix instace */
160 int row /**< row index */
161 );
162
163/** get right-hand-side of row */
164SCIP_EXPORT
166 SCIP_MATRIX* matrix, /**< matrix instance */
167 int row /**< row index */
168 );
169
170/** flag indicating if right-hand-side of row is infinity */
171SCIP_EXPORT
173 SCIP_MATRIX* matrix, /**< matrix instance */
174 int row /**< row index */
175 );
176
177/** get number of non-zeros of matrix */
178SCIP_EXPORT
180 SCIP_MATRIX* matrix /**< matrix instance */
181 );
182
183/** get minimal activity of row */
184SCIP_EXPORT
186 SCIP_MATRIX* matrix, /**< matrix instance */
187 int row /**< row index */
188 );
189
190/** get maximal activity of row */
191SCIP_EXPORT
193 SCIP_MATRIX* matrix, /**< matrix instance */
194 int row /**< row index */
195 );
196
197/** get number of negative infinities present within minimal activity */
198SCIP_EXPORT
200 SCIP_MATRIX* matrix, /**< matrix instance */
201 int row /**< row index */
202 );
203
204/** get number of positive infinities present within minimal activity */
205SCIP_EXPORT
207 SCIP_MATRIX* matrix, /**< matrix instance */
208 int row /**< row index */
209 );
210
211/** get number of negative infinities present within maximal activity */
212SCIP_EXPORT
214 SCIP_MATRIX* matrix, /**< matrix instance */
215 int row /**< row index */
216 );
217
218/** get number of positive infinities present within maximal activity */
219SCIP_EXPORT
221 SCIP_MATRIX* matrix, /**< matrix instance */
222 int row /**< row index */
223 );
224
225/** get constraint pointer for constraint representing row */
226SCIP_EXPORT
228 SCIP_MATRIX* matrix, /**< matrix instance */
229 int row /**< row index */
230 );
231
232/** get if conflicting uplocks of variable present */
233SCIP_EXPORT
235 SCIP_MATRIX* matrix, /**< matrix instance */
236 int col /**< column index */
237 );
238
239/** get if conflicting downlocks of variable present */
240SCIP_EXPORT
242 SCIP_MATRIX* matrix, /**< matrix instance */
243 int col /**< column index */
244 );
245
246
247#ifdef NDEBUG
248
249/* In optimized mode, the function calls are overwritten by defines to reduce the number of function calls and
250 * speed up the algorithms.
251 */
252
253#define SCIPmatrixGetColValPtr(matrix,col) (matrix->colmatval + matrix->colmatbeg[col])
254#define SCIPmatrixGetColIdxPtr(matrix,col) (matrix->colmatind + matrix->colmatbeg[col])
255#define SCIPmatrixGetColNNonzs(matrix,col) (matrix->colmatcnt[col])
256#define SCIPmatrixGetNColumns(matrix) (matrix->ncols)
257#define SCIPmatrixGetColUb(matrix,col) (matrix->ub[col])
258#define SCIPmatrixGetColLb(matrix,col) (matrix->lb[col])
259#define SCIPmatrixGetColNUplocks(matrix,col) (matrix->nuplocks[col])
260#define SCIPmatrixGetColNDownlocks(matrix,col) (matrix->ndownlocks[col])
261#define SCIPmatrixGetVar(matrix,col) (matrix->vars[col])
262#define SCIPmatrixGetColName(matrix,col) (SCIPvarGetName(matrix->vars[col]))
263#define SCIPmatrixGetRowValPtr(matrix,row) (matrix->rowmatval + matrix->rowmatbeg[row])
264#define SCIPmatrixGetRowIdxPtr(matrix,row) (matrix->rowmatind + matrix->rowmatbeg[row])
265#define SCIPmatrixGetRowNNonzs(matrix,row) (matrix->rowmatcnt[row])
266#define SCIPmatrixGetRowName(matrix,row) (SCIPconsGetName(matrix->cons[row]))
267#define SCIPmatrixGetNRows(matrix) (matrix->nrows)
268#define SCIPmatrixGetRowLhs(matrix,row) (matrix->lhs[row])
269#define SCIPmatrixGetRowRhs(matrix,row) (matrix->rhs[row])
270#define SCIPmatrixIsRowRhsInfinity(matrix,row) (matrix->isrhsinfinite[row])
271#define SCIPmatrixGetNNonzs(matrix) (matrix->nnonzs)
272#define SCIPmatrixGetRowMinActivity(matrix,row) (matrix->minactivity[row])
273#define SCIPmatrixGetRowMaxActivity(matrix,row) (matrix->maxactivity[row])
274#define SCIPmatrixGetRowNMinActNegInf(matrix,row) (matrix->minactivityneginf[row])
275#define SCIPmatrixGetRowNMinActPosInf(matrix,row) (matrix->minactivityposinf[row])
276#define SCIPmatrixGetRowNMaxActNegInf(matrix,row) (matrix->maxactivityneginf[row])
277#define SCIPmatrixGetRowNMaxActPosInf(matrix,row) (matrix->maxactivityposinf[row])
278#define SCIPmatrixGetCons(matrix,row) (matrix->cons[row])
279
280#endif
281
282/** initialize matrix by copying all check constraints
283 *
284 * @note Completeness is checked by testing whether all check constraints are from a list of linear constraint handlers
285 * that can be represented.
286 */
287SCIP_EXPORT
289 SCIP* scip, /**< current scip instance */
290 SCIP_MATRIX** matrixptr, /**< pointer to constraint matrix object to be initialized */
291 SCIP_Bool onlyifcomplete, /**< should matrix creation be skipped if matrix will not be complete? */
292 SCIP_Bool* initialized, /**< was the initialization successful? */
293 SCIP_Bool* complete, /**< are all constraint represented within the matrix? */
294 SCIP_Bool* infeasible, /**< pointer to return whether problem was detected to be infeasible during matrix creation */
295 int* naddconss, /**< pointer to count number of added (linear) constraints during matrix creation */
296 int* ndelconss, /**< pointer to count number of deleted specialized linear constraints during matrix creation */
297 int* nchgcoefs, /**< pointer to count number of changed coefficients during matrix creation */
298 int* nchgbds, /**< pointer to count number of changed bounds during matrix creation */
299 int* nfixedvars /**< pointer to count number of fixed variables during matrix creation */
300 );
301
302/** frees the constraint matrix */
303SCIP_EXPORT
304void SCIPmatrixFree(
305 SCIP* scip, /**< current SCIP instance */
306 SCIP_MATRIX** matrix /**< constraint matrix object */
307 );
308
309/** print one row of the MIP matrix */
310SCIP_EXPORT
312 SCIP* scip, /**< current SCIP instance */
313 SCIP_MATRIX* matrix, /**< constraint matrix object */
314 int row /**< row index */
315 );
316
317/** detect parallel rows, rhs/lhs are ignored */
318SCIP_EXPORT
320 SCIP* scip, /**< current SCIP instance */
321 SCIP_MATRIX* matrix, /**< matrix containing the constraints */
322 SCIP_Real* scale, /**< scale factors of rows */
323 int* pclass /**< parallel row classes */
324 );
325
326/** removes the bounds of a column and updates the activities accordingly */
327SCIP_EXPORT
329 SCIP* scip, /**< current scip instance */
330 SCIP_MATRIX* matrix, /**< constraint matrix */
331 int col /**< column variable to remove bounds from */
332 );
333
334/** detect parallel columns, obj ignored */
335SCIP_EXPORT
337 SCIP* scip, /**< current SCIP instance */
338 SCIP_MATRIX* matrix, /**< matrix containing the constraints */
339 SCIP_Real* scale, /**< scale factors of cols */
340 int* pclass, /**< parallel column classes */
341 SCIP_Bool* varineq /**< indicating if variable is within an equation */
342 );
343
344
345#ifdef __cplusplus
346}
347#endif
348
349#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:173
SCIP_Bool SCIPmatrixUplockConflict(SCIP_MATRIX *matrix, int col)
Definition: matrix.c:1872
int SCIPmatrixGetRowNMinActNegInf(SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1812
int * SCIPmatrixGetColIdxPtr(SCIP_MATRIX *matrix, int col)
Definition: matrix.c:1580
int SCIPmatrixGetNNonzs(SCIP_MATRIX *matrix)
Definition: matrix.c:1778
int SCIPmatrixGetRowNNonzs(SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1708
const char * SCIPmatrixGetRowName(SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1720
int SCIPmatrixGetColNDownlocks(SCIP_MATRIX *matrix, int col)
Definition: matrix.c:1648
int SCIPmatrixGetColNNonzs(SCIP_MATRIX *matrix, int col)
Definition: matrix.c:1592
SCIP_Bool SCIPmatrixIsRowRhsInfinity(SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1766
int SCIPmatrixGetColNUplocks(SCIP_MATRIX *matrix, int col)
Definition: matrix.c:1636
SCIP_Real SCIPmatrixGetRowMaxActivity(SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1800
SCIP_Real SCIPmatrixGetColLb(SCIP_MATRIX *matrix, int col)
Definition: matrix.c:1625
SCIP_Real SCIPmatrixGetRowLhs(SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1742
const char * SCIPmatrixGetColName(SCIP_MATRIX *matrix, int col)
Definition: matrix.c:1672
SCIP_Real * SCIPmatrixGetRowValPtr(SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1684
SCIP_Bool SCIPmatrixDownlockConflict(SCIP_MATRIX *matrix, int col)
Definition: matrix.c:1884
SCIP_Real SCIPmatrixGetRowRhs(SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1754
SCIP_Real * SCIPmatrixGetColValPtr(SCIP_MATRIX *matrix, int col)
Definition: matrix.c:1568
int SCIPmatrixGetRowNMinActPosInf(SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1824
SCIP_RETCODE SCIPmatrixCreate(SCIP *scip, SCIP_MATRIX **matrixptr, SCIP_Bool onlyifcomplete, SCIP_Bool *initialized, SCIP_Bool *complete, SCIP_Bool *infeasible, int *naddconss, int *ndelconss, int *nchgcoefs, int *nchgbds, int *nfixedvars)
Definition: matrix.c:454
int SCIPmatrixGetNColumns(SCIP_MATRIX *matrix)
Definition: matrix.c:1604
SCIP_Real SCIPmatrixGetRowMinActivity(SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1788
SCIP_CONS * SCIPmatrixGetCons(SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1860
SCIP_RETCODE SCIPmatrixGetParallelRows(SCIP *scip, SCIP_MATRIX *matrix, SCIP_Real *scale, int *pclass)
Definition: matrix.c:1214
void SCIPmatrixFree(SCIP *scip, SCIP_MATRIX **matrix)
Definition: matrix.c:1072
int SCIPmatrixGetRowNMaxActPosInf(SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1848
int SCIPmatrixGetRowNMaxActNegInf(SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1836
SCIP_VAR * SCIPmatrixGetVar(SCIP_MATRIX *matrix, int col)
Definition: matrix.c:1660
int * SCIPmatrixGetRowIdxPtr(SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1696
void SCIPmatrixPrintRow(SCIP *scip, SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1135
SCIP_RETCODE SCIPmatrixGetParallelCols(SCIP *scip, SCIP_MATRIX *matrix, SCIP_Real *scale, int *pclass, SCIP_Bool *varineq)
Definition: matrix.c:1370
int SCIPmatrixGetNRows(SCIP_MATRIX *matrix)
Definition: matrix.c:1732
void SCIPmatrixRemoveColumnBounds(SCIP *scip, SCIP_MATRIX *matrix, int col)
Definition: matrix.c:1169
SCIP_Real SCIPmatrixGetColUb(SCIP_MATRIX *matrix, int col)
Definition: matrix.c:1614
data structure for MIP matrix
type definitions for constraints and constraint handlers
type definitions for MIP matrix
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:63
type definitions for problem variables