Scippy

SCIP

Solving Constraint Integer Programs

relax.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 relax.c
17  * @brief methods and datastructures for relaxation handlers
18  * @author Tobias Achterberg
19  * @author Timo Berthold
20  */
21 
22 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
23 
24 #include <assert.h>
25 #include <string.h>
26 
27 #include "scip/def.h"
28 #include "scip/set.h"
29 #include "scip/stat.h"
30 #include "scip/clock.h"
31 #include "scip/paramset.h"
32 #include "scip/scip.h"
33 #include "scip/sol.h"
34 #include "scip/var.h"
35 #include "scip/relax.h"
36 #include "scip/pub_message.h"
37 #include "scip/pub_misc.h"
38 
39 #include "scip/struct_relax.h"
40 
41 
42 
43 /** compares two relaxation handlers w. r. to their priority */
44 SCIP_DECL_SORTPTRCOMP(SCIPrelaxComp)
45 { /*lint --e{715}*/
46  return ((SCIP_RELAX*)elem2)->priority - ((SCIP_RELAX*)elem1)->priority;
47 }
48 
49 /** comparison method for sorting relaxators w.r.t. to their name */
50 SCIP_DECL_SORTPTRCOMP(SCIPrelaxCompName)
51 {
52  return strcmp(SCIPrelaxGetName((SCIP_RELAX*)elem1), SCIPrelaxGetName((SCIP_RELAX*)elem2));
53 }
54 
55 /** method to call, when the priority of a relaxation handler was changed */
56 static
57 SCIP_DECL_PARAMCHGD(paramChgdRelaxPriority)
58 { /*lint --e{715}*/
59  SCIP_PARAMDATA* paramdata;
60 
61  paramdata = SCIPparamGetData(param);
62  assert(paramdata != NULL);
63 
64  /* use SCIPsetRelaxPriority() to mark the relaxs unsorted */
65  SCIP_CALL( SCIPsetRelaxPriority(scip, (SCIP_RELAX*)paramdata, SCIPparamGetInt(param)) ); /*lint !e740*/
66 
67  return SCIP_OKAY;
68 }
69 
70 /** copies the given relaxation handler to a new scip */
72  SCIP_RELAX* relax, /**< relaxation handler */
73  SCIP_SET* set /**< SCIP_SET of SCIP to copy to */
74  )
75 {
76  assert(relax != NULL);
77  assert(set != NULL);
78  assert(set->scip != NULL);
79 
80  if( relax->relaxcopy != NULL )
81  {
82  SCIPsetDebugMsg(set, "including relaxation handler %s in subscip %p\n", SCIPrelaxGetName(relax), (void*)set->scip);
83  SCIP_CALL( relax->relaxcopy(set->scip, relax) );
84  }
85  return SCIP_OKAY;
86 }
87 
88 /** internal method for creating a relaxation handler */
89 static
91  SCIP_RELAX** relax, /**< pointer to relaxation handler data structure */
92  SCIP_SET* set, /**< global SCIP settings */
93  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
94  BMS_BLKMEM* blkmem, /**< block memory for parameter settings */
95  const char* name, /**< name of relaxation handler */
96  const char* desc, /**< description of relaxation handler */
97  int priority, /**< priority of the relaxation handler (negative: after LP, non-negative: before LP) */
98  int freq, /**< frequency for calling relaxation handler */
99  SCIP_DECL_RELAXCOPY ((*relaxcopy)), /**< copy method of relaxation handler or NULL if you don't want to copy your plugin into sub-SCIPs */
100  SCIP_DECL_RELAXFREE ((*relaxfree)), /**< destructor of relaxation handler */
101  SCIP_DECL_RELAXINIT ((*relaxinit)), /**< initialize relaxation handler */
102  SCIP_DECL_RELAXEXIT ((*relaxexit)), /**< deinitialize relaxation handler */
103  SCIP_DECL_RELAXINITSOL((*relaxinitsol)), /**< solving process initialization method of relaxation handler */
104  SCIP_DECL_RELAXEXITSOL((*relaxexitsol)), /**< solving process deinitialization method of relaxation handler */
105  SCIP_DECL_RELAXEXEC ((*relaxexec)), /**< execution method of relaxation handler */
106  SCIP_RELAXDATA* relaxdata /**< relaxation handler data */
107  )
108 {
109  char paramname[SCIP_MAXSTRLEN];
110  char paramdesc[SCIP_MAXSTRLEN];
111 
112  assert(relax != NULL);
113  assert(name != NULL);
114  assert(desc != NULL);
115  assert(freq >= -1);
116  assert(relaxexec != NULL);
117 
118  SCIP_ALLOC( BMSallocMemory(relax) );
119  BMSclearMemory(*relax);
120 
121  SCIP_ALLOC( BMSduplicateMemoryArray(&(*relax)->name, name, strlen(name)+1) );
122  SCIP_ALLOC( BMSduplicateMemoryArray(&(*relax)->desc, desc, strlen(desc)+1) );
123  (*relax)->priority = priority;
124  (*relax)->freq = freq;
125  (*relax)->relaxcopy = relaxcopy;
126  (*relax)->relaxfree = relaxfree;
127  (*relax)->relaxinit = relaxinit;
128  (*relax)->relaxexit = relaxexit;
129  (*relax)->relaxinitsol = relaxinitsol;
130  (*relax)->relaxexitsol = relaxexitsol;
131  (*relax)->relaxexec = relaxexec;
132  (*relax)->relaxdata = relaxdata;
133  SCIP_CALL( SCIPclockCreate(&(*relax)->setuptime, SCIP_CLOCKTYPE_DEFAULT) );
134  SCIP_CALL( SCIPclockCreate(&(*relax)->relaxclock, SCIP_CLOCKTYPE_DEFAULT) );
135  (*relax)->ncalls = 0;
136  (*relax)->lastsolvednode = -1;
137  (*relax)->initialized = FALSE;
138 
139  /* add parameters */
140  (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "relaxing/%s/priority", name);
141  (void) SCIPsnprintf(paramdesc, SCIP_MAXSTRLEN, "priority of relaxation handler <%s>", name);
142  SCIP_CALL( SCIPsetAddIntParam(set, messagehdlr, blkmem, paramname, paramdesc,
143  &(*relax)->priority, FALSE, priority, INT_MIN/4, INT_MAX/4,
144  paramChgdRelaxPriority, (SCIP_PARAMDATA*)(*relax)) ); /*lint !e740*/
145  (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "relaxing/%s/freq", name);
146  (void) SCIPsnprintf(paramdesc, SCIP_MAXSTRLEN, "frequency for calling relaxation handler <%s> (-1: never, 0: only in root node)", name);
147  SCIP_CALL( SCIPsetAddIntParam(set, messagehdlr, blkmem, paramname, paramdesc,
148  &(*relax)->freq, FALSE, freq, -1, SCIP_MAXTREEDEPTH, NULL, NULL) );
149 
150  return SCIP_OKAY;
151 }
152 
153 /** creates a relaxation handler */
155  SCIP_RELAX** relax, /**< pointer to relaxation handler data structure */
156  SCIP_SET* set, /**< global SCIP settings */
157  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
158  BMS_BLKMEM* blkmem, /**< block memory for parameter settings */
159  const char* name, /**< name of relaxation handler */
160  const char* desc, /**< description of relaxation handler */
161  int priority, /**< priority of the relaxation handler (negative: after LP, non-negative: before LP) */
162  int freq, /**< frequency for calling relaxation handler */
163  SCIP_DECL_RELAXCOPY ((*relaxcopy)), /**< copy method of relaxation handler or NULL if you don't want to copy your plugin into sub-SCIPs */
164  SCIP_DECL_RELAXFREE ((*relaxfree)), /**< destructor of relaxation handler */
165  SCIP_DECL_RELAXINIT ((*relaxinit)), /**< initialize relaxation handler */
166  SCIP_DECL_RELAXEXIT ((*relaxexit)), /**< deinitialize relaxation handler */
167  SCIP_DECL_RELAXINITSOL((*relaxinitsol)), /**< solving process initialization method of relaxation handler */
168  SCIP_DECL_RELAXEXITSOL((*relaxexitsol)), /**< solving process deinitialization method of relaxation handler */
169  SCIP_DECL_RELAXEXEC ((*relaxexec)), /**< execution method of relaxation handler */
170  SCIP_RELAXDATA* relaxdata /**< relaxation handler data */
171  )
172 {
173  assert(relax != NULL);
174  assert(name != NULL);
175  assert(desc != NULL);
176  assert(freq >= -1);
177  assert(relaxexec != NULL);
178 
179  SCIP_CALL_FINALLY( doRelaxCreate(relax, set, messagehdlr, blkmem, name, desc, priority, freq, relaxcopy, relaxfree,
180  relaxinit, relaxexit, relaxinitsol, relaxexitsol, relaxexec, relaxdata), (void) SCIPrelaxFree(relax, set) );
181 
182  return SCIP_OKAY;
183 }
184 
185 /** calls destructor and frees memory of relaxation handler */
187  SCIP_RELAX** relax, /**< pointer to relaxation handler data structure */
188  SCIP_SET* set /**< global SCIP settings */
189  )
190 {
191  assert(relax != NULL);
192  if( *relax == NULL )
193  return SCIP_OKAY;
194  assert(!(*relax)->initialized);
195  assert(set != NULL);
196 
197  /* call destructor of relaxation handler */
198  if( (*relax)->relaxfree != NULL )
199  {
200  SCIP_CALL( (*relax)->relaxfree(set->scip, *relax) );
201  }
202 
203  SCIPclockFree(&(*relax)->relaxclock);
204  SCIPclockFree(&(*relax)->setuptime);
205  BMSfreeMemoryArrayNull(&(*relax)->name);
206  BMSfreeMemoryArrayNull(&(*relax)->desc);
207  BMSfreeMemory(relax);
208 
209  return SCIP_OKAY;
210 }
211 
212 /** initializes relaxation handler */
214  SCIP_RELAX* relax, /**< relaxation handler */
215  SCIP_SET* set /**< global SCIP settings */
216  )
217 {
218  assert(relax != NULL);
219  assert(set != NULL);
220 
221  if( relax->initialized )
222  {
223  SCIPerrorMessage("relaxation handler <%s> already initialized\n", relax->name);
224  return SCIP_INVALIDCALL;
225  }
226 
227  if( set->misc_resetstat )
228  {
229  SCIPclockReset(relax->setuptime);
230  SCIPclockReset(relax->relaxclock);
231  relax->ncalls = 0;
232  relax->lastsolvednode = -1;
233  }
234 
235  if( relax->relaxinit != NULL )
236  {
237  /* start timing */
238  SCIPclockStart(relax->setuptime, set);
239 
240  SCIP_CALL( relax->relaxinit(set->scip, relax) );
241 
242  /* stop timing */
243  SCIPclockStop(relax->setuptime, set);
244  }
245  relax->initialized = TRUE;
246 
247  return SCIP_OKAY;
248 }
249 
250 /** calls exit method of relaxation handler */
252  SCIP_RELAX* relax, /**< relaxation handler */
253  SCIP_SET* set /**< global SCIP settings */
254  )
255 {
256  assert(relax != NULL);
257  assert(set != NULL);
258 
259  if( !relax->initialized )
260  {
261  SCIPerrorMessage("relaxation handler <%s> not initialized\n", relax->name);
262  return SCIP_INVALIDCALL;
263  }
264 
265  if( relax->relaxexit != NULL )
266  {
267  /* start timing */
268  SCIPclockStart(relax->setuptime, set);
269 
270  SCIP_CALL( relax->relaxexit(set->scip, relax) );
271 
272  /* stop timing */
273  SCIPclockStop(relax->setuptime, set);
274  }
275  relax->initialized = FALSE;
276 
277  return SCIP_OKAY;
278 }
279 
280 /** informs relaxation handler that the branch and bound process is being started */
282  SCIP_RELAX* relax, /**< relaxation handler */
283  SCIP_SET* set /**< global SCIP settings */
284  )
285 {
286  assert(relax != NULL);
287  assert(set != NULL);
288 
289  /* call solving process initialization method of relaxation handler */
290  if( relax->relaxinitsol != NULL )
291  {
292  /* start timing */
293  SCIPclockStart(relax->setuptime, set);
294 
295  SCIP_CALL( relax->relaxinitsol(set->scip, relax) );
296 
297  /* stop timing */
298  SCIPclockStop(relax->setuptime, set);
299  }
300 
301  return SCIP_OKAY;
302 }
303 
304 /** informs relaxation handler that the branch and bound process data is being freed */
306  SCIP_RELAX* relax, /**< relaxation handler */
307  SCIP_SET* set /**< global SCIP settings */
308  )
309 {
310  assert(relax != NULL);
311  assert(set != NULL);
312 
313  /* call solving process deinitialization method of relaxation handler */
314  if( relax->relaxexitsol != NULL )
315  {
316  /* start timing */
317  SCIPclockStart(relax->setuptime, set);
318 
319  SCIP_CALL( relax->relaxexitsol(set->scip, relax) );
320 
321  /* stop timing */
322  SCIPclockStop(relax->setuptime, set);
323  }
324 
325  return SCIP_OKAY;
326 }
327 
328 /** calls execution method of relaxation handler */
330  SCIP_RELAX* relax, /**< relaxation handler */
331  SCIP_SET* set, /**< global SCIP settings */
332  SCIP_STAT* stat, /**< dynamic problem statistics */
333  int depth, /**< depth of current node */
334  SCIP_Real* lowerbound, /**< pointer to lower bound computed by the relaxation handler */
335  SCIP_RESULT* result /**< pointer to store the result of the callback method */
336  )
337 {
338  assert(relax != NULL);
339  assert(relax->relaxexec != NULL);
340  assert(relax->freq >= -1);
341  assert(set != NULL);
342  assert(set->scip != NULL);
343  assert(depth >= 0);
344  assert(result != NULL);
345 
346  *result = SCIP_DIDNOTRUN;
347 
348  /* check, if the relaxation is already solved */
349  if( relax->lastsolvednode == stat->ntotalnodes && ! SCIPinProbing(set->scip) )
350  return SCIP_OKAY;
351 
352  relax->lastsolvednode = stat->ntotalnodes;
353 
354  if( (depth == 0 && relax->freq == 0) || (relax->freq > 0 && depth % relax->freq == 0) )
355  {
356  SCIPsetDebugMsg(set, "executing relaxation handler <%s>\n", relax->name);
357 
358  /* start timing */
359  SCIPclockStart(relax->relaxclock, set);
360 
361  /* call external relaxation method */
362  SCIP_CALL( relax->relaxexec(set->scip, relax, lowerbound, result) );
363 
364  /* stop timing */
365  SCIPclockStop(relax->relaxclock, set);
366 
367  /* evaluate result */
368  if( *result != SCIP_CUTOFF
369  && *result != SCIP_CONSADDED
370  && *result != SCIP_REDUCEDDOM
371  && *result != SCIP_SEPARATED
372  && *result != SCIP_SUCCESS
373  && *result != SCIP_SUSPENDED
374  && *result != SCIP_DIDNOTRUN )
375  {
376  SCIPerrorMessage("execution method of relaxation handler <%s> returned invalid result <%d>\n",
377  relax->name, *result);
378  return SCIP_INVALIDRESULT;
379  }
380  if( *result != SCIP_DIDNOTRUN )
381  {
382  relax->ncalls++;
383  stat->relaxcount++;
384  if( *result == SCIP_SUSPENDED )
385  SCIPrelaxMarkUnsolved(relax);
386  }
387  }
388 
389  return SCIP_OKAY;
390 }
391 
392 /** gets user data of relaxation handler */
394  SCIP_RELAX* relax /**< relaxation handler */
395  )
396 {
397  assert(relax != NULL);
398 
399  return relax->relaxdata;
400 }
401 
402 /** sets user data of relaxation handler; user has to free old data in advance! */
404  SCIP_RELAX* relax, /**< relaxation handler */
405  SCIP_RELAXDATA* relaxdata /**< new relaxation handler user data */
406  )
407 {
408  assert(relax != NULL);
409 
410  relax->relaxdata = relaxdata;
411 }
412 
413 /** set copy method of relaxation handler */
415  SCIP_RELAX* relax, /**< relaxation handler */
416  SCIP_DECL_RELAXCOPY ((*relaxcopy)) /**< copy method of relaxation handler */
417  )
418 {
419  assert(relax != NULL);
420 
421  relax->relaxcopy = relaxcopy;
422 }
423 
424 /** set destructor of relaxation handler */
426  SCIP_RELAX* relax, /**< relaxation handler */
427  SCIP_DECL_RELAXFREE ((*relaxfree)) /**< destructor of relaxation handler */
428  )
429 {
430  assert(relax != NULL);
431 
432  relax->relaxfree = relaxfree;
433 }
434 
435 /** set initialization method of relaxation handler */
437  SCIP_RELAX* relax, /**< relaxation handler */
438  SCIP_DECL_RELAXINIT ((*relaxinit)) /**< initialize relaxation handler */
439  )
440 {
441  assert(relax != NULL);
442 
443  relax->relaxinit = relaxinit;
444 }
445 
446 /** set deinitialization method of relaxation handler */
448  SCIP_RELAX* relax, /**< relaxation handler */
449  SCIP_DECL_RELAXEXIT ((*relaxexit)) /**< deinitialize relaxation handler */
450  )
451 {
452  assert(relax != NULL);
453 
454  relax->relaxexit = relaxexit;
455 }
456 
457 /** set solving process initialization method of relaxation handler */
459  SCIP_RELAX* relax, /**< relaxation handler */
460  SCIP_DECL_RELAXINITSOL((*relaxinitsol)) /**< solving process initialization method of relaxation handler */
461  )
462 {
463  assert(relax != NULL);
464 
465  relax->relaxinitsol = relaxinitsol;
466 }
467 
468 /** set solving process deinitialization method of relaxation handler */
470  SCIP_RELAX* relax, /**< relaxation handler */
471  SCIP_DECL_RELAXEXITSOL((*relaxexitsol)) /**< solving process deinitialization relaxation handler */
472  )
473 {
474  assert(relax != NULL);
475 
476  relax->relaxexitsol = relaxexitsol;
477 }
478 
479 /** gets name of relaxation handler */
480 const char* SCIPrelaxGetName(
481  SCIP_RELAX* relax /**< relaxation handler */
482  )
483 {
484  assert(relax != NULL);
485 
486  return relax->name;
487 }
488 
489 /** gets description of relaxation handler */
490 const char* SCIPrelaxGetDesc(
491  SCIP_RELAX* relax /**< relaxation handler */
492  )
493 {
494  assert(relax != NULL);
495 
496  return relax->desc;
497 }
498 
499 /** gets priority of relaxation handler */
501  SCIP_RELAX* relax /**< relaxation handler */
502  )
503 {
504  assert(relax != NULL);
505 
506  return relax->priority;
507 }
508 
509 /** sets priority of relaxation handler */
511  SCIP_RELAX* relax, /**< relaxation handler */
512  SCIP_SET* set, /**< global SCIP settings */
513  int priority /**< new priority of the relaxation handler */
514  )
515 {
516  assert(relax != NULL);
517  assert(set != NULL);
518 
519  relax->priority = priority;
520  set->relaxssorted = FALSE;
521 }
522 
523 /** gets frequency of relaxation handler */
525  SCIP_RELAX* relax /**< relaxation handler */
526  )
527 {
528  assert(relax != NULL);
529 
530  return relax->freq;
531 }
532 
533 /** gets time in seconds used in this relaxator for setting up for next stages */
535  SCIP_RELAX* relax /**< relaxator */
536  )
537 {
538  assert(relax != NULL);
539 
540  return SCIPclockGetTime(relax->setuptime);
541 }
542 
543 /** enables or disables all clocks of \p relax, depending on the value of the flag */
545  SCIP_RELAX* relax, /**< the relaxation handler for which all clocks should be enabled or disabled */
546  SCIP_Bool enable /**< should the clocks of the relaxation handler be enabled? */
547  )
548 {
549  assert(relax != NULL);
550 
551  SCIPclockEnableOrDisable(relax->setuptime, enable);
552  SCIPclockEnableOrDisable(relax->relaxclock, enable);
553 }
554 
555 /** gets time in seconds used in this relaxation handler */
557  SCIP_RELAX* relax /**< relaxation handler */
558  )
559 {
560  assert(relax != NULL);
561 
562  return SCIPclockGetTime(relax->relaxclock);
563 }
564 
565 /** gets the total number of times, the relaxation handler was called */
567  SCIP_RELAX* relax /**< relaxation handler */
568  )
569 {
570  assert(relax != NULL);
571 
572  return relax->ncalls;
573 }
574 
575 /** is relaxation handler initialized? */
577  SCIP_RELAX* relax /**< relaxation handler */
578  )
579 {
580  assert(relax != NULL);
581 
582  return relax->initialized;
583 }
584 
585 /** returns whether the relaxation was completely solved at the current node */
587  SCIP_RELAX* relax, /**< relaxation handler */
588  SCIP_STAT* stat /**< dynamic problem statistics */
589  )
590 {
591  assert(relax != NULL);
592  assert(stat != NULL);
593 
594  return (relax->lastsolvednode == stat->ntotalnodes);
595 }
596 
597 /** marks the current relaxation unsolved, s.t. the relaxation handler is called again in the next solving round */
599  SCIP_RELAX* relax /**< relaxation handler */
600  )
601 {
602  assert(relax != NULL);
603 
604  relax->lastsolvednode = -1;
605 }
606 
607 /*
608  * methods for the global relaxation data
609  */
610 
611 /** creates global relaxation data */
613  SCIP_RELAXATION** relaxation, /**< global relaxation data */
614  BMS_BLKMEM* blkmem, /**< block memory */
615  SCIP_SET* set, /**< global SCIP settings */
616  SCIP_STAT* stat, /**< problem statistics data */
617  SCIP_PRIMAL* primal, /**< primal data */
618  SCIP_TREE* tree /**< branch and bound tree */
619  )
620 {
621  assert(relaxation != NULL);
622  assert(blkmem != NULL);
623  assert(set != NULL);
624  assert(stat != NULL);
625  assert(primal != NULL);
626  assert(tree != NULL);
627 
628  SCIP_ALLOC( BMSallocMemory(relaxation) );
629 
630  (*relaxation)->relaxsolobjval = 0.0;
631  (*relaxation)->relaxsolvalid = FALSE;
632  (*relaxation)->relaxsolincludeslp = FALSE;
633  (*relaxation)->relaxsolzero = TRUE;
634 
635  return SCIP_OKAY;
636 }
637 
638 /** frees global relaxation data */
640  SCIP_RELAXATION** relaxation /**< global relaxation data */
641  )
642 {
643  assert(relaxation != NULL);
644 
645  BMSfreeMemory(relaxation);
646 
647  return SCIP_OKAY;
648 }
649 
650 /** sets the relaxsolzero flag in the relaxation data to the given value */
652  SCIP_RELAXATION* relaxation, /**< global relaxation data */
653  SCIP_Bool iszero /**< are all values of the relaxation solution set to zero? */
654  )
655 {
656  assert(relaxation != NULL);
657 
658  relaxation->relaxsolzero = iszero;
659 }
660 
661 /** returns whether the global relaxation solution is cleared and all values are set to zero */
663  SCIP_RELAXATION* relaxation /**< global relaxation data */
664  )
665 {
666  assert(relaxation != NULL);
667 
668  return relaxation->relaxsolzero;
669 }
670 
671 /** sets the relaxsolvalid and includeslp flags in the relaxation data to the given values */
673  SCIP_RELAXATION* relaxation, /**< global relaxation data */
674  SCIP_Bool isvalid, /**< is the stored solution valid? */
675  SCIP_Bool includeslp /**< does the relaxator contain all cuts in the LP? */
676  )
677 {
678  assert(relaxation != NULL);
679 
680  relaxation->relaxsolvalid = isvalid;
681  relaxation->relaxsolincludeslp = includeslp;
682 }
683 
684 /** returns whether the global relaxation solution is valid */
686  SCIP_RELAXATION* relaxation /**< global relaxation data */
687  )
688 {
689  assert(relaxation != NULL);
690 
691  return relaxation->relaxsolvalid;
692 }
693 
694 /** returns whether the global relaxation solution was computed by a relaxator which included all LP cuts */
696  SCIP_RELAXATION* relaxation /**< global relaxation data */
697  )
698 {
699  assert(relaxation != NULL);
700 
701  return relaxation->relaxsolincludeslp;
702 }
703 
704 /** sets the objective value of the global relaxation solution */
706  SCIP_RELAXATION* relaxation, /**< global relaxation data */
707  SCIP_Real obj /**< objective value */
708  )
709 {
710  assert(relaxation != NULL);
711 
712  relaxation->relaxsolobjval = obj;
713 }
714 
715 /** returns the objective value of the global relaxation solution w.r.t. the transformed problem */
717  SCIP_RELAXATION* relaxation /**< global relaxation data */
718  )
719 {
720  assert(relaxation != NULL);
721 
722  return relaxation->relaxsolobjval;
723 }
724 
725 /** adds the given value to the global relaxation solution's objective value */
727  SCIP_RELAXATION* relaxation, /**< global relaxation data */
728  SCIP_Real val /**< value to add to the objective value */
729  )
730 {
731  assert(relaxation != NULL);
732 
733  relaxation->relaxsolobjval += val;
734 }
735 
736 /** updates objective value of current relaxation solution after change of objective coefficient */
738  SCIP_RELAXATION* relaxation, /**< global relaxation data */
739  SCIP_SET* set, /**< global SCIP settings */
740  SCIP_VAR* var, /**< variable with changed objective coefficient */
741  SCIP_Real oldobj, /**< old objective coefficient */
742  SCIP_Real newobj /**< new objective coefficient */
743  )
744 {
745  SCIP_Real relaxsolval;
746 
747  assert(relaxation != NULL);
748  assert(set != NULL);
749  assert(var != NULL);
750  assert(SCIPvarGetStatus(var) == SCIP_VARSTATUS_COLUMN);
751 
752  relaxsolval = SCIPvarGetRelaxSol(var, set);
753  relaxation->relaxsolobjval += (newobj - oldobj) * relaxsolval;
754 }
enum SCIP_Result SCIP_RESULT
Definition: type_result.h:52
#define SCIP_DECL_RELAXFREE(x)
Definition: type_relax.h:55
void SCIPrelaxationUpdateVarObj(SCIP_RELAXATION *relaxation, SCIP_SET *set, SCIP_VAR *var, SCIP_Real oldobj, SCIP_Real newobj)
Definition: relax.c:737
#define NULL
Definition: def.h:253
internal methods for storing primal CIP solutions
#define BMSfreeMemoryArrayNull(ptr)
Definition: memory.h:138
SCIP_Real SCIPrelaxationGetSolObj(SCIP_RELAXATION *relaxation)
Definition: relax.c:716
char * desc
Definition: struct_relax.h:42
SCIP_Longint relaxcount
Definition: struct_stat.h:175
SCIP_RETCODE SCIPrelaxInit(SCIP_RELAX *relax, SCIP_SET *set)
Definition: relax.c:213
SCIP_PARAMDATA * SCIPparamGetData(SCIP_PARAM *param)
Definition: paramset.c:661
#define SCIP_MAXSTRLEN
Definition: def.h:274
internal methods for clocks and timing issues
SCIP_Longint ntotalnodes
Definition: struct_stat.h:78
struct SCIP_ParamData SCIP_PARAMDATA
Definition: type_paramset.h:76
#define SCIP_CALL_FINALLY(x, y)
Definition: def.h:407
void SCIPrelaxSetPriority(SCIP_RELAX *relax, SCIP_SET *set, int priority)
Definition: relax.c:510
SCIP_Longint SCIPrelaxGetNCalls(SCIP_RELAX *relax)
Definition: relax.c:566
void SCIPclockStop(SCIP_CLOCK *clck, SCIP_SET *set)
Definition: clock.c:350
#define FALSE
Definition: def.h:73
#define SCIP_DECL_RELAXINIT(x)
Definition: type_relax.h:63
#define SCIP_DECL_RELAXINITSOL(x)
Definition: type_relax.h:82
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
void SCIPrelaxSetCopy(SCIP_RELAX *relax, SCIP_DECL_RELAXCOPY((*relaxcopy)))
Definition: relax.c:414
SCIP_EXPORT SCIP_VARSTATUS SCIPvarGetStatus(SCIP_VAR *var)
Definition: var.c:16857
SCIP_RETCODE SCIPrelaxFree(SCIP_RELAX **relax, SCIP_SET *set)
Definition: relax.c:186
void SCIPrelaxationSetSolValid(SCIP_RELAXATION *relaxation, SCIP_Bool isvalid, SCIP_Bool includeslp)
Definition: relax.c:672
internal methods for handling parameter settings
static SCIP_RETCODE doRelaxCreate(SCIP_RELAX **relax, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, BMS_BLKMEM *blkmem, const char *name, const char *desc, int priority, int freq, SCIP_DECL_RELAXCOPY((*relaxcopy)), SCIP_DECL_RELAXFREE((*relaxfree)), SCIP_DECL_RELAXINIT((*relaxinit)), SCIP_DECL_RELAXEXIT((*relaxexit)), SCIP_DECL_RELAXINITSOL((*relaxinitsol)), SCIP_DECL_RELAXEXITSOL((*relaxexitsol)), SCIP_DECL_RELAXEXEC((*relaxexec)), SCIP_RELAXDATA *relaxdata)
Definition: relax.c:90
SCIP_Bool SCIPrelaxationIsSolValid(SCIP_RELAXATION *relaxation)
Definition: relax.c:685
void SCIPclockEnableOrDisable(SCIP_CLOCK *clck, SCIP_Bool enable)
Definition: clock.c:250
#define BMSfreeMemory(ptr)
Definition: memory.h:135
void SCIPrelaxMarkUnsolved(SCIP_RELAX *relax)
Definition: relax.c:598
#define SCIP_DECL_RELAXEXIT(x)
Definition: type_relax.h:71
SCIP_RELAXDATA * relaxdata
Definition: struct_relax.h:50
const char * SCIPrelaxGetDesc(SCIP_RELAX *relax)
Definition: relax.c:490
void SCIPrelaxSetFree(SCIP_RELAX *relax, SCIP_DECL_RELAXFREE((*relaxfree)))
Definition: relax.c:425
SCIP_CLOCK * relaxclock
Definition: struct_relax.h:52
SCIP_RETCODE SCIPrelaxCreate(SCIP_RELAX **relax, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, BMS_BLKMEM *blkmem, const char *name, const char *desc, int priority, int freq, SCIP_DECL_RELAXCOPY((*relaxcopy)), SCIP_DECL_RELAXFREE((*relaxfree)), SCIP_DECL_RELAXINIT((*relaxinit)), SCIP_DECL_RELAXEXIT((*relaxexit)), SCIP_DECL_RELAXINITSOL((*relaxinitsol)), SCIP_DECL_RELAXEXITSOL((*relaxexitsol)), SCIP_DECL_RELAXEXEC((*relaxexec)), SCIP_RELAXDATA *relaxdata)
Definition: relax.c:154
SCIP_Real SCIPrelaxGetSetupTime(SCIP_RELAX *relax)
Definition: relax.c:534
#define SCIPerrorMessage
Definition: pub_message.h:45
SCIP_RETCODE SCIPrelaxExit(SCIP_RELAX *relax, SCIP_SET *set)
Definition: relax.c:251
SCIP_Bool relaxsolincludeslp
Definition: struct_relax.h:63
SCIP_Bool SCIPrelaxationIsSolZero(SCIP_RELAXATION *relaxation)
Definition: relax.c:662
void SCIPclockReset(SCIP_CLOCK *clck)
Definition: clock.c:199
SCIP_Real relaxsolobjval
Definition: struct_relax.h:61
int SCIPrelaxGetPriority(SCIP_RELAX *relax)
Definition: relax.c:500
SCIP_Bool SCIPinProbing(SCIP *scip)
Definition: scip_probing.c:87
SCIP_Real SCIPclockGetTime(SCIP_CLOCK *clck)
Definition: clock.c:428
#define SCIP_DECL_RELAXCOPY(x)
Definition: type_relax.h:47
SCIP_Real SCIPrelaxGetTime(SCIP_RELAX *relax)
Definition: relax.c:556
void SCIPrelaxSetInitsol(SCIP_RELAX *relax, SCIP_DECL_RELAXINITSOL((*relaxinitsol)))
Definition: relax.c:458
void SCIPrelaxSetExitsol(SCIP_RELAX *relax, SCIP_DECL_RELAXEXITSOL((*relaxexitsol)))
Definition: relax.c:469
SCIP_Bool relaxsolvalid
Definition: struct_relax.h:62
internal methods for global SCIP settings
#define SCIP_CALL(x)
Definition: def.h:365
SCIP_RETCODE SCIPrelaxCopyInclude(SCIP_RELAX *relax, SCIP_SET *set)
Definition: relax.c:71
SCIP_CLOCK * setuptime
Definition: struct_relax.h:51
SCIP_RETCODE SCIPrelaxationCreate(SCIP_RELAXATION **relaxation, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PRIMAL *primal, SCIP_TREE *tree)
Definition: relax.c:612
void SCIPrelaxSetData(SCIP_RELAX *relax, SCIP_RELAXDATA *relaxdata)
Definition: relax.c:403
SCIP_RETCODE SCIPsetRelaxPriority(SCIP *scip, SCIP_RELAX *relax, int priority)
Definition: scip_relax.c:261
internal methods for relaxators
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
#define BMSduplicateMemoryArray(ptr, source, num)
Definition: memory.h:133
SCIP_RETCODE SCIPclockCreate(SCIP_CLOCK **clck, SCIP_CLOCKTYPE clocktype)
Definition: clock.c:160
internal methods for problem variables
char * name
Definition: struct_relax.h:41
public data structures and miscellaneous methods
int SCIPrelaxGetFreq(SCIP_RELAX *relax)
Definition: relax.c:524
SCIP_RETCODE SCIPrelaxationFree(SCIP_RELAXATION **relaxation)
Definition: relax.c:639
#define SCIP_Bool
Definition: def.h:70
SCIP_Bool SCIPrelaxIsSolved(SCIP_RELAX *relax, SCIP_STAT *stat)
Definition: relax.c:586
SCIP_RETCODE SCIPrelaxInitsol(SCIP_RELAX *relax, SCIP_SET *set)
Definition: relax.c:281
void SCIPclockFree(SCIP_CLOCK **clck)
Definition: clock.c:175
SCIP_Bool initialized
Definition: struct_relax.h:55
#define SCIPsetDebugMsg
Definition: set.h:1720
SCIP_RELAXDATA * SCIPrelaxGetData(SCIP_RELAX *relax)
Definition: relax.c:393
static SCIP_DECL_PARAMCHGD(paramChgdRelaxPriority)
Definition: relax.c:57
SCIP_Longint lastsolvednode
Definition: struct_relax.h:40
void SCIPrelaxEnableOrDisableClocks(SCIP_RELAX *relax, SCIP_Bool enable)
Definition: relax.c:544
SCIP_Real SCIPvarGetRelaxSol(SCIP_VAR *var, SCIP_SET *set)
Definition: var.c:13413
#define BMSclearMemory(ptr)
Definition: memory.h:119
void SCIPrelaxationSetSolObj(SCIP_RELAXATION *relaxation, SCIP_Real obj)
Definition: relax.c:705
#define SCIP_MAXTREEDEPTH
Definition: def.h:301
SCIP_Bool SCIPrelaxIsInitialized(SCIP_RELAX *relax)
Definition: relax.c:576
int SCIPparamGetInt(SCIP_PARAM *param)
Definition: paramset.c:716
SCIP_Longint ncalls
Definition: struct_relax.h:39
void SCIPrelaxationSetSolZero(SCIP_RELAXATION *relaxation, SCIP_Bool iszero)
Definition: relax.c:651
struct SCIP_RelaxData SCIP_RELAXDATA
Definition: type_relax.h:38
#define SCIP_DECL_RELAXEXEC(x)
Definition: type_relax.h:118
void SCIPrelaxationSolObjAdd(SCIP_RELAXATION *relaxation, SCIP_Real val)
Definition: relax.c:726
SCIP_Bool relaxsolzero
Definition: struct_relax.h:64
public methods for message output
int SCIPsnprintf(char *t, int len, const char *s,...)
Definition: misc.c:10263
const char * SCIPrelaxGetName(SCIP_RELAX *relax)
Definition: relax.c:480
#define SCIP_Real
Definition: def.h:164
internal methods for problem statistics
SCIP_DECL_SORTPTRCOMP(SCIPrelaxComp)
Definition: relax.c:44
#define BMSallocMemory(ptr)
Definition: memory.h:109
#define SCIP_Longint
Definition: def.h:149
data structures for relaxators
#define SCIP_DECL_RELAXEXITSOL(x)
Definition: type_relax.h:93
common defines and data types used in all packages of SCIP
struct BMS_BlkMem BMS_BLKMEM
Definition: memory.h:427
void SCIPrelaxSetExit(SCIP_RELAX *relax, SCIP_DECL_RELAXEXIT((*relaxexit)))
Definition: relax.c:447
#define SCIP_ALLOC(x)
Definition: def.h:376
SCIP_RETCODE SCIPrelaxExec(SCIP_RELAX *relax, SCIP_SET *set, SCIP_STAT *stat, int depth, SCIP_Real *lowerbound, SCIP_RESULT *result)
Definition: relax.c:329
SCIP_Bool SCIPrelaxationIsLpIncludedForSol(SCIP_RELAXATION *relaxation)
Definition: relax.c:695
SCIP callable library.
void SCIPrelaxSetInit(SCIP_RELAX *relax, SCIP_DECL_RELAXINIT((*relaxinit)))
Definition: relax.c:436
SCIP_RETCODE SCIPrelaxExitsol(SCIP_RELAX *relax, SCIP_SET *set)
Definition: relax.c:305