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 */
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 given variable bound is valid for the debugging solution */
120  SCIP_SET* set, /**< global SCIP settings */
121  SCIP_VAR* var, /**< problem variable x in x <= b*z + d or x >= b*z + d */
122  SCIP_BOUNDTYPE vbtype, /**< type of variable bound (LOWER or UPPER) */
123  SCIP_VAR* vbvar, /**< variable z in x <= b*z + d or x >= b*z + d */
124  SCIP_Real vbcoef, /**< coefficient b in x <= b*z + d or x >= b*z + d */
125  SCIP_Real vbconstant /**< constant d in x <= b*z + d or x >= b*z + d */
126  );
127 
128 /** checks whether given implication is valid for the debugging solution */
130  SCIP_SET* set, /**< global SCIP settings */
131  SCIP_VAR* var, /**< problem variable */
132  SCIP_Bool varfixing, /**< FALSE if y should be added in implications for x == 0, TRUE for x == 1 */
133  SCIP_VAR* implvar, /**< variable y in implication y <= b or y >= b */
134  SCIP_BOUNDTYPE impltype, /**< type of implication y <= b (SCIP_BOUNDTYPE_UPPER) or y >= b (SCIP_BOUNDTYPE_LOWER) */
135  SCIP_Real implbound /**< bound b in implication y <= b or y >= b */
136  );
137 
138 /** checks whether given (multi)-aggregation is valid for the debugging solution */
140  SCIP_SET* set, /**< global SCIP settings */
141  SCIP_VAR* var, /**< problem variable */
142  SCIP_VAR** aggrvars, /**< variables y_i in aggregation x = a_1*y_1 + ... + a_n*y_n + c */
143  SCIP_Real* scalars, /**< multipliers a_i in aggregation x = a_1*y_1 + ... + a_n*y_n + c */
144  SCIP_Real constant, /**< constant shift c in aggregation x = a_1*y_1 + ... + a_n*y_n + c */
145  int naggrvars /**< number n of variables in aggregation x = a_1*y_1 + ... + a_n*y_n + c */
146  );
147 
148 /** check whether given clique is valid for the debugging solution */
150  SCIP_SET* set, /**< global SCIP settings */
151  SCIP_VAR** vars, /**< binary variables in the clique: at most one can be set to the given value */
152  SCIP_Bool* values, /**< values of the variables in the clique; NULL to use TRUE for all vars */
153  int nvars /**< number of variables in the clique */
154  );
155 
156 /** checks whether given conflict is valid for the debugging solution */
158  BMS_BLKMEM* blkmem, /**< block memory */
159  SCIP_SET* set, /**< global SCIP settings */
160  SCIP_NODE* node, /**< node where the conflict clause is added */
161  SCIP_BDCHGINFO** bdchginfos, /**< bound change informations of the conflict set */
162  SCIP_Real* relaxedbds, /**< array with relaxed bounds which are efficient to create a valid conflict */
163  int nbdchginfos /**< number of bound changes in the conflict set */
164  );
165 
166 /** checks whether given conflict graph frontier is valid for the debugging solution */
168  BMS_BLKMEM* blkmem, /**< block memory */
169  SCIP_SET* set, /**< global SCIP settings */
170  SCIP_NODE* node, /**< node where the conflict clause is added */
171  SCIP_BDCHGINFO* bdchginfo, /**< bound change info which got resolved, or NULL */
172  SCIP_BDCHGINFO** bdchginfos, /**< bound change informations of the conflict set */
173  SCIP_Real* relaxedbds, /**< array with relaxed bounds which are efficient to create a valid conflict */
174  int nbdchginfos, /**< number of bound changes in the conflict set */
175  SCIP_PQUEUE* bdchgqueue, /**< unprocessed conflict bound changes */
176  SCIP_PQUEUE* forcedbdchgqueue /**< unprocessed conflict bound changes that must be resolved */
177  );
178 
179 /** creates the debugging propagator and includes it in SCIP */
181  SCIP* scip /**< SCIP data structure */
182  );
183 
184 /** adds a solution value for a new variable in the transformed problem that has no original counterpart
185  * a value can only be set if no value has been set for this variable before
186  */
188  SCIP* scip, /**< SCIP data structure */
189  SCIP_VAR* var, /**< variable for which to add a value */
190  SCIP_Real val /**< solution value for variable */
191  );
192 
193 /** gets pointer to the debug solution */
194 SCIP_RETCODE SCIPdebugGetSol(
195  SCIP* scip, /**< SCIP data structure */
196  SCIP_SOL** sol /**< buffer to store pointer to the debug solution */
197  );
198 
199 /** gets value for a variable in the debug solution
200  *
201  * if no value is stored for the variable, gives 0.0
202  */
204  SCIP* scip, /**< SCIP data structure */
205  SCIP_VAR* var, /**< variable for which to get the value */
206  SCIP_Real* val /**< buffer to store solution value */
207  );
208 
209 /** check whether the debugging solution is valid in the current node */
211  SCIP* scip, /**< SCIP data structure */
212  SCIP_Bool* isvalidinsubtree /**< pointer to store whether the solution is valid in the current
213  * subtree
214  */
215  );
216 
217 /** checks whether SCIP data structure is the main SCIP (the one for which debugging is enabled) */
218 SCIP_Bool SCIPdebugIsMainscip(
219  SCIP* scip /**< SCIP data structure */
220  );
221 
222 /** enabling solution debugging mechanism */
223 void SCIPdebugSolEnable(
224  SCIP* scip /**< SCIP data structure */
225  );
226 
227 /** disabling solution debugging mechanism */
229  SCIP* scip /**< SCIP data structure */
230  );
231 
232 /** check if solution debugging mechanism is enabled */
234  SCIP* scip /**< SCIP data structure */
235  );
236 
237 #else
238 
239 #define SCIPdebugSolDataCreate(debugsoldata) SCIP_OKAY
240 #define SCIPdebugFreeSol(set) SCIP_OKAY
241 #define SCIPdebugReset(set) SCIP_OKAY
242 #define SCIPdebugFreeDebugData(set) SCIP_OKAY
243 #define SCIPdebugCheckConss(scip,conss,nconss) SCIP_OKAY
244 #define SCIPdebugCheckRow(set,row) SCIP_OKAY
245 #define SCIPdebugCheckLbGlobal(scip,var,lb) SCIP_OKAY
246 #define SCIPdebugCheckUbGlobal(scip,var,ub) SCIP_OKAY
247 #define SCIPdebugCheckInference(blkmem,set,node,var,newbound,boundtype) SCIP_OKAY
248 #define SCIPdebugRemoveNode(blkmem,set,node) SCIP_OKAY
249 #define SCIPdebugCheckVbound(set,var,vbtype,vbvar,vbcoef,vbconstant) SCIP_OKAY
250 #define SCIPdebugCheckImplic(set,var,varfixing,implvar,impltype,implbound) SCIP_OKAY
251 #define SCIPdebugCheckAggregation(set,var,aggrvars,scalars,constant,naggrvars) SCIP_OKAY
252 #define SCIPdebugCheckClique(set,vars,values,nvars) SCIP_OKAY
253 #define SCIPdebugCheckConflict(blkmem,set,node,bdchginfos,relaxedbds,nliterals) SCIP_OKAY
254 #define SCIPdebugCheckConflictFrontier(blkmem,set,node,bdchginfo,bdchginfos,relaxedbds,nliterals,bdchgqueue,forcedbdchgqueue) SCIP_OKAY
255 #define SCIPdebugIncludeProp(scip) SCIP_OKAY
256 #define SCIPdebugAddSolVal(scip,var,val) SCIP_OKAY
257 #define SCIPdebugGetSolVal(scip,var,val) SCIP_OKAY
258 #define SCIPdebugSolIsValidInSubtree(scip,isvalidinsubtree) SCIP_OKAY
259 #define SCIPdebugSolEnable(scip) /**/
260 #define SCIPdebugSolDisable(scip) /**/
261 #define SCIPdebugSolIsEnabled(scip) FALSE
262 #endif
263 
264 
265 /*
266  * debug method for LP interface, to check if the LP interface works correct
267  */
268 #ifdef SCIP_DEBUG_LP_INTERFACE
269 
270 /* check if the coef is the r-th line of the inverse matrix B^-1; this is
271  * the case if (coef * B) is the r-th unit vector */
273  SCIP* scip, /**< SCIP data structure */
274  int r, /**< row number */
275  SCIP_Real* coef /**< pointer to store the coefficients of the row */
276  );
277 
278 #else
279 
280 #define SCIPdebugCheckBInvRow(scip,r,coef) SCIP_OKAY
281 
282 #endif
283 
284 /** checks, if SCIP is in one of the feasible stages */
285 #ifndef NDEBUG
286 
288  SCIP* scip, /**< SCIP data structure */
289  const char* method, /**< method that was called */
290  SCIP_Bool init, /**< may method be called in the INIT stage? */
291  SCIP_Bool problem, /**< may method be called in the PROBLEM stage? */
292  SCIP_Bool transforming, /**< may method be called in the TRANSFORMING stage? */
293  SCIP_Bool transformed, /**< may method be called in the TRANSFORMED stage? */
294  SCIP_Bool initpresolve, /**< may method be called in the INITPRESOLVE stage? */
295  SCIP_Bool presolving, /**< may method be called in the PRESOLVING stage? */
296  SCIP_Bool exitpresolve, /**< may method be called in the EXITPRESOLE stage? */
297  SCIP_Bool presolved, /**< may method be called in the PRESOLVED stage? */
298  SCIP_Bool initsolve, /**< may method be called in the INITSOLVE stage? */
299  SCIP_Bool solving, /**< may method be called in the SOLVING stage? */
300  SCIP_Bool solved, /**< may method be called in the SOLVED stage? */
301  SCIP_Bool exitsolve, /**< may method be called in the EXITSOLVE stage? */
302  SCIP_Bool freetrans, /**< may method be called in the FREETRANS stage? */
303  SCIP_Bool freescip /**< may method be called in the FREE stage? */
304  );
305 #else
306 
307 #define SCIPcheckStage(scip,method,init,problem,transforming,transformed,initpresolve,presolving,exitpresolve,presolved, \
308  initsolve,solving,solved,exitsolve,freetrans,freescip) SCIP_OKAY
309 
310 #endif
311 
312 #ifdef __cplusplus
313 }
314 #endif
315 
316 #endif
enum SCIP_BoundType SCIP_BOUNDTYPE
Definition: type_lp.h:50
#define SCIPdebugRemoveNode(blkmem, set, node)
Definition: debug.h:248
type definitions for miscellaneous datastructures
#define SCIPdebugFreeDebugData(set)
Definition: debug.h:242
#define SCIPdebugCheckImplic(set, var, varfixing, implvar, impltype, implbound)
Definition: debug.h:250
#define SCIPdebugSolDataCreate(debugsoldata)
Definition: debug.h:239
#define SCIPdebugCheckClique(set, vars, values, nvars)
Definition: debug.h:252
#define SCIPdebugCheckRow(set, row)
Definition: debug.h:244
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:249
type definitions for LP management
#define SCIPdebugCheckConflict(blkmem, set, node, bdchginfos, relaxedbds, nliterals)
Definition: debug.h:253
struct SCIP_DebugSolData SCIP_DEBUGSOLDATA
Definition: debug.h:50
#define SCIPdebugIncludeProp(scip)
Definition: debug.h:255
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:247
type definitions for SCIP&#39;s main datastructure
#define SCIPdebugCheckAggregation(set, var, aggrvars, scalars, constant, naggrvars)
Definition: debug.h:251
type definitions for problem variables
#define SCIPdebugCheckBInvRow(scip, r, coef)
Definition: debug.h:280
#define SCIPdebugCheckLbGlobal(scip, var, lb)
Definition: debug.h:245
#define SCIPdebugGetSolVal(scip, var, val)
Definition: debug.h:257
#define SCIPdebugCheckUbGlobal(scip, var, ub)
Definition: debug.h:246
#define SCIPdebugCheckConss(scip, conss, nconss)
Definition: debug.h:243
#define SCIP_Bool
Definition: def.h:70
#define SCIPdebugSolIsValidInSubtree(scip, isvalidinsubtree)
Definition: debug.h:258
#define SCIPdebugCheckConflictFrontier(blkmem, set, node, bdchginfo, bdchginfos, relaxedbds, nliterals, bdchgqueue, forcedbdchgqueue)
Definition: debug.h:254
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:241
static const SCIP_Real scalars[]
Definition: lp.c:5650
#define SCIPdebugSolDisable(scip)
Definition: debug.h:260
#define SCIP_Real
Definition: def.h:164
#define SCIPdebugAddSolVal(scip, var, val)
Definition: debug.h:256
#define SCIPdebugSolIsEnabled(scip)
Definition: debug.h:261
common defines and data types used in all packages of SCIP
struct BMS_BlkMem BMS_BLKMEM
Definition: memory.h:427
#define SCIPdebugSolEnable(scip)
Definition: debug.h:259
#define SCIPdebugFreeSol(set)
Definition: debug.h:240
type definitions for constraints and constraint handlers
memory allocation routines