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