Scippy

SCIP

Solving Constraint Integer Programs

presol.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-2018 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 presol.c
17  * @brief methods for presolvers
18  * @author Tobias Achterberg
19  * @author Timo Berthold
20  *
21  * @todo add maxrounds parameter for single timings, count number of runs of a presolver with given timing
22  */
23 
24 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
25 
26 #include <assert.h>
27 #include <string.h>
28 
29 #include "scip/def.h"
30 #include "blockmemshell/memory.h"
31 #include "scip/set.h"
32 #include "scip/clock.h"
33 #include "scip/paramset.h"
34 #include "scip/scip.h"
35 #include "scip/pub_misc.h"
36 #include "scip/presol.h"
37 
38 #include "scip/struct_presol.h"
39 
40 
41 
42 /*
43  * presolver methods
44  */
45 
46 /** compares two presolvers w. r. to their priority */
47 SCIP_DECL_SORTPTRCOMP(SCIPpresolComp)
48 { /*lint --e{715}*/
49  return ((SCIP_PRESOL*)elem2)->priority - ((SCIP_PRESOL*)elem1)->priority;
50 }
51 
52 /** comparison method for sorting presolvers w.r.t. to their name */
53 SCIP_DECL_SORTPTRCOMP(SCIPpresolCompName)
54 {
55  return strcmp(SCIPpresolGetName((SCIP_PRESOL*)elem1), SCIPpresolGetName((SCIP_PRESOL*)elem2));
56 }
57 
58 /** method to call, when the priority of a presolver was changed */
59 static
60 SCIP_DECL_PARAMCHGD(paramChgdPresolPriority)
61 { /*lint --e{715}*/
62  SCIP_PARAMDATA* paramdata;
63 
64  paramdata = SCIPparamGetData(param);
65  assert(paramdata != NULL);
66 
67  /* use SCIPsetPresolPriority() to mark the presols unsorted */
68  SCIP_CALL( SCIPsetPresolPriority(scip, (SCIP_PRESOL*)paramdata, SCIPparamGetInt(param)) ); /*lint !e740*/
69 
70  return SCIP_OKAY;
71 }
72 
73 /** copies the given presolver to a new scip */
75  SCIP_PRESOL* presol, /**< presolver */
76  SCIP_SET* set /**< SCIP_SET of SCIP to copy to */
77  )
78 {
79  assert(presol != NULL);
80  assert(set != NULL);
81  assert(set->scip != NULL);
82 
83  if( presol->presolcopy != NULL )
84  {
85  SCIPsetDebugMsg(set, "including presolver %s in subscip %p\n", SCIPpresolGetName(presol), (void*)set->scip);
86  SCIP_CALL( presol->presolcopy(set->scip, presol) );
87  }
88  return SCIP_OKAY;
89 }
90 
91 /** creates a presolver */
93  SCIP_PRESOL** presol, /**< pointer to store presolver */
94  SCIP_SET* set, /**< global SCIP settings */
95  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
96  BMS_BLKMEM* blkmem, /**< block memory for parameter settings */
97  const char* name, /**< name of presolver */
98  const char* desc, /**< description of presolver */
99  int priority, /**< priority of the presolver (>= 0: before, < 0: after constraint handlers) */
100  int maxrounds, /**< maximal number of presolving rounds the presolver participates in (-1: no limit) */
101  SCIP_PRESOLTIMING timing, /**< timing mask of the presolver */
102  SCIP_DECL_PRESOLCOPY ((*presolcopy)), /**< copy method of presolver or NULL if you don't want to copy your plugin into sub-SCIPs */
103  SCIP_DECL_PRESOLFREE ((*presolfree)), /**< destructor of presolver to free user data (called when SCIP is exiting) */
104  SCIP_DECL_PRESOLINIT ((*presolinit)), /**< initialization method of presolver (called after problem was transformed) */
105  SCIP_DECL_PRESOLEXIT ((*presolexit)), /**< deinitialization method of presolver (called before transformed problem is freed) */
106  SCIP_DECL_PRESOLINITPRE((*presolinitpre)),/**< presolving initialization method of presolver (called when presolving is about to begin) */
107  SCIP_DECL_PRESOLEXITPRE((*presolexitpre)),/**< presolving deinitialization method of presolver (called after presolving has been finished) */
108  SCIP_DECL_PRESOLEXEC ((*presolexec)), /**< execution method of presolver */
109  SCIP_PRESOLDATA* presoldata /**< presolver data */
110  )
111 {
112  char paramname[SCIP_MAXSTRLEN];
113  char paramdesc[SCIP_MAXSTRLEN];
114 
115  assert(presol != NULL);
116  assert(name != NULL);
117  assert(desc != NULL);
118 
119  /* the interface change from delay flags to timings cannot be recognized at compile time: Exit with an appropriate
120  * error message
121  */
122  if( timing < SCIP_PRESOLTIMING_NONE || timing > SCIP_PRESOLTIMING_MAX )
123  {
124  SCIPmessagePrintError("ERROR: 'PRESOLDELAY'-flag no longer available since SCIP 3.2, use an appropriate "
125  "'SCIP_PRESOLTIMING' for <%s> presolver instead.\n", name);
126 
127  return SCIP_PARAMETERWRONGVAL;
128  }
129 
130  SCIP_ALLOC( BMSallocMemory(presol) );
131  SCIP_ALLOC( BMSduplicateMemoryArray(&(*presol)->name, name, strlen(name)+1) );
132  SCIP_ALLOC( BMSduplicateMemoryArray(&(*presol)->desc, desc, strlen(desc)+1) );
133  (*presol)->presolcopy = presolcopy;
134  (*presol)->presolfree = presolfree;
135  (*presol)->presolinit = presolinit;
136  (*presol)->presolexit = presolexit;
137  (*presol)->presolinitpre = presolinitpre;
138  (*presol)->presolexitpre = presolexitpre;
139  (*presol)->presolexec = presolexec;
140  (*presol)->presoldata = presoldata;
141  SCIP_CALL( SCIPclockCreate(&(*presol)->setuptime, SCIP_CLOCKTYPE_DEFAULT) );
142  SCIP_CALL( SCIPclockCreate(&(*presol)->presolclock, SCIP_CLOCKTYPE_DEFAULT) );
143  (*presol)->initialized = FALSE;
144 
145  /* add parameters */
146  (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "presolving/%s/priority", name);
147  (void) SCIPsnprintf(paramdesc, SCIP_MAXSTRLEN, "priority of presolver <%s>", name);
148  SCIP_CALL( SCIPsetAddIntParam(set, messagehdlr, blkmem, paramname, paramdesc,
149  &(*presol)->priority, TRUE, priority, INT_MIN/4, INT_MAX/4,
150  paramChgdPresolPriority, (SCIP_PARAMDATA*)(*presol)) ); /*lint !e740*/
151 
152  (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "presolving/%s/maxrounds", name);
153  SCIP_CALL( SCIPsetAddIntParam(set, messagehdlr, blkmem, paramname,
154  "maximal number of presolving rounds the presolver participates in (-1: no limit)",
155  &(*presol)->maxrounds, FALSE, maxrounds, -1, INT_MAX, NULL, NULL) ); /*lint !e740*/
156 
157  (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "presolving/%s/timing", name);
158  (void) SCIPsnprintf(paramdesc, SCIP_MAXSTRLEN, "timing mask of presolver <%s> (%u:FAST, %u:MEDIUM, %u:EXHAUSTIVE, %u:FINAL)",
160  SCIP_CALL( SCIPsetAddIntParam(set, messagehdlr, blkmem, paramname, paramdesc,
161  (int*)&(*presol)->timing, TRUE, (int)timing, (int) SCIP_PRESOLTIMING_FAST, (int) SCIP_PRESOLTIMING_MAX, NULL, NULL) ); /*lint !e740*/
162 
163  return SCIP_OKAY;
164 }
165 
166 /** frees memory of presolver */
168  SCIP_PRESOL** presol, /**< pointer to presolver data structure */
169  SCIP_SET* set /**< global SCIP settings */
170  )
171 {
172  assert(presol != NULL);
173  assert(*presol != NULL);
174  assert(!(*presol)->initialized);
175  assert(set != NULL);
176 
177  /* call destructor of presolver */
178  if( (*presol)->presolfree != NULL )
179  {
180  SCIP_CALL( (*presol)->presolfree(set->scip, *presol) );
181  }
182 
183  SCIPclockFree(&(*presol)->presolclock);
184  SCIPclockFree(&(*presol)->setuptime);
185  BMSfreeMemoryArray(&(*presol)->name);
186  BMSfreeMemoryArray(&(*presol)->desc);
187  BMSfreeMemory(presol);
188 
189  return SCIP_OKAY;
190 }
191 
192 /** initializes presolver */
194  SCIP_PRESOL* presol, /**< presolver */
195  SCIP_SET* set /**< global SCIP settings */
196  )
197 {
198  assert(presol != NULL);
199  assert(set != NULL);
200 
201  if( presol->initialized )
202  {
203  SCIPerrorMessage("presolver <%s> already initialized\n", presol->name);
204  return SCIP_INVALIDCALL;
205  }
206 
207  if( set->misc_resetstat )
208  {
209  SCIPclockReset(presol->setuptime);
210  SCIPclockReset(presol->presolclock);
211 
212  presol->lastnfixedvars = 0;
213  presol->lastnaggrvars = 0;
214  presol->lastnchgvartypes = 0;
215  presol->lastnchgbds = 0;
216  presol->lastnaddholes = 0;
217  presol->lastndelconss = 0;
218  presol->lastnaddconss = 0;
219  presol->lastnupgdconss = 0;
220  presol->lastnchgcoefs = 0;
221  presol->lastnchgsides = 0;
222  presol->nfixedvars = 0;
223  presol->naggrvars = 0;
224  presol->nchgvartypes = 0;
225  presol->nchgbds = 0;
226  presol->naddholes = 0;
227  presol->ndelconss = 0;
228  presol->naddconss = 0;
229  presol->nupgdconss = 0;
230  presol->nchgcoefs = 0;
231  presol->nchgsides = 0;
232  presol->ncalls = 0;
233  }
234 
235  /* call initialization method of presolver */
236  if( presol->presolinit != NULL )
237  {
238  /* start timing */
239  SCIPclockStart(presol->setuptime, set);
240 
241  SCIP_CALL( presol->presolinit(set->scip, presol) );
242 
243  /* stop timing */
244  SCIPclockStop(presol->setuptime, set);
245  }
246  presol->initialized = TRUE;
247 
248  return SCIP_OKAY;
249 }
250 
251 /** deinitializes presolver */
253  SCIP_PRESOL* presol, /**< presolver */
254  SCIP_SET* set /**< global SCIP settings */
255  )
256 {
257  assert(presol != NULL);
258  assert(set != NULL);
259 
260  if( !presol->initialized )
261  {
262  SCIPerrorMessage("presolver <%s> not initialized\n", presol->name);
263  return SCIP_INVALIDCALL;
264  }
265 
266  /* call deinitialization method of presolver */
267  if( presol->presolexit != NULL )
268  {
269  /* start timing */
270  SCIPclockStart(presol->setuptime, set);
271 
272  SCIP_CALL( presol->presolexit(set->scip, presol) );
273 
274  /* stop timing */
275  SCIPclockStop(presol->setuptime, set);
276  }
277  presol->initialized = FALSE;
278 
279  return SCIP_OKAY;
280 }
281 
282 /** informs presolver that the presolving process is being started */
284  SCIP_PRESOL* presol, /**< presolver */
285  SCIP_SET* set /**< global SCIP settings */
286  )
287 {
288  assert(presol != NULL);
289  assert(set != NULL);
290 
291  presol->lastnfixedvars = 0;
292  presol->lastnaggrvars = 0;
293  presol->lastnchgvartypes = 0;
294  presol->lastnchgbds = 0;
295  presol->lastnaddholes = 0;
296  presol->lastndelconss = 0;
297  presol->lastnaddconss = 0;
298  presol->lastnupgdconss = 0;
299  presol->lastnchgcoefs = 0;
300  presol->lastnchgsides = 0;
301 
302  /* call presolving initialization method of presolver */
303  if( presol->presolinitpre != NULL )
304  {
305  /* start timing */
306  SCIPclockStart(presol->setuptime, set);
307 
308  SCIP_CALL( presol->presolinitpre(set->scip, presol) );
309 
310  /* stop timing */
311  SCIPclockStop(presol->setuptime, set);
312  }
313 
314  return SCIP_OKAY;
315 }
316 
317 /** informs presolver that the presolving process is finished */
319  SCIP_PRESOL* presol, /**< presolver */
320  SCIP_SET* set /**< global SCIP settings */
321  )
322 {
323  assert(presol != NULL);
324  assert(set != NULL);
325 
326  /* call presolving deinitialization method of presolver */
327  if( presol->presolexitpre != NULL )
328  {
329  /* start timing */
330  SCIPclockStart(presol->setuptime, set);
331 
332  SCIP_CALL( presol->presolexitpre(set->scip, presol) );
333 
334  /* stop timing */
335  SCIPclockStop(presol->setuptime, set);
336  }
337 
338  return SCIP_OKAY;
339 }
340 
341 /** executes presolver */
343  SCIP_PRESOL* presol, /**< presolver */
344  SCIP_SET* set, /**< global SCIP settings */
345  SCIP_PRESOLTIMING timing, /**< current presolving timing */
346  int nrounds, /**< number of presolving rounds already done */
347  int* nfixedvars, /**< pointer to total number of variables fixed of all presolvers */
348  int* naggrvars, /**< pointer to total number of variables aggregated of all presolvers */
349  int* nchgvartypes, /**< pointer to total number of variable type changes of all presolvers */
350  int* nchgbds, /**< pointer to total number of variable bounds tightened of all presolvers */
351  int* naddholes, /**< pointer to total number of domain holes added of all presolvers */
352  int* ndelconss, /**< pointer to total number of deleted constraints of all presolvers */
353  int* naddconss, /**< pointer to total number of added constraints of all presolvers */
354  int* nupgdconss, /**< pointer to total number of upgraded constraints of all presolvers */
355  int* nchgcoefs, /**< pointer to total number of changed coefficients of all presolvers */
356  int* nchgsides, /**< pointer to total number of changed left/right hand sides of all presolvers */
357  SCIP_RESULT* result /**< pointer to store the result of the callback method */
358  )
359 {
360  int nnewfixedvars;
361  int nnewaggrvars;
362  int nnewchgvartypes;
363  int nnewchgbds;
364  int nnewaddholes;
365  int nnewdelconss;
366  int nnewaddconss;
367  int nnewupgdconss;
368  int nnewchgcoefs;
369  int nnewchgsides;
370 
371  assert(presol != NULL);
372  assert(presol->presolexec != NULL);
373  assert(set != NULL);
374  assert(nfixedvars != NULL);
375  assert(naggrvars != NULL);
376  assert(nchgvartypes != NULL);
377  assert(nchgbds != NULL);
378  assert(naddholes != NULL);
379  assert(ndelconss != NULL);
380  assert(naddconss != NULL);
381  assert(nupgdconss != NULL);
382  assert(nchgcoefs != NULL);
383  assert(nchgsides != NULL);
384  assert(result != NULL);
385 
386  *result = SCIP_DIDNOTRUN;
387 
388  /* check number of presolving rounds */
389  if( presol->maxrounds >= 0 && nrounds >= presol->maxrounds )
390  return SCIP_OKAY;
391 
392  /* calculate the number of changes since last call */
393  nnewfixedvars = *nfixedvars - presol->lastnfixedvars;
394  nnewaggrvars = *naggrvars - presol->lastnaggrvars;
395  nnewchgvartypes = *nchgvartypes - presol->lastnchgvartypes;
396  nnewchgbds = *nchgbds - presol->lastnchgbds;
397  nnewaddholes = *naddholes - presol->lastnaddholes;
398  nnewdelconss = *ndelconss - presol->lastndelconss;
399  nnewaddconss = *naddconss - presol->lastnaddconss;
400  nnewupgdconss = *nupgdconss - presol->lastnupgdconss;
401  nnewchgcoefs = *nchgcoefs - presol->lastnchgcoefs;
402  nnewchgsides = *nchgsides - presol->lastnchgsides;
403 
404  /* remember the number of changes prior to the call of the presolver */
405  presol->lastnfixedvars = *nfixedvars;
406  presol->lastnaggrvars = *naggrvars;
407  presol->lastnchgvartypes = *nchgvartypes;
408  presol->lastnchgbds = *nchgbds;
409  presol->lastnaddholes = *naddholes;
410  presol->lastndelconss = *ndelconss;
411  presol->lastnaddconss = *naddconss;
412  presol->lastnupgdconss = *nupgdconss;
413  presol->lastnchgcoefs = *nchgcoefs;
414  presol->lastnchgsides = *nchgsides;
415 
416  /* check, if presolver should be called with the current timing */
417  if( timing & presol->timing )
418  {
419  SCIPsetDebugMsg(set, "calling presolver <%s> with timing %u\n", presol->name, timing);
420 
421  /* start timing */
422  SCIPclockStart(presol->presolclock, set);
423 
424  /* call external method */
425  SCIP_CALL( presol->presolexec(set->scip, presol, nrounds, timing,
426  nnewfixedvars, nnewaggrvars, nnewchgvartypes, nnewchgbds, nnewaddholes,
427  nnewdelconss, nnewaddconss, nnewupgdconss, nnewchgcoefs, nnewchgsides,
428  nfixedvars, naggrvars, nchgvartypes, nchgbds, naddholes,
429  ndelconss, naddconss, nupgdconss, nchgcoefs, nchgsides, result) );
430 
431  /* stop timing */
432  SCIPclockStop(presol->presolclock, set);
433 
434  /* add/count the new changes */
435  presol->nfixedvars += *nfixedvars - presol->lastnfixedvars;
436  presol->naggrvars += *naggrvars - presol->lastnaggrvars;
437  presol->nchgvartypes += *nchgvartypes - presol->lastnchgvartypes;
438  presol->nchgbds += *nchgbds - presol->lastnchgbds;
439  presol->naddholes += *naddholes - presol->lastnaddholes;
440  presol->ndelconss += *ndelconss - presol->lastndelconss;
441  presol->naddconss += *naddconss - presol->lastnaddconss;
442  presol->nupgdconss += *nupgdconss - presol->lastnupgdconss;
443  presol->nchgcoefs += *nchgcoefs - presol->lastnchgcoefs;
444  presol->nchgsides += *nchgsides - presol->lastnchgsides;
445 
446  /* check result code of callback method */
447  if( *result != SCIP_CUTOFF
448  && *result != SCIP_UNBOUNDED
449  && *result != SCIP_SUCCESS
450  && *result != SCIP_DIDNOTFIND
451  && *result != SCIP_DIDNOTRUN )
452  {
453  SCIPerrorMessage("presolver <%s> returned invalid result <%d>\n", presol->name, *result);
454  return SCIP_INVALIDRESULT;
455  }
456 
457  /* increase the number of calls, if the presolver tried to find reductions */
458  if( *result != SCIP_DIDNOTRUN )
459  ++(presol->ncalls);
460  }
461 
462  return SCIP_OKAY;
463 }
464 
465 /** gets user data of presolver */
467  SCIP_PRESOL* presol /**< presolver */
468  )
469 {
470  assert(presol != NULL);
471 
472  return presol->presoldata;
473 }
474 
475 /** sets user data of presolver; user has to free old data in advance! */
477  SCIP_PRESOL* presol, /**< presolver */
478  SCIP_PRESOLDATA* presoldata /**< new presolver user data */
479  )
480 {
481  assert(presol != NULL);
482 
483  presol->presoldata = presoldata;
484 }
485 
486 /** sets copy method of presolver */
488  SCIP_PRESOL* presol, /**< presolver */
489  SCIP_DECL_PRESOLCOPY ((*presolcopy)) /**< copy method of presolver or NULL if you don't want to copy your plugin into sub-SCIPs */
490  )
491 {
492  assert(presol != NULL);
493 
494  presol->presolcopy = presolcopy;
495 }
496 
497 /** sets destructor method of presolver */
499  SCIP_PRESOL* presol, /**< presolver */
500  SCIP_DECL_PRESOLFREE ((*presolfree)) /**< destructor of presolver */
501  )
502 {
503  assert(presol != NULL);
504 
505  presol->presolfree = presolfree;
506 }
507 
508 /** sets initialization method of presolver */
510  SCIP_PRESOL* presol, /**< presolver */
511  SCIP_DECL_PRESOLINIT ((*presolinit)) /**< initialize presolver */
512  )
513 {
514  assert(presol != NULL);
515 
516  presol->presolinit = presolinit;
517 }
518 
519 /** sets deinitialization method of presolver */
521  SCIP_PRESOL* presol, /**< presolver */
522  SCIP_DECL_PRESOLEXIT ((*presolexit)) /**< deinitialize presolver */
523  )
524 {
525  assert(presol != NULL);
526 
527  presol->presolexit = presolexit;
528 }
529 
530 /** sets solving process initialization method of presolver */
532  SCIP_PRESOL* presol, /**< presolver */
533  SCIP_DECL_PRESOLINITPRE ((*presolinitpre))/**< solving process initialization method of presolver */
534  )
535 {
536  assert(presol != NULL);
537 
538  presol->presolinitpre = presolinitpre;
539 }
540 
541 /** sets solving process deinitialization method of presolver */
543  SCIP_PRESOL* presol, /**< presolver */
544  SCIP_DECL_PRESOLEXITPRE ((*presolexitpre))/**< solving process deinitialization method of presolver */
545  )
546 {
547  assert(presol != NULL);
548 
549  presol->presolexitpre = presolexitpre;
550 }
551 
552 /** gets name of presolver */
553 const char* SCIPpresolGetName(
554  SCIP_PRESOL* presol /**< presolver */
555  )
556 {
557  assert(presol != NULL);
558 
559  return presol->name;
560 }
561 
562 /** gets description of presolver */
563 const char* SCIPpresolGetDesc(
564  SCIP_PRESOL* presol /**< presolver */
565  )
566 {
567  assert(presol != NULL);
568 
569  return presol->desc;
570 }
571 
572 /** gets priority of presolver */
574  SCIP_PRESOL* presol /**< presolver */
575  )
576 {
577  assert(presol != NULL);
578 
579  return presol->priority;
580 }
581 
582 /** gets round limit of presolver */
584  SCIP_PRESOL* presol /**< presolver */
585  )
586 {
587  assert(presol != NULL);
588 
589  return presol->maxrounds;
590 }
591 
592 /** sets priority of presolver */
594  SCIP_PRESOL* presol, /**< presolver */
595  SCIP_SET* set, /**< global SCIP settings */
596  int priority /**< new priority of the presolver */
597  )
598 {
599  assert(presol != NULL);
600  assert(set != NULL);
601 
602  presol->priority = priority;
603  set->presolssorted = FALSE;
604 }
605 
606 /** gets the timing mask of the presolver */
608  SCIP_PRESOL* presol /**< presolver */
609  )
610 {
611  assert(presol != NULL);
612 
613  return presol->timing;
614 }
615 
616 /** sets the timing mask of the presolver */
618  SCIP_PRESOL* presol, /**< presolver */
619  SCIP_PRESOLTIMING timing /**< timing mask of the presolver */
620  )
621 {
622  assert(presol != NULL);
623 
624  presol->timing = timing;
625 }
626 
627 
628 /** is presolver initialized? */
630  SCIP_PRESOL* presol /**< presolver */
631  )
632 {
633  assert(presol != NULL);
634 
635  return presol->initialized;
636 }
637 
638 /** enables or disables all clocks of \p presol, depending on the value of the flag */
640  SCIP_PRESOL* presol, /**< the presolver for which all clocks should be enabled or disabled */
641  SCIP_Bool enable /**< should the clocks of the presolver be enabled? */
642  )
643 {
644  assert(presol != NULL);
645 
646  SCIPclockEnableOrDisable(presol->setuptime, enable);
647  SCIPclockEnableOrDisable(presol->presolclock, enable);
648 }
649 
650 /** gets time in seconds used in this presolver for setting up for next stages */
652  SCIP_PRESOL* presol /**< presolver */
653  )
654 {
655  assert(presol != NULL);
656 
657  return SCIPclockGetTime(presol->setuptime);
658 }
659 
660 /** gets time in seconds used in this presolver */
662  SCIP_PRESOL* presol /**< presolver */
663  )
664 {
665  assert(presol != NULL);
666 
667  return SCIPclockGetTime(presol->presolclock);
668 }
669 
670 /** gets number of variables fixed in presolver */
672  SCIP_PRESOL* presol /**< presolver */
673  )
674 {
675  assert(presol != NULL);
676 
677  return presol->nfixedvars;
678 }
679 
680 /** gets number of variables aggregated in presolver */
682  SCIP_PRESOL* presol /**< presolver */
683  )
684 {
685  assert(presol != NULL);
686 
687  return presol->naggrvars;
688 }
689 
690 /** gets number of variable types changed in presolver */
692  SCIP_PRESOL* presol /**< presolver */
693  )
694 {
695  assert(presol != NULL);
696 
697  return presol->nchgvartypes;
698 }
699 
700 /** gets number of bounds changed in presolver */
702  SCIP_PRESOL* presol /**< presolver */
703  )
704 {
705  assert(presol != NULL);
706 
707  return presol->nchgbds;
708 }
709 
710 /** gets number of holes added to domains of variables in presolver */
712  SCIP_PRESOL* presol /**< presolver */
713  )
714 {
715  assert(presol != NULL);
716 
717  return presol->naddholes;
718 }
719 
720 /** gets number of constraints deleted in presolver */
722  SCIP_PRESOL* presol /**< presolver */
723  )
724 {
725  assert(presol != NULL);
726 
727  return presol->ndelconss;
728 }
729 
730 /** gets number of constraints added in presolver */
732  SCIP_PRESOL* presol /**< presolver */
733  )
734 {
735  assert(presol != NULL);
736 
737  return presol->naddconss;
738 }
739 
740 /** gets number of constraints upgraded in presolver */
742  SCIP_PRESOL* presol /**< presolver */
743  )
744 {
745  assert(presol != NULL);
746 
747  return presol->nupgdconss;
748 }
749 
750 /** gets number of coefficients changed in presolver */
752  SCIP_PRESOL* presol /**< presolver */
753  )
754 {
755  assert(presol != NULL);
756 
757  return presol->nchgcoefs;
758 }
759 
760 /** gets number of constraint sides changed in presolver */
762  SCIP_PRESOL* presol /**< presolver */
763  )
764 {
765  assert(presol != NULL);
766 
767  return presol->nchgsides;
768 }
769 
770 /** gets number of times the presolver was called and tried to find reductions */
772  SCIP_PRESOL* presol /**< presolver */
773  )
774 {
775  assert(presol != NULL);
776 
777  return presol->ncalls;
778 }
enum SCIP_Result SCIP_RESULT
Definition: type_result.h:52
int lastnfixedvars
Definition: struct_presol.h:53
int SCIPpresolGetNDelConss(SCIP_PRESOL *presol)
Definition: presol.c:721
struct SCIP_PresolData SCIP_PRESOLDATA
Definition: type_presol.h:37
int SCIPpresolGetNAggrVars(SCIP_PRESOL *presol)
Definition: presol.c:681
SCIP_RETCODE SCIPpresolInit(SCIP_PRESOL *presol, SCIP_SET *set)
Definition: presol.c:193
static SCIP_DECL_PARAMCHGD(paramChgdPresolPriority)
Definition: presol.c:60
SCIP_PRESOLTIMING timing
Definition: struct_presol.h:75
SCIP_PARAMDATA * SCIPparamGetData(SCIP_PARAM *param)
Definition: paramset.c:661
datastructures for presolvers
#define SCIP_MAXSTRLEN
Definition: def.h:259
SCIP_RETCODE SCIPpresolFree(SCIP_PRESOL **presol, SCIP_SET *set)
Definition: presol.c:167
internal methods for clocks and timing issues
struct SCIP_ParamData SCIP_PARAMDATA
Definition: type_paramset.h:76
void SCIPpresolSetPriority(SCIP_PRESOL *presol, SCIP_SET *set, int priority)
Definition: presol.c:593
#define SCIP_DECL_PRESOLINITPRE(x)
Definition: type_presol.h:84
SCIP_CLOCK * presolclock
Definition: struct_presol.h:50
int SCIPpresolGetNChgCoefs(SCIP_PRESOL *presol)
Definition: presol.c:751
SCIP_RETCODE SCIPpresolExit(SCIP_PRESOL *presol, SCIP_SET *set)
Definition: presol.c:252
void SCIPclockStop(SCIP_CLOCK *clck, SCIP_SET *set)
Definition: clock.c:350
#define FALSE
Definition: def.h:64
#define SCIP_DECL_PRESOLCOPY(x)
Definition: type_presol.h:46
void SCIPclockStart(SCIP_CLOCK *clck, SCIP_SET *set)
Definition: clock.c:280
SCIP_DECL_SORTPTRCOMP(SCIPpresolComp)
Definition: presol.c:47
int SCIPsnprintf(char *t, int len, const char *s,...)
Definition: misc.c:10011
#define TRUE
Definition: def.h:63
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
#define SCIP_PRESOLTIMING_EXHAUSTIVE
Definition: type_timing.h:45
SCIP_PRESOLDATA * SCIPpresolGetData(SCIP_PRESOL *presol)
Definition: presol.c:466
int lastnupgdconss
Definition: struct_presol.h:60
int SCIPpresolGetNFixedVars(SCIP_PRESOL *presol)
Definition: presol.c:671
internal methods for handling parameter settings
const char * SCIPpresolGetDesc(SCIP_PRESOL *presol)
Definition: presol.c:563
SCIP_CLOCK * setuptime
Definition: struct_presol.h:49
void SCIPclockEnableOrDisable(SCIP_CLOCK *clck, SCIP_Bool enable)
Definition: clock.c:250
#define BMSfreeMemory(ptr)
Definition: memory.h:127
SCIP_Bool SCIPpresolIsInitialized(SCIP_PRESOL *presol)
Definition: presol.c:629
SCIP_Real SCIPpresolGetSetupTime(SCIP_PRESOL *presol)
Definition: presol.c:651
#define SCIP_PRESOLTIMING_FAST
Definition: type_timing.h:43
int SCIPpresolGetNChgVarTypes(SCIP_PRESOL *presol)
Definition: presol.c:691
SCIP_RETCODE SCIPpresolCreate(SCIP_PRESOL **presol, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, BMS_BLKMEM *blkmem, const char *name, const char *desc, int priority, int maxrounds, SCIP_PRESOLTIMING timing, SCIP_DECL_PRESOLCOPY((*presolcopy)), SCIP_DECL_PRESOLFREE((*presolfree)), SCIP_DECL_PRESOLINIT((*presolinit)), SCIP_DECL_PRESOLEXIT((*presolexit)), SCIP_DECL_PRESOLINITPRE((*presolinitpre)), SCIP_DECL_PRESOLEXITPRE((*presolexitpre)), SCIP_DECL_PRESOLEXEC((*presolexec)), SCIP_PRESOLDATA *presoldata)
Definition: presol.c:92
#define SCIP_DECL_PRESOLEXEC(x)
Definition: type_presol.h:153
#define SCIP_PRESOLTIMING_MEDIUM
Definition: type_timing.h:44
#define BMSfreeMemoryArray(ptr)
Definition: memory.h:129
void SCIPmessagePrintError(const char *formatstr,...)
Definition: message.c:781
#define SCIPerrorMessage
Definition: pub_message.h:45
#define SCIP_DECL_PRESOLFREE(x)
Definition: type_presol.h:54
SCIP_RETCODE SCIPpresolExec(SCIP_PRESOL *presol, SCIP_SET *set, SCIP_PRESOLTIMING timing, int nrounds, int *nfixedvars, int *naggrvars, int *nchgvartypes, int *nchgbds, int *naddholes, int *ndelconss, int *naddconss, int *nupgdconss, int *nchgcoefs, int *nchgsides, SCIP_RESULT *result)
Definition: presol.c:342
void SCIPclockReset(SCIP_CLOCK *clck)
Definition: clock.c:199
void SCIPpresolSetData(SCIP_PRESOL *presol, SCIP_PRESOLDATA *presoldata)
Definition: presol.c:476
#define SCIP_DECL_PRESOLEXIT(x)
Definition: type_presol.h:70
void SCIPpresolEnableOrDisableClocks(SCIP_PRESOL *presol, SCIP_Bool enable)
Definition: presol.c:639
internal methods for presolvers
SCIP_Real SCIPclockGetTime(SCIP_CLOCK *clck)
Definition: clock.c:428
int SCIPpresolGetPriority(SCIP_PRESOL *presol)
Definition: presol.c:573
SCIP_RETCODE SCIPsetPresolPriority(SCIP *scip, SCIP_PRESOL *presol, int priority)
Definition: scip.c:7085
internal methods for global SCIP settings
#define SCIP_CALL(x)
Definition: def.h:350
unsigned int SCIP_PRESOLTIMING
Definition: type_timing.h:52
SCIP_RETCODE SCIPsetAddIntParam(SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, BMS_BLKMEM *blkmem, const char *name, const char *desc, int *valueptr, SCIP_Bool isadvanced, int defaultvalue, int minvalue, int maxvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
Definition: set.c:2813
void SCIPpresolSetInitpre(SCIP_PRESOL *presol, SCIP_DECL_PRESOLINITPRE((*presolinitpre)))
Definition: presol.c:531
#define BMSduplicateMemoryArray(ptr, source, num)
Definition: memory.h:125
SCIP_RETCODE SCIPclockCreate(SCIP_CLOCK **clck, SCIP_CLOCKTYPE clocktype)
Definition: clock.c:160
public data structures and miscellaneous methods
#define SCIP_Bool
Definition: def.h:61
#define SCIP_DECL_PRESOLEXITPRE(x)
Definition: type_presol.h:102
SCIP_Real SCIPpresolGetTime(SCIP_PRESOL *presol)
Definition: presol.c:661
void SCIPpresolSetFree(SCIP_PRESOL *presol, SCIP_DECL_PRESOLFREE((*presolfree)))
Definition: presol.c:498
int lastnchgvartypes
Definition: struct_presol.h:55
int SCIPpresolGetNCalls(SCIP_PRESOL *presol)
Definition: presol.c:771
void SCIPclockFree(SCIP_CLOCK **clck)
Definition: clock.c:175
#define SCIP_DECL_PRESOLINIT(x)
Definition: type_presol.h:62
int SCIPpresolGetMaxrounds(SCIP_PRESOL *presol)
Definition: presol.c:583
#define SCIPsetDebugMsg
Definition: set.h:1913
const char * SCIPpresolGetName(SCIP_PRESOL *presol)
Definition: presol.c:553
SCIP_Bool initialized
Definition: struct_presol.h:74
void SCIPpresolSetInit(SCIP_PRESOL *presol, SCIP_DECL_PRESOLINIT((*presolinit)))
Definition: presol.c:509
#define SCIP_PRESOLTIMING_MAX
Definition: type_timing.h:50
void SCIPpresolSetTiming(SCIP_PRESOL *presol, SCIP_PRESOLTIMING timing)
Definition: presol.c:617
void SCIPpresolSetExit(SCIP_PRESOL *presol, SCIP_DECL_PRESOLEXIT((*presolexit)))
Definition: presol.c:520
int SCIPpresolGetNUpgdConss(SCIP_PRESOL *presol)
Definition: presol.c:741
int SCIPpresolGetNChgSides(SCIP_PRESOL *presol)
Definition: presol.c:761
int SCIPparamGetInt(SCIP_PARAM *param)
Definition: paramset.c:716
int SCIPpresolGetNAddHoles(SCIP_PRESOL *presol)
Definition: presol.c:711
SCIP_PRESOLDATA * presoldata
Definition: struct_presol.h:48
#define SCIP_PRESOLTIMING_FINAL
Definition: type_timing.h:46
SCIP_RETCODE SCIPpresolCopyInclude(SCIP_PRESOL *presol, SCIP_SET *set)
Definition: presol.c:74
void SCIPpresolSetCopy(SCIP_PRESOL *presol, SCIP_DECL_PRESOLCOPY((*presolcopy)))
Definition: presol.c:487
#define SCIP_Real
Definition: def.h:149
#define BMSallocMemory(ptr)
Definition: memory.h:101
SCIP_RETCODE SCIPpresolExitpre(SCIP_PRESOL *presol, SCIP_SET *set)
Definition: presol.c:318
common defines and data types used in all packages of SCIP
struct BMS_BlkMem BMS_BLKMEM
Definition: memory.h:419
#define SCIP_ALLOC(x)
Definition: def.h:361
int SCIPpresolGetNAddConss(SCIP_PRESOL *presol)
Definition: presol.c:731
SCIP_RETCODE SCIPpresolInitpre(SCIP_PRESOL *presol, SCIP_SET *set)
Definition: presol.c:283
int SCIPpresolGetNChgBds(SCIP_PRESOL *presol)
Definition: presol.c:701
SCIP callable library.
SCIP_PRESOLTIMING SCIPpresolGetTiming(SCIP_PRESOL *presol)
Definition: presol.c:607
void SCIPpresolSetExitpre(SCIP_PRESOL *presol, SCIP_DECL_PRESOLEXITPRE((*presolexitpre)))
Definition: presol.c:542
memory allocation routines