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