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-2019 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 /** checks whether given (multi)-aggregation is valid for the debugging solution */
150  SCIP_SET* set, /**< global SCIP settings */
151  SCIP_VAR* var, /**< problem variable */
152  SCIP_VAR** aggrvars, /**< variables y_i in aggregation x = a_1*y_1 + ... + a_n*y_n + c */
153  SCIP_Real* scalars, /**< multipliers a_i in aggregation x = a_1*y_1 + ... + a_n*y_n + c */
154  SCIP_Real constant, /**< constant shift c in aggregation x = a_1*y_1 + ... + a_n*y_n + c */
155  int naggrvars /**< number n of variables in aggregation x = a_1*y_1 + ... + a_n*y_n + c */
156  );
157 
158 /** check whether given clique is valid for the debugging solution */
159 extern
161  SCIP_SET* set, /**< global SCIP settings */
162  SCIP_VAR** vars, /**< binary variables in the clique: at most one can be set to the given value */
163  SCIP_Bool* values, /**< values of the variables in the clique; NULL to use TRUE for all vars */
164  int nvars /**< number of variables in the clique */
165  );
166 
167 /** checks whether given conflict is valid for the debugging solution */
168 extern
170  BMS_BLKMEM* blkmem, /**< block memory */
171  SCIP_SET* set, /**< global SCIP settings */
172  SCIP_NODE* node, /**< node where the conflict clause is added */
173  SCIP_BDCHGINFO** bdchginfos, /**< bound change informations of the conflict set */
174  SCIP_Real* relaxedbds, /**< array with relaxed bounds which are efficient to create a valid conflict */
175  int nbdchginfos /**< number of bound changes in the conflict set */
176  );
177 
178 /** checks whether given conflict graph frontier is valid for the debugging solution */
179 extern
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 */
193 extern
195  SCIP* scip /**< SCIP data structure */
196  );
197 
198 /** adds a solution value for a new variable in the transformed problem that has no original counterpart
199  * a value can only be set if no value has been set for this variable before
200  */
201 extern
203  SCIP* scip, /**< SCIP data structure */
204  SCIP_VAR* var, /**< variable for which to add a value */
205  SCIP_Real val /**< solution value for variable */
206  );
207 
208 /** gets pointer to the debug solution */
209 extern
210 SCIP_RETCODE SCIPdebugGetSol(
211  SCIP* scip, /**< SCIP data structure */
212  SCIP_SOL** sol /**< buffer to store pointer to the debug solution */
213  );
214 
215 /** gets value for a variable in the debug solution
216  *
217  * if no value is stored for the variable, gives 0.0
218  */
219 extern
221  SCIP* scip, /**< SCIP data structure */
222  SCIP_VAR* var, /**< variable for which to get the value */
223  SCIP_Real* val /**< buffer to store solution value */
224  );
225 
226 /** check whether the debugging solution is valid in the current node */
227 extern
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 extern
237 SCIP_Bool SCIPdebugIsMainscip(
238  SCIP* scip /**< SCIP data structure */
239  );
240 
241 /** enabling solution debugging mechanism */
242 extern
243 void SCIPdebugSolEnable(
244  SCIP* scip /**< SCIP data structure */
245  );
246 
247 /** disabling solution debugging mechanism */
248 extern
250  SCIP* scip /**< SCIP data structure */
251  );
252 
253 /** check if solution debugging mechanism is enabled */
254 extern
256  SCIP* scip /**< SCIP data structure */
257  );
258 
259 #else
260 
261 #define SCIPdebugSolDataCreate(debugsoldata) SCIP_OKAY
262 #define SCIPdebugFreeSol(set) SCIP_OKAY
263 #define SCIPdebugReset(set) SCIP_OKAY
264 #define SCIPdebugFreeDebugData(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 SCIPdebugCheckVbound(set,var,vbtype,vbvar,vbcoef,vbconstant) SCIP_OKAY
272 #define SCIPdebugCheckImplic(set,var,varfixing,implvar,impltype,implbound) SCIP_OKAY
273 #define SCIPdebugCheckAggregation(set,var,aggrvars,scalars,constant,naggrvars) SCIP_OKAY
274 #define SCIPdebugCheckClique(set,vars,values,nvars) SCIP_OKAY
275 #define SCIPdebugCheckConflict(blkmem,set,node,bdchginfos,relaxedbds,nliterals) SCIP_OKAY
276 #define SCIPdebugCheckConflictFrontier(blkmem,set,node,bdchginfo,bdchginfos,relaxedbds,nliterals,bdchgqueue,forcedbdchgqueue) SCIP_OKAY
277 #define SCIPdebugIncludeProp(scip) SCIP_OKAY
278 #define SCIPdebugAddSolVal(scip,var,val) SCIP_OKAY
279 #define SCIPdebugGetSolVal(scip,var,val) SCIP_OKAY
280 #define SCIPdebugSolIsValidInSubtree(scip,isvalidinsubtree) SCIP_OKAY
281 #define SCIPdebugSolEnable(scip) /**/
282 #define SCIPdebugSolDisable(scip) /**/
283 #define SCIPdebugSolIsEnabled(scip) FALSE
284 #endif
285 
286 
287 /*
288  * debug method for LP interface, to check if the LP interface works correct
289  */
290 #ifdef SCIP_DEBUG_LP_INTERFACE
291 
292 /* check if the coef is the r-th line of the inverse matrix B^-1; this is
293  * the case if (coef * B) is the r-th unit vector */
294 extern
296  SCIP* scip, /**< SCIP data structure */
297  int r, /**< row number */
298  SCIP_Real* coef /**< pointer to store the coefficients of the row */
299  );
300 
301 #else
302 
303 #define SCIPdebugCheckBInvRow(scip,r,coef) SCIP_OKAY
304 
305 #endif
306 
307 /** checks, if SCIP is in one of the feasible stages */
308 #ifndef NDEBUG
309 
311  SCIP* scip, /**< SCIP data structure */
312  const char* method, /**< method that was called */
313  SCIP_Bool init, /**< may method be called in the INIT stage? */
314  SCIP_Bool problem, /**< may method be called in the PROBLEM stage? */
315  SCIP_Bool transforming, /**< may method be called in the TRANSFORMING stage? */
316  SCIP_Bool transformed, /**< may method be called in the TRANSFORMED stage? */
317  SCIP_Bool initpresolve, /**< may method be called in the INITPRESOLVE stage? */
318  SCIP_Bool presolving, /**< may method be called in the PRESOLVING stage? */
319  SCIP_Bool exitpresolve, /**< may method be called in the EXITPRESOLE stage? */
320  SCIP_Bool presolved, /**< may method be called in the PRESOLVED stage? */
321  SCIP_Bool initsolve, /**< may method be called in the INITSOLVE stage? */
322  SCIP_Bool solving, /**< may method be called in the SOLVING stage? */
323  SCIP_Bool solved, /**< may method be called in the SOLVED stage? */
324  SCIP_Bool exitsolve, /**< may method be called in the EXITSOLVE stage? */
325  SCIP_Bool freetrans, /**< may method be called in the FREETRANS stage? */
326  SCIP_Bool freescip /**< may method be called in the FREE stage? */
327  );
328 #else
329 
330 #define SCIPcheckStage(scip,method,init,problem,transforming,transformed,initpresolve,presolving,exitpresolve,presolved, \
331  initsolve,solving,solved,exitsolve,freetrans,freescip) SCIP_OKAY
332 
333 #endif
334 
335 #ifdef __cplusplus
336 }
337 #endif
338 
339 #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:264
#define SCIPdebugCheckImplic(set, var, varfixing, implvar, impltype, implbound)
Definition: debug.h:272
#define SCIPdebugSolDataCreate(debugsoldata)
Definition: debug.h:261
#define SCIPdebugCheckClique(set, vars, values, nvars)
Definition: debug.h:274
#define SCIPdebugCheckRow(set, row)
Definition: debug.h:266
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:271
type definitions for LP management
#define SCIPdebugCheckConflict(blkmem, set, node, bdchginfos, relaxedbds, nliterals)
Definition: debug.h:275
struct SCIP_DebugSolData SCIP_DEBUGSOLDATA
Definition: debug.h:50
#define SCIPdebugIncludeProp(scip)
Definition: debug.h:277
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:2010
#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:273
type definitions for problem variables
#define SCIPdebugCheckBInvRow(scip, r, coef)
Definition: debug.h:303
#define SCIPdebugCheckLbGlobal(scip, var, lb)
Definition: debug.h:267
#define SCIPdebugGetSolVal(scip, var, val)
Definition: debug.h:279
#define SCIPdebugCheckUbGlobal(scip, var, ub)
Definition: debug.h:268
#define SCIPdebugCheckConss(scip, conss, nconss)
Definition: debug.h:265
#define SCIP_Bool
Definition: def.h:69
#define SCIPdebugSolIsValidInSubtree(scip, isvalidinsubtree)
Definition: debug.h:280
#define SCIPdebugCheckConflictFrontier(blkmem, set, node, bdchginfo, bdchginfos, relaxedbds, nliterals, bdchgqueue, forcedbdchgqueue)
Definition: debug.h:276
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:263
static const SCIP_Real scalars[]
Definition: lp.c:5650
#define SCIPdebugSolDisable(scip)
Definition: debug.h:282
#define SCIP_Real
Definition: def.h:157
#define SCIPdebugAddSolVal(scip, var, val)
Definition: debug.h:278
#define SCIPdebugSolIsEnabled(scip)
Definition: debug.h:283
common defines and data types used in all packages of SCIP
struct BMS_BlkMem BMS_BLKMEM
Definition: memory.h:426
#define SCIPdebugSolEnable(scip)
Definition: debug.h:281
#define SCIPdebugFreeSol(set)
Definition: debug.h:262
type definitions for constraints and constraint handlers
memory allocation routines