SCIP

    Solving Constraint Integer Programs

    debug.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-2026 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 debug.h
    26 * @ingroup INTERNALAPI
    27 * @brief methods for debugging
    28 * @author Tobias Achterberg
    29 */
    30
    31/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
    32
    33#ifndef __SCIP_DEBUG_H__
    34#define __SCIP_DEBUG_H__
    35
    36/** uncomment this define to activate debugging the LP interface */
    37/* #define SCIP_DEBUG_LP_INTERFACE */
    38
    39#include "scip/def.h"
    40#include "scip/type_retcode.h"
    41#include "scip/type_scip.h"
    42
    43#ifdef WITH_DEBUG_SOLUTION
    45#include "scip/type_cons.h"
    46#include "scip/type_lp.h"
    47#include "scip/type_misc.h"
    48#include "scip/type_set.h"
    49#include "scip/type_sol.h"
    50#include "scip/type_tree.h"
    51#include "scip/type_var.h"
    52#endif
    53
    54
    55#ifdef __cplusplus
    56extern "C" {
    57#endif
    58
    59/** solution data for debugging purposes */
    60typedef struct SCIP_DebugSolData SCIP_DEBUGSOLDATA;
    61
    62#ifdef WITH_DEBUG_SOLUTION
    63
    64/** creates debug solution data */
    66 SCIP_DEBUGSOLDATA** debugsoldata /**< pointer to debug solution data */
    67 );
    68
    69/** frees the debug solution */
    72 );
    73
    74/** clears the debug solution */
    75SCIP_RETCODE SCIPdebugClearSol(
    76 SCIP* scip /**< SCIP data structure */
    77 );
    78
    79/** resets the data structure after restart */
    82 );
    83
    84/** frees debugging data for the particular instance */
    86 SCIP_SET* set /**< global SCIP settings */
    87 );
    88
    89/** frees all debugging data */
    91 SCIP_SET* set /**< global SCIP settings */
    92 );
    93
    94/** checks for validity of the debugging solution in given active constraints */
    96 SCIP* scip, /**< SCIP data structure */
    97 SCIP_CONS** conss, /**< constraints to check for validity */
    98 int nconss /**< number of given constraints */
    99 );
    100
    101/** checks for validity of the debugging solution for any globally valid constraints. */
    103 SCIP* scip, /**< SCIP data structure */
    104 SCIP_CONS** conss, /**< constraints to check for validity */
    105 int nconss /**< number of given constraints */
    106 );
    107
    108/** checks whether given row is valid for the debugging solution */
    110 SCIP_SET* set, /**< global SCIP settings */
    111 SCIP_ROW* row /**< row to check for validity */
    112 );
    113
    114/** checks whether given global lower bound is valid for the debugging solution */
    116 SCIP* scip, /**< SCIP data structure */
    117 SCIP_VAR* var, /**< problem variable */
    118 SCIP_Real lb /**< lower bound */
    119 );
    120
    121/** checks whether given global upper bound is valid for the debugging solution */
    123 SCIP* scip, /**< SCIP data structure */
    124 SCIP_VAR* var, /**< problem variable */
    125 SCIP_Real ub /**< upper bound */
    126 );
    127
    128/** checks whether given local bound implication is valid for the debugging solution */
    130 BMS_BLKMEM* blkmem, /**< block memory */
    131 SCIP_SET* set, /**< global SCIP settings */
    132 SCIP_NODE* node, /**< local node where this bound change was applied */
    133 SCIP_VAR* var, /**< problem variable */
    134 SCIP_Real newbound, /**< new value for bound */
    135 SCIP_BOUNDTYPE boundtype /**< type of bound: lower or upper bound */
    136 );
    137
    138/** informs solution debugger, that the given node will be freed */
    140 BMS_BLKMEM* blkmem, /**< block memory */
    141 SCIP_SET* set, /**< global SCIP settings */
    142 SCIP_NODE* node /**< node that will be freed */
    143 );
    144
    145/** checks whether global lower bound does not exceed debuging solution value */
    147 BMS_BLKMEM* blkmem, /**< block memory */
    148 SCIP_SET* set /**< global SCIP settings */
    149 );
    150
    151/** checks whether local lower bound does not exceed debuging solution value */
    153 BMS_BLKMEM* blkmem, /**< block memory */
    154 SCIP_SET* set, /**< global SCIP settings */
    155 SCIP_NODE* node /**< node that will be freed */
    156 );
    157
    158/** checks whether given variable bound is valid for the debugging solution */
    160 SCIP_SET* set, /**< global SCIP settings */
    161 SCIP_VAR* var, /**< problem variable x in x <= b*z + d or x >= b*z + d */
    162 SCIP_BOUNDTYPE vbtype, /**< type of variable bound (LOWER or UPPER) */
    163 SCIP_VAR* vbvar, /**< variable z in x <= b*z + d or x >= b*z + d */
    164 SCIP_Real vbcoef, /**< coefficient b in x <= b*z + d or x >= b*z + d */
    165 SCIP_Real vbconstant /**< constant d in x <= b*z + d or x >= b*z + d */
    166 );
    167
    168/** checks whether given implication is valid for the debugging solution */
    170 SCIP_SET* set, /**< global SCIP settings */
    171 SCIP_VAR* var, /**< problem variable */
    172 SCIP_Bool varfixing, /**< FALSE if y should be added in implications for x == 0, TRUE for x == 1 */
    173 SCIP_VAR* implvar, /**< variable y in implication y <= b or y >= b */
    174 SCIP_BOUNDTYPE impltype, /**< type of implication y <= b (SCIP_BOUNDTYPE_UPPER) or y >= b (SCIP_BOUNDTYPE_LOWER) */
    175 SCIP_Real implbound /**< bound b in implication y <= b or y >= b */
    176 );
    177
    178/** checks whether given (multi)-aggregation is valid for the debugging solution */
    180 SCIP_SET* set, /**< global SCIP settings */
    181 SCIP_VAR* var, /**< problem variable */
    182 SCIP_VAR** aggrvars, /**< variables y_i in aggregation x = a_1*y_1 + ... + a_n*y_n + c */
    183 SCIP_Real* scalars, /**< multipliers a_i in aggregation x = a_1*y_1 + ... + a_n*y_n + c */
    184 SCIP_Real constant, /**< constant shift c in aggregation x = a_1*y_1 + ... + a_n*y_n + c */
    185 int naggrvars /**< number n of variables in aggregation x = a_1*y_1 + ... + a_n*y_n + c */
    186 );
    187
    188/** check whether given clique is valid for the debugging solution */
    190 SCIP_SET* set, /**< global SCIP settings */
    191 SCIP_VAR** vars, /**< binary variables in the clique: at most one can be set to the given value */
    192 SCIP_Bool* values, /**< values of the variables in the clique; NULL to use TRUE for all vars */
    193 int nvars /**< number of variables in the clique */
    194 );
    195
    196/** checks whether given conflict is valid for the debugging solution */
    198 BMS_BLKMEM* blkmem, /**< block memory */
    199 SCIP_SET* set, /**< global SCIP settings */
    200 SCIP_NODE* node, /**< node where the conflict clause is added */
    201 SCIP_BDCHGINFO** bdchginfos, /**< bound change informations of the conflict set */
    202 SCIP_Real* relaxedbds, /**< array with relaxed bounds which are efficient to create a valid conflict */
    203 int nbdchginfos /**< number of bound changes in the conflict set */
    204 );
    205
    206/** checks whether given conflict graph frontier is valid for the debugging solution */
    208 BMS_BLKMEM* blkmem, /**< block memory */
    209 SCIP_SET* set, /**< global SCIP settings */
    210 SCIP_NODE* node, /**< node where the conflict clause is added */
    211 SCIP_BDCHGINFO* bdchginfo, /**< bound change info which got resolved, or NULL */
    212 SCIP_BDCHGINFO** bdchginfos, /**< bound change informations of the conflict set */
    213 SCIP_Real* relaxedbds, /**< array with relaxed bounds which are efficient to create a valid conflict */
    214 int nbdchginfos, /**< number of bound changes in the conflict set */
    215 SCIP_PQUEUE* bdchgqueue, /**< unprocessed conflict bound changes */
    216 SCIP_PQUEUE* forcedbdchgqueue /**< unprocessed conflict bound changes that must be resolved */
    217 );
    218
    219/** creates the debugging propagator and includes it in SCIP */
    221 SCIP* scip /**< SCIP data structure */
    222 );
    223
    224/** adds a solution value for a new variable in the transformed problem that has no original counterpart
    225 * a value can only be set if no value has been set for this variable before
    226 */
    227SCIP_EXPORT
    229 SCIP* scip, /**< SCIP data structure */
    230 SCIP_VAR* var, /**< variable for which to add a value */
    231 SCIP_Real val /**< solution value for variable */
    232 );
    233
    234/** gets pointer to the debug solution */
    235SCIP_EXPORT
    236SCIP_RETCODE SCIPdebugGetSol(
    237 SCIP* scip, /**< SCIP data structure */
    238 SCIP_SOL** sol /**< buffer to store pointer to the debug solution */
    239 );
    240
    241/** gets value for a variable in the debug solution
    242 *
    243 * if no value is stored for the variable, gives 0.0
    244 */
    245SCIP_EXPORT
    247 SCIP* scip, /**< SCIP data structure */
    248 SCIP_VAR* var, /**< variable for which to get the value */
    249 SCIP_Real* val /**< buffer to store solution value */
    250 );
    251
    252/** check whether the debugging solution is valid in the current node */
    253SCIP_EXPORT
    255 SCIP* scip, /**< SCIP data structure */
    256 SCIP_Bool* isvalidinsubtree /**< pointer to store whether the solution is valid in the current
    257 * subtree
    258 */
    259 );
    260
    261/** checks whether SCIP data structure is the main SCIP (the one for which debugging is enabled) */
    262SCIP_EXPORT
    263SCIP_Bool SCIPdebugIsMainscip(
    264 SCIP* scip /**< SCIP data structure */
    265 );
    266
    267/** enabling solution debugging mechanism */
    268SCIP_EXPORT
    270 SCIP* scip /**< SCIP data structure */
    271 );
    272
    273/** disabling solution debugging mechanism */
    274SCIP_EXPORT
    276 SCIP* scip /**< SCIP data structure */
    277 );
    278
    279/** check if solution debugging mechanism is enabled */
    280SCIP_EXPORT
    282 SCIP* scip /**< SCIP data structure */
    283 );
    284
    285/** check if SCIP is compiled with WITH_DEBUG_SOLUTION */
    286SCIP_EXPORT
    288
    289#else
    290
    291#define SCIPdebugSolDataCreate(debugsoldata) SCIP_OKAY
    292#define SCIPdebugFreeSol(set) SCIP_OKAY
    293#define SCIPdebugReset(set) SCIP_OKAY
    294#define SCIPdebugFreeDebugData(set) SCIP_OKAY
    295#define SCIPdebugFree(set) SCIP_OKAY
    296#define SCIPdebugCheckActiveConss(scip,conss,nconss) SCIP_OKAY
    297#define SCIPdebugCheckConss(scip,conss,nconss) SCIP_OKAY
    298#define SCIPdebugCheckRow(set,row) SCIP_OKAY
    299#define SCIPdebugCheckLbGlobal(scip,var,lb) SCIP_OKAY
    300#define SCIPdebugCheckUbGlobal(scip,var,ub) SCIP_OKAY
    301#define SCIPdebugCheckInference(blkmem,set,node,var,newbound,boundtype) SCIP_OKAY
    302#define SCIPdebugRemoveNode(blkmem,set,node) SCIP_OKAY
    303#define SCIPdebugCheckGlobalLowerbound(blkmem,set) SCIP_OKAY
    304#define SCIPdebugCheckLocalLowerbound(blkmem,set,node) SCIP_OKAY
    305#define SCIPdebugCheckVbound(set,var,vbtype,vbvar,vbcoef,vbconstant) SCIP_OKAY
    306#define SCIPdebugCheckImplic(set,var,varfixing,implvar,impltype,implbound) SCIP_OKAY
    307#define SCIPdebugCheckAggregation(set,var,aggrvars,scalars,constant,naggrvars) SCIP_OKAY
    308#define SCIPdebugCheckClique(set,vars,values,nvars) SCIP_OKAY
    309#define SCIPdebugCheckConflict(blkmem,set,node,bdchginfos,relaxedbds,nliterals) SCIP_OKAY
    310#define SCIPdebugCheckConflictFrontier(blkmem,set,node,bdchginfo,bdchginfos,relaxedbds,nliterals,bdchgqueue,forcedbdchgqueue) SCIP_OKAY
    311#define SCIPdebugIncludeProp(scip) SCIP_OKAY
    312#define SCIPdebugAddSolVal(scip,var,val) SCIP_OKAY
    313#define SCIPdebugGetSolVal(scip,var,val) SCIP_OKAY
    314#define SCIPdebugSolIsValidInSubtree(scip,isvalidinsubtree) SCIP_OKAY
    315#define SCIPdebugSolEnable(scip) /**/
    316#define SCIPdebugSolDisable(scip) /**/
    317#define SCIPdebugSolIsEnabled(scip) FALSE
    318#define SCIPwithDebugSol(void) FALSE
    319
    320#endif
    321
    322
    323/*
    324 * debug method for LP interface, to check if the LP interface works correct
    325 */
    326#ifdef SCIP_DEBUG_LP_INTERFACE
    327
    328/* check if the coef is the r-th line of the inverse matrix B^-1; this is
    329 * the case if (coef * B) is the r-th unit vector */
    331 SCIP* scip, /**< SCIP data structure */
    332 int r, /**< row number */
    333 SCIP_Real* coef /**< pointer to store the coefficients of the row */
    334 );
    335
    336#else
    337
    338#define SCIPdebugCheckBInvRow(scip,r,coef) SCIP_OKAY
    339
    340#endif
    341
    342/** checks if SCIP is in one of the feasible stages */
    343#ifdef SCIP_CHECK_STAGE
    344
    346 SCIP* scip, /**< SCIP data structure */
    347 const char* method, /**< method that was called */
    348 SCIP_Bool init, /**< may method be called in the INIT stage? */
    349 SCIP_Bool problem, /**< may method be called in the PROBLEM stage? */
    350 SCIP_Bool transforming, /**< may method be called in the TRANSFORMING stage? */
    351 SCIP_Bool transformed, /**< may method be called in the TRANSFORMED stage? */
    352 SCIP_Bool initpresolve, /**< may method be called in the INITPRESOLVE stage? */
    353 SCIP_Bool presolving, /**< may method be called in the PRESOLVING stage? */
    354 SCIP_Bool exitpresolve, /**< may method be called in the EXITPRESOLE stage? */
    355 SCIP_Bool presolved, /**< may method be called in the PRESOLVED stage? */
    356 SCIP_Bool initsolve, /**< may method be called in the INITSOLVE stage? */
    357 SCIP_Bool solving, /**< may method be called in the SOLVING stage? */
    358 SCIP_Bool solved, /**< may method be called in the SOLVED stage? */
    359 SCIP_Bool exitsolve, /**< may method be called in the EXITSOLVE stage? */
    360 SCIP_Bool freetrans, /**< may method be called in the FREETRANS stage? */
    361 SCIP_Bool freescip /**< may method be called in the FREE stage? */
    362 );
    363#else
    364
    365#define SCIPcheckStage(scip,method,init,problem,transforming,transformed,initpresolve,presolving,exitpresolve,presolved, \
    366 initsolve,solving,solved,exitsolve,freetrans,freescip) SCIP_OKAY
    367
    368#endif
    369
    370#ifdef __cplusplus
    371}
    372#endif
    373
    374#endif
    SCIP_Real * r
    Definition: circlepacking.c:59
    #define SCIPdebugCheckLbGlobal(scip, var, lb)
    Definition: debug.h:299
    #define SCIPdebugCheckClique(set, vars, values, nvars)
    Definition: debug.h:308
    #define SCIPdebugFree(set)
    Definition: debug.h:295
    struct SCIP_DebugSolData SCIP_DEBUGSOLDATA
    Definition: debug.h:60
    #define SCIPdebugCheckRow(set, row)
    Definition: debug.h:298
    #define SCIPdebugSolDisable(scip)
    Definition: debug.h:316
    #define SCIPdebugCheckConflict(blkmem, set, node, bdchginfos, relaxedbds, nliterals)
    Definition: debug.h:309
    #define SCIPdebugCheckActiveConss(scip, conss, nconss)
    Definition: debug.h:296
    #define SCIPdebugCheckImplic(set, var, varfixing, implvar, impltype, implbound)
    Definition: debug.h:306
    #define SCIPdebugGetSolVal(scip, var, val)
    Definition: debug.h:313
    #define SCIPdebugFreeSol(set)
    Definition: debug.h:292
    #define SCIPdebugCheckUbGlobal(scip, var, ub)
    Definition: debug.h:300
    #define SCIPdebugSolEnable(scip)
    Definition: debug.h:315
    #define SCIPdebugCheckGlobalLowerbound(blkmem, set)
    Definition: debug.h:303
    #define SCIPcheckStage(scip, method, init, problem, transforming, transformed, initpresolve, presolving, exitpresolve, presolved, initsolve, solving, solved, exitsolve, freetrans, freescip)
    Definition: debug.h:365
    #define SCIPdebugCheckLocalLowerbound(blkmem, set, node)
    Definition: debug.h:304
    #define SCIPdebugAddSolVal(scip, var, val)
    Definition: debug.h:312
    #define SCIPdebugCheckVbound(set, var, vbtype, vbvar, vbcoef, vbconstant)
    Definition: debug.h:305
    #define SCIPdebugCheckConss(scip, conss, nconss)
    Definition: debug.h:297
    #define SCIPdebugFreeDebugData(set)
    Definition: debug.h:294
    #define SCIPdebugSolIsEnabled(scip)
    Definition: debug.h:317
    #define SCIPdebugCheckAggregation(set, var, aggrvars, scalars, constant, naggrvars)
    Definition: debug.h:307
    #define SCIPdebugCheckBInvRow(scip, r, coef)
    Definition: debug.h:338
    #define SCIPdebugRemoveNode(blkmem, set, node)
    Definition: debug.h:302
    #define SCIPdebugSolIsValidInSubtree(scip, isvalidinsubtree)
    Definition: debug.h:314
    #define SCIPdebugReset(set)
    Definition: debug.h:293
    #define SCIPdebugCheckConflictFrontier(blkmem, set, node, bdchginfo, bdchginfos, relaxedbds, nliterals, bdchgqueue, forcedbdchgqueue)
    Definition: debug.h:310
    #define SCIPdebugIncludeProp(scip)
    Definition: debug.h:311
    #define SCIPdebugCheckInference(blkmem, set, node, var, newbound, boundtype)
    Definition: debug.h:301
    #define SCIPwithDebugSol(void)
    Definition: debug.h:318
    #define SCIPdebugSolDataCreate(debugsoldata)
    Definition: debug.h:291
    common defines and data types used in all packages of SCIP
    #define SCIP_Bool
    Definition: def.h:100
    #define SCIP_Real
    Definition: def.h:165
    static const SCIP_Real scalars[]
    Definition: lp.c:5959
    memory allocation routines
    struct BMS_BlkMem BMS_BLKMEM
    Definition: memory.h:437
    Definition: heur_padm.c:132
    type definitions for constraints and constraint handlers
    type definitions for LP management
    enum SCIP_BoundType SCIP_BOUNDTYPE
    Definition: type_lp.h:60
    type definitions for miscellaneous datastructures
    type definitions for return codes for SCIP methods
    enum SCIP_Retcode SCIP_RETCODE
    Definition: type_retcode.h:63
    type definitions for SCIP's main datastructure
    type definitions for global SCIP settings
    type definitions for storing primal CIP solutions
    type definitions for branch and bound tree
    type definitions for problem variables