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-2015 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 PUBLICMETHODS
18  * @brief public methods for MILP 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 MILP matrix access
42  */
43 
44 /** get column based start pointer of values */
45 extern
47  SCIPMILPMATRIX* matrix, /**< matrix instance */
48  int col /**< column index */
49  );
50 
51 /** get column based start pointer of row indices */
52 extern
54  SCIPMILPMATRIX* matrix, /**< matrix instance */
55  int col /**< column index */
56  );
57 
58 /** get the number of non-zero entries of this column */
59 extern
61  SCIPMILPMATRIX* matrix, /**< matrix instance */
62  int col /**< column index */
63  );
64 
65 /** get number of columns of the matrix */
66 extern
68  SCIPMILPMATRIX* matrix /**< matrix instance */
69  );
70 
71 /** get upper bound of column */
72 extern
74  SCIPMILPMATRIX* matrix, /**< matrix instance */
75  int col /**< column index */
76  );
77 
78 /** get lower bound of column */
79 extern
81  SCIPMILPMATRIX* matrix, /**< matrix instance */
82  int col /**< column index */
83  );
84 
85 /** get number of uplocks of column */
86 extern
88  SCIPMILPMATRIX* matrix, /**< matrix instance */
89  int col /**< column index */
90  );
91 
92 /** get number of downlocks of column */
93 extern
95  SCIPMILPMATRIX* matrix, /**< matrix instance */
96  int col /**< column index */
97  );
98 
99 /** get variable pointer of column */
100 extern
102  SCIPMILPMATRIX* matrix, /**< matrix instance */
103  int col /**< column index */
104  );
105 
106 /** get name of column/variable */
107 extern
108 const char* SCIPmatrixGetColName(
109  SCIPMILPMATRIX* matrix, /**< matrix instance */
110  int col /**< column index */
111  );
112 
113 /** get row based start pointer of values */
114 extern
116  SCIPMILPMATRIX* matrix, /**< matrix instance */
117  int row /**< row index */
118  );
119 
120 /** get row based start pointer of column indices */
121 extern
123  SCIPMILPMATRIX* matrix, /**< matrix instance */
124  int row /**< row index */
125  );
126 
127 /** get number of non-zeros of this row */
128 extern
130  SCIPMILPMATRIX* matrix, /**< matrix instance */
131  int row /**< row index */
132  );
133 
134 /** get name of row */
135 extern
136 const char* SCIPmatrixGetRowName(
137  SCIPMILPMATRIX* matrix, /**< matrix instance */
138  int row /**< row index */
139  );
140 
141 /** get number of rows of the matrix */
142 extern
144  SCIPMILPMATRIX* matrix /**< matrix instance */
145  );
146 
147 /** get left-hand-side of row */
148 extern
150  SCIPMILPMATRIX* matrix, /**< matrix instace */
151  int row /**< row index */
152  );
153 
154 /** get right-hand-side of row */
155 extern
157  SCIPMILPMATRIX* matrix, /**< matrix instance */
158  int row /**< row index */
159  );
160 
161 /** flag indicating if right-hand-side of row is infinity */
162 extern
164  SCIPMILPMATRIX* matrix, /**< matrix instance */
165  int row /**< row index */
166  );
167 
168 /** get number of non-zeros of matrix */
169 extern
171  SCIPMILPMATRIX* matrix /**< matrix instance */
172  );
173 
174 /** get minimal activity of row */
175 extern
177  SCIPMILPMATRIX* matrix, /**< matrix instance */
178  int row /**< row index */
179  );
180 
181 /** get maximal activity of row */
182 extern
184  SCIPMILPMATRIX* matrix, /**< matrix instance */
185  int row /**< row index */
186  );
187 
188 /** get number of negative infinities present within minimal activity */
189 extern
191  SCIPMILPMATRIX* matrix, /**< matrix instance */
192  int row /**< row index */
193  );
194 
195 /** get number of positive infinities present within minimal activity */
196 extern
198  SCIPMILPMATRIX* matrix, /**< matrix instance */
199  int row /**< row index */
200  );
201 
202 /** get number of negative infinities present within maximal activity */
203 extern
205  SCIPMILPMATRIX* matrix, /**< matrix instance */
206  int row /**< row index */
207  );
208 
209 /** get number of positive infinities present within maximal activity */
210 extern
212  SCIPMILPMATRIX* matrix, /**< matrix instance */
213  int row /**< row index */
214  );
215 
216 /** get constraint pointer for constraint representing row */
217 extern
219  SCIPMILPMATRIX* matrix, /**< matrix instance */
220  int row /**< row index */
221  );
222 
223 /** get if conflicting uplocks of variable present */
224 extern
226  SCIPMILPMATRIX* matrix, /**< matrix instance */
227  int col /**< column index */
228  );
229 
230 /** get if conflicting downlocks of variable present */
231 extern
233  SCIPMILPMATRIX* 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  SCIPMILPMATRIX** 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  SCIPMILPMATRIX** matrix /**< constraint matrix object */
289  );
290 
291 /** print one row of the MILP matrix */
292 extern
293 void SCIPmatrixPrintRow(
294  SCIP* scip, /**< current SCIP instance */
295  SCIPMILPMATRIX* 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  SCIPMILPMATRIX* 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  SCIPMILPMATRIX* 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 SCIPmatrixGetNRows(SCIPMILPMATRIX *matrix)
struct SCIP_Cons SCIP_CONS
Definition: type_cons.h:48
int SCIPmatrixGetColNNonzs(SCIPMILPMATRIX *matrix, int col)
SCIP_Real SCIPmatrixGetRowMaxActivity(SCIPMILPMATRIX *matrix, int row)
const char * SCIPmatrixGetRowName(SCIPMILPMATRIX *matrix, int row)
int SCIPmatrixGetRowNMinActNegInf(SCIPMILPMATRIX *matrix, int row)
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
SCIP_Real SCIPmatrixGetRowLhs(SCIPMILPMATRIX *matrix, int row)
SCIP_Bool SCIPmatrixDownlockConflict(SCIPMILPMATRIX *matrix, int col)
SCIP_Bool SCIPmatrixIsRowRhsInfinity(SCIPMILPMATRIX *matrix, int row)
void SCIPmatrixPrintRow(SCIP *scip, SCIPMILPMATRIX *matrix, int row)
SCIP_CONS * SCIPmatrixGetCons(SCIPMILPMATRIX *matrix, int row)
type definitions for MILP matrix
int SCIPmatrixGetColNUplocks(SCIPMILPMATRIX *matrix, int col)
SCIP_Real SCIPmatrixGetColUb(SCIPMILPMATRIX *matrix, int col)
SCIP_Real SCIPmatrixGetColLb(SCIPMILPMATRIX *matrix, int col)
int * SCIPmatrixGetRowIdxPtr(SCIPMILPMATRIX *matrix, int row)
int SCIPmatrixGetRowNMinActPosInf(SCIPMILPMATRIX *matrix, int row)
SCIP_Real * SCIPmatrixGetRowValPtr(SCIPMILPMATRIX *matrix, int row)
SCIP_Bool SCIPmatrixUplockConflict(SCIPMILPMATRIX *matrix, int col)
type definitions for problem variables
void SCIPmatrixFree(SCIP *scip, SCIPMILPMATRIX **matrix)
struct Scip SCIP
Definition: type_scip.h:30
int SCIPmatrixGetRowNMaxActPosInf(SCIPMILPMATRIX *matrix, int row)
#define SCIP_Bool
Definition: def.h:50
int SCIPmatrixGetColNDownlocks(SCIPMILPMATRIX *matrix, int col)
int SCIPmatrixGetRowNMaxActNegInf(SCIPMILPMATRIX *matrix, int row)
SCIP_RETCODE SCIPmatrixGetParallelRows(SCIP *scip, SCIPMILPMATRIX *matrix, SCIP_Real *scale, int *pclass)
int SCIPmatrixGetNColumns(SCIPMILPMATRIX *matrix)
struct SCIP_Var SCIP_VAR
Definition: type_var.h:95
SCIP_Real SCIPmatrixGetRowRhs(SCIPMILPMATRIX *matrix, int row)
const char * SCIPmatrixGetColName(SCIPMILPMATRIX *matrix, int col)
int SCIPmatrixGetRowNNonzs(SCIPMILPMATRIX *matrix, int row)
#define SCIP_Real
Definition: def.h:124
SCIP_VAR * SCIPmatrixGetVar(SCIPMILPMATRIX *matrix, int col)
int SCIPmatrixGetNNonzs(SCIPMILPMATRIX *matrix)
int * SCIPmatrixGetColIdxPtr(SCIPMILPMATRIX *matrix, int col)
SCIP_Real SCIPmatrixGetRowMinActivity(SCIPMILPMATRIX *matrix, int row)
SCIP_Real * SCIPmatrixGetColValPtr(SCIPMILPMATRIX *matrix, int col)
common defines and data types used in all packages of SCIP
SCIP_RETCODE SCIPmatrixCreate(SCIP *scip, SCIPMILPMATRIX **matrixptr, SCIP_Bool *initialized, SCIP_Bool *complete)
SCIP_RETCODE SCIPmatrixGetParallelCols(SCIP *scip, SCIPMILPMATRIX *matrix, SCIP_Real *scale, int *pclass, SCIP_Bool *varineq)
type definitions for constraints and constraint handlers
struct SCIPmilpMatrix SCIPMILPMATRIX
Definition: type_matrix.h:31