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-2019 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 scip.zib.de. */
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 #define SCIPmatrixUplockConflict(matrix,col) (SCIPvarGetNLocksUp(matrix->vars[col]) == matrix->nuplocks[col] ? FALSE : TRUE)
271 #define SCIPmatrixDownlockConflict(matrix,col) (SCIPvarGetNLocksDown(matrix->vars[col]) == matrix->ndownlocks[col] ? FALSE : TRUE)
272 
273 #endif
274 
275 /** initialize matrix */
278  SCIP* scip, /**< current scip instance */
279  SCIP_MATRIX** matrixptr, /**< pointer to constraint matrix object to be initialized */
280  SCIP_Bool* initialized, /**< was the initialization successful? */
281  SCIP_Bool* complete /**< are all constraint represented within the matrix? */
282  );
283 
284 /** frees the constraint matrix */
286 void SCIPmatrixFree(
287  SCIP* scip, /**< current SCIP instance */
288  SCIP_MATRIX** matrix /**< constraint matrix object */
289  );
290 
291 /** print one row of the MIP matrix */
293 void SCIPmatrixPrintRow(
294  SCIP* scip, /**< current SCIP instance */
295  SCIP_MATRIX* matrix, /**< constraint matrix object */
296  int row /**< row index */
297  );
298 
299 /** detect parallel rows, rhs/lhs are ignored */
302  SCIP* scip, /**< current SCIP instance */
303  SCIP_MATRIX* matrix, /**< matrix containing the constraints */
304  SCIP_Real* scale, /**< scale factors of rows */
305  int* pclass /**< parallel row classes */
306  );
307 
308 /** detect parallel rows, obj ignored */
311  SCIP* scip, /**< current SCIP instance */
312  SCIP_MATRIX* matrix, /**< matrix containing the constraints */
313  SCIP_Real* scale, /**< scale factors of cols */
314  int* pclass, /**< parallel column classes */
315  SCIP_Bool* varineq /**< indicating if variable is within an equation */
316  );
317 
318 
319 #ifdef __cplusplus
320 }
321 #endif
322 
323 #endif
SCIP_EXPORT SCIP_Real SCIPmatrixGetRowRhs(SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1501
SCIP_EXPORT SCIP_Real SCIPmatrixGetRowMinActivity(SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1535
SCIP_EXPORT SCIP_Real SCIPmatrixGetColLb(SCIP_MATRIX *matrix, int col)
Definition: matrix.c:1372
SCIP_EXPORT int SCIPmatrixGetRowNMaxActPosInf(SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1595
#define SCIP_EXPORT
Definition: def.h:98
SCIP_EXPORT SCIP_RETCODE SCIPmatrixGetParallelRows(SCIP *scip, SCIP_MATRIX *matrix, SCIP_Real *scale, int *pclass)
Definition: matrix.c:959
SCIP_EXPORT const char * SCIPmatrixGetRowName(SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1467
SCIP_EXPORT void SCIPmatrixPrintRow(SCIP *scip, SCIP_MATRIX *matrix, int row)
Definition: matrix.c:927
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
type definitions for MIP matrix
SCIP_EXPORT int SCIPmatrixGetColNNonzs(SCIP_MATRIX *matrix, int col)
Definition: matrix.c:1339
SCIP_EXPORT SCIP_Real SCIPmatrixGetRowMaxActivity(SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1547
SCIP_EXPORT int SCIPmatrixGetNRows(SCIP_MATRIX *matrix)
Definition: matrix.c:1479
SCIP_EXPORT const char * SCIPmatrixGetColName(SCIP_MATRIX *matrix, int col)
Definition: matrix.c:1419
SCIP_EXPORT int SCIPmatrixGetRowNMaxActNegInf(SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1583
SCIP_EXPORT SCIP_Bool SCIPmatrixIsRowRhsInfinity(SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1513
SCIP_EXPORT int SCIPmatrixGetColNDownlocks(SCIP_MATRIX *matrix, int col)
Definition: matrix.c:1395
type definitions for problem variables
SCIP_EXPORT int * SCIPmatrixGetRowIdxPtr(SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1443
SCIP_EXPORT SCIP_Real SCIPmatrixGetRowLhs(SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1489
#define SCIP_Bool
Definition: def.h:70
SCIP_EXPORT int SCIPmatrixGetRowNMinActPosInf(SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1571
SCIP_EXPORT SCIP_Bool SCIPmatrixUplockConflict(SCIP_MATRIX *matrix, int col)
Definition: matrix.c:1619
SCIP_EXPORT SCIP_Real SCIPmatrixGetColUb(SCIP_MATRIX *matrix, int col)
Definition: matrix.c:1361
SCIP_EXPORT SCIP_Real * SCIPmatrixGetRowValPtr(SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1431
data structure for MIP matrix
SCIP_EXPORT int SCIPmatrixGetNColumns(SCIP_MATRIX *matrix)
Definition: matrix.c:1351
SCIP_EXPORT int * SCIPmatrixGetColIdxPtr(SCIP_MATRIX *matrix, int col)
Definition: matrix.c:1327
SCIP_EXPORT SCIP_Bool SCIPmatrixDownlockConflict(SCIP_MATRIX *matrix, int col)
Definition: matrix.c:1631
SCIP_EXPORT void SCIPmatrixFree(SCIP *scip, SCIP_MATRIX **matrix)
Definition: matrix.c:864
SCIP_EXPORT int SCIPmatrixGetNNonzs(SCIP_MATRIX *matrix)
Definition: matrix.c:1525
SCIP_EXPORT int SCIPmatrixGetRowNNonzs(SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1455
#define SCIP_Real
Definition: def.h:164
SCIP_EXPORT SCIP_RETCODE SCIPmatrixCreate(SCIP *scip, SCIP_MATRIX **matrixptr, SCIP_Bool *initialized, SCIP_Bool *complete)
Definition: matrix.c:437
SCIP_EXPORT int SCIPmatrixGetRowNMinActNegInf(SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1559
common defines and data types used in all packages of SCIP
SCIP_EXPORT SCIP_Real * SCIPmatrixGetColValPtr(SCIP_MATRIX *matrix, int col)
Definition: matrix.c:1315
SCIP_EXPORT SCIP_CONS * SCIPmatrixGetCons(SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1607
SCIP_EXPORT SCIP_RETCODE SCIPmatrixGetParallelCols(SCIP *scip, SCIP_MATRIX *matrix, SCIP_Real *scale, int *pclass, SCIP_Bool *varineq)
Definition: matrix.c:1115
SCIP_EXPORT int SCIPmatrixGetColNUplocks(SCIP_MATRIX *matrix, int col)
Definition: matrix.c:1383
SCIP_EXPORT SCIP_VAR * SCIPmatrixGetVar(SCIP_MATRIX *matrix, int col)
Definition: matrix.c:1407
type definitions for constraints and constraint handlers