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 */
46  SCIP_STAT** stat, /**< pointer to problem statistics data */
47  BMS_BLKMEM* blkmem, /**< block memory */
48  SCIP_SET* set, /**< global SCIP settings */
49  SCIP_PROB* transprob, /**< transformed problem, or NULL */
50  SCIP_PROB* origprob, /**< original problem, or NULL */
51  SCIP_MESSAGEHDLR* messagehdlr /**< message handler */
52  );
53 
54 /** frees problem statistics data */
56  SCIP_STAT** stat, /**< pointer to problem statistics data */
57  BMS_BLKMEM* blkmem /**< block memory */
58  );
59 
60 /** diables the collection of any statistic for a variable */
62  SCIP_STAT* stat /**< problem statistics data */
63  );
64 
65 /** enables the collection of statistics for a variable */
67  SCIP_STAT* stat /**< problem statistics data */
68  );
69 
70 /** marks statistics to be able to reset them when solving process is freed */
71 void SCIPstatMark(
72  SCIP_STAT* stat /**< problem statistics data */
73  );
74 
75 /** reset statistics to the data before solving started */
76 void SCIPstatReset(
77  SCIP_STAT* stat, /**< problem statistics data */
78  SCIP_SET* set, /**< global SCIP settings */
79  SCIP_PROB* transprob, /**< transformed problem, or NULL */
80  SCIP_PROB* origprob /**< original problem, or NULL */
81  );
82 
83 /** reset implication counter */
85  SCIP_STAT* stat /**< problem statistics data */
86  );
87 
88 /** reset presolving and current run specific statistics */
90  SCIP_STAT* stat, /**< problem statistics data */
91  SCIP_SET* set, /**< global SCIP settings */
92  SCIP_PROB* transprob, /**< transformed problem, or NULL */
93  SCIP_PROB* origprob /**< original problem, or NULL */
94  );
95 
96 /* reset primal-dual integral */
98  SCIP_STAT* stat, /**< problem statistics data */
99  SCIP_SET* set, /**< global SCIP settings */
100  SCIP_Bool partialreset /**< should time and integral value be kept? (in combination with no statistical
101  * reset, integrals are added for each problem to be solved) */
102  );
103 
104 /** update the primal-dual integral statistic. method accepts + and - SCIPsetInfinity() as values for
105  * upper and lower bound, respectively
106  */
108  SCIP_STAT* stat, /**< problem statistics data */
109  SCIP_SET* set, /**< global SCIP settings */
110  SCIP_PROB* transprob, /**< transformed problem */
111  SCIP_PROB* origprob, /**< original problem */
112  SCIP_Real primalbound, /**< current primal bound in transformed problem, or infinity */
113  SCIP_Real dualbound /**< current lower bound in transformed space, or -infinity */
114  );
115 
116 /** update and return the primal-dual integral statistic */
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  );
123 
124 /** reset current branch and bound run specific statistics */
126  SCIP_STAT* stat, /**< problem statistics data */
127  SCIP_SET* set, /**< global SCIP settings */
128  SCIP_PROB* transprob, /**< transformed problem, or NULL */
129  SCIP_PROB* origprob, /**< original problem, or NULL */
130  SCIP_Bool solved /**< is problem already solved? */
131  );
132 
133 /** resets display statistics, such that a new header line is displayed before the next display line */
135  SCIP_STAT* stat /**< problem statistics data */
136  );
137 
138 /** increases LP count, such that all lazy updates depending on the LP are enforced again */
140  SCIP_STAT* stat /**< problem statistics data */
141  );
142 
143 /** depending on the current memory usage, switches mode flag to standard or memory saving mode */
145  SCIP_STAT* stat, /**< problem statistics data */
146  SCIP_SET* set, /**< global SCIP settings */
147  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
148  SCIP_MEM* mem /**< block memory pools */
149  );
150 
151 /** returns the estimated number of bytes used by extern software, e.g., the LP solver */
153  SCIP_STAT* stat /**< dynamic SCIP statistics */
154  );
155 
156 /** enables or disables all statistic clocks of \p stat concerning LP execution time, strong branching time, etc.
157  *
158  * @note: The (pre-)solving time clocks which are relevant for the output during (pre-)solving
159  * are not affected by this method
160  *
161  * @see: For completely disabling all timing of SCIP, consider setting the parameter timing/enabled to FALSE
162  */
164  SCIP_STAT* stat, /**< SCIP statistics */
165  SCIP_Bool enable /**< should the LP clocks be enabled? */
166  );
167 
168 /** recompute root LP best-estimate from scratch */
170  SCIP_STAT* stat, /**< SCIP statistics */
171  SCIP_SET* set, /**< global SCIP settings */
172  SCIP_Real rootlpobjval, /**< root LP objective value */
173  SCIP_VAR** vars, /**< problem variables */
174  int nvars /**< number of variables */
175  );
176 
177 /** update root LP best-estimate with changed variable pseudo-costs */
179  SCIP_STAT* stat, /**< SCIP statistics */
180  SCIP_SET* set, /**< global SCIP settings */
181  SCIP_VAR* var, /**< variable with changed pseudo costs */
182  SCIP_Real oldrootpscostscore /**< old minimum pseudo cost score of variable */
183  );
184 
185 #ifdef TPI_NONE
186 /* no TPI included so just update the stats */
187 
188 #define SCIPstatUpdate(stat, set, field, val) do { \
189  (stat)->field = (val); \
190  } while(0)
191 
192 #define SCIPstatIncrement(stat, set, field) do { \
193  ++(stat)->field; \
194  } while(0)
195 
196 #define SCIPstatAdd(stat, set, field, val) do { \
197  (stat)->field += (val); \
198  } while(0)
199 
200 #else
201 /* TPI not none, so increment deterministic time for relevant stats */
202 
203 #define SCIPupdateDeterministicTimeCount(stat, set, val) do { \
204  (stat)->detertimecnt += (val); \
205  if( (stat)->detertimecnt > 10000.0 ) { \
206  SCIP_CALL_ABORT( SCIPincrementConcurrentTime( (set)->scip, (stat)->detertimecnt ) ); \
207  (stat)->detertimecnt = 0.0; \
208  }\
209  } while(0) \
210 
211 #define SCIPstatUpdate(stat, set, field, val) do { \
212  switch( offsetof(SCIP_STAT, field) ) \
213  { \
214  default: \
215  break; \
216  case offsetof(SCIP_STAT, nprimalresolvelpiterations): \
217  SCIPupdateDeterministicTimeCount(stat, set, 0.00328285264101 * ((val) - (stat)->field) * (stat)->nnz ); \
218  break; \
219  case offsetof(SCIP_STAT, ndualresolvelpiterations): \
220  SCIPupdateDeterministicTimeCount(stat, set, 0.00531625104146 * ((val) - (stat)->field) * (stat)->nnz ); \
221  break; \
222  case offsetof(SCIP_STAT, nprobboundchgs): \
223  SCIPupdateDeterministicTimeCount(stat, set, 0.000738719124051 * ((val) - (stat)->field) * (stat)->nnz ); \
224  break; \
225  case offsetof(SCIP_STAT, nisstoppedcalls): \
226  SCIPupdateDeterministicTimeCount(stat, set, 0.0011123144764 * ((val) - (stat)->field) * (stat)->nnz ); \
227  } \
228  (stat)->field = (val); \
229  } while(0)
230 
231 
232 #define SCIPstatIncrement(stat, set, field) do { \
233  switch( offsetof(SCIP_STAT, field) ) \
234  { \
235  default: \
236  break; \
237  case offsetof(SCIP_STAT, nprimalresolvelpiterations): \
238  SCIPupdateDeterministicTimeCount(stat, set, 0.00328285264101 * (stat)->nnz ); \
239  break; \
240  case offsetof(SCIP_STAT, ndualresolvelpiterations): \
241  SCIPupdateDeterministicTimeCount(stat, set, 0.00531625104146 * (stat)->nnz ); \
242  break; \
243  case offsetof(SCIP_STAT, nprobboundchgs): \
244  SCIPupdateDeterministicTimeCount(stat, set, 0.000738719124051 * (stat)->nnz ); \
245  break; \
246  case offsetof(SCIP_STAT, nisstoppedcalls): \
247  SCIPupdateDeterministicTimeCount(stat, set, 0.0011123144764 * (stat)->nnz ); \
248  } \
249  ++(stat)->field; \
250  } while(0)
251 
252 #define SCIPstatAdd(stat, set, field, val) do { \
253  switch( offsetof(SCIP_STAT, field) ) \
254  { \
255  default: \
256  break; \
257  case offsetof(SCIP_STAT, nprimalresolvelpiterations): \
258  SCIPupdateDeterministicTimeCount(stat, set, 0.00328285264101 * (val) * (stat)->nnz); \
259  break; \
260  case offsetof(SCIP_STAT, ndualresolvelpiterations): \
261  SCIPupdateDeterministicTimeCount(stat, set, 0.00531625104146 * (val) * (stat)->nnz); \
262  break; \
263  case offsetof(SCIP_STAT, nprobboundchgs): \
264  SCIPupdateDeterministicTimeCount(stat, set, 0.000738719124051 * (val) * (stat)->nnz ); \
265  break; \
266  case offsetof(SCIP_STAT, nisstoppedcalls): \
267  SCIPupdateDeterministicTimeCount(stat, set, 0.0011123144764 * (val) * (stat)->nnz ); \
268  } \
269  (stat)->field += (val); \
270  } while(0)
271 #endif
272 
273 
274 /* if we have a C99 compiler */
275 #ifdef SCIP_HAVE_VARIADIC_MACROS
276 
277 /** prints a debugging message if SCIP_DEBUG flag is set */
278 #ifdef SCIP_DEBUG
279 #define SCIPstatDebugMsg(set, ...) SCIPstatPrintDebugMessage(stat, __FILE__, __LINE__, __VA_ARGS__)
280 #define SCIPstatDebugMsgPrint(set, ...) SCIPstatPrintDebugMessagePrint(stat, __VA_ARGS__)
281 #else
282 #define SCIPstatDebugMsg(set, ...) while ( FALSE ) SCIPstatPrintDebugMessage(stat, __FILE__, __LINE__, __VA_ARGS__)
283 #define SCIPstatDebugMsgPrint(set, ...) while ( FALSE ) SCIPstatPrintDebugMessagePrint(stat, __VA_ARGS__)
284 #endif
285 
286 #else
287 /* if we do not have a C99 compiler, use a workaround that prints a message, but not the file and linenumber */
288 
289 /** prints a debugging message if SCIP_DEBUG flag is set */
290 #ifdef SCIP_DEBUG
291 #define SCIPstatDebugMsg printf("debug: "), SCIPstatDebugMessagePrint
292 #define SCIPstatDebugMsgPrint SCIPstatDebugMessagePrint
293 #else
294 #define SCIPstatDebugMsg while ( FALSE ) SCIPstatDebugMessagePrint
295 #define SCIPstatDebugMsgPrint while ( FALSE ) SCIPstatDebugMessagePrint
296 #endif
297 
298 #endif
299 
300 
301 /** prints a debug message */
304  SCIP_STAT* stat, /**< SCIP statistics */
305  const char* sourcefile, /**< name of the source file that called the function */
306  int sourceline, /**< line in the source file where the function was called */
307  const char* formatstr, /**< format string like in printf() function */
308  ... /**< format arguments line in printf() function */
309  );
310 
311 /** prints a debug message without precode */
314  SCIP_STAT* stat, /**< SCIP statistics */
315  const char* formatstr, /**< format string like in printf() function */
316  ... /**< format arguments line in printf() function */
317  );
318 
319 #ifdef __cplusplus
320 }
321 #endif
322 
323 #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
#define SCIP_EXPORT
Definition: def.h:98
void SCIPstatResetCurrentRun(SCIP_STAT *stat, SCIP_SET *set, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_Bool solved)
Definition: stat.c:512
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
SCIP_EXPORT void SCIPstatDebugMessagePrint(SCIP_STAT *stat, const char *formatstr,...)
Definition: stat.c:763
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
SCIP_EXPORT void SCIPstatPrintDebugMessage(SCIP_STAT *stat, const char *sourcefile, int sourceline, const char *formatstr,...)
Definition: stat.c:739
#define SCIP_Bool
Definition: def.h:70
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:164
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:149
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:427
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