Scippy

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-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 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#ifdef __cplusplus
55extern "C" {
56#endif
57
58/** solution data for debugging purposes */
59typedef struct SCIP_DebugSolData SCIP_DEBUGSOLDATA;
60
61#ifdef WITH_DEBUG_SOLUTION
62
63/** creates debug solution data */
65 SCIP_DEBUGSOLDATA** debugsoldata /**< pointer to debug solution data */
66 );
67
68/** frees the debug solution */
71 );
72
73/** clears the debug solution */
74SCIP_RETCODE SCIPdebugClearSol(
75 SCIP* scip /**< SCIP data structure */
76 );
77
78/** resets the data structure after restart */
81 );
82
83/** frees debugging data for the particular instance */
85 SCIP_SET* set /**< global SCIP settings */
86 );
87
88/** frees all debugging data */
90 SCIP_SET* set /**< global SCIP settings */
91 );
92
93/** checks for validity of the debugging solution in given active constraints */
95 SCIP* scip, /**< SCIP data structure */
96 SCIP_CONS** conss, /**< constraints to check for validity */
97 int nconss /**< number of given constraints */
98 );
99
100/** checks for validity of the debugging solution for any globally valid constraints. */
102 SCIP* scip, /**< SCIP data structure */
103 SCIP_CONS** conss, /**< constraints to check for validity */
104 int nconss /**< number of given constraints */
105 );
106
107/** checks whether given row is valid for the debugging solution */
109 SCIP_SET* set, /**< global SCIP settings */
110 SCIP_ROW* row /**< row to check for validity */
111 );
112
113/** checks whether given global lower bound is valid for the debugging solution */
115 SCIP* scip, /**< SCIP data structure */
116 SCIP_VAR* var, /**< problem variable */
117 SCIP_Real lb /**< lower bound */
118 );
119
120/** checks whether given global upper bound is valid for the debugging solution */
122 SCIP* scip, /**< SCIP data structure */
123 SCIP_VAR* var, /**< problem variable */
124 SCIP_Real ub /**< upper bound */
125 );
126
127/** checks whether given local bound implication is valid for the debugging solution */
129 BMS_BLKMEM* blkmem, /**< block memory */
130 SCIP_SET* set, /**< global SCIP settings */
131 SCIP_NODE* node, /**< local node where this bound change was applied */
132 SCIP_VAR* var, /**< problem variable */
133 SCIP_Real newbound, /**< new value for bound */
134 SCIP_BOUNDTYPE boundtype /**< type of bound: lower or upper bound */
135 );
136
137/** informs solution debugger, that the given node will be freed */
139 BMS_BLKMEM* blkmem, /**< block memory */
140 SCIP_SET* set, /**< global SCIP settings */
141 SCIP_NODE* node /**< node that will be freed */
142 );
143
144/** checks whether global lower bound does not exceed debuging solution value */
146 BMS_BLKMEM* blkmem, /**< block memory */
147 SCIP_SET* set /**< global SCIP settings */
148 );
149
150/** checks whether local lower bound does not exceed debuging solution value */
152 BMS_BLKMEM* blkmem, /**< block memory */
153 SCIP_SET* set, /**< global SCIP settings */
154 SCIP_NODE* node /**< node that will be freed */
155 );
156
157/** checks whether given variable bound is valid for the debugging solution */
159 SCIP_SET* set, /**< global SCIP settings */
160 SCIP_VAR* var, /**< problem variable x in x <= b*z + d or x >= b*z + d */
161 SCIP_BOUNDTYPE vbtype, /**< type of variable bound (LOWER or UPPER) */
162 SCIP_VAR* vbvar, /**< variable z in x <= b*z + d or x >= b*z + d */
163 SCIP_Real vbcoef, /**< coefficient b in x <= b*z + d or x >= b*z + d */
164 SCIP_Real vbconstant /**< constant d in x <= b*z + d or x >= b*z + d */
165 );
166
167/** checks whether given implication is valid for the debugging solution */
169 SCIP_SET* set, /**< global SCIP settings */
170 SCIP_VAR* var, /**< problem variable */
171 SCIP_Bool varfixing, /**< FALSE if y should be added in implications for x == 0, TRUE for x == 1 */
172 SCIP_VAR* implvar, /**< variable y in implication y <= b or y >= b */
173 SCIP_BOUNDTYPE impltype, /**< type of implication y <= b (SCIP_BOUNDTYPE_UPPER) or y >= b (SCIP_BOUNDTYPE_LOWER) */
174 SCIP_Real implbound /**< bound b in implication y <= b or y >= b */
175 );
176
177/** checks whether given (multi)-aggregation is valid for the debugging solution */
179 SCIP_SET* set, /**< global SCIP settings */
180 SCIP_VAR* var, /**< problem variable */
181 SCIP_VAR** aggrvars, /**< variables y_i in aggregation x = a_1*y_1 + ... + a_n*y_n + c */
182 SCIP_Real* scalars, /**< multipliers a_i in aggregation x = a_1*y_1 + ... + a_n*y_n + c */
183 SCIP_Real constant, /**< constant shift c in aggregation x = a_1*y_1 + ... + a_n*y_n + c */
184 int naggrvars /**< number n of variables in aggregation x = a_1*y_1 + ... + a_n*y_n + c */
185 );
186
187/** check whether given clique is valid for the debugging solution */
189 SCIP_SET* set, /**< global SCIP settings */
190 SCIP_VAR** vars, /**< binary variables in the clique: at most one can be set to the given value */
191 SCIP_Bool* values, /**< values of the variables in the clique; NULL to use TRUE for all vars */
192 int nvars /**< number of variables in the clique */
193 );
194
195/** checks whether given conflict is valid for the debugging solution */
197 BMS_BLKMEM* blkmem, /**< block memory */
198 SCIP_SET* set, /**< global SCIP settings */
199 SCIP_NODE* node, /**< node where the conflict clause is added */
200 SCIP_BDCHGINFO** bdchginfos, /**< bound change informations of the conflict set */
201 SCIP_Real* relaxedbds, /**< array with relaxed bounds which are efficient to create a valid conflict */
202 int nbdchginfos /**< number of bound changes in the conflict set */
203 );
204
205/** checks whether given conflict graph frontier is valid for the debugging solution */
207 BMS_BLKMEM* blkmem, /**< block memory */
208 SCIP_SET* set, /**< global SCIP settings */
209 SCIP_NODE* node, /**< node where the conflict clause is added */
210 SCIP_BDCHGINFO* bdchginfo, /**< bound change info which got resolved, or NULL */
211 SCIP_BDCHGINFO** bdchginfos, /**< bound change informations of the conflict set */
212 SCIP_Real* relaxedbds, /**< array with relaxed bounds which are efficient to create a valid conflict */
213 int nbdchginfos, /**< number of bound changes in the conflict set */
214 SCIP_PQUEUE* bdchgqueue, /**< unprocessed conflict bound changes */
215 SCIP_PQUEUE* forcedbdchgqueue /**< unprocessed conflict bound changes that must be resolved */
216 );
217
218/** creates the debugging propagator and includes it in SCIP */
220 SCIP* scip /**< SCIP data structure */
221 );
222
223/** adds a solution value for a new variable in the transformed problem that has no original counterpart
224 * a value can only be set if no value has been set for this variable before
225 */
226SCIP_EXPORT
228 SCIP* scip, /**< SCIP data structure */
229 SCIP_VAR* var, /**< variable for which to add a value */
230 SCIP_Real val /**< solution value for variable */
231 );
232
233/** gets pointer to the debug solution */
234SCIP_EXPORT
235SCIP_RETCODE SCIPdebugGetSol(
236 SCIP* scip, /**< SCIP data structure */
237 SCIP_SOL** sol /**< buffer to store pointer to the debug solution */
238 );
239
240/** gets value for a variable in the debug solution
241 *
242 * if no value is stored for the variable, gives 0.0
243 */
244SCIP_EXPORT
246 SCIP* scip, /**< SCIP data structure */
247 SCIP_VAR* var, /**< variable for which to get the value */
248 SCIP_Real* val /**< buffer to store solution value */
249 );
250
251/** check whether the debugging solution is valid in the current node */
252SCIP_EXPORT
254 SCIP* scip, /**< SCIP data structure */
255 SCIP_Bool* isvalidinsubtree /**< pointer to store whether the solution is valid in the current
256 * subtree
257 */
258 );
259
260/** checks whether SCIP data structure is the main SCIP (the one for which debugging is enabled) */
261SCIP_EXPORT
262SCIP_Bool SCIPdebugIsMainscip(
263 SCIP* scip /**< SCIP data structure */
264 );
265
266/** enabling solution debugging mechanism */
267SCIP_EXPORT
269 SCIP* scip /**< SCIP data structure */
270 );
271
272/** disabling solution debugging mechanism */
273SCIP_EXPORT
275 SCIP* scip /**< SCIP data structure */
276 );
277
278/** check if solution debugging mechanism is enabled */
279SCIP_EXPORT
281 SCIP* scip /**< SCIP data structure */
282 );
283
284/** check if SCIP is compiled with WITH_DEBUG_SOLUTION */
285SCIP_EXPORT
287
288#else
289
290#define SCIPdebugSolDataCreate(debugsoldata) SCIP_OKAY
291#define SCIPdebugFreeSol(set) SCIP_OKAY
292#define SCIPdebugReset(set) SCIP_OKAY
293#define SCIPdebugFreeDebugData(set) SCIP_OKAY
294#define SCIPdebugFree(set) SCIP_OKAY
295#define SCIPdebugCheckActiveConss(scip,conss,nconss) SCIP_OKAY
296#define SCIPdebugCheckConss(scip,conss,nconss) SCIP_OKAY
297#define SCIPdebugCheckRow(set,row) SCIP_OKAY
298#define SCIPdebugCheckLbGlobal(scip,var,lb) SCIP_OKAY
299#define SCIPdebugCheckUbGlobal(scip,var,ub) SCIP_OKAY
300#define SCIPdebugCheckInference(blkmem,set,node,var,newbound,boundtype) SCIP_OKAY
301#define SCIPdebugRemoveNode(blkmem,set,node) SCIP_OKAY
302#define SCIPdebugCheckGlobalLowerbound(blkmem,set) SCIP_OKAY
303#define SCIPdebugCheckLocalLowerbound(blkmem,set,node) SCIP_OKAY
304#define SCIPdebugCheckVbound(set,var,vbtype,vbvar,vbcoef,vbconstant) SCIP_OKAY
305#define SCIPdebugCheckImplic(set,var,varfixing,implvar,impltype,implbound) SCIP_OKAY
306#define SCIPdebugCheckAggregation(set,var,aggrvars,scalars,constant,naggrvars) SCIP_OKAY
307#define SCIPdebugCheckClique(set,vars,values,nvars) SCIP_OKAY
308#define SCIPdebugCheckConflict(blkmem,set,node,bdchginfos,relaxedbds,nliterals) SCIP_OKAY
309#define SCIPdebugCheckConflictFrontier(blkmem,set,node,bdchginfo,bdchginfos,relaxedbds,nliterals,bdchgqueue,forcedbdchgqueue) SCIP_OKAY
310#define SCIPdebugIncludeProp(scip) SCIP_OKAY
311#define SCIPdebugAddSolVal(scip,var,val) SCIP_OKAY
312#define SCIPdebugGetSolVal(scip,var,val) SCIP_OKAY
313#define SCIPdebugSolIsValidInSubtree(scip,isvalidinsubtree) SCIP_OKAY
314#define SCIPdebugSolEnable(scip) /**/
315#define SCIPdebugSolDisable(scip) /**/
316#define SCIPdebugSolIsEnabled(scip) FALSE
317#define SCIPwithDebugSol(void) FALSE
318
319#endif
320
321
322/*
323 * debug method for LP interface, to check if the LP interface works correct
324 */
325#ifdef SCIP_DEBUG_LP_INTERFACE
326
327/* check if the coef is the r-th line of the inverse matrix B^-1; this is
328 * the case if (coef * B) is the r-th unit vector */
330 SCIP* scip, /**< SCIP data structure */
331 int r, /**< row number */
332 SCIP_Real* coef /**< pointer to store the coefficients of the row */
333 );
334
335#else
336
337#define SCIPdebugCheckBInvRow(scip,r,coef) SCIP_OKAY
338
339#endif
340
341/** checks if SCIP is in one of the feasible stages */
342#ifdef SCIP_CHECK_STAGE
343
345 SCIP* scip, /**< SCIP data structure */
346 const char* method, /**< method that was called */
347 SCIP_Bool init, /**< may method be called in the INIT stage? */
348 SCIP_Bool problem, /**< may method be called in the PROBLEM stage? */
349 SCIP_Bool transforming, /**< may method be called in the TRANSFORMING stage? */
350 SCIP_Bool transformed, /**< may method be called in the TRANSFORMED stage? */
351 SCIP_Bool initpresolve, /**< may method be called in the INITPRESOLVE stage? */
352 SCIP_Bool presolving, /**< may method be called in the PRESOLVING stage? */
353 SCIP_Bool exitpresolve, /**< may method be called in the EXITPRESOLE stage? */
354 SCIP_Bool presolved, /**< may method be called in the PRESOLVED stage? */
355 SCIP_Bool initsolve, /**< may method be called in the INITSOLVE stage? */
356 SCIP_Bool solving, /**< may method be called in the SOLVING stage? */
357 SCIP_Bool solved, /**< may method be called in the SOLVED stage? */
358 SCIP_Bool exitsolve, /**< may method be called in the EXITSOLVE stage? */
359 SCIP_Bool freetrans, /**< may method be called in the FREETRANS stage? */
360 SCIP_Bool freescip /**< may method be called in the FREE stage? */
361 );
362#else
363
364#define SCIPcheckStage(scip,method,init,problem,transforming,transformed,initpresolve,presolving,exitpresolve,presolved, \
365 initsolve,solving,solved,exitsolve,freetrans,freescip) SCIP_OKAY
366
367#endif
368
369#ifdef __cplusplus
370}
371#endif
372
373#endif
SCIP_Real * r
Definition: circlepacking.c:59
#define SCIPdebugCheckLbGlobal(scip, var, lb)
Definition: debug.h:298
#define SCIPdebugCheckClique(set, vars, values, nvars)
Definition: debug.h:307
#define SCIPdebugFree(set)
Definition: debug.h:294
struct SCIP_DebugSolData SCIP_DEBUGSOLDATA
Definition: debug.h:59
#define SCIPdebugCheckRow(set, row)
Definition: debug.h:297
#define SCIPdebugSolDisable(scip)
Definition: debug.h:315
#define SCIPdebugCheckConflict(blkmem, set, node, bdchginfos, relaxedbds, nliterals)
Definition: debug.h:308
#define SCIPdebugCheckActiveConss(scip, conss, nconss)
Definition: debug.h:295
#define SCIPdebugCheckImplic(set, var, varfixing, implvar, impltype, implbound)
Definition: debug.h:305
#define SCIPdebugGetSolVal(scip, var, val)
Definition: debug.h:312
#define SCIPdebugFreeSol(set)
Definition: debug.h:291
#define SCIPdebugCheckUbGlobal(scip, var, ub)
Definition: debug.h:299
#define SCIPdebugSolEnable(scip)
Definition: debug.h:314
#define SCIPdebugCheckGlobalLowerbound(blkmem, set)
Definition: debug.h:302
#define SCIPcheckStage(scip, method, init, problem, transforming, transformed, initpresolve, presolving, exitpresolve, presolved, initsolve, solving, solved, exitsolve, freetrans, freescip)
Definition: debug.h:364
#define SCIPdebugCheckLocalLowerbound(blkmem, set, node)
Definition: debug.h:303
#define SCIPdebugAddSolVal(scip, var, val)
Definition: debug.h:311
#define SCIPdebugCheckVbound(set, var, vbtype, vbvar, vbcoef, vbconstant)
Definition: debug.h:304
#define SCIPdebugCheckConss(scip, conss, nconss)
Definition: debug.h:296
#define SCIPdebugFreeDebugData(set)
Definition: debug.h:293
#define SCIPdebugSolIsEnabled(scip)
Definition: debug.h:316
#define SCIPdebugCheckAggregation(set, var, aggrvars, scalars, constant, naggrvars)
Definition: debug.h:306
#define SCIPdebugCheckBInvRow(scip, r, coef)
Definition: debug.h:337
#define SCIPdebugRemoveNode(blkmem, set, node)
Definition: debug.h:301
#define SCIPdebugSolIsValidInSubtree(scip, isvalidinsubtree)
Definition: debug.h:313
#define SCIPdebugReset(set)
Definition: debug.h:292
#define SCIPdebugCheckConflictFrontier(blkmem, set, node, bdchginfo, bdchginfos, relaxedbds, nliterals, bdchgqueue, forcedbdchgqueue)
Definition: debug.h:309
#define SCIPdebugIncludeProp(scip)
Definition: debug.h:310
#define SCIPdebugCheckInference(blkmem, set, node, var, newbound, boundtype)
Definition: debug.h:300
#define SCIPwithDebugSol(void)
Definition: debug.h:317
#define SCIPdebugSolDataCreate(debugsoldata)
Definition: debug.h:290
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
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:135
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