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-2018 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 email to 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 */
45 extern
47  SCIP_MATRIX* matrix, /**< matrix instance */
48  int col /**< column index */
49  );
50 
51 /** get column based start pointer of row indices */
52 extern
54  SCIP_MATRIX* matrix, /**< matrix instance */
55  int col /**< column index */
56  );
57 
58 /** get the number of non-zero entries of this column */
59 extern
61  SCIP_MATRIX* matrix, /**< matrix instance */
62  int col /**< column index */
63  );
64 
65 /** get number of columns of the matrix */
66 extern
68  SCIP_MATRIX* matrix /**< matrix instance */
69  );
70 
71 /** get upper bound of column */
72 extern
74  SCIP_MATRIX* matrix, /**< matrix instance */
75  int col /**< column index */
76  );
77 
78 /** get lower bound of column */
79 extern
81  SCIP_MATRIX* matrix, /**< matrix instance */
82  int col /**< column index */
83  );
84 
85 /** get number of uplocks of column */
86 extern
88  SCIP_MATRIX* matrix, /**< matrix instance */
89  int col /**< column index */
90  );
91 
92 /** get number of downlocks of column */
93 extern
95  SCIP_MATRIX* matrix, /**< matrix instance */
96  int col /**< column index */
97  );
98 
99 /** get variable pointer of column */
100 extern
102  SCIP_MATRIX* matrix, /**< matrix instance */
103  int col /**< column index */
104  );
105 
106 /** get name of column/variable */
107 extern
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 */
114 extern
116  SCIP_MATRIX* matrix, /**< matrix instance */
117  int row /**< row index */
118  );
119 
120 /** get row based start pointer of column indices */
121 extern
123  SCIP_MATRIX* matrix, /**< matrix instance */
124  int row /**< row index */
125  );
126 
127 /** get number of non-zeros of this row */
128 extern
130  SCIP_MATRIX* matrix, /**< matrix instance */
131  int row /**< row index */
132  );
133 
134 /** get name of row */
135 extern
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 */
142 extern
144  SCIP_MATRIX* matrix /**< matrix instance */
145  );
146 
147 /** get left-hand-side of row */
148 extern
150  SCIP_MATRIX* matrix, /**< matrix instace */
151  int row /**< row index */
152  );
153 
154 /** get right-hand-side of row */
155 extern
157  SCIP_MATRIX* matrix, /**< matrix instance */
158  int row /**< row index */
159  );
160 
161 /** flag indicating if right-hand-side of row is infinity */
162 extern
164  SCIP_MATRIX* matrix, /**< matrix instance */
165  int row /**< row index */
166  );
167 
168 /** get number of non-zeros of matrix */
169 extern
171  SCIP_MATRIX* matrix /**< matrix instance */
172  );
173 
174 /** get minimal activity of row */
175 extern
177  SCIP_MATRIX* matrix, /**< matrix instance */
178  int row /**< row index */
179  );
180 
181 /** get maximal activity of row */
182 extern
184  SCIP_MATRIX* matrix, /**< matrix instance */
185  int row /**< row index */
186  );
187 
188 /** get number of negative infinities present within minimal activity */
189 extern
191  SCIP_MATRIX* matrix, /**< matrix instance */
192  int row /**< row index */
193  );
194 
195 /** get number of positive infinities present within minimal activity */
196 extern
198  SCIP_MATRIX* matrix, /**< matrix instance */
199  int row /**< row index */
200  );
201 
202 /** get number of negative infinities present within maximal activity */
203 extern
205  SCIP_MATRIX* matrix, /**< matrix instance */
206  int row /**< row index */
207  );
208 
209 /** get number of positive infinities present within maximal activity */
210 extern
212  SCIP_MATRIX* matrix, /**< matrix instance */
213  int row /**< row index */
214  );
215 
216 /** get constraint pointer for constraint representing row */
217 extern
219  SCIP_MATRIX* matrix, /**< matrix instance */
220  int row /**< row index */
221  );
222 
223 /** get if conflicting uplocks of variable present */
224 extern
226  SCIP_MATRIX* matrix, /**< matrix instance */
227  int col /**< column index */
228  );
229 
230 /** get if conflicting downlocks of variable present */
231 extern
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 */
276 extern
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 */
285 extern
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 */
292 extern
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 */
300 extern
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 */
309 extern
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
int SCIPmatrixGetRowNMinActNegInf(SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1477
int * SCIPmatrixGetColIdxPtr(SCIP_MATRIX *matrix, int col)
Definition: matrix.c:1245
void SCIPmatrixPrintRow(SCIP *scip, SCIP_MATRIX *matrix, int row)
Definition: matrix.c:845
SCIP_Real * SCIPmatrixGetRowValPtr(SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1349
SCIP_Real SCIPmatrixGetRowMinActivity(SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1453
int SCIPmatrixGetRowNMaxActNegInf(SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1501
SCIP_RETCODE SCIPmatrixCreate(SCIP *scip, SCIP_MATRIX **matrixptr, SCIP_Bool *initialized, SCIP_Bool *complete)
Definition: matrix.c:430
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
SCIP_Bool SCIPmatrixUplockConflict(SCIP_MATRIX *matrix, int col)
Definition: matrix.c:1537
void SCIPmatrixFree(SCIP *scip, SCIP_MATRIX **matrix)
Definition: matrix.c:782
SCIP_Real SCIPmatrixGetColUb(SCIP_MATRIX *matrix, int col)
Definition: matrix.c:1279
type definitions for MIP matrix
int SCIPmatrixGetColNUplocks(SCIP_MATRIX *matrix, int col)
Definition: matrix.c:1301
int SCIPmatrixGetRowNMinActPosInf(SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1489
SCIP_Real SCIPmatrixGetRowRhs(SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1419
int SCIPmatrixGetNNonzs(SCIP_MATRIX *matrix)
Definition: matrix.c:1443
SCIP_Bool SCIPmatrixDownlockConflict(SCIP_MATRIX *matrix, int col)
Definition: matrix.c:1549
type definitions for problem variables
int SCIPmatrixGetNColumns(SCIP_MATRIX *matrix)
Definition: matrix.c:1269
int SCIPmatrixGetRowNNonzs(SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1373
int SCIPmatrixGetNRows(SCIP_MATRIX *matrix)
Definition: matrix.c:1397
const char * SCIPmatrixGetRowName(SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1385
#define SCIP_Bool
Definition: def.h:61
SCIP_Real SCIPmatrixGetColLb(SCIP_MATRIX *matrix, int col)
Definition: matrix.c:1290
SCIP_RETCODE SCIPmatrixGetParallelCols(SCIP *scip, SCIP_MATRIX *matrix, SCIP_Real *scale, int *pclass, SCIP_Bool *varineq)
Definition: matrix.c:1033
int SCIPmatrixGetRowNMaxActPosInf(SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1513
SCIP_Real SCIPmatrixGetRowMaxActivity(SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1465
SCIP_Bool SCIPmatrixIsRowRhsInfinity(SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1431
int SCIPmatrixGetColNDownlocks(SCIP_MATRIX *matrix, int col)
Definition: matrix.c:1313
data structure for MIP matrix
int SCIPmatrixGetColNNonzs(SCIP_MATRIX *matrix, int col)
Definition: matrix.c:1257
SCIP_Real * SCIPmatrixGetColValPtr(SCIP_MATRIX *matrix, int col)
Definition: matrix.c:1233
const char * SCIPmatrixGetColName(SCIP_MATRIX *matrix, int col)
Definition: matrix.c:1337
SCIP_Real SCIPmatrixGetRowLhs(SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1407
SCIP_CONS * SCIPmatrixGetCons(SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1525
SCIP_RETCODE SCIPmatrixGetParallelRows(SCIP *scip, SCIP_MATRIX *matrix, SCIP_Real *scale, int *pclass)
Definition: matrix.c:877
#define SCIP_Real
Definition: def.h:149
int * SCIPmatrixGetRowIdxPtr(SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1361
SCIP_VAR * SCIPmatrixGetVar(SCIP_MATRIX *matrix, int col)
Definition: matrix.c:1325
common defines and data types used in all packages of SCIP
type definitions for constraints and constraint handlers