Scippy

SCIP

Solving Constraint Integer Programs

stat.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 stat.h
17  * @ingroup INTERNALAPI
18  * @brief internal methods for problem statistics
19  * @author Tobias Achterberg
20  */
21 
22 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
23 
24 #ifndef __SCIP_STAT_H__
25 #define __SCIP_STAT_H__
26 
27 
28 #include "scip/def.h"
29 #include "blockmemshell/memory.h"
30 #include "scip/type_prob.h"
31 #include "scip/type_retcode.h"
32 #include "scip/type_set.h"
33 #include "scip/type_stat.h"
34 #include "scip/type_mem.h"
35 #include "scip/pub_message.h"
36 #include "scip/concurrent.h"
37 
38 #include "scip/struct_stat.h"
39 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 
44 /** creates problem statistics data */
45 extern
47  SCIP_STAT** stat, /**< pointer to problem statistics data */
48  BMS_BLKMEM* blkmem, /**< block memory */
49  SCIP_SET* set, /**< global SCIP settings */
50  SCIP_PROB* transprob, /**< transformed problem, or NULL */
51  SCIP_PROB* origprob, /**< original problem, or NULL */
52  SCIP_MESSAGEHDLR* messagehdlr /**< message handler */
53  );
54 
55 /** frees problem statistics data */
56 extern
58  SCIP_STAT** stat, /**< pointer to problem statistics data */
59  BMS_BLKMEM* blkmem /**< block memory */
60  );
61 
62 /** diables the collection of any statistic for a variable */
63 extern
65  SCIP_STAT* stat /**< problem statistics data */
66  );
67 
68 /** enables the collection of statistics for a variable */
69 extern
71  SCIP_STAT* stat /**< problem statistics data */
72  );
73 
74 /** marks statistics to be able to reset them when solving process is freed */
75 extern
76 void SCIPstatMark(
77  SCIP_STAT* stat /**< problem statistics data */
78  );
79 
80 /** reset statistics to the data before solving started */
81 extern
82 void SCIPstatReset(
83  SCIP_STAT* stat, /**< problem statistics data */
84  SCIP_SET* set, /**< global SCIP settings */
85  SCIP_PROB* transprob, /**< transformed problem, or NULL */
86  SCIP_PROB* origprob /**< original problem, or NULL */
87  );
88 
89 /** reset implication counter */
90 extern
92  SCIP_STAT* stat /**< problem statistics data */
93  );
94 
95 /** reset presolving and current run specific statistics */
96 extern
98  SCIP_STAT* stat, /**< problem statistics data */
99  SCIP_SET* set, /**< global SCIP settings */
100  SCIP_PROB* transprob, /**< transformed problem, or NULL */
101  SCIP_PROB* origprob /**< original problem, or NULL */
102  );
103 
104 /* reset primal-dual integral */
105 extern
107  SCIP_STAT* stat, /**< problem statistics data */
108  SCIP_SET* set, /**< global SCIP settings */
109  SCIP_Bool partialreset /**< should time and integral value be kept? (in combination with no statistical
110  * reset, integrals are added for each problem to be solved) */
111  );
112 
113 /** update the primal-dual integral statistic. method accepts + and - SCIPsetInfinity() as values for
114  * upper and lower bound, respectively
115  */
116 extern
118  SCIP_STAT* stat, /**< problem statistics data */
119  SCIP_SET* set, /**< global SCIP settings */
120  SCIP_PROB* transprob, /**< transformed problem */
121  SCIP_PROB* origprob, /**< original problem */
122  SCIP_Real primalbound, /**< current primal bound in transformed problem, or infinity */
123  SCIP_Real dualbound /**< current lower bound in transformed space, or -infinity */
124  );
125 
126 /** update and return the primal-dual integral statistic */
127 extern
129  SCIP_STAT* stat, /**< problem statistics data */
130  SCIP_SET* set, /**< global SCIP settings */
131  SCIP_PROB* transprob, /**< transformed problem */
132  SCIP_PROB* origprob /**< original problem */
133  );
134 
135 /** reset current branch and bound run specific statistics */
136 extern
138  SCIP_STAT* stat, /**< problem statistics data */
139  SCIP_SET* set, /**< global SCIP settings */
140  SCIP_PROB* transprob, /**< transformed problem, or NULL */
141  SCIP_PROB* origprob, /**< original problem, or NULL */
142  SCIP_Bool solved /**< is problem already solved? */
143  );
144 
145 /** resets display statistics, such that a new header line is displayed before the next display line */
146 extern
148  SCIP_STAT* stat /**< problem statistics data */
149  );
150 
151 /** increases LP count, such that all lazy updates depending on the LP are enforced again */
152 extern
154  SCIP_STAT* stat /**< problem statistics data */
155  );
156 
157 /** depending on the current memory usage, switches mode flag to standard or memory saving mode */
158 extern
160  SCIP_STAT* stat, /**< problem statistics data */
161  SCIP_SET* set, /**< global SCIP settings */
162  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
163  SCIP_MEM* mem /**< block memory pools */
164  );
165 
166 /** returns the estimated number of bytes used by extern software, e.g., the LP solver */
167 extern
169  SCIP_STAT* stat /**< dynamic SCIP statistics */
170  );
171 
172 /** enables or disables all statistic clocks of \p stat concerning LP execution time, strong branching time, etc.
173  *
174  * @note: The (pre-)solving time clocks which are relevant for the output during (pre-)solving
175  * are not affected by this method
176  *
177  * @see: For completely disabling all timing of SCIP, consider setting the parameter timing/enabled to FALSE
178  */
179 extern
181  SCIP_STAT* stat, /**< SCIP statistics */
182  SCIP_Bool enable /**< should the LP clocks be enabled? */
183  );
184 
185 /** recompute root LP best-estimate from scratch */
186 extern
188  SCIP_STAT* stat, /**< SCIP statistics */
189  SCIP_SET* set, /**< global SCIP settings */
190  SCIP_Real rootlpobjval, /**< root LP objective value */
191  SCIP_VAR** vars, /**< problem variables */
192  int nvars /**< number of variables */
193  );
194 
195 /** update root LP best-estimate with changed variable pseudo-costs */
196 extern
198  SCIP_STAT* stat, /**< SCIP statistics */
199  SCIP_SET* set, /**< global SCIP settings */
200  SCIP_VAR* var, /**< variable with changed pseudo costs */
201  SCIP_Real oldrootpscostscore /**< old minimum pseudo cost score of variable */
202  );
203 
204 #ifdef TPI_NONE
205 /* no TPI included so just update the stats */
206 
207 #define SCIPstatUpdate(stat, set, field, val) do { \
208  (stat)->field = (val); \
209  } while(0)
210 
211 #define SCIPstatIncrement(stat, set, field) do { \
212  ++(stat)->field; \
213  } while(0)
214 
215 #define SCIPstatAdd(stat, set, field, val) do { \
216  (stat)->field += (val); \
217  } while(0)
218 
219 #else
220 /* TPI not none, so increment deterministic time for relevant stats */
221 
222 #define SCIPupdateDeterministicTimeCount(stat, set, val) do { \
223  (stat)->detertimecnt += (val); \
224  if( (stat)->detertimecnt > 10000.0 ) { \
225  SCIP_CALL_ABORT( SCIPincrementConcurrentTime( (set)->scip, (stat)->detertimecnt ) ); \
226  (stat)->detertimecnt = 0.0; \
227  }\
228  } while(0) \
229 
230 #define SCIPstatUpdate(stat, set, field, val) do { \
231  switch( offsetof(SCIP_STAT, field) ) \
232  { \
233  default: \
234  break; \
235  case offsetof(SCIP_STAT, nprimalresolvelpiterations): \
236  SCIPupdateDeterministicTimeCount(stat, set, 0.00328285264101 * ((val) - (stat)->field) * (stat)->nnz ); \
237  break; \
238  case offsetof(SCIP_STAT, ndualresolvelpiterations): \
239  SCIPupdateDeterministicTimeCount(stat, set, 0.00531625104146 * ((val) - (stat)->field) * (stat)->nnz ); \
240  break; \
241  case offsetof(SCIP_STAT, nprobboundchgs): \
242  SCIPupdateDeterministicTimeCount(stat, set, 0.000738719124051 * ((val) - (stat)->field) * (stat)->nnz ); \
243  break; \
244  case offsetof(SCIP_STAT, nisstoppedcalls): \
245  SCIPupdateDeterministicTimeCount(stat, set, 0.0011123144764 * ((val) - (stat)->field) * (stat)->nnz ); \
246  } \
247  (stat)->field = (val); \
248  } while(0)
249 
250 
251 #define SCIPstatIncrement(stat, set, field) do { \
252  switch( offsetof(SCIP_STAT, field) ) \
253  { \
254  default: \
255  break; \
256  case offsetof(SCIP_STAT, nprimalresolvelpiterations): \
257  SCIPupdateDeterministicTimeCount(stat, set, 0.00328285264101 * (stat)->nnz ); \
258  break; \
259  case offsetof(SCIP_STAT, ndualresolvelpiterations): \
260  SCIPupdateDeterministicTimeCount(stat, set, 0.00531625104146 * (stat)->nnz ); \
261  break; \
262  case offsetof(SCIP_STAT, nprobboundchgs): \
263  SCIPupdateDeterministicTimeCount(stat, set, 0.000738719124051 * (stat)->nnz ); \
264  break; \
265  case offsetof(SCIP_STAT, nisstoppedcalls): \
266  SCIPupdateDeterministicTimeCount(stat, set, 0.0011123144764 * (stat)->nnz ); \
267  } \
268  ++(stat)->field; \
269  } while(0)
270 
271 #define SCIPstatAdd(stat, set, field, val) do { \
272  switch( offsetof(SCIP_STAT, field) ) \
273  { \
274  default: \
275  break; \
276  case offsetof(SCIP_STAT, nprimalresolvelpiterations): \
277  SCIPupdateDeterministicTimeCount(stat, set, 0.00328285264101 * (val) * (stat)->nnz); \
278  break; \
279  case offsetof(SCIP_STAT, ndualresolvelpiterations): \
280  SCIPupdateDeterministicTimeCount(stat, set, 0.00531625104146 * (val) * (stat)->nnz); \
281  break; \
282  case offsetof(SCIP_STAT, nprobboundchgs): \
283  SCIPupdateDeterministicTimeCount(stat, set, 0.000738719124051 * (val) * (stat)->nnz ); \
284  break; \
285  case offsetof(SCIP_STAT, nisstoppedcalls): \
286  SCIPupdateDeterministicTimeCount(stat, set, 0.0011123144764 * (val) * (stat)->nnz ); \
287  } \
288  (stat)->field += (val); \
289  } while(0)
290 #endif
291 
292 
293 /* if we have a C99 compiler */
294 #ifdef SCIP_HAVE_VARIADIC_MACROS
295 
296 /** prints a debugging message if SCIP_DEBUG flag is set */
297 #ifdef SCIP_DEBUG
298 #define SCIPstatDebugMsg(set, ...) SCIPstatPrintDebugMessage(stat, __FILE__, __LINE__, __VA_ARGS__)
299 #define SCIPstatDebugMsgPrint(set, ...) SCIPstatPrintDebugMessagePrint(stat, __VA_ARGS__)
300 #else
301 #define SCIPstatDebugMsg(set, ...) while ( FALSE ) SCIPstatPrintDebugMessage(stat, __FILE__, __LINE__, __VA_ARGS__)
302 #define SCIPstatDebugMsgPrint(set, ...) while ( FALSE ) SCIPstatPrintDebugMessagePrint(stat, __VA_ARGS__)
303 #endif
304 
305 #else
306 /* if we do not have a C99 compiler, use a workaround that prints a message, but not the file and linenumber */
307 
308 /** prints a debugging message if SCIP_DEBUG flag is set */
309 #ifdef SCIP_DEBUG
310 #define SCIPstatDebugMsg printf("debug: "), SCIPstatDebugMessagePrint
311 #define SCIPstatDebugMsgPrint SCIPstatDebugMessagePrint
312 #else
313 #define SCIPstatDebugMsg while ( FALSE ) SCIPstatDebugMessagePrint
314 #define SCIPstatDebugMsgPrint while ( FALSE ) SCIPstatDebugMessagePrint
315 #endif
316 
317 #endif
318 
319 
320 /** prints a debug message */
321 extern
323  SCIP_STAT* stat, /**< SCIP statistics */
324  const char* sourcefile, /**< name of the source file that called the function */
325  int sourceline, /**< line in the source file where the function was called */
326  const char* formatstr, /**< format string like in printf() function */
327  ... /**< format arguments line in printf() function */
328  );
329 
330 /** prints a debug message without precode */
331 extern
333  SCIP_STAT* stat, /**< SCIP statistics */
334  const char* formatstr, /**< format string like in printf() function */
335  ... /**< format arguments line in printf() function */
336  );
337 
338 #ifdef __cplusplus
339 }
340 #endif
341 
342 #endif
SCIP_Longint SCIPstatGetMemExternEstim(SCIP_STAT *stat)
Definition: stat.c:633
void SCIPstatEnableOrDisableStatClocks(SCIP_STAT *stat, SCIP_Bool enable)
Definition: stat.c:647
void SCIPstatResetImplications(SCIP_STAT *stat)
Definition: stat.c:338
void SCIPstatResetCurrentRun(SCIP_STAT *stat, SCIP_SET *set, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_Bool solved)
Definition: stat.c:512
void SCIPstatDebugMessagePrint(SCIP_STAT *stat, const char *formatstr,...)
Definition: stat.c:764
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
type definitions for global SCIP settings
void SCIPstatMark(SCIP_STAT *stat)
Definition: stat.c:173
type definitions for return codes for SCIP methods
type definitions for problem statistics
void SCIPstatEnforceLPUpdates(SCIP_STAT *stat)
Definition: stat.c:584
void SCIPstatReset(SCIP_STAT *stat, SCIP_SET *set, SCIP_PROB *transprob, SCIP_PROB *origprob)
Definition: stat.c:185
#define SCIP_Bool
Definition: def.h:69
void SCIPstatResetPresolving(SCIP_STAT *stat, SCIP_SET *set, SCIP_PROB *transprob, SCIP_PROB *origprob)
Definition: stat.c:348
SCIP_RETCODE SCIPstatUpdateVarRootLPBestEstimate(SCIP_STAT *stat, SCIP_SET *set, SCIP_VAR *var, SCIP_Real oldrootpscostscore)
Definition: stat.c:704
void SCIPstatResetPrimalDualIntegral(SCIP_STAT *stat, SCIP_SET *set, SCIP_Bool partialreset)
Definition: stat.c:376
datastructures for problem statistics
helper functions for concurrent scip solvers
type definitions for storing and manipulating the main problem
SCIP_RETCODE SCIPstatFree(SCIP_STAT **stat, BMS_BLKMEM *blkmem)
Definition: stat.c:111
void SCIPstatResetDisplay(SCIP_STAT *stat)
Definition: stat.c:573
type definitions for block memory pools and memory buffers
void SCIPstatEnableVarHistory(SCIP_STAT *stat)
Definition: stat.c:163
public methods for message output
#define SCIP_Real
Definition: def.h:157
void SCIPstatComputeRootLPBestEstimate(SCIP_STAT *stat, SCIP_SET *set, SCIP_Real rootlpobjval, SCIP_VAR **vars, int nvars)
Definition: stat.c:673
#define SCIP_Longint
Definition: def.h:142
void SCIPstatPrintDebugMessage(SCIP_STAT *stat, const char *sourcefile, int sourceline, const char *formatstr,...)
Definition: stat.c:739
void SCIPstatUpdatePrimalDualIntegral(SCIP_STAT *stat, SCIP_SET *set, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_Real primalbound, SCIP_Real dualbound)
Definition: stat.c:402
SCIP_RETCODE SCIPstatCreate(SCIP_STAT **stat, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_MESSAGEHDLR *messagehdlr)
Definition: stat.c:45
common defines and data types used in all packages of SCIP
struct BMS_BlkMem BMS_BLKMEM
Definition: memory.h:426
void SCIPstatDisableVarHistory(SCIP_STAT *stat)
Definition: stat.c:153
void SCIPstatUpdateMemsaveMode(SCIP_STAT *stat, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, SCIP_MEM *mem)
Definition: stat.c:594
SCIP_Real SCIPstatGetPrimalDualIntegral(SCIP_STAT *stat, SCIP_SET *set, SCIP_PROB *transprob, SCIP_PROB *origprob)
Definition: stat.c:493
memory allocation routines