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-2017 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 email to 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 
31 #include "scip/def.h"
32 #include "blockmemshell/memory.h"
33 #include "scip/type_retcode.h"
34 #include "scip/type_lp.h"
35 #include "scip/type_prob.h"
36 #include "scip/type_tree.h"
37 #include "scip/type_misc.h"
38 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
43 /** solution data for debugging purposes */
44 typedef struct SCIP_DebugSolData SCIP_DEBUGSOLDATA;
45 
46 #ifdef WITH_DEBUG_SOLUTION
47 
48 /** creates debug solution data */
50  SCIP_DEBUGSOLDATA** debugsoldata /**< pointer to debug solution data */
51  );
52 
53 /** frees the debug solution */
55  SCIP_SET* set
56  );
57 
58 /** resets the data structure after restart */
59 extern
61  SCIP_SET* set
62  );
63 
64 /** frees debugging data */
65 extern
67  SCIP_SET* set /**< global SCIP settings */
68  );
69 
70 /** checks for validity of the debugging solution in given constraints */
71 extern
73  SCIP* scip, /**< SCIP data structure */
74  SCIP_CONS** conss, /**< constraints to check for validity */
75  int nconss /**< number of given constraints */
76  );
77 
78 /** checks whether given row is valid for the debugging solution */
79 extern
81  SCIP_SET* set, /**< global SCIP settings */
82  SCIP_ROW* row /**< row to check for validity */
83  );
84 
85 /** checks whether given global lower bound is valid for the debugging solution */
86 extern
88  SCIP* scip, /**< SCIP data structure */
89  SCIP_VAR* var, /**< problem variable */
90  SCIP_Real lb /**< lower bound */
91  );
92 
93 /** checks whether given global upper bound is valid for the debugging solution */
94 extern
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 */
102 extern
104  BMS_BLKMEM* blkmem, /**< block memory */
105  SCIP_SET* set, /**< global SCIP settings */
106  SCIP_NODE* node, /**< local node where this bound change was applied */
107  SCIP_VAR* var, /**< problem variable */
108  SCIP_Real newbound, /**< new value for bound */
109  SCIP_BOUNDTYPE boundtype /**< type of bound: lower or upper bound */
110  );
111 
112 /** informs solution debugger, that the given node will be freed */
113 extern
115  BMS_BLKMEM* blkmem, /**< block memory */
116  SCIP_SET* set, /**< global SCIP settings */
117  SCIP_NODE* node /**< node that will be freed */
118  );
119 
120 /** checks whether given variable bound is valid for the debugging solution */
121 extern
123  SCIP_SET* set, /**< global SCIP settings */
124  SCIP_VAR* var, /**< problem variable x in x <= b*z + d or x >= b*z + d */
125  SCIP_BOUNDTYPE vbtype, /**< type of variable bound (LOWER or UPPER) */
126  SCIP_VAR* vbvar, /**< variable z in x <= b*z + d or x >= b*z + d */
127  SCIP_Real vbcoef, /**< coefficient b in x <= b*z + d or x >= b*z + d */
128  SCIP_Real vbconstant /**< constant d in x <= b*z + d or x >= b*z + d */
129  );
130 
131 /** checks whether given implication is valid for the debugging solution */
132 extern
134  SCIP_SET* set, /**< global SCIP settings */
135  SCIP_VAR* var, /**< problem variable */
136  SCIP_Bool varfixing, /**< FALSE if y should be added in implications for x == 0, TRUE for x == 1 */
137  SCIP_VAR* implvar, /**< variable y in implication y <= b or y >= b */
138  SCIP_BOUNDTYPE impltype, /**< type of implication y <= b (SCIP_BOUNDTYPE_UPPER) or y >= b (SCIP_BOUNDTYPE_LOWER) */
139  SCIP_Real implbound /**< bound b in implication y <= b or y >= b */
140  );
141 
142 /** check whether given clique is valid for the debugging solution */
143 extern
145  SCIP_SET* set, /**< global SCIP settings */
146  SCIP_VAR** vars, /**< binary variables in the clique: at most one can be set to the given value */
147  SCIP_Bool* values, /**< values of the variables in the clique; NULL to use TRUE for all vars */
148  int nvars /**< number of variables in the clique */
149  );
150 
151 /** checks whether given conflict is valid for the debugging solution */
152 extern
154  BMS_BLKMEM* blkmem, /**< block memory */
155  SCIP_SET* set, /**< global SCIP settings */
156  SCIP_NODE* node, /**< node where the conflict clause is added */
157  SCIP_BDCHGINFO** bdchginfos, /**< bound change informations of the conflict set */
158  SCIP_Real* relaxedbds, /**< array with relaxed bounds which are efficient to create a valid conflict */
159  int nbdchginfos /**< number of bound changes in the conflict set */
160  );
161 
162 /** checks whether given conflict graph frontier is valid for the debugging solution */
163 extern
165  BMS_BLKMEM* blkmem, /**< block memory */
166  SCIP_SET* set, /**< global SCIP settings */
167  SCIP_NODE* node, /**< node where the conflict clause is added */
168  SCIP_BDCHGINFO* bdchginfo, /**< bound change info which got resolved, or NULL */
169  SCIP_BDCHGINFO** bdchginfos, /**< bound change informations of the conflict set */
170  SCIP_Real* relaxedbds, /**< array with relaxed bounds which are efficient to create a valid conflict */
171  int nbdchginfos, /**< number of bound changes in the conflict set */
172  SCIP_PQUEUE* bdchgqueue, /**< unprocessed conflict bound changes */
173  SCIP_PQUEUE* forcedbdchgqueue /**< unprocessed conflict bound changes that must be resolved */
174  );
175 
176 /** creates the debugging propagator and includes it in SCIP */
177 extern
179  SCIP* scip /**< SCIP data structure */
180  );
181 
182 /** adds a solution value for a new variable in the transformed problem that has no original counterpart
183  * a value can only be set if no value has been set for this variable before
184  */
185 extern
187  SCIP* scip, /**< SCIP data structure */
188  SCIP_VAR* var, /**< variable for which to add a value */
189  SCIP_Real val /**< solution value for variable */
190  );
191 
192 /** gets pointer to the debug solution */
193 extern
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  */
203 extern
205  SCIP* scip, /**< SCIP data structure */
206  SCIP_VAR* var, /**< variable for which to get the value */
207  SCIP_Real* val /**< buffer to store solution value */
208  );
209 
210 /** check whether the debugging solution is valid in the current node */
211 extern
213  SCIP* scip, /**< SCIP data structure */
214  SCIP_Bool* isvalidinsubtree /**< pointer to store whether the solution is valid in the current
215  * subtree
216  */
217  );
218 
219 /** checks whether SCIP data structure is the main SCIP (the one for which debugging is enabled) */
220 extern
221 SCIP_Bool SCIPdebugIsMainscip(
222  SCIP* scip /**< SCIP data structure */
223  );
224 
225 /** enabling solution debugging mechanism */
226 extern
227 void SCIPdebugSolEnable(
228  SCIP* scip /**< SCIP data structure */
229  );
230 
231 /** disabling solution debugging mechanism */
232 extern
234  SCIP* scip /**< SCIP data structure */
235  );
236 
237 /** check if solution debugging mechanism is enabled */
238 extern
240  SCIP* scip /**< SCIP data structure */
241  );
242 
243 #else
244 
245 #define SCIPdebugSolDataCreate(debugsoldata) SCIP_OKAY
246 #define SCIPdebugFreeSol(set) SCIP_OKAY
247 #define SCIPdebugReset(set) SCIP_OKAY
248 #define SCIPdebugFreeDebugData(set) SCIP_OKAY
249 #define SCIPdebugCheckConss(scip,conss,nconss) SCIP_OKAY
250 #define SCIPdebugCheckRow(set,row) SCIP_OKAY
251 #define SCIPdebugCheckLbGlobal(scip,var,lb) SCIP_OKAY
252 #define SCIPdebugCheckUbGlobal(scip,var,ub) SCIP_OKAY
253 #define SCIPdebugCheckInference(blkmem,set,node,var,newbound,boundtype) SCIP_OKAY
254 #define SCIPdebugRemoveNode(blkmem,set,node) SCIP_OKAY
255 #define SCIPdebugCheckVbound(set,var,vbtype,vbvar,vbcoef,vbconstant) SCIP_OKAY
256 #define SCIPdebugCheckImplic(set,var,varfixing,implvar,impltype,implbound) SCIP_OKAY
257 #define SCIPdebugCheckClique(set,vars,values,nvars) SCIP_OKAY
258 #define SCIPdebugCheckConflict(blkmem,set,node,bdchginfos,relaxedbds,nliterals) SCIP_OKAY
259 #define SCIPdebugCheckConflictFrontier(blkmem,set,node,bdchginfo,bdchginfos,relaxedbds,nliterals,bdchgqueue,forcedbdchgqueue) SCIP_OKAY
260 #define SCIPdebugIncludeProp(scip) SCIP_OKAY
261 #define SCIPdebugAddSolVal(scip,var,val) SCIP_OKAY
262 #define SCIPdebugGetSolVal(scip,var,val) SCIP_OKAY
263 #define SCIPdebugSolIsValidInSubtree(scip,isvalidinsubtree) SCIP_OKAY
264 #define SCIPdebugSolEnable(scip) /**/
265 #define SCIPdebugSolDisable(scip) /**/
266 #define SCIPdebugSolIsEnabled(scip) FALSE
267 #endif
268 
269 
270 /*
271  * debug method for LP interface, to check if the LP interface works correct
272  */
273 #ifdef SCIP_DEBUG_LP_INTERFACE
274 
275 /* check if the coef is the r-th line of the inverse matrix B^-1; this is
276  * the case if (coef * B) is the r-th unit vector */
277 extern
279  SCIP* scip, /**< SCIP data structure */
280  int r, /**< row number */
281  SCIP_Real* coef /**< pointer to store the coefficients of the row */
282  );
283 
284 #else
285 
286 #define SCIPdebugCheckBInvRow(scip,r,coef) SCIP_OKAY
287 
288 #endif
289 
290 #ifdef __cplusplus
291 }
292 #endif
293 
294 #endif
enum SCIP_BoundType SCIP_BOUNDTYPE
Definition: type_lp.h:50
#define SCIPdebugRemoveNode(blkmem, set, node)
Definition: debug.h:254
type definitions for miscellaneous datastructures
#define SCIPdebugFreeDebugData(set)
Definition: debug.h:248
#define SCIPdebugCheckImplic(set, var, varfixing, implvar, impltype, implbound)
Definition: debug.h:256
#define SCIPdebugSolDataCreate(debugsoldata)
Definition: debug.h:245
#define SCIPdebugCheckClique(set, vars, values, nvars)
Definition: debug.h:257
#define SCIPdebugCheckRow(set, row)
Definition: debug.h:250
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
type definitions for return codes for SCIP methods
#define SCIPdebugCheckVbound(set, var, vbtype, vbvar, vbcoef, vbconstant)
Definition: debug.h:255
type definitions for LP management
#define SCIPdebugCheckConflict(blkmem, set, node, bdchginfos, relaxedbds, nliterals)
Definition: debug.h:258
struct SCIP_DebugSolData SCIP_DEBUGSOLDATA
Definition: debug.h:44
#define SCIPdebugIncludeProp(scip)
Definition: debug.h:260
#define SCIPdebugCheckInference(blkmem, set, node, var, newbound, boundtype)
Definition: debug.h:253
#define SCIPdebugCheckBInvRow(scip, r, coef)
Definition: debug.h:286
#define SCIPdebugCheckLbGlobal(scip, var, lb)
Definition: debug.h:251
#define SCIPdebugGetSolVal(scip, var, val)
Definition: debug.h:262
#define SCIPdebugCheckUbGlobal(scip, var, ub)
Definition: debug.h:252
#define SCIPdebugCheckConss(scip, conss, nconss)
Definition: debug.h:249
#define SCIP_Bool
Definition: def.h:61
#define SCIPdebugSolIsValidInSubtree(scip, isvalidinsubtree)
Definition: debug.h:263
#define SCIPdebugCheckConflictFrontier(blkmem, set, node, bdchginfo, bdchginfos, relaxedbds, nliterals, bdchgqueue, forcedbdchgqueue)
Definition: debug.h:259
type definitions for branch and bound tree
type definitions for storing and manipulating the main problem
#define SCIPdebugReset(set)
Definition: debug.h:247
#define SCIPdebugSolDisable(scip)
Definition: debug.h:265
#define SCIP_Real
Definition: def.h:149
#define SCIPdebugAddSolVal(scip, var, val)
Definition: debug.h:261
#define SCIPdebugSolIsEnabled(scip)
Definition: debug.h:266
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:264
#define SCIPdebugFreeSol(set)
Definition: debug.h:246
memory allocation routines