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