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-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 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 /** reset current branch and bound run specific statistics */
127 extern
129  SCIP_STAT* stat, /**< problem statistics data */
130  SCIP_SET* set, /**< global SCIP settings */
131  SCIP_PROB* transprob, /**< transformed problem, or NULL */
132  SCIP_PROB* origprob, /**< original problem, or NULL */
133  SCIP_Bool solved /**< is problem already solved? */
134  );
135 
136 /** resets display statistics, such that a new header line is displayed before the next display line */
137 extern
139  SCIP_STAT* stat /**< problem statistics data */
140  );
141 
142 /** increases LP count, such that all lazy updates depending on the LP are enforced again */
143 extern
145  SCIP_STAT* stat /**< problem statistics data */
146  );
147 
148 /** depending on the current memory usage, switches mode flag to standard or memory saving mode */
149 extern
151  SCIP_STAT* stat, /**< problem statistics data */
152  SCIP_SET* set, /**< global SCIP settings */
153  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
154  SCIP_MEM* mem /**< block memory pools */
155  );
156 
157 /** returns the estimated number of bytes used by extern software, e.g., the LP solver */
158 extern
160  SCIP_STAT* stat /**< dynamic SCIP statistics */
161  );
162 
163 /** enables or disables all statistic clocks of \p stat concerning LP execution time, strong branching time, etc.
164  *
165  * @note: The (pre-)solving time clocks which are relevant for the output during (pre-)solving
166  * are not affected by this method
167  *
168  * @see: For completely disabling all timing of SCIP, consider setting the parameter timing/enabled to FALSE
169  */
170 extern
172  SCIP_STAT* stat, /**< SCIP statistics */
173  SCIP_Bool enable /**< should the LP clocks be enabled? */
174  );
175 
176 /** recompute root LP best-estimate from scratch */
177 extern
179  SCIP_STAT* stat, /**< SCIP statistics */
180  SCIP_SET* set, /**< global SCIP settings */
181  SCIP_Real rootlpobjval, /**< root LP objective value */
182  SCIP_VAR** vars, /**< problem variables */
183  int nvars /**< number of variables */
184  );
185 
186 /** update root LP best-estimate with changed variable pseudo-costs */
187 extern
189  SCIP_STAT* stat, /**< SCIP statistics */
190  SCIP_SET* set, /**< global SCIP settings */
191  SCIP_VAR* var, /**< variable with changed pseudo costs */
192  SCIP_Real oldrootpscostscore /**< old minimum pseudo cost score of variable */
193  );
194 
195 #ifdef TPI_NONE
196 /* no TPI included so just update the stats */
197 
198 #define SCIPstatUpdate(stat, set, field, val) do { \
199  (stat)->field = (val); \
200  } while(0)
201 
202 #define SCIPstatIncrement(stat, set, field) do { \
203  ++(stat)->field; \
204  } while(0)
205 
206 #define SCIPstatAdd(stat, set, field, val) do { \
207  (stat)->field += (val); \
208  } while(0)
209 
210 #else
211 /* TPI not none, so increment deterministic time for relevant stats */
212 
213 #define SCIPupdateDeterministicTimeCount(stat, set, val) do { \
214  (stat)->detertimecnt += (val); \
215  if( (stat)->detertimecnt > 10000.0 ) { \
216  SCIP_CALL_ABORT( SCIPincrementConcurrentTime( (set)->scip, (stat)->detertimecnt ) ); \
217  (stat)->detertimecnt = 0.0; \
218  }\
219  } while(0) \
220 
221 #define SCIPstatUpdate(stat, set, field, val) do { \
222  switch( offsetof(SCIP_STAT, field) ) \
223  { \
224  default: \
225  break; \
226  case offsetof(SCIP_STAT, nprimalresolvelpiterations): \
227  SCIPupdateDeterministicTimeCount(stat, set, 0.00328285264101 * ((val) - (stat)->field) * (stat)->nnz ); \
228  break; \
229  case offsetof(SCIP_STAT, ndualresolvelpiterations): \
230  SCIPupdateDeterministicTimeCount(stat, set, 0.00531625104146 * ((val) - (stat)->field) * (stat)->nnz ); \
231  break; \
232  case offsetof(SCIP_STAT, nprobboundchgs): \
233  SCIPupdateDeterministicTimeCount(stat, set, 0.000738719124051 * ((val) - (stat)->field) * (stat)->nnz ); \
234  break; \
235  case offsetof(SCIP_STAT, nisstoppedcalls): \
236  SCIPupdateDeterministicTimeCount(stat, set, 0.0011123144764 * ((val) - (stat)->field) * (stat)->nnz ); \
237  } \
238  (stat)->field = (val); \
239  } while(0)
240 
241 
242 #define SCIPstatIncrement(stat, set, field) do { \
243  switch( offsetof(SCIP_STAT, field) ) \
244  { \
245  default: \
246  break; \
247  case offsetof(SCIP_STAT, nprimalresolvelpiterations): \
248  SCIPupdateDeterministicTimeCount(stat, set, 0.00328285264101 * (stat)->nnz ); \
249  break; \
250  case offsetof(SCIP_STAT, ndualresolvelpiterations): \
251  SCIPupdateDeterministicTimeCount(stat, set, 0.00531625104146 * (stat)->nnz ); \
252  break; \
253  case offsetof(SCIP_STAT, nprobboundchgs): \
254  SCIPupdateDeterministicTimeCount(stat, set, 0.000738719124051 * (stat)->nnz ); \
255  break; \
256  case offsetof(SCIP_STAT, nisstoppedcalls): \
257  SCIPupdateDeterministicTimeCount(stat, set, 0.0011123144764 * (stat)->nnz ); \
258  } \
259  ++(stat)->field; \
260  } while(0)
261 
262 #define SCIPstatAdd(stat, set, field, val) do { \
263  switch( offsetof(SCIP_STAT, field) ) \
264  { \
265  default: \
266  break; \
267  case offsetof(SCIP_STAT, nprimalresolvelpiterations): \
268  SCIPupdateDeterministicTimeCount(stat, set, 0.00328285264101 * (val) * (stat)->nnz); \
269  break; \
270  case offsetof(SCIP_STAT, ndualresolvelpiterations): \
271  SCIPupdateDeterministicTimeCount(stat, set, 0.00531625104146 * (val) * (stat)->nnz); \
272  break; \
273  case offsetof(SCIP_STAT, nprobboundchgs): \
274  SCIPupdateDeterministicTimeCount(stat, set, 0.000738719124051 * (val) * (stat)->nnz ); \
275  break; \
276  case offsetof(SCIP_STAT, nisstoppedcalls): \
277  SCIPupdateDeterministicTimeCount(stat, set, 0.0011123144764 * (val) * (stat)->nnz ); \
278  } \
279  (stat)->field += (val); \
280  } while(0)
281 #endif
282 
283 
284 /* if we have a C99 compiler */
285 #ifdef SCIP_HAVE_VARIADIC_MACROS
286 
287 /** prints a debugging message if SCIP_DEBUG flag is set */
288 #ifdef SCIP_DEBUG
289 #define SCIPstatDebugMsg(set, ...) SCIPstatPrintDebugMessage(stat, __FILE__, __LINE__, __VA_ARGS__)
290 #define SCIPstatDebugMsgPrint(set, ...) SCIPstatPrintDebugMessagePrint(stat, __VA_ARGS__)
291 #else
292 #define SCIPstatDebugMsg(set, ...) while ( FALSE ) SCIPstatPrintDebugMessage(stat, __FILE__, __LINE__, __VA_ARGS__)
293 #define SCIPstatDebugMsgPrint(set, ...) while ( FALSE ) SCIPstatPrintDebugMessagePrint(stat, __VA_ARGS__)
294 #endif
295 
296 #else
297 /* if we do not have a C99 compiler, use a workaround that prints a message, but not the file and linenumber */
298 
299 /** prints a debugging message if SCIP_DEBUG flag is set */
300 #ifdef SCIP_DEBUG
301 #define SCIPstatDebugMsg printf("debug: "), SCIPstatDebugMessagePrint
302 #define SCIPstatDebugMsgPrint SCIPstatDebugMessagePrint
303 #else
304 #define SCIPstatDebugMsg while ( FALSE ) SCIPstatDebugMessagePrint
305 #define SCIPstatDebugMsgPrint while ( FALSE ) SCIPstatDebugMessagePrint
306 #endif
307 
308 #endif
309 
310 
311 /** prints a debug message */
312 extern
314  SCIP_STAT* stat, /**< SCIP statistics */
315  const char* sourcefile, /**< name of the source file that called the function */
316  int sourceline, /**< line in the source file where the function was called */
317  const char* formatstr, /**< format string like in printf() function */
318  ... /**< format arguments line in printf() function */
319  );
320 
321 /** prints a debug message without precode */
322 extern
324  SCIP_STAT* stat, /**< SCIP statistics */
325  const char* formatstr, /**< format string like in printf() function */
326  ... /**< format arguments line in printf() function */
327  );
328 
329 #ifdef __cplusplus
330 }
331 #endif
332 
333 #endif
SCIP_Longint SCIPstatGetMemExternEstim(SCIP_STAT *stat)
Definition: stat.c:604
void SCIPstatEnableOrDisableStatClocks(SCIP_STAT *stat, SCIP_Bool enable)
Definition: stat.c:618
void SCIPstatResetImplications(SCIP_STAT *stat)
Definition: stat.c:328
void SCIPstatResetCurrentRun(SCIP_STAT *stat, SCIP_SET *set, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_Bool solved)
Definition: stat.c:483
void SCIPstatDebugMessagePrint(SCIP_STAT *stat, const char *formatstr,...)
Definition: stat.c:734
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
type definitions for global SCIP settings
void SCIPstatMark(SCIP_STAT *stat)
Definition: stat.c:171
type definitions for return codes for SCIP methods
type definitions for problem statistics
void SCIPstatEnforceLPUpdates(SCIP_STAT *stat)
Definition: stat.c:555
void SCIPstatReset(SCIP_STAT *stat, SCIP_SET *set, SCIP_PROB *transprob, SCIP_PROB *origprob)
Definition: stat.c:183
#define SCIP_Bool
Definition: def.h:61
void SCIPstatResetPresolving(SCIP_STAT *stat, SCIP_SET *set, SCIP_PROB *transprob, SCIP_PROB *origprob)
Definition: stat.c:338
SCIP_RETCODE SCIPstatUpdateVarRootLPBestEstimate(SCIP_STAT *stat, SCIP_SET *set, SCIP_VAR *var, SCIP_Real oldrootpscostscore)
Definition: stat.c:674
void SCIPstatResetPrimalDualIntegral(SCIP_STAT *stat, SCIP_SET *set, SCIP_Bool partialreset)
Definition: stat.c:366
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:110
void SCIPstatResetDisplay(SCIP_STAT *stat)
Definition: stat.c:544
type definitions for block memory pools and memory buffers
void SCIPstatEnableVarHistory(SCIP_STAT *stat)
Definition: stat.c:161
public methods for message output
#define SCIP_Real
Definition: def.h:135
void SCIPstatComputeRootLPBestEstimate(SCIP_STAT *stat, SCIP_SET *set, SCIP_Real rootlpobjval, SCIP_VAR **vars, int nvars)
Definition: stat.c:643
#define SCIP_Longint
Definition: def.h:120
void SCIPstatPrintDebugMessage(SCIP_STAT *stat, const char *sourcefile, int sourceline, const char *formatstr,...)
Definition: stat.c:709
void SCIPstatUpdatePrimalDualIntegral(SCIP_STAT *stat, SCIP_SET *set, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_Real primalbound, SCIP_Real dualbound)
Definition: stat.c:392
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:392
void SCIPstatDisableVarHistory(SCIP_STAT *stat)
Definition: stat.c:151
void SCIPstatUpdateMemsaveMode(SCIP_STAT *stat, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, SCIP_MEM *mem)
Definition: stat.c:565
memory allocation routines