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-2025 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#include "scip/type_rational.h"
    41
    42#ifdef NDEBUG
    43#include "scip/struct_matrix.h"
    44#endif
    45
    46#ifdef __cplusplus
    47extern "C" {
    48#endif
    49
    50/*
    51 * methods for matrix access
    52 */
    53
    54/** get column based start pointer of values */
    55SCIP_EXPORT
    57 SCIP_MATRIX* matrix, /**< matrix instance */
    58 int col /**< column index */
    59 );
    60
    61/** get column based start pointer of row indices */
    62SCIP_EXPORT
    64 SCIP_MATRIX* matrix, /**< matrix instance */
    65 int col /**< column index */
    66 );
    67
    68/** get the number of non-zero entries of this column */
    69SCIP_EXPORT
    71 SCIP_MATRIX* matrix, /**< matrix instance */
    72 int col /**< column index */
    73 );
    74
    75/** get number of columns of the matrix */
    76SCIP_EXPORT
    78 SCIP_MATRIX* matrix /**< matrix instance */
    79 );
    80
    81/** get upper bound of column */
    82SCIP_EXPORT
    84 SCIP_MATRIX* matrix, /**< matrix instance */
    85 int col /**< column index */
    86 );
    87
    88/** get lower bound of column */
    89SCIP_EXPORT
    91 SCIP_MATRIX* matrix, /**< matrix instance */
    92 int col /**< column index */
    93 );
    94
    95/** get number of uplocks of column */
    96SCIP_EXPORT
    98 SCIP_MATRIX* matrix, /**< matrix instance */
    99 int col /**< column index */
    100 );
    101
    102/** get number of downlocks of column */
    103SCIP_EXPORT
    105 SCIP_MATRIX* matrix, /**< matrix instance */
    106 int col /**< column index */
    107 );
    108
    109/** get variable pointer of column */
    110SCIP_EXPORT
    112 SCIP_MATRIX* matrix, /**< matrix instance */
    113 int col /**< column index */
    114 );
    115
    116/** get name of column/variable */
    117SCIP_EXPORT
    118const char* SCIPmatrixGetColName(
    119 SCIP_MATRIX* matrix, /**< matrix instance */
    120 int col /**< column index */
    121 );
    122
    123/** get row based start pointer of values */
    124SCIP_EXPORT
    126 SCIP_MATRIX* matrix, /**< matrix instance */
    127 int row /**< row index */
    128 );
    129
    130/** get row based start pointer of values */
    131SCIP_EXPORT
    133 SCIP_MATRIX* matrix, /**< matrix instance */
    134 int row /**< row index */
    135 );
    136
    137/** get row based start pointer of column indices */
    138SCIP_EXPORT
    140 SCIP_MATRIX* matrix, /**< matrix instance */
    141 int row /**< row index */
    142 );
    143
    144/** get number of non-zeros of this row */
    145SCIP_EXPORT
    147 SCIP_MATRIX* matrix, /**< matrix instance */
    148 int row /**< row index */
    149 );
    150
    151/** get name of row */
    152SCIP_EXPORT
    153const char* SCIPmatrixGetRowName(
    154 SCIP_MATRIX* matrix, /**< matrix instance */
    155 int row /**< row index */
    156 );
    157
    158/** get number of rows of the matrix */
    159SCIP_EXPORT
    161 SCIP_MATRIX* matrix /**< matrix instance */
    162 );
    163
    164/** get left-hand-side of row */
    165SCIP_EXPORT
    167 SCIP_MATRIX* matrix, /**< matrix instace */
    168 int row /**< row index */
    169 );
    170
    171/** get right-hand-side of row */
    172SCIP_EXPORT
    174 SCIP_MATRIX* matrix, /**< matrix instance */
    175 int row /**< row index */
    176 );
    177
    178/** get left-hand-side of row */
    179SCIP_EXPORT
    181 SCIP_MATRIX* matrix, /**< matrix instace */
    182 int row /**< row index */
    183 );
    184
    185/** get right-hand-side of row */
    186SCIP_EXPORT
    188 SCIP_MATRIX* matrix, /**< matrix instance */
    189 int row /**< row index */
    190 );
    191
    192/** flag indicating if right-hand-side of row is infinity */
    193SCIP_EXPORT
    195 SCIP_MATRIX* matrix, /**< matrix instance */
    196 int row /**< row index */
    197 );
    198
    199/** get number of non-zeros of matrix */
    200SCIP_EXPORT
    202 SCIP_MATRIX* matrix /**< matrix instance */
    203 );
    204
    205/** get minimal activity of row */
    206SCIP_EXPORT
    208 SCIP_MATRIX* matrix, /**< matrix instance */
    209 int row /**< row index */
    210 );
    211
    212/** get maximal activity of row */
    213SCIP_EXPORT
    215 SCIP_MATRIX* matrix, /**< matrix instance */
    216 int row /**< row index */
    217 );
    218
    219/** get number of negative infinities present within minimal activity */
    220SCIP_EXPORT
    222 SCIP_MATRIX* matrix, /**< matrix instance */
    223 int row /**< row index */
    224 );
    225
    226/** get number of positive infinities present within minimal activity */
    227SCIP_EXPORT
    229 SCIP_MATRIX* matrix, /**< matrix instance */
    230 int row /**< row index */
    231 );
    232
    233/** get number of negative infinities present within maximal activity */
    234SCIP_EXPORT
    236 SCIP_MATRIX* matrix, /**< matrix instance */
    237 int row /**< row index */
    238 );
    239
    240/** get number of positive infinities present within maximal activity */
    241SCIP_EXPORT
    243 SCIP_MATRIX* matrix, /**< matrix instance */
    244 int row /**< row index */
    245 );
    246
    247/** get constraint pointer for constraint representing row */
    248SCIP_EXPORT
    250 SCIP_MATRIX* matrix, /**< matrix instance */
    251 int row /**< row index */
    252 );
    253
    254/** get if conflicting uplocks of variable present */
    255SCIP_EXPORT
    257 SCIP_MATRIX* matrix, /**< matrix instance */
    258 int col /**< column index */
    259 );
    260
    261/** get if conflicting downlocks of variable present */
    262SCIP_EXPORT
    264 SCIP_MATRIX* matrix, /**< matrix instance */
    265 int col /**< column index */
    266 );
    267
    268
    269#ifdef NDEBUG
    270
    271/* In optimized mode, the function calls are overwritten by defines to reduce the number of function calls and
    272 * speed up the algorithms.
    273 */
    274
    275#define SCIPmatrixGetColValPtr(matrix,col) (matrix->colmatval + matrix->colmatbeg[col])
    276#define SCIPmatrixGetColIdxPtr(matrix,col) (matrix->colmatind + matrix->colmatbeg[col])
    277#define SCIPmatrixGetColNNonzs(matrix,col) (matrix->colmatcnt[col])
    278#define SCIPmatrixGetNColumns(matrix) (matrix->ncols)
    279#define SCIPmatrixGetColUb(matrix,col) (matrix->ub[col])
    280#define SCIPmatrixGetColLb(matrix,col) (matrix->lb[col])
    281#define SCIPmatrixGetColNUplocks(matrix,col) (matrix->nuplocks[col])
    282#define SCIPmatrixGetColNDownlocks(matrix,col) (matrix->ndownlocks[col])
    283#define SCIPmatrixGetVar(matrix,col) (matrix->vars[col])
    284#define SCIPmatrixGetColName(matrix,col) (SCIPvarGetName(matrix->vars[col]))
    285#define SCIPmatrixGetRowValPtr(matrix,row) (matrix->rowmatval + matrix->rowmatbeg[row])
    286#define SCIPmatrixGetRowValPtrExact(matrix,row) (matrix->matrixvalsexact->rowmatvalexact + matrix->rowmatbeg[row])
    287#define SCIPmatrixGetRowIdxPtr(matrix,row) (matrix->rowmatind + matrix->rowmatbeg[row])
    288#define SCIPmatrixGetRowNNonzs(matrix,row) (matrix->rowmatcnt[row])
    289#define SCIPmatrixGetRowName(matrix,row) (SCIPconsGetName(matrix->cons[row]))
    290#define SCIPmatrixGetNRows(matrix) (matrix->nrows)
    291#define SCIPmatrixGetRowLhs(matrix,row) (matrix->lhs[row])
    292#define SCIPmatrixGetRowRhs(matrix,row) (matrix->rhs[row])
    293#define SCIPmatrixGetRowLhsExact(matrix,row) (matrix->matrixvalsexact->lhsexact[row])
    294#define SCIPmatrixGetRowRhsExact(matrix,row) (matrix->matrixvalsexact->rhsexact[row])
    295#define SCIPmatrixIsRowRhsInfinity(matrix,row) (matrix->isrhsinfinite[row])
    296#define SCIPmatrixGetNNonzs(matrix) (matrix->nnonzs)
    297#define SCIPmatrixGetRowMinActivity(matrix,row) (matrix->minactivity[row])
    298#define SCIPmatrixGetRowMaxActivity(matrix,row) (matrix->maxactivity[row])
    299#define SCIPmatrixGetRowNMinActNegInf(matrix,row) (matrix->minactivityneginf[row])
    300#define SCIPmatrixGetRowNMinActPosInf(matrix,row) (matrix->minactivityposinf[row])
    301#define SCIPmatrixGetRowNMaxActNegInf(matrix,row) (matrix->maxactivityneginf[row])
    302#define SCIPmatrixGetRowNMaxActPosInf(matrix,row) (matrix->maxactivityposinf[row])
    303#define SCIPmatrixGetCons(matrix,row) (matrix->cons[row])
    304
    305#endif
    306
    307/** initialize matrix by copying all check constraints
    308 *
    309 * @note Completeness is checked by testing whether all check constraints are from a list of linear constraint handlers
    310 * that can be represented.
    311 */
    312SCIP_EXPORT
    314 SCIP* scip, /**< current scip instance */
    315 SCIP_MATRIX** matrixptr, /**< pointer to constraint matrix object to be initialized */
    316 SCIP_Bool onlyifcomplete, /**< should matrix creation be skipped if matrix will not be complete? */
    317 SCIP_Bool* initialized, /**< was the initialization successful? */
    318 SCIP_Bool* complete, /**< are all constraint represented within the matrix? */
    319 SCIP_Bool* infeasible, /**< pointer to return whether problem was detected to be infeasible during matrix creation */
    320 int* naddconss, /**< pointer to count number of added (linear) constraints during matrix creation */
    321 int* ndelconss, /**< pointer to count number of deleted specialized linear constraints during matrix creation */
    322 int* nchgcoefs, /**< pointer to count number of changed coefficients during matrix creation */
    323 int* nchgbds, /**< pointer to count number of changed bounds during matrix creation */
    324 int* nfixedvars /**< pointer to count number of fixed variables during matrix creation */
    325 );
    326
    327/** frees the constraint matrix */
    328SCIP_EXPORT
    329void SCIPmatrixFree(
    330 SCIP* scip, /**< current SCIP instance */
    331 SCIP_MATRIX** matrix /**< constraint matrix object */
    332 );
    333
    334/** print one row of the MIP matrix */
    335SCIP_EXPORT
    337 SCIP* scip, /**< current SCIP instance */
    338 SCIP_MATRIX* matrix, /**< constraint matrix object */
    339 int row /**< row index */
    340 );
    341
    342/** detect parallel rows, rhs/lhs are ignored */
    343SCIP_EXPORT
    345 SCIP* scip, /**< current SCIP instance */
    346 SCIP_MATRIX* matrix, /**< matrix containing the constraints */
    347 SCIP_Real* scale, /**< scale factors of rows */
    348 int* pclass /**< parallel row classes */
    349 );
    350
    351/** removes the bounds of a column and updates the activities accordingly */
    352SCIP_EXPORT
    354 SCIP* scip, /**< current scip instance */
    355 SCIP_MATRIX* matrix, /**< constraint matrix */
    356 int col /**< column variable to remove bounds from */
    357 );
    358
    359/** detect parallel columns, obj ignored */
    360SCIP_EXPORT
    362 SCIP* scip, /**< current SCIP instance */
    363 SCIP_MATRIX* matrix, /**< matrix containing the constraints */
    364 SCIP_Real* scale, /**< scale factors of cols */
    365 int* pclass, /**< parallel column classes */
    366 SCIP_Bool* varineq /**< indicating if variable is within an equation */
    367 );
    368
    369
    370#ifdef __cplusplus
    371}
    372#endif
    373
    374#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:156
    SCIP_Bool SCIPmatrixUplockConflict(SCIP_MATRIX *matrix, int col)
    Definition: matrix.c:2201
    int SCIPmatrixGetRowNMinActNegInf(SCIP_MATRIX *matrix, int row)
    Definition: matrix.c:2141
    int * SCIPmatrixGetColIdxPtr(SCIP_MATRIX *matrix, int col)
    Definition: matrix.c:1873
    int SCIPmatrixGetNNonzs(SCIP_MATRIX *matrix)
    Definition: matrix.c:2107
    SCIP_RATIONAL * SCIPmatrixGetRowLhsExact(SCIP_MATRIX *matrix, int row)
    Definition: matrix.c:2071
    int SCIPmatrixGetRowNNonzs(SCIP_MATRIX *matrix, int row)
    Definition: matrix.c:2013
    const char * SCIPmatrixGetRowName(SCIP_MATRIX *matrix, int row)
    Definition: matrix.c:2025
    int SCIPmatrixGetColNDownlocks(SCIP_MATRIX *matrix, int col)
    Definition: matrix.c:1941
    int SCIPmatrixGetColNNonzs(SCIP_MATRIX *matrix, int col)
    Definition: matrix.c:1885
    SCIP_Bool SCIPmatrixIsRowRhsInfinity(SCIP_MATRIX *matrix, int row)
    Definition: matrix.c:2095
    int SCIPmatrixGetColNUplocks(SCIP_MATRIX *matrix, int col)
    Definition: matrix.c:1929
    SCIP_Real SCIPmatrixGetRowMaxActivity(SCIP_MATRIX *matrix, int row)
    Definition: matrix.c:2129
    SCIP_Real SCIPmatrixGetColLb(SCIP_MATRIX *matrix, int col)
    Definition: matrix.c:1918
    SCIP_Real SCIPmatrixGetRowLhs(SCIP_MATRIX *matrix, int row)
    Definition: matrix.c:2047
    const char * SCIPmatrixGetColName(SCIP_MATRIX *matrix, int col)
    Definition: matrix.c:1965
    SCIP_Real * SCIPmatrixGetRowValPtr(SCIP_MATRIX *matrix, int row)
    Definition: matrix.c:1977
    SCIP_Bool SCIPmatrixDownlockConflict(SCIP_MATRIX *matrix, int col)
    Definition: matrix.c:2213
    SCIP_RATIONAL ** SCIPmatrixGetRowValPtrExact(SCIP_MATRIX *matrix, int row)
    Definition: matrix.c:1989
    SCIP_Real SCIPmatrixGetRowRhs(SCIP_MATRIX *matrix, int row)
    Definition: matrix.c:2059
    SCIP_Real * SCIPmatrixGetColValPtr(SCIP_MATRIX *matrix, int col)
    Definition: matrix.c:1861
    int SCIPmatrixGetRowNMinActPosInf(SCIP_MATRIX *matrix, int row)
    Definition: matrix.c:2153
    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:703
    int SCIPmatrixGetNColumns(SCIP_MATRIX *matrix)
    Definition: matrix.c:1897
    SCIP_Real SCIPmatrixGetRowMinActivity(SCIP_MATRIX *matrix, int row)
    Definition: matrix.c:2117
    SCIP_CONS * SCIPmatrixGetCons(SCIP_MATRIX *matrix, int row)
    Definition: matrix.c:2189
    SCIP_RETCODE SCIPmatrixGetParallelRows(SCIP *scip, SCIP_MATRIX *matrix, SCIP_Real *scale, int *pclass)
    Definition: matrix.c:1504
    void SCIPmatrixFree(SCIP *scip, SCIP_MATRIX **matrix)
    Definition: matrix.c:1348
    int SCIPmatrixGetRowNMaxActPosInf(SCIP_MATRIX *matrix, int row)
    Definition: matrix.c:2177
    int SCIPmatrixGetRowNMaxActNegInf(SCIP_MATRIX *matrix, int row)
    Definition: matrix.c:2165
    SCIP_VAR * SCIPmatrixGetVar(SCIP_MATRIX *matrix, int col)
    Definition: matrix.c:1953
    SCIP_RATIONAL * SCIPmatrixGetRowRhsExact(SCIP_MATRIX *matrix, int row)
    Definition: matrix.c:2083
    int * SCIPmatrixGetRowIdxPtr(SCIP_MATRIX *matrix, int row)
    Definition: matrix.c:2001
    void SCIPmatrixPrintRow(SCIP *scip, SCIP_MATRIX *matrix, int row)
    Definition: matrix.c:1425
    SCIP_RETCODE SCIPmatrixGetParallelCols(SCIP *scip, SCIP_MATRIX *matrix, SCIP_Real *scale, int *pclass, SCIP_Bool *varineq)
    Definition: matrix.c:1660
    int SCIPmatrixGetNRows(SCIP_MATRIX *matrix)
    Definition: matrix.c:2037
    void SCIPmatrixRemoveColumnBounds(SCIP *scip, SCIP_MATRIX *matrix, int col)
    Definition: matrix.c:1459
    SCIP_Real SCIPmatrixGetColUb(SCIP_MATRIX *matrix, int col)
    Definition: matrix.c:1907
    data structure for MIP matrix
    type definitions for constraints and constraint handlers
    type definitions for MIP matrix
    type definitions for rational numbers
    enum SCIP_Retcode SCIP_RETCODE
    Definition: type_retcode.h:63
    type definitions for problem variables