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-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 pub_matrix.h
17  * @ingroup PUBLICCOREAPI
18  * @brief public methods for matrix
19  * @author Dieter Weninger
20  */
21 
22 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
23 
24 #ifndef __SCIP_PUB_MATRIX_H__
25 #define __SCIP_PUB_MATRIX_H__
26 
27 #include "scip/def.h"
28 #include "scip/type_var.h"
29 #include "scip/type_cons.h"
30 #include "scip/type_matrix.h"
31 
32 #ifdef NDEBUG
33 #include "scip/struct_matrix.h"
34 #endif
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 /*
41  * methods for matrix access
42  */
43 
44 /** get column based start pointer of values */
47  SCIP_MATRIX* matrix, /**< matrix instance */
48  int col /**< column index */
49  );
50 
51 /** get column based start pointer of row indices */
54  SCIP_MATRIX* matrix, /**< matrix instance */
55  int col /**< column index */
56  );
57 
58 /** get the number of non-zero entries of this column */
61  SCIP_MATRIX* matrix, /**< matrix instance */
62  int col /**< column index */
63  );
64 
65 /** get number of columns of the matrix */
68  SCIP_MATRIX* matrix /**< matrix instance */
69  );
70 
71 /** get upper bound of column */
74  SCIP_MATRIX* matrix, /**< matrix instance */
75  int col /**< column index */
76  );
77 
78 /** get lower bound of column */
81  SCIP_MATRIX* matrix, /**< matrix instance */
82  int col /**< column index */
83  );
84 
85 /** get number of uplocks of column */
88  SCIP_MATRIX* matrix, /**< matrix instance */
89  int col /**< column index */
90  );
91 
92 /** get number of downlocks of column */
95  SCIP_MATRIX* matrix, /**< matrix instance */
96  int col /**< column index */
97  );
98 
99 /** get variable pointer of column */
102  SCIP_MATRIX* matrix, /**< matrix instance */
103  int col /**< column index */
104  );
105 
106 /** get name of column/variable */
108 const char* SCIPmatrixGetColName(
109  SCIP_MATRIX* matrix, /**< matrix instance */
110  int col /**< column index */
111  );
112 
113 /** get row based start pointer of values */
116  SCIP_MATRIX* matrix, /**< matrix instance */
117  int row /**< row index */
118  );
119 
120 /** get row based start pointer of column indices */
123  SCIP_MATRIX* matrix, /**< matrix instance */
124  int row /**< row index */
125  );
126 
127 /** get number of non-zeros of this row */
130  SCIP_MATRIX* matrix, /**< matrix instance */
131  int row /**< row index */
132  );
133 
134 /** get name of row */
136 const char* SCIPmatrixGetRowName(
137  SCIP_MATRIX* matrix, /**< matrix instance */
138  int row /**< row index */
139  );
140 
141 /** get number of rows of the matrix */
144  SCIP_MATRIX* matrix /**< matrix instance */
145  );
146 
147 /** get left-hand-side of row */
150  SCIP_MATRIX* matrix, /**< matrix instace */
151  int row /**< row index */
152  );
153 
154 /** get right-hand-side of row */
157  SCIP_MATRIX* matrix, /**< matrix instance */
158  int row /**< row index */
159  );
160 
161 /** flag indicating if right-hand-side of row is infinity */
164  SCIP_MATRIX* matrix, /**< matrix instance */
165  int row /**< row index */
166  );
167 
168 /** get number of non-zeros of matrix */
171  SCIP_MATRIX* matrix /**< matrix instance */
172  );
173 
174 /** get minimal activity of row */
177  SCIP_MATRIX* matrix, /**< matrix instance */
178  int row /**< row index */
179  );
180 
181 /** get maximal activity of row */
184  SCIP_MATRIX* matrix, /**< matrix instance */
185  int row /**< row index */
186  );
187 
188 /** get number of negative infinities present within minimal activity */
191  SCIP_MATRIX* matrix, /**< matrix instance */
192  int row /**< row index */
193  );
194 
195 /** get number of positive infinities present within minimal activity */
198  SCIP_MATRIX* matrix, /**< matrix instance */
199  int row /**< row index */
200  );
201 
202 /** get number of negative infinities present within maximal activity */
205  SCIP_MATRIX* matrix, /**< matrix instance */
206  int row /**< row index */
207  );
208 
209 /** get number of positive infinities present within maximal activity */
212  SCIP_MATRIX* matrix, /**< matrix instance */
213  int row /**< row index */
214  );
215 
216 /** get constraint pointer for constraint representing row */
219  SCIP_MATRIX* matrix, /**< matrix instance */
220  int row /**< row index */
221  );
222 
223 /** get if conflicting uplocks of variable present */
226  SCIP_MATRIX* matrix, /**< matrix instance */
227  int col /**< column index */
228  );
229 
230 /** get if conflicting downlocks of variable present */
233  SCIP_MATRIX* matrix, /**< matrix instance */
234  int col /**< column index */
235  );
236 
237 
238 #ifdef NDEBUG
239 
240 /* In optimized mode, the function calls are overwritten by defines to reduce the number of function calls and
241  * speed up the algorithms.
242  */
243 
244 #define SCIPmatrixGetColValPtr(matrix,col) (matrix->colmatval + matrix->colmatbeg[col])
245 #define SCIPmatrixGetColIdxPtr(matrix,col) (matrix->colmatind + matrix->colmatbeg[col])
246 #define SCIPmatrixGetColNNonzs(matrix,col) (matrix->colmatcnt[col])
247 #define SCIPmatrixGetNColumns(matrix) (matrix->ncols)
248 #define SCIPmatrixGetColUb(matrix,col) (matrix->ub[col])
249 #define SCIPmatrixGetColLb(matrix,col) (matrix->lb[col])
250 #define SCIPmatrixGetColNUplocks(matrix,col) (matrix->nuplocks[col])
251 #define SCIPmatrixGetColNDownlocks(matrix,col) (matrix->ndownlocks[col])
252 #define SCIPmatrixGetVar(matrix,col) (matrix->vars[col])
253 #define SCIPmatrixGetColName(matrix,col) (SCIPvarGetName(matrix->vars[col]))
254 #define SCIPmatrixGetRowValPtr(matrix,row) (matrix->rowmatval + matrix->rowmatbeg[row])
255 #define SCIPmatrixGetRowIdxPtr(matrix,row) (matrix->rowmatind + matrix->rowmatbeg[row])
256 #define SCIPmatrixGetRowNNonzs(matrix,row) (matrix->rowmatcnt[row])
257 #define SCIPmatrixGetRowName(matrix,row) (SCIPconsGetName(matrix->cons[row]))
258 #define SCIPmatrixGetNRows(matrix) (matrix->nrows)
259 #define SCIPmatrixGetRowLhs(matrix,row) (matrix->lhs[row])
260 #define SCIPmatrixGetRowRhs(matrix,row) (matrix->rhs[row])
261 #define SCIPmatrixIsRowRhsInfinity(matrix,row) (matrix->isrhsinfinite[row])
262 #define SCIPmatrixGetNNonzs(matrix) (matrix->nnonzs)
263 #define SCIPmatrixGetRowMinActivity(matrix,row) (matrix->minactivity[row])
264 #define SCIPmatrixGetRowMaxActivity(matrix,row) (matrix->maxactivity[row])
265 #define SCIPmatrixGetRowNMinActNegInf(matrix,row) (matrix->minactivityneginf[row])
266 #define SCIPmatrixGetRowNMinActPosInf(matrix,row) (matrix->minactivityposinf[row])
267 #define SCIPmatrixGetRowNMaxActNegInf(matrix,row) (matrix->maxactivityneginf[row])
268 #define SCIPmatrixGetRowNMaxActPosInf(matrix,row) (matrix->maxactivityposinf[row])
269 #define SCIPmatrixGetCons(matrix,row) (matrix->cons[row])
270 
271 #endif
272 
273 /** initialize matrix by copying all check constraints
274  *
275  * @note Completeness is checked by testing whether all check constraints are from a list of linear constraint handlers
276  * that can be represented.
277  */
280  SCIP* scip, /**< current scip instance */
281  SCIP_MATRIX** matrixptr, /**< pointer to constraint matrix object to be initialized */
282  SCIP_Bool onlyifcomplete, /**< should matrix creation be skipped if matrix will not be complete? */
283  SCIP_Bool* initialized, /**< was the initialization successful? */
284  SCIP_Bool* complete, /**< are all constraint represented within the matrix? */
285  SCIP_Bool* infeasible, /**< pointer to return whether problem was detected to be infeasible during matrix creation */
286  int* naddconss, /**< pointer to count number of added (linear) constraints during matrix creation */
287  int* ndelconss, /**< pointer to count number of deleted specialized linear constraints during matrix creation */
288  int* nchgcoefs, /**< pointer to count number of changed coefficients during matrix creation */
289  int* nchgbds, /**< pointer to count number of changed bounds during matrix creation */
290  int* nfixedvars /**< pointer to count number of fixed variables during matrix creation */
291  );
292 
293 /** frees the constraint matrix */
295 void SCIPmatrixFree(
296  SCIP* scip, /**< current SCIP instance */
297  SCIP_MATRIX** matrix /**< constraint matrix object */
298  );
299 
300 /** print one row of the MIP matrix */
302 void SCIPmatrixPrintRow(
303  SCIP* scip, /**< current SCIP instance */
304  SCIP_MATRIX* matrix, /**< constraint matrix object */
305  int row /**< row index */
306  );
307 
308 /** detect parallel rows, rhs/lhs are ignored */
311  SCIP* scip, /**< current SCIP instance */
312  SCIP_MATRIX* matrix, /**< matrix containing the constraints */
313  SCIP_Real* scale, /**< scale factors of rows */
314  int* pclass /**< parallel row classes */
315  );
316 
317 /** removes the bounds of a column and updates the activities accordingly */
320  SCIP* scip, /**< current scip instance */
321  SCIP_MATRIX* matrix, /**< constraint matrix */
322  int col /**< column variable to remove bounds from */
323  );
324 
325 /** detect parallel columns, obj ignored */
328  SCIP* scip, /**< current SCIP instance */
329  SCIP_MATRIX* matrix, /**< matrix containing the constraints */
330  SCIP_Real* scale, /**< scale factors of cols */
331  int* pclass, /**< parallel column classes */
332  SCIP_Bool* varineq /**< indicating if variable is within an equation */
333  );
334 
335 
336 #ifdef __cplusplus
337 }
338 #endif
339 
340 #endif
SCIP_EXPORT SCIP_Real SCIPmatrixGetRowRhs(SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1714
SCIP_EXPORT SCIP_Real SCIPmatrixGetRowMinActivity(SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1748
SCIP_EXPORT SCIP_Real SCIPmatrixGetColLb(SCIP_MATRIX *matrix, int col)
Definition: matrix.c:1585
SCIP_EXPORT int SCIPmatrixGetRowNMaxActPosInf(SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1808
#define SCIP_EXPORT
Definition: def.h:100
SCIP_EXPORT SCIP_RETCODE SCIPmatrixGetParallelRows(SCIP *scip, SCIP_MATRIX *matrix, SCIP_Real *scale, int *pclass)
Definition: matrix.c:1174
SCIP_EXPORT const char * SCIPmatrixGetRowName(SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1680
SCIP_EXPORT void SCIPmatrixPrintRow(SCIP *scip, SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1095
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:54
type definitions for MIP matrix
SCIP_EXPORT int SCIPmatrixGetColNNonzs(SCIP_MATRIX *matrix, int col)
Definition: matrix.c:1552
SCIP_EXPORT SCIP_Real SCIPmatrixGetRowMaxActivity(SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1760
SCIP_EXPORT int SCIPmatrixGetNRows(SCIP_MATRIX *matrix)
Definition: matrix.c:1692
SCIP_EXPORT const char * SCIPmatrixGetColName(SCIP_MATRIX *matrix, int col)
Definition: matrix.c:1632
SCIP_EXPORT int SCIPmatrixGetRowNMaxActNegInf(SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1796
SCIP_EXPORT SCIP_Bool SCIPmatrixIsRowRhsInfinity(SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1726
SCIP_EXPORT void SCIPmatrixRemoveColumnBounds(SCIP *scip, SCIP_MATRIX *matrix, int col)
Definition: matrix.c:1129
SCIP_EXPORT int SCIPmatrixGetColNDownlocks(SCIP_MATRIX *matrix, int col)
Definition: matrix.c:1608
type definitions for problem variables
SCIP_EXPORT int * SCIPmatrixGetRowIdxPtr(SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1656
SCIP_EXPORT SCIP_Real SCIPmatrixGetRowLhs(SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1702
#define SCIP_Bool
Definition: def.h:70
SCIP_EXPORT int SCIPmatrixGetRowNMinActPosInf(SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1784
SCIP_EXPORT SCIP_Bool SCIPmatrixUplockConflict(SCIP_MATRIX *matrix, int col)
Definition: matrix.c:1832
SCIP_EXPORT SCIP_Real SCIPmatrixGetColUb(SCIP_MATRIX *matrix, int col)
Definition: matrix.c:1574
SCIP_EXPORT SCIP_Real * SCIPmatrixGetRowValPtr(SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1644
data structure for MIP matrix
SCIP_EXPORT int SCIPmatrixGetNColumns(SCIP_MATRIX *matrix)
Definition: matrix.c:1564
SCIP_EXPORT 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:445
SCIP_EXPORT int * SCIPmatrixGetColIdxPtr(SCIP_MATRIX *matrix, int col)
Definition: matrix.c:1540
SCIP_EXPORT SCIP_Bool SCIPmatrixDownlockConflict(SCIP_MATRIX *matrix, int col)
Definition: matrix.c:1844
SCIP_EXPORT void SCIPmatrixFree(SCIP *scip, SCIP_MATRIX **matrix)
Definition: matrix.c:1032
SCIP_EXPORT int SCIPmatrixGetNNonzs(SCIP_MATRIX *matrix)
Definition: matrix.c:1738
SCIP_EXPORT int SCIPmatrixGetRowNNonzs(SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1668
#define SCIP_Real
Definition: def.h:163
SCIP_EXPORT int SCIPmatrixGetRowNMinActNegInf(SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1772
common defines and data types used in all packages of SCIP
SCIP_EXPORT SCIP_Real * SCIPmatrixGetColValPtr(SCIP_MATRIX *matrix, int col)
Definition: matrix.c:1528
SCIP_EXPORT SCIP_CONS * SCIPmatrixGetCons(SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1820
SCIP_EXPORT SCIP_RETCODE SCIPmatrixGetParallelCols(SCIP *scip, SCIP_MATRIX *matrix, SCIP_Real *scale, int *pclass, SCIP_Bool *varineq)
Definition: matrix.c:1330
SCIP_EXPORT int SCIPmatrixGetColNUplocks(SCIP_MATRIX *matrix, int col)
Definition: matrix.c:1596
SCIP_EXPORT SCIP_VAR * SCIPmatrixGetVar(SCIP_MATRIX *matrix, int col)
Definition: matrix.c:1620
type definitions for constraints and constraint handlers