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