Scippy

SCIP

Solving Constraint Integer Programs

scip_timing.c
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 scip_timing.c
17  * @brief public methods for timing
18  * @author Tobias Achterberg
19  * @author Timo Berthold
20  * @author Gerald Gamrath
21  * @author Robert Lion Gottwald
22  * @author Stefan Heinz
23  * @author Gregor Hendel
24  * @author Thorsten Koch
25  * @author Alexander Martin
26  * @author Marc Pfetsch
27  * @author Michael Winkler
28  * @author Kati Wolter
29  *
30  * @todo check all SCIP_STAGE_* switches, and include the new stages TRANSFORMED and INITSOLVE
31  */
32 
33 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
34 
35 #include "scip/clock.h"
36 #include "scip/conflict.h"
37 #include "scip/debug.h"
38 #include "scip/pub_message.h"
39 #include "scip/reader.h"
40 #include "scip/scip_numerics.h"
41 #include "scip/scip_timing.h"
42 #include "scip/set.h"
43 #include "scip/stat.h"
44 #include "scip/struct_scip.h"
45 #include "scip/struct_set.h"
46 #include "scip/struct_stat.h"
47 
48 /** gets current time of day in seconds (standard time zone)
49  *
50  * @return the current time of day in seconds (standard time zone).
51  */
53  SCIP* scip /**< SCIP data structure */
54  )
55 {
56  assert(scip != NULL);
57 
58  return SCIPclockGetTimeOfDay();
59 }
60 
61 /** creates a clock using the default clock type
62  *
63  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
64  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
65  */
67  SCIP* scip, /**< SCIP data structure */
68  SCIP_CLOCK** clck /**< pointer to clock timer */
69  )
70 {
71  assert(scip != NULL);
72 
74 
75  return SCIP_OKAY;
76 }
77 
78 /** creates a clock counting the CPU user seconds
79  *
80  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
81  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
82  */
84  SCIP* scip, /**< SCIP data structure */
85  SCIP_CLOCK** clck /**< pointer to clock timer */
86  )
87 {
88  assert(scip != NULL);
89 
91 
92  return SCIP_OKAY;
93 }
94 
95 /** creates a clock counting the wall clock seconds
96  *
97  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
98  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
99  */
101  SCIP* scip, /**< SCIP data structure */
102  SCIP_CLOCK** clck /**< pointer to clock timer */
103  )
104 {
105  assert(scip != NULL);
106 
108 
109  return SCIP_OKAY;
110 }
111 
112 /** frees a clock
113  *
114  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
115  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
116  */
118  SCIP* scip, /**< SCIP data structure */
119  SCIP_CLOCK** clck /**< pointer to clock timer */
120  )
121 {
122  assert(scip != NULL);
123 
124  SCIPclockFree(clck);
125 
126  return SCIP_OKAY;
127 }
128 
129 /** resets the time measurement of a clock to zero and completely stops the clock
130  *
131  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
132  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
133  */
135  SCIP* scip, /**< SCIP data structure */
136  SCIP_CLOCK* clck /**< clock timer */
137  )
138 {
139  assert(scip != NULL);
140 
141  SCIPclockReset(clck);
142 
143  return SCIP_OKAY;
144 }
145 
146 /** starts the time measurement of a clock
147  *
148  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
149  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
150  */
152  SCIP* scip, /**< SCIP data structure */
153  SCIP_CLOCK* clck /**< clock timer */
154  )
155 {
156  assert(scip != NULL);
157 
158  SCIPclockStart(clck, scip->set);
159 
160  return SCIP_OKAY;
161 }
162 
163 /** stops the time measurement of a clock
164  *
165  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
166  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
167  */
169  SCIP* scip, /**< SCIP data structure */
170  SCIP_CLOCK* clck /**< clock timer */
171  )
172 {
173  assert(scip != NULL);
174 
175  SCIPclockStop(clck, scip->set);
176 
177  return SCIP_OKAY;
178 }
179 
180 /** enables or disables all statistic clocks of SCIP concerning plugin statistics,
181  * LP execution time, strong branching time, etc.
182  *
183  * Method reads the value of the parameter timing/statistictiming. In order to disable statistic timing,
184  * set the parameter to FALSE.
185  *
186  * @note: The (pre-)solving time clocks which are relevant for the output during (pre-)solving
187  * are not affected by this method
188  *
189  * @see: For completely disabling all timing of SCIP, consider setting the parameter timing/enabled to FALSE
190  *
191  * @pre This method can be called if SCIP is in one of the following stages:
192  * - \ref SCIP_STAGE_INIT
193  * - \ref SCIP_STAGE_PROBLEM
194  * - \ref SCIP_STAGE_TRANSFORMING
195  * - \ref SCIP_STAGE_TRANSFORMED
196  * - \ref SCIP_STAGE_INITPRESOLVE
197  * - \ref SCIP_STAGE_PRESOLVING
198  * - \ref SCIP_STAGE_EXITPRESOLVE
199  * - \ref SCIP_STAGE_PRESOLVED
200  * - \ref SCIP_STAGE_INITSOLVE
201  * - \ref SCIP_STAGE_SOLVING
202  * - \ref SCIP_STAGE_SOLVED
203  * - \ref SCIP_STAGE_EXITSOLVE
204  * - \ref SCIP_STAGE_FREETRANS
205  *
206  * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
207  */
209  SCIP* scip /**< SCIP data structure */
210  )
211 {
212  SCIP_CALL( SCIPcheckStage(scip, "SCIPenableOrDisableStatisticTiming", TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
213 
215 
216  if( scip->set->stage > SCIP_STAGE_INIT )
217  {
218  assert(scip->stat != NULL);
220  }
221  if( scip->set->stage >= SCIP_STAGE_TRANSFORMING )
222  {
223  assert(scip->conflict != NULL);
225  }
226 
227  return SCIP_OKAY;
228 }
229 
230 /** starts the current solving time
231  *
232  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
233  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
234  *
235  * @pre This method can be called if SCIP is in one of the following stages:
236  * - \ref SCIP_STAGE_PROBLEM
237  * - \ref SCIP_STAGE_TRANSFORMING
238  * - \ref SCIP_STAGE_TRANSFORMED
239  * - \ref SCIP_STAGE_INITPRESOLVE
240  * - \ref SCIP_STAGE_PRESOLVING
241  * - \ref SCIP_STAGE_EXITPRESOLVE
242  * - \ref SCIP_STAGE_PRESOLVED
243  * - \ref SCIP_STAGE_INITSOLVE
244  * - \ref SCIP_STAGE_SOLVING
245  * - \ref SCIP_STAGE_SOLVED
246  * - \ref SCIP_STAGE_EXITSOLVE
247  * - \ref SCIP_STAGE_FREETRANS
248  *
249  * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
250  */
252  SCIP* scip /**< SCIP data structure */
253  )
254 {
255  SCIP_CALL( SCIPcheckStage(scip, "SCIPstartSolvingTime", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
256 
257  SCIPclockStart(scip->stat->solvingtime, scip->set);
258  SCIPclockStart(scip->stat->solvingtimeoverall, scip->set);
259 
260  return SCIP_OKAY;
261 }
262 
263 /** stops the current solving time in seconds
264  *
265  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
266  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
267  *
268  * @pre This method can be called if SCIP is in one of the following stages:
269  * - \ref SCIP_STAGE_PROBLEM
270  * - \ref SCIP_STAGE_TRANSFORMING
271  * - \ref SCIP_STAGE_TRANSFORMED
272  * - \ref SCIP_STAGE_INITPRESOLVE
273  * - \ref SCIP_STAGE_PRESOLVING
274  * - \ref SCIP_STAGE_EXITPRESOLVE
275  * - \ref SCIP_STAGE_PRESOLVED
276  * - \ref SCIP_STAGE_INITSOLVE
277  * - \ref SCIP_STAGE_SOLVING
278  * - \ref SCIP_STAGE_SOLVED
279  * - \ref SCIP_STAGE_EXITSOLVE
280  * - \ref SCIP_STAGE_FREETRANS
281  *
282  * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
283  */
285  SCIP* scip /**< SCIP data structure */
286  )
287 {
288  SCIP_CALL( SCIPcheckStage(scip, "SCIPstopSolvingTime", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
289 
290  SCIPclockStop(scip->stat->solvingtime, scip->set);
291  SCIPclockStop(scip->stat->solvingtimeoverall, scip->set);
292 
293  return SCIP_OKAY;
294 }
295 
296 /** gets the measured time of a clock in seconds
297  *
298  * @return the measured time of a clock in seconds.
299  */
301  SCIP* scip, /**< SCIP data structure */
302  SCIP_CLOCK* clck /**< clock timer */
303  )
304 {
305  assert(scip != NULL);
306 
307  return SCIPclockGetTime(clck);
308 }
309 
310 /** sets the measured time of a clock to the given value in seconds
311  *
312  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
313  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
314  */
316  SCIP* scip, /**< SCIP data structure */
317  SCIP_CLOCK* clck, /**< clock timer */
318  SCIP_Real sec /**< time in seconds to set the clock's timer to */
319  )
320 {
321  assert(scip != NULL);
322 
323  SCIPclockSetTime(clck, sec);
324 
325  return SCIP_OKAY;
326 }
327 
328 /** gets the current total SCIP time in seconds, possibly accumulated over several problems.
329  *
330  * @return the current total SCIP time in seconds, ie. the total time since the SCIP instance has been created
331  */
333  SCIP* scip /**< SCIP data structure */
334  )
335 {
336  assert(scip != NULL);
337 
338  return SCIPclockGetTime(scip->totaltime);
339 }
340 
341 /** gets the current solving time in seconds
342  *
343  * @return the current solving time in seconds.
344  *
345  * @pre This method can be called if SCIP is in one of the following stages:
346  * - \ref SCIP_STAGE_PROBLEM
347  * - \ref SCIP_STAGE_TRANSFORMING
348  * - \ref SCIP_STAGE_TRANSFORMED
349  * - \ref SCIP_STAGE_INITPRESOLVE
350  * - \ref SCIP_STAGE_PRESOLVING
351  * - \ref SCIP_STAGE_EXITPRESOLVE
352  * - \ref SCIP_STAGE_PRESOLVED
353  * - \ref SCIP_STAGE_INITSOLVE
354  * - \ref SCIP_STAGE_SOLVING
355  * - \ref SCIP_STAGE_SOLVED
356  *
357  * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
358  */
360  SCIP* scip /**< SCIP data structure */
361  )
362 {
363  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetSolvingTime", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
364 
365  return SCIPclockGetTime(scip->stat->solvingtime);
366 }
367 
368 /** gets the current reading time in seconds
369  *
370  * @return the current reading time in seconds.
371  *
372  * @pre This method can be called if SCIP is in one of the following stages:
373  * - \ref SCIP_STAGE_PROBLEM
374  * - \ref SCIP_STAGE_TRANSFORMING
375  * - \ref SCIP_STAGE_TRANSFORMED
376  * - \ref SCIP_STAGE_INITPRESOLVE
377  * - \ref SCIP_STAGE_PRESOLVING
378  * - \ref SCIP_STAGE_EXITPRESOLVE
379  * - \ref SCIP_STAGE_PRESOLVED
380  * - \ref SCIP_STAGE_INITSOLVE
381  * - \ref SCIP_STAGE_SOLVING
382  * - \ref SCIP_STAGE_SOLVED
383  *
384  * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
385  */
387  SCIP* scip /**< SCIP data structure */
388  )
389 {
390  SCIP_Real readingtime;
391  int r;
392 
393  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetReadingTime", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
394 
395  readingtime = 0.0;
396 
397  /* sum up the reading time of all readers */
398  for( r = 0; r < scip->set->nreaders; ++r )
399  {
400  assert(scip->set->readers[r] != NULL);
401  assert(!SCIPisNegative(scip, SCIPreaderGetReadingTime(scip->set->readers[r])));
402  readingtime += SCIPreaderGetReadingTime(scip->set->readers[r]);
403  }
404 
405  return readingtime;
406 }
407 
408 /** gets the current presolving time in seconds
409  *
410  * @return the current presolving time in seconds.
411  *
412  * @pre This method can be called if SCIP is in one of the following stages:
413  * - \ref SCIP_STAGE_INITPRESOLVE
414  * - \ref SCIP_STAGE_PRESOLVING
415  * - \ref SCIP_STAGE_EXITPRESOLVE
416  * - \ref SCIP_STAGE_PRESOLVED
417  * - \ref SCIP_STAGE_INITSOLVE
418  * - \ref SCIP_STAGE_SOLVING
419  * - \ref SCIP_STAGE_SOLVED
420  *
421  * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
422  */
424  SCIP* scip /**< SCIP data structure */
425  )
426 {
427  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetPresolvingTime", FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
428 
429  return SCIPclockGetTime(scip->stat->presolvingtime);
430 }
431 
432 /** gets the time need to solve the first LP in the root node
433  *
434  * @return the solving time for the first LP in the root node in seconds.
435  *
436  * @pre This method can be called if SCIP is in one of the following stages:
437  * - \ref SCIP_STAGE_TRANSFORMING
438  * - \ref SCIP_STAGE_TRANSFORMED
439  * - \ref SCIP_STAGE_INITPRESOLVE
440  * - \ref SCIP_STAGE_PRESOLVING
441  * - \ref SCIP_STAGE_EXITPRESOLVE
442  * - \ref SCIP_STAGE_PRESOLVED
443  * - \ref SCIP_STAGE_INITSOLVE
444  * - \ref SCIP_STAGE_SOLVING
445  * - \ref SCIP_STAGE_SOLVED
446  *
447  * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
448  */
450  SCIP* scip /**< SCIP data structure */
451  )
452 {
453  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetFirstLPTime", FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
454 
455  return scip->stat->firstlptime;
456 }
void SCIPconflictEnableOrDisableClocks(SCIP_CONFLICT *conflict, SCIP_Bool enable)
Definition: conflict.c:9021
SCIP_STAT * stat
Definition: struct_scip.h:69
#define NULL
Definition: def.h:253
SCIP_READER ** readers
Definition: struct_set.h:68
SCIP_RETCODE SCIPresetClock(SCIP *scip, SCIP_CLOCK *clck)
Definition: scip_timing.c:134
SCIP_CONFLICT * conflict
Definition: struct_scip.h:85
internal methods for clocks and timing issues
SCIP_RETCODE SCIPstopSolvingTime(SCIP *scip)
Definition: scip_timing.c:284
SCIP_RETCODE SCIPcreateClock(SCIP *scip, SCIP_CLOCK **clck)
Definition: scip_timing.c:66
SCIP_CLOCK * totaltime
Definition: struct_scip.h:66
public methods for timing
SCIP_Real SCIPgetReadingTime(SCIP *scip)
Definition: scip_timing.c:386
SCIP_Bool time_statistictiming
Definition: struct_set.h:554
void SCIPclockStop(SCIP_CLOCK *clck, SCIP_SET *set)
Definition: clock.c:350
SCIP_Real SCIPgetSolvingTime(SCIP *scip)
Definition: scip_timing.c:359
#define FALSE
Definition: def.h:73
void SCIPstatEnableOrDisableStatClocks(SCIP_STAT *stat, SCIP_Bool enable)
Definition: stat.c:647
void SCIPclockStart(SCIP_CLOCK *clck, SCIP_SET *set)
Definition: clock.c:280
SCIP_Real SCIPgetPresolvingTime(SCIP *scip)
Definition: scip_timing.c:423
SCIP_STAGE stage
Definition: struct_set.h:63
#define TRUE
Definition: def.h:72
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
SCIP_Real SCIPgetFirstLPTime(SCIP *scip)
Definition: scip_timing.c:449
SCIP_Real SCIPgetClockTime(SCIP *scip, SCIP_CLOCK *clck)
Definition: scip_timing.c:300
public methods for numerical tolerances
void SCIPclockSetTime(SCIP_CLOCK *clck, SCIP_Real sec)
Definition: clock.c:518
SCIP_RETCODE SCIPcreateCPUClock(SCIP *scip, SCIP_CLOCK **clck)
Definition: scip_timing.c:83
void SCIPclockReset(SCIP_CLOCK *clck)
Definition: clock.c:199
SCIP_RETCODE SCIPenableOrDisableStatisticTiming(SCIP *scip)
Definition: scip_timing.c:208
SCIP_RETCODE SCIPcheckStage(SCIP *scip, const char *method, SCIP_Bool init, SCIP_Bool problem, SCIP_Bool transforming, SCIP_Bool transformed, SCIP_Bool initpresolve, SCIP_Bool presolving, SCIP_Bool exitpresolve, SCIP_Bool presolved, SCIP_Bool initsolve, SCIP_Bool solving, SCIP_Bool solved, SCIP_Bool exitsolve, SCIP_Bool freetrans, SCIP_Bool freescip)
Definition: debug.c:2010
SCIP_CLOCK * solvingtimeoverall
Definition: struct_stat.h:145
SCIP_Real SCIPclockGetTime(SCIP_CLOCK *clck)
Definition: clock.c:428
internal methods for global SCIP settings
#define SCIP_CALL(x)
Definition: def.h:365
SCIP main data structure.
SCIP_RETCODE SCIPclockCreate(SCIP_CLOCK **clck, SCIP_CLOCKTYPE clocktype)
Definition: clock.c:160
SCIP_Real SCIPgetTotalTime(SCIP *scip)
Definition: scip_timing.c:332
SCIP_Real SCIPreaderGetReadingTime(SCIP_READER *reader)
Definition: reader.c:597
SCIP_CLOCK * presolvingtime
Definition: struct_stat.h:146
internal methods for input file readers
void SCIPclockFree(SCIP_CLOCK **clck)
Definition: clock.c:175
int nreaders
Definition: struct_set.h:97
methods for debugging
SCIP_Bool SCIPisNegative(SCIP *scip, SCIP_Real val)
SCIP_Real SCIPclockGetTimeOfDay(void)
Definition: clock.c:600
SCIP_RETCODE SCIPstopClock(SCIP *scip, SCIP_CLOCK *clck)
Definition: scip_timing.c:168
datastructures for problem statistics
SCIP_RETCODE SCIPfreeClock(SCIP *scip, SCIP_CLOCK **clck)
Definition: scip_timing.c:117
void SCIPsetEnableOrDisablePluginClocks(SCIP_SET *set, SCIP_Bool enabled)
Definition: set.c:830
SCIP_Real * r
Definition: circlepacking.c:50
internal methods for conflict analysis
SCIP_CLOCK * solvingtime
Definition: struct_stat.h:144
SCIP_SET * set
Definition: struct_scip.h:62
public methods for message output
#define SCIP_Real
Definition: def.h:164
internal methods for problem statistics
SCIP_RETCODE SCIPstartClock(SCIP *scip, SCIP_CLOCK *clck)
Definition: scip_timing.c:151
SCIP_Real SCIPgetTimeOfDay(SCIP *scip)
Definition: scip_timing.c:52
SCIP_Real firstlptime
Definition: struct_stat.h:130
SCIP_RETCODE SCIPsetClockTime(SCIP *scip, SCIP_CLOCK *clck, SCIP_Real sec)
Definition: scip_timing.c:315
#define SCIP_CALL_ABORT(x)
Definition: def.h:344
datastructures for global SCIP settings
SCIP_RETCODE SCIPcreateWallClock(SCIP *scip, SCIP_CLOCK **clck)
Definition: scip_timing.c:100
SCIP_RETCODE SCIPstartSolvingTime(SCIP *scip)
Definition: scip_timing.c:251