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