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-2016 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  * @brief methods for debugging
18  * @author Tobias Achterberg
19  */
20 
21 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
22 
23 #ifndef __SCIP_DEBUG_H__
24 #define __SCIP_DEBUG_H__
25 
26 /** uncomment this define to activate debugging on given solution */
27 /* #define SCIP_DEBUG_SOLUTION "debug.sol" */
28 
29 /** uncomment this define to activate debugging the LP interface */
30 /* #define SCIP_DEBUG_LP_INTERFACE */
31 
32 
33 #include "scip/def.h"
34 #include "blockmemshell/memory.h"
35 #include "scip/type_retcode.h"
36 #include "scip/type_lp.h"
37 #include "scip/type_prob.h"
38 #include "scip/type_tree.h"
39 #include "scip/type_misc.h"
40 
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
45 /** solution data for debugging purposes */
46 typedef struct SCIP_DebugSolData SCIP_DEBUGSOLDATA;
47 
48 #ifdef SCIP_DEBUG_SOLUTION
49 
50 /** creates debug solution data */
52  SCIP_DEBUGSOLDATA** debugsoldata /**< pointer to debug solution data */
53  );
54 
55 /** frees the debug solution */
57  SCIP_SET* set
58  );
59 
60 /** resets the data structure after restart */
61 extern
63  SCIP_SET* set
64  );
65 
66 /** frees debugging data */
67 extern
69  SCIP_SET* set /**< global SCIP settings */
70  );
71 
72 /** checks for validity of the debugging solution in given constraints */
73 extern
75  SCIP* scip, /**< SCIP data structure */
76  SCIP_CONS** conss, /**< constraints to check for validity */
77  int nconss /**< number of given constraints */
78  );
79 
80 /** checks whether given row is valid for the debugging solution */
81 extern
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 */
88 extern
90  SCIP* scip, /**< SCIP data structure */
91  SCIP_VAR* var, /**< problem variable */
92  SCIP_Real lb /**< lower bound */
93  );
94 
95 /** checks whether given global upper bound is valid for the debugging solution */
96 extern
98  SCIP* scip, /**< SCIP data structure */
99  SCIP_VAR* var, /**< problem variable */
100  SCIP_Real ub /**< upper bound */
101  );
102 
103 /** checks whether given local bound implication is valid for the debugging solution */
104 extern
106  BMS_BLKMEM* blkmem, /**< block memory */
107  SCIP_SET* set, /**< global SCIP settings */
108  SCIP_NODE* node, /**< local node where this bound change was applied */
109  SCIP_VAR* var, /**< problem variable */
110  SCIP_Real newbound, /**< new value for bound */
111  SCIP_BOUNDTYPE boundtype /**< type of bound: lower or upper bound */
112  );
113 
114 /** informs solution debugger, that the given node will be freed */
115 extern
117  BMS_BLKMEM* blkmem, /**< block memory */
118  SCIP_SET* set, /**< global SCIP settings */
119  SCIP_NODE* node /**< node that will be freed */
120  );
121 
122 /** checks whether given variable bound is valid for the debugging solution */
123 extern
125  SCIP_SET* set, /**< global SCIP settings */
126  SCIP_VAR* var, /**< problem variable x in x <= b*z + d or x >= b*z + d */
127  SCIP_BOUNDTYPE vbtype, /**< type of variable bound (LOWER or UPPER) */
128  SCIP_VAR* vbvar, /**< variable z in x <= b*z + d or x >= b*z + d */
129  SCIP_Real vbcoef, /**< coefficient b in x <= b*z + d or x >= b*z + d */
130  SCIP_Real vbconstant /**< constant d in x <= b*z + d or x >= b*z + d */
131  );
132 
133 /** checks whether given implication is valid for the debugging solution */
134 extern
136  SCIP_SET* set, /**< global SCIP settings */
137  SCIP_VAR* var, /**< problem variable */
138  SCIP_Bool varfixing, /**< FALSE if y should be added in implications for x == 0, TRUE for x == 1 */
139  SCIP_VAR* implvar, /**< variable y in implication y <= b or y >= b */
140  SCIP_BOUNDTYPE impltype, /**< type of implication y <= b (SCIP_BOUNDTYPE_UPPER) or y >= b (SCIP_BOUNDTYPE_LOWER) */
141  SCIP_Real implbound /**< bound b in implication y <= b or y >= b */
142  );
143 
144 /** check whether given clique is valid for the debugging solution */
145 extern
147  SCIP_SET* set, /**< global SCIP settings */
148  SCIP_VAR** vars, /**< binary variables in the clique: at most one can be set to the given value */
149  SCIP_Bool* values, /**< values of the variables in the clique; NULL to use TRUE for all vars */
150  int nvars /**< number of variables in the clique */
151  );
152 
153 /** checks whether given conflict is valid for the debugging solution */
154 extern
156  BMS_BLKMEM* blkmem, /**< block memory */
157  SCIP_SET* set, /**< global SCIP settings */
158  SCIP_NODE* node, /**< node where the conflict clause is added */
159  SCIP_BDCHGINFO** bdchginfos, /**< bound change informations of the conflict set */
160  SCIP_Real* relaxedbds, /**< array with relaxed bounds which are efficient to create a valid conflict */
161  int nbdchginfos /**< number of bound changes in the conflict set */
162  );
163 
164 /** checks whether given conflict graph frontier is valid for the debugging solution */
165 extern
167  BMS_BLKMEM* blkmem, /**< block memory */
168  SCIP_SET* set, /**< global SCIP settings */
169  SCIP_NODE* node, /**< node where the conflict clause is added */
170  SCIP_BDCHGINFO* bdchginfo, /**< bound change info which got resolved, or NULL */
171  SCIP_BDCHGINFO** bdchginfos, /**< bound change informations of the conflict set */
172  SCIP_Real* relaxedbds, /**< array with relaxed bounds which are efficient to create a valid conflict */
173  int nbdchginfos, /**< number of bound changes in the conflict set */
174  SCIP_PQUEUE* bdchgqueue, /**< unprocessed conflict bound changes */
175  SCIP_PQUEUE* forcedbdchgqueue /**< unprocessed conflict bound changes that must be resolved */
176  );
177 
178 /** creates the debugging propagator and includes it in SCIP */
179 extern
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  */
187 extern
189  SCIP* scip, /**< SCIP data structure */
190  SCIP_VAR* var, /**< variable for which to add a value */
191  SCIP_Real val /**< solution value for variable */
192  );
193 
194 /** gets pointer to the debug solution */
195 extern
196 SCIP_RETCODE SCIPdebugGetSol(
197  SCIP* scip, /**< SCIP data structure */
198  SCIP_SOL** sol /**< buffer to store pointer to the debug solution */
199  );
200 
201 /** gets value for a variable in the debug solution
202  *
203  * if no value is stored for the variable, gives 0.0
204  */
205 extern
207  SCIP* scip, /**< SCIP data structure */
208  SCIP_VAR* var, /**< variable for which to get the value */
209  SCIP_Real* val /**< buffer to store solution value */
210  );
211 
212 /** check whether the debugging solution is valid in the current node */
213 extern
215  SCIP* scip, /**< SCIP data structure */
216  SCIP_Bool* isvalidinsubtree /**< pointer to store whether the solution is valid in the current
217  * subtree
218  */
219  );
220 
221 /** checks whether SCIP data structure is the main SCIP (the one for which debugging is enabled) */
222 extern
223 SCIP_Bool SCIPdebugIsMainscip(
224  SCIP* scip /**< SCIP data structure */
225  );
226 
227 /** enabling solution debugging mechanism */
228 extern
229 void SCIPdebugSolEnable(
230  SCIP* scip /**< SCIP data structure */
231  );
232 
233 /** disabling solution debugging mechanism */
234 extern
236  SCIP* scip /**< SCIP data structure */
237  );
238 
239 /** check if solution debugging mechanism is enabled */
240 extern
242  SCIP* scip /**< SCIP data structure */
243  );
244 
245 #else
246 
247 #define SCIPdebugSolDataCreate(debugsoldata) SCIP_OKAY
248 #define SCIPdebugFreeSol(set) SCIP_OKAY
249 #define SCIPdebugReset(set) SCIP_OKAY
250 #define SCIPdebugFreeDebugData(set) SCIP_OKAY
251 #define SCIPdebugCheckConss(scip,conss,nconss) SCIP_OKAY
252 #define SCIPdebugCheckRow(set,row) SCIP_OKAY
253 #define SCIPdebugCheckLbGlobal(scip,var,lb) SCIP_OKAY
254 #define SCIPdebugCheckUbGlobal(scip,var,ub) SCIP_OKAY
255 #define SCIPdebugCheckInference(blkmem,set,node,var,newbound,boundtype) SCIP_OKAY
256 #define SCIPdebugRemoveNode(blkmem,set,node) SCIP_OKAY
257 #define SCIPdebugCheckVbound(set,var,vbtype,vbvar,vbcoef,vbconstant) SCIP_OKAY
258 #define SCIPdebugCheckImplic(set,var,varfixing,implvar,impltype,implbound) SCIP_OKAY
259 #define SCIPdebugCheckClique(set,vars,values,nvars) SCIP_OKAY
260 #define SCIPdebugCheckConflict(blkmem,set,node,bdchginfos,relaxedbds,nliterals) SCIP_OKAY
261 #define SCIPdebugCheckConflictFrontier(blkmem,set,node,bdchginfo,bdchginfos,relaxedbds,nliterals,bdchgqueue,forcedbdchgqueue) SCIP_OKAY
262 #define SCIPdebugIncludeProp(scip) SCIP_OKAY
263 #define SCIPdebugAddSolVal(scip,var,val) SCIP_OKAY
264 #define SCIPdebugGetSolVal(scip,var,val) SCIP_OKAY
265 #define SCIPdebugSolIsValidInSubtree(scip,isvalidinsubtree) SCIP_OKAY
266 #define SCIPdebugSolEnable(scip) /**/
267 #define SCIPdebugSolDisable(scip) /**/
268 #define SCIPdebugSolIsEnabled(scip) FALSE
269 #endif
270 
271 
272 /*
273  * debug method for LP interface, to check if the LP interface works correct
274  */
275 #ifdef SCIP_DEBUG_LP_INTERFACE
276 
277 /* check if the coef is the r-th line of the inverse matrix B^-1; this is
278  * the case if (coef * B) is the r-th unit vector */
279 extern
281  SCIP* scip, /**< SCIP data structure */
282  int r, /**< row number */
283  SCIP_Real* coef /**< pointer to store the coefficients of the row */
284  );
285 
286 #else
287 
288 #define SCIPdebugCheckBInvRow(scip,r,coef) SCIP_OKAY
289 
290 #endif
291 
292 #ifdef __cplusplus
293 }
294 #endif
295 
296 #endif
enum SCIP_BoundType SCIP_BOUNDTYPE
Definition: type_lp.h:50
#define SCIPdebugRemoveNode(blkmem, set, node)
Definition: debug.h:256
type definitions for miscellaneous datastructures
#define SCIPdebugFreeDebugData(set)
Definition: debug.h:250
#define SCIPdebugCheckImplic(set, var, varfixing, implvar, impltype, implbound)
Definition: debug.h:258
#define SCIPdebugSolDataCreate(debugsoldata)
Definition: debug.h:247
#define SCIPdebugCheckClique(set, vars, values, nvars)
Definition: debug.h:259
#define SCIPdebugCheckRow(set, row)
Definition: debug.h:252
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:257
type definitions for LP management
#define SCIPdebugCheckConflict(blkmem, set, node, bdchginfos, relaxedbds, nliterals)
Definition: debug.h:260
struct SCIP_DebugSolData SCIP_DEBUGSOLDATA
Definition: debug.h:46
#define SCIPdebugIncludeProp(scip)
Definition: debug.h:262
#define SCIPdebugCheckInference(blkmem, set, node, var, newbound, boundtype)
Definition: debug.h:255
#define SCIPdebugCheckBInvRow(scip, r, coef)
Definition: debug.h:288
#define SCIPdebugCheckLbGlobal(scip, var, lb)
Definition: debug.h:253
#define SCIPdebugGetSolVal(scip, var, val)
Definition: debug.h:264
#define SCIPdebugCheckUbGlobal(scip, var, ub)
Definition: debug.h:254
#define SCIPdebugCheckConss(scip, conss, nconss)
Definition: debug.h:251
#define SCIP_Bool
Definition: def.h:53
#define SCIPdebugSolIsValidInSubtree(scip, isvalidinsubtree)
Definition: debug.h:265
#define SCIPdebugCheckConflictFrontier(blkmem, set, node, bdchginfo, bdchginfos, relaxedbds, nliterals, bdchgqueue, forcedbdchgqueue)
Definition: debug.h:261
type definitions for branch and bound tree
type definitions for storing and manipulating the main problem
#define SCIPdebugReset(set)
Definition: debug.h:249
#define SCIPdebugSolDisable(scip)
Definition: debug.h:267
#define SCIP_Real
Definition: def.h:127
#define SCIPdebugAddSolVal(scip, var, val)
Definition: debug.h:263
#define SCIPdebugSolIsEnabled(scip)
Definition: debug.h:268
common defines and data types used in all packages of SCIP
struct BMS_BlkMem BMS_BLKMEM
Definition: memory.h:392
#define SCIPdebugSolEnable(scip)
Definition: debug.h:266
#define SCIPdebugFreeSol(set)
Definition: debug.h:248
memory allocation routines