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