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-2022 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 for the particular instance */
71  SCIP_SET* set /**< global SCIP settings */
72  );
73 
74 /** frees all debugging data */
76  SCIP_SET* set /**< global SCIP settings */
77  );
78 
79 /** checks for validity of the debugging solution in given constraints */
81  SCIP* scip, /**< SCIP data structure */
82  SCIP_CONS** conss, /**< constraints to check for validity */
83  int nconss /**< number of given constraints */
84  );
85 
86 /** checks whether given row is valid for the debugging solution */
88  SCIP_SET* set, /**< global SCIP settings */
89  SCIP_ROW* row /**< row to check for validity */
90  );
91 
92 /** checks whether given global lower bound is valid for the debugging solution */
94  SCIP* scip, /**< SCIP data structure */
95  SCIP_VAR* var, /**< problem variable */
96  SCIP_Real lb /**< lower bound */
97  );
98 
99 /** checks whether given global upper bound is valid for the debugging solution */
101  SCIP* scip, /**< SCIP data structure */
102  SCIP_VAR* var, /**< problem variable */
103  SCIP_Real ub /**< upper bound */
104  );
105 
106 /** checks whether given local bound implication is valid for the debugging solution */
108  BMS_BLKMEM* blkmem, /**< block memory */
109  SCIP_SET* set, /**< global SCIP settings */
110  SCIP_NODE* node, /**< local node where this bound change was applied */
111  SCIP_VAR* var, /**< problem variable */
112  SCIP_Real newbound, /**< new value for bound */
113  SCIP_BOUNDTYPE boundtype /**< type of bound: lower or upper bound */
114  );
115 
116 /** informs solution debugger, that the given node will be freed */
118  BMS_BLKMEM* blkmem, /**< block memory */
119  SCIP_SET* set, /**< global SCIP settings */
120  SCIP_NODE* node /**< node that will be freed */
121  );
122 
123 /** checks whether global lower bound does not exceed debuging solution value */
125  BMS_BLKMEM* blkmem, /**< block memory */
126  SCIP_SET* set /**< global SCIP settings */
127  );
128 
129 /** checks whether local lower bound does not exceed debuging solution value */
131  BMS_BLKMEM* blkmem, /**< block memory */
132  SCIP_SET* set, /**< global SCIP settings */
133  SCIP_NODE* node /**< node that will be freed */
134  );
135 
136 /** checks whether given variable bound is valid for the debugging solution */
138  SCIP_SET* set, /**< global SCIP settings */
139  SCIP_VAR* var, /**< problem variable x in x <= b*z + d or x >= b*z + d */
140  SCIP_BOUNDTYPE vbtype, /**< type of variable bound (LOWER or UPPER) */
141  SCIP_VAR* vbvar, /**< variable z in x <= b*z + d or x >= b*z + d */
142  SCIP_Real vbcoef, /**< coefficient b in x <= b*z + d or x >= b*z + d */
143  SCIP_Real vbconstant /**< constant d in x <= b*z + d or x >= b*z + d */
144  );
145 
146 /** checks whether given implication is valid for the debugging solution */
148  SCIP_SET* set, /**< global SCIP settings */
149  SCIP_VAR* var, /**< problem variable */
150  SCIP_Bool varfixing, /**< FALSE if y should be added in implications for x == 0, TRUE for x == 1 */
151  SCIP_VAR* implvar, /**< variable y in implication y <= b or y >= b */
152  SCIP_BOUNDTYPE impltype, /**< type of implication y <= b (SCIP_BOUNDTYPE_UPPER) or y >= b (SCIP_BOUNDTYPE_LOWER) */
153  SCIP_Real implbound /**< bound b in implication y <= b or y >= b */
154  );
155 
156 /** checks whether given (multi)-aggregation is valid for the debugging solution */
158  SCIP_SET* set, /**< global SCIP settings */
159  SCIP_VAR* var, /**< problem variable */
160  SCIP_VAR** aggrvars, /**< variables y_i in aggregation x = a_1*y_1 + ... + a_n*y_n + c */
161  SCIP_Real* scalars, /**< multipliers a_i in aggregation x = a_1*y_1 + ... + a_n*y_n + c */
162  SCIP_Real constant, /**< constant shift c in aggregation x = a_1*y_1 + ... + a_n*y_n + c */
163  int naggrvars /**< number n of variables in aggregation x = a_1*y_1 + ... + a_n*y_n + c */
164  );
165 
166 /** check whether given clique is valid for the debugging solution */
168  SCIP_SET* set, /**< global SCIP settings */
169  SCIP_VAR** vars, /**< binary variables in the clique: at most one can be set to the given value */
170  SCIP_Bool* values, /**< values of the variables in the clique; NULL to use TRUE for all vars */
171  int nvars /**< number of variables in the clique */
172  );
173 
174 /** checks whether given conflict is valid for the debugging solution */
176  BMS_BLKMEM* blkmem, /**< block memory */
177  SCIP_SET* set, /**< global SCIP settings */
178  SCIP_NODE* node, /**< node where the conflict clause is added */
179  SCIP_BDCHGINFO** bdchginfos, /**< bound change informations of the conflict set */
180  SCIP_Real* relaxedbds, /**< array with relaxed bounds which are efficient to create a valid conflict */
181  int nbdchginfos /**< number of bound changes in the conflict set */
182  );
183 
184 /** checks whether given conflict graph frontier is valid for the debugging solution */
186  BMS_BLKMEM* blkmem, /**< block memory */
187  SCIP_SET* set, /**< global SCIP settings */
188  SCIP_NODE* node, /**< node where the conflict clause is added */
189  SCIP_BDCHGINFO* bdchginfo, /**< bound change info which got resolved, or NULL */
190  SCIP_BDCHGINFO** bdchginfos, /**< bound change informations of the conflict set */
191  SCIP_Real* relaxedbds, /**< array with relaxed bounds which are efficient to create a valid conflict */
192  int nbdchginfos, /**< number of bound changes in the conflict set */
193  SCIP_PQUEUE* bdchgqueue, /**< unprocessed conflict bound changes */
194  SCIP_PQUEUE* forcedbdchgqueue /**< unprocessed conflict bound changes that must be resolved */
195  );
196 
197 /** creates the debugging propagator and includes it in SCIP */
199  SCIP* scip /**< SCIP data structure */
200  );
201 
202 /** adds a solution value for a new variable in the transformed problem that has no original counterpart
203  * a value can only be set if no value has been set for this variable before
204  */
206  SCIP* scip, /**< SCIP data structure */
207  SCIP_VAR* var, /**< variable for which to add a value */
208  SCIP_Real val /**< solution value for variable */
209  );
210 
211 /** gets pointer to the debug solution */
212 SCIP_RETCODE SCIPdebugGetSol(
213  SCIP* scip, /**< SCIP data structure */
214  SCIP_SOL** sol /**< buffer to store pointer to the debug solution */
215  );
216 
217 /** gets value for a variable in the debug solution
218  *
219  * if no value is stored for the variable, gives 0.0
220  */
222  SCIP* scip, /**< SCIP data structure */
223  SCIP_VAR* var, /**< variable for which to get the value */
224  SCIP_Real* val /**< buffer to store solution value */
225  );
226 
227 /** check whether the debugging solution is valid in the current node */
229  SCIP* scip, /**< SCIP data structure */
230  SCIP_Bool* isvalidinsubtree /**< pointer to store whether the solution is valid in the current
231  * subtree
232  */
233  );
234 
235 /** checks whether SCIP data structure is the main SCIP (the one for which debugging is enabled) */
236 SCIP_Bool SCIPdebugIsMainscip(
237  SCIP* scip /**< SCIP data structure */
238  );
239 
240 /** enabling solution debugging mechanism */
241 void SCIPdebugSolEnable(
242  SCIP* scip /**< SCIP data structure */
243  );
244 
245 /** disabling solution debugging mechanism */
247  SCIP* scip /**< SCIP data structure */
248  );
249 
250 /** check if solution debugging mechanism is enabled */
252  SCIP* scip /**< SCIP data structure */
253  );
254 
255 /** check if SCIP is compiled with WITH_DEBUG_SOLUTION */
257 
258 #else
259 
260 #define SCIPdebugSolDataCreate(debugsoldata) SCIP_OKAY
261 #define SCIPdebugFreeSol(set) SCIP_OKAY
262 #define SCIPdebugReset(set) SCIP_OKAY
263 #define SCIPdebugFreeDebugData(set) SCIP_OKAY
264 #define SCIPdebugFree(set) SCIP_OKAY
265 #define SCIPdebugCheckConss(scip,conss,nconss) SCIP_OKAY
266 #define SCIPdebugCheckRow(set,row) SCIP_OKAY
267 #define SCIPdebugCheckLbGlobal(scip,var,lb) SCIP_OKAY
268 #define SCIPdebugCheckUbGlobal(scip,var,ub) SCIP_OKAY
269 #define SCIPdebugCheckInference(blkmem,set,node,var,newbound,boundtype) SCIP_OKAY
270 #define SCIPdebugRemoveNode(blkmem,set,node) SCIP_OKAY
271 #define SCIPdebugCheckGlobalLowerbound(blkmem,set) SCIP_OKAY
272 #define SCIPdebugCheckLocalLowerbound(blkmem,set,node) SCIP_OKAY
273 #define SCIPdebugCheckVbound(set,var,vbtype,vbvar,vbcoef,vbconstant) SCIP_OKAY
274 #define SCIPdebugCheckImplic(set,var,varfixing,implvar,impltype,implbound) SCIP_OKAY
275 #define SCIPdebugCheckAggregation(set,var,aggrvars,scalars,constant,naggrvars) SCIP_OKAY
276 #define SCIPdebugCheckClique(set,vars,values,nvars) SCIP_OKAY
277 #define SCIPdebugCheckConflict(blkmem,set,node,bdchginfos,relaxedbds,nliterals) SCIP_OKAY
278 #define SCIPdebugCheckConflictFrontier(blkmem,set,node,bdchginfo,bdchginfos,relaxedbds,nliterals,bdchgqueue,forcedbdchgqueue) SCIP_OKAY
279 #define SCIPdebugIncludeProp(scip) SCIP_OKAY
280 #define SCIPdebugAddSolVal(scip,var,val) SCIP_OKAY
281 #define SCIPdebugGetSolVal(scip,var,val) SCIP_OKAY
282 #define SCIPdebugSolIsValidInSubtree(scip,isvalidinsubtree) SCIP_OKAY
283 #define SCIPdebugSolEnable(scip) /**/
284 #define SCIPdebugSolDisable(scip) /**/
285 #define SCIPdebugSolIsEnabled(scip) FALSE
286 #define SCIPwithDebugSol(void) FALSE
287 
288 #endif
289 
290 
291 /*
292  * debug method for LP interface, to check if the LP interface works correct
293  */
294 #ifdef SCIP_DEBUG_LP_INTERFACE
295 
296 /* check if the coef is the r-th line of the inverse matrix B^-1; this is
297  * the case if (coef * B) is the r-th unit vector */
299  SCIP* scip, /**< SCIP data structure */
300  int r, /**< row number */
301  SCIP_Real* coef /**< pointer to store the coefficients of the row */
302  );
303 
304 #else
305 
306 #define SCIPdebugCheckBInvRow(scip,r,coef) SCIP_OKAY
307 
308 #endif
309 
310 /** checks, if SCIP is in one of the feasible stages */
311 #ifndef NDEBUG
312 
314  SCIP* scip, /**< SCIP data structure */
315  const char* method, /**< method that was called */
316  SCIP_Bool init, /**< may method be called in the INIT stage? */
317  SCIP_Bool problem, /**< may method be called in the PROBLEM stage? */
318  SCIP_Bool transforming, /**< may method be called in the TRANSFORMING stage? */
319  SCIP_Bool transformed, /**< may method be called in the TRANSFORMED stage? */
320  SCIP_Bool initpresolve, /**< may method be called in the INITPRESOLVE stage? */
321  SCIP_Bool presolving, /**< may method be called in the PRESOLVING stage? */
322  SCIP_Bool exitpresolve, /**< may method be called in the EXITPRESOLE stage? */
323  SCIP_Bool presolved, /**< may method be called in the PRESOLVED stage? */
324  SCIP_Bool initsolve, /**< may method be called in the INITSOLVE stage? */
325  SCIP_Bool solving, /**< may method be called in the SOLVING stage? */
326  SCIP_Bool solved, /**< may method be called in the SOLVED stage? */
327  SCIP_Bool exitsolve, /**< may method be called in the EXITSOLVE stage? */
328  SCIP_Bool freetrans, /**< may method be called in the FREETRANS stage? */
329  SCIP_Bool freescip /**< may method be called in the FREE stage? */
330  );
331 #else
332 
333 #define SCIPcheckStage(scip,method,init,problem,transforming,transformed,initpresolve,presolving,exitpresolve,presolved, \
334  initsolve,solving,solved,exitsolve,freetrans,freescip) SCIP_OKAY
335 
336 #endif
337 
338 #ifdef __cplusplus
339 }
340 #endif
341 
342 #endif
enum SCIP_BoundType SCIP_BOUNDTYPE
Definition: type_lp.h:50
#define SCIPdebugRemoveNode(blkmem, set, node)
Definition: debug.h:270
type definitions for miscellaneous datastructures
#define SCIPdebugFreeDebugData(set)
Definition: debug.h:263
#define SCIPdebugCheckImplic(set, var, varfixing, implvar, impltype, implbound)
Definition: debug.h:274
#define SCIPdebugSolDataCreate(debugsoldata)
Definition: debug.h:260
#define SCIPdebugCheckClique(set, vars, values, nvars)
Definition: debug.h:276
#define SCIPdebugCheckRow(set, row)
Definition: debug.h:266
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:54
type definitions for global SCIP settings
#define SCIPdebugCheckLocalLowerbound(blkmem, set, node)
Definition: debug.h:272
type definitions for return codes for SCIP methods
#define SCIPdebugCheckVbound(set, var, vbtype, vbvar, vbcoef, vbconstant)
Definition: debug.h:273
type definitions for LP management
#define SCIPdebugCheckConflict(blkmem, set, node, bdchginfos, relaxedbds, nliterals)
Definition: debug.h:277
struct SCIP_DebugSolData SCIP_DEBUGSOLDATA
Definition: debug.h:50
#define SCIPdebugIncludeProp(scip)
Definition: debug.h:279
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:2177
#define SCIPdebugCheckInference(blkmem, set, node, var, newbound, boundtype)
Definition: debug.h:269
type definitions for SCIP&#39;s main datastructure
#define SCIPdebugCheckAggregation(set, var, aggrvars, scalars, constant, naggrvars)
Definition: debug.h:275
#define SCIPdebugFree(set)
Definition: debug.h:264
type definitions for problem variables
#define SCIPdebugCheckBInvRow(scip, r, coef)
Definition: debug.h:306
#define SCIPdebugCheckLbGlobal(scip, var, lb)
Definition: debug.h:267
#define SCIPdebugGetSolVal(scip, var, val)
Definition: debug.h:281
#define SCIPdebugCheckUbGlobal(scip, var, ub)
Definition: debug.h:268
#define SCIPdebugCheckConss(scip, conss, nconss)
Definition: debug.h:265
#define SCIP_Bool
Definition: def.h:84
#define SCIPdebugSolIsValidInSubtree(scip, isvalidinsubtree)
Definition: debug.h:282
#define SCIPdebugCheckGlobalLowerbound(blkmem, set)
Definition: debug.h:271
#define SCIPdebugCheckConflictFrontier(blkmem, set, node, bdchginfo, bdchginfos, relaxedbds, nliterals, bdchgqueue, forcedbdchgqueue)
Definition: debug.h:278
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:262
static const SCIP_Real scalars[]
Definition: lp.c:5738
#define SCIPdebugSolDisable(scip)
Definition: debug.h:284
#define SCIP_Real
Definition: def.h:177
#define SCIPwithDebugSol(void)
Definition: debug.h:286
#define SCIPdebugAddSolVal(scip, var, val)
Definition: debug.h:280
#define SCIPdebugSolIsEnabled(scip)
Definition: debug.h:285
common defines and data types used in all packages of SCIP
struct BMS_BlkMem BMS_BLKMEM
Definition: memory.h:430
#define SCIPdebugSolEnable(scip)
Definition: debug.h:283
#define SCIPdebugFreeSol(set)
Definition: debug.h:261
type definitions for constraints and constraint handlers
memory allocation routines