Scippy

SCIP

Solving Constraint Integer Programs

var.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-2024 Zuse Institute Berlin (ZIB) */
7/* */
8/* Licensed under the Apache License, Version 2.0 (the "License"); */
9/* you may not use this file except in compliance with the License. */
10/* You may obtain a copy of the License at */
11/* */
12/* http://www.apache.org/licenses/LICENSE-2.0 */
13/* */
14/* Unless required by applicable law or agreed to in writing, software */
15/* distributed under the License is distributed on an "AS IS" BASIS, */
16/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
17/* See the License for the specific language governing permissions and */
18/* limitations under the License. */
19/* */
20/* You should have received a copy of the Apache-2.0 license */
21/* along with SCIP; see the file LICENSE. If not visit scipopt.org. */
22/* */
23/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
24
25/**@file var.c
26 * @ingroup OTHER_CFILES
27 * @brief methods for problem variables
28 * @author Tobias Achterberg
29 * @author Timo Berthold
30 * @author Gerald Gamrath
31 * @author Stefan Heinz
32 * @author Marc Pfetsch
33 * @author Michael Winkler
34 * @author Kati Wolter
35 * @author Stefan Vigerske
36 *
37 * @todo Possibly implement the access of bounds of multi-aggregated variables by accessing the
38 * corresponding linear constraint if it exists. This seems to require some work, since the linear
39 * constraint has to be stored. Moreover, it has even to be created in case the original constraint
40 * was deleted after multi-aggregation, but the bounds of the multi-aggregated variable should be
41 * changed. This has to be done with care in order to not loose the performance gains of
42 * multi-aggregation.
43 */
44
45/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
46
47#include "scip/cons.h"
48#include "scip/event.h"
49#include "scip/history.h"
50#include "scip/implics.h"
51#include "scip/lp.h"
52#include "scip/primal.h"
53#include "scip/prob.h"
54#include "scip/pub_cons.h"
55#include "scip/pub_history.h"
56#include "scip/pub_implics.h"
57#include "scip/pub_lp.h"
58#include "scip/pub_message.h"
59#include "scip/pub_misc.h"
60#include "scip/pub_misc_sort.h"
61#include "scip/pub_prop.h"
62#include "scip/pub_var.h"
63#include "scip/relax.h"
64#include "scip/set.h"
65#include "scip/sol.h"
66#include "scip/stat.h"
67#include "scip/struct_event.h"
68#include "scip/struct_lp.h"
69#include "scip/struct_prob.h"
70#include "scip/struct_set.h"
71#include "scip/struct_stat.h"
72#include "scip/struct_var.h"
73#include "scip/tree.h"
74#include "scip/var.h"
75#include <string.h>
76
77#define MAXIMPLSCLOSURE 100 /**< maximal number of descendants of implied variable for building closure
78 * in implication graph */
79#define MAXABSVBCOEF 1e+5 /**< maximal absolute coefficient in variable bounds added due to implications */
80
81
82/*
83 * Debugging variable release and capture
84 *
85 * Define DEBUGUSES_VARNAME to the name of the variable for which to print
86 * a backtrace when it is captured and released.
87 * Optionally define DEBUGUSES_PROBNAME to the name of a SCIP problem to consider.
88 * Have DEBUGUSES_NOADDR2LINE defined if you do not have addr2line installed on your system.
89 */
90/* #define DEBUGUSES_VARNAME "t_t_b7" */
91/* #define DEBUGUSES_PROBNAME "t_st_e35_rens" */
92/* #define DEBUGUSES_NOADDR2LINE */
93
94#ifdef DEBUGUSES_VARNAME
95#include <execinfo.h>
96#include <stdio.h>
97#include <stdlib.h>
98#include "scip/struct_scip.h"
99
100/** obtains a backtrace and prints it to stdout. */
101static
102void print_backtrace(void)
103{
104 void* array[10];
105 char** strings;
106 int size;
107 int i;
108
109 size = backtrace(array, 10);
110 strings = backtrace_symbols(array, size);
111 if( strings == NULL )
112 return;
113
114 /* skip first entry, which is the print_backtrace function */
115 for( i = 1; i < size; ++i )
116 {
117 /* if string is something like
118 * /path/to/scip/bin/../lib/shared/libscip-7.0.1.3.linux.x86_64.gnu.dbg.so(+0x2675dd3)
119 * (that is, no function name because it is a inlined function), then call
120 * addr2line -e <libname> <addr> to get func and code line
121 * dladdr() may be an alternative
122 */
123 char* openpar;
124 char* closepar = NULL;
125#ifndef DEBUGUSES_NOADDR2LINE
126 openpar = strchr(strings[i], '(');
127 if( openpar != NULL && openpar[1] == '+' )
128 closepar = strchr(openpar+2, ')');
129#endif
130 if( closepar != NULL )
131 {
132 char cmd[SCIP_MAXSTRLEN];
133 (void) SCIPsnprintf(cmd, SCIP_MAXSTRLEN, "addr2line -f -p -e \"%.*s\" %.*s", openpar - strings[i], strings[i], closepar-openpar-1, openpar+1);
134 printf(" ");
135 fflush(stdout);
136 system(cmd);
137 }
138 else
139 printf(" %s\n", strings[i]);
140 }
141
142 free(strings);
143}
144#endif
145
146/*
147 * hole, holelist, and domain methods
148 */
149
150/** creates a new holelist element */
151static
153 SCIP_HOLELIST** holelist, /**< pointer to holelist to create */
154 BMS_BLKMEM* blkmem, /**< block memory for target holelist */
155 SCIP_SET* set, /**< global SCIP settings */
156 SCIP_Real left, /**< left bound of open interval in new hole */
157 SCIP_Real right /**< right bound of open interval in new hole */
158 )
159{
160 assert(holelist != NULL);
161 assert(blkmem != NULL);
162 assert(SCIPsetIsLT(set, left, right));
163
164 SCIPsetDebugMsg(set, "create hole list element (%.15g,%.15g) in blkmem %p\n", left, right, (void*)blkmem);
165
166 SCIP_ALLOC( BMSallocBlockMemory(blkmem, holelist) );
167 (*holelist)->hole.left = left;
168 (*holelist)->hole.right = right;
169 (*holelist)->next = NULL;
170
171 return SCIP_OKAY;
172}
173
174/** frees all elements in the holelist */
175static
177 SCIP_HOLELIST** holelist, /**< pointer to holelist to free */
178 BMS_BLKMEM* blkmem /**< block memory for target holelist */
179 )
180{
181 assert(holelist != NULL);
182 assert(blkmem != NULL);
183
184 while( *holelist != NULL )
185 {
186 SCIP_HOLELIST* next;
187
188 SCIPdebugMessage("free hole list element (%.15g,%.15g) in blkmem %p\n",
189 (*holelist)->hole.left, (*holelist)->hole.right, (void*)blkmem);
190
191 next = (*holelist)->next;
192 BMSfreeBlockMemory(blkmem, holelist);
193 assert(*holelist == NULL);
194
195 *holelist = next;
196 }
197 assert(*holelist == NULL);
198}
199
200/** duplicates a list of holes */
201static
203 SCIP_HOLELIST** target, /**< pointer to target holelist */
204 BMS_BLKMEM* blkmem, /**< block memory for target holelist */
205 SCIP_SET* set, /**< global SCIP settings */
206 SCIP_HOLELIST* source /**< holelist to duplicate */
207 )
208{
209 assert(target != NULL);
210
211 while( source != NULL )
212 {
213 assert(source->next == NULL || SCIPsetIsGE(set, source->next->hole.left, source->hole.right));
214 SCIP_CALL( holelistCreate(target, blkmem, set, source->hole.left, source->hole.right) );
215 source = source->next;
216 target = &(*target)->next;
217 }
218
219 return SCIP_OKAY;
220}
221
222/** adds a hole to the domain */
223static
225 SCIP_DOM* dom, /**< domain to add hole to */
226 BMS_BLKMEM* blkmem, /**< block memory */
227 SCIP_SET* set, /**< global SCIP settings */
228 SCIP_Real left, /**< left bound of open interval in new hole */
229 SCIP_Real right, /**< right bound of open interval in new hole */
230 SCIP_Bool* added /**< pointer to store whether the hole was added (variable didn't had that hole before), or NULL */
231 )
232{
233 SCIP_HOLELIST** insertpos;
234 SCIP_HOLELIST* next;
235
236 assert(dom != NULL);
237 assert(added != NULL);
238
239 /* search for the position of the new hole */
240 insertpos = &dom->holelist;
241 while( *insertpos != NULL && (*insertpos)->hole.left < left )
242 insertpos = &(*insertpos)->next;
243
244 /* check if new hole already exists in the hole list or is a sub hole of an existing one */
245 if( *insertpos != NULL && (*insertpos)->hole.left == left && (*insertpos)->hole.right >= right ) /*lint !e777 */
246 {
247 SCIPsetDebugMsg(set, "new hole (%.15g,%.15g) is redundant through known hole (%.15g,%.15g)\n",
248 left, right, (*insertpos)->hole.left, (*insertpos)->hole.right);
249 *added = FALSE;
250 return SCIP_OKAY;
251 }
252
253 /* add hole */
254 *added = TRUE;
255
256 next = *insertpos;
257 SCIP_CALL( holelistCreate(insertpos, blkmem, set, left, right) );
258 (*insertpos)->next = next;
259
260 return SCIP_OKAY;
261}
262
263/** merges overlapping holes into single holes, computes and moves lower and upper bound, respectively */
264/**@todo the domMerge() method is currently called if a lower or an upper bound locally or globally changed; this could
265 * be more efficient if performed with the knowledge if it was a lower or an upper bound which triggered this
266 * merge */
267static
269 SCIP_DOM* dom, /**< domain to merge */
270 BMS_BLKMEM* blkmem, /**< block memory */
271 SCIP_SET* set, /**< global SCIP settings */
272 SCIP_Real* newlb, /**< pointer to store new lower bound */
273 SCIP_Real* newub /**< pointer to store new upper bound */
274 )
275{
276 SCIP_HOLELIST** holelistptr;
277 SCIP_HOLELIST** lastnextptr;
278 SCIP_Real* lastrightptr;
279
280 assert(dom != NULL);
281 assert(SCIPsetIsLE(set, dom->lb, dom->ub));
282
283#ifndef NDEBUG
284 {
285 /* check if the holelist is sorted w.r.t. to the left interval bounds */
286 SCIP_Real lastleft;
287
288 holelistptr = &dom->holelist;
289
290 lastleft = -SCIPsetInfinity(set);
291
292 while( *holelistptr != NULL )
293 {
294 if( (*holelistptr)->next != NULL )
295 {
296 assert( SCIPsetIsLE(set, lastleft, (*holelistptr)->hole.left) );
297 lastleft = (*holelistptr)->hole.left;
298 }
299
300 holelistptr = &(*holelistptr)->next;
301 }
302 }
303#endif
304
305 SCIPsetDebugMsg(set, "merge hole list\n");
306
307 holelistptr = &dom->holelist;
308 lastrightptr = &dom->lb; /* lower bound is the right bound of the hole (-infinity,lb) */
309 lastnextptr = holelistptr;
310
311 while( *holelistptr != NULL )
312 {
313 SCIPsetDebugMsg(set, "check hole (%.15g,%.15g) last right interval was <%.15g>\n", (*holelistptr)->hole.left, (*holelistptr)->hole.right, *lastrightptr);
314
315 /* check that the hole is not empty */
316 assert(SCIPsetIsLT(set, (*holelistptr)->hole.left, (*holelistptr)->hole.right));
317
318 if( SCIPsetIsGE(set, (*holelistptr)->hole.left, dom->ub) )
319 {
320 /* the remaining holes start behind the upper bound: remove them */
321 SCIPsetDebugMsg(set, "remove remaining hole since upper bound <%.15g> is less then the left hand side of the current hole\n", dom->ub);
322 holelistFree(holelistptr, blkmem);
323 assert(*holelistptr == NULL);
324
325 /* unlink this hole from the previous hole */
326 *lastnextptr = NULL;
327 }
328 else if( SCIPsetIsGT(set, (*holelistptr)->hole.right, dom->ub) )
329 {
330 /* the hole overlaps the upper bound: decrease upper bound, remove this hole and all remaining holes */
331 SCIPsetDebugMsg(set, "upper bound <%.15g> lays in current hole; store new upper bound and remove this and all remaining holes\n", dom->ub);
332
333 assert(SCIPsetIsLT(set, (*holelistptr)->hole.left, dom->ub));
334
335 /* adjust upper bound */
336 dom->ub = (*holelistptr)->hole.left;
337
338 if(newub != NULL )
339 *newub = (*holelistptr)->hole.left;
340
341 /* remove remaining hole list */
342 holelistFree(holelistptr, blkmem);
343 assert(*holelistptr == NULL);
344
345 /* unlink this hole from the previous hole */
346 *lastnextptr = NULL;
347 }
348 else if( SCIPsetIsGT(set, *lastrightptr, (*holelistptr)->hole.left) )
349 {
350 /* the right bound of the last hole is greater than the left bound of this hole: increase the right bound of
351 * the last hole, delete this hole */
352 SCIP_HOLELIST* nextholelist;
353
354 if( SCIPsetIsEQ(set, *lastrightptr, dom->lb ) )
355 {
356 /* the reason for the overlap results from the lower bound hole (-infinity,lb); therefore, we can increase
357 * the lower bound */
358 SCIPsetDebugMsg(set, "lower bound <%.15g> lays in current hole; store new lower bound and remove hole\n", dom->lb);
359 *lastrightptr = MAX(*lastrightptr, (*holelistptr)->hole.right);
360
361 /* adjust lower bound */
362 dom->lb = *lastrightptr;
363
364 if(newlb != NULL )
365 *newlb = *lastrightptr;
366 }
367 else
368 {
369 SCIPsetDebugMsg(set, "current hole overlaps with the previous one (...,%.15g); merge to (...,%.15g)\n",
370 *lastrightptr, MAX(*lastrightptr, (*holelistptr)->hole.right) );
371 *lastrightptr = MAX(*lastrightptr, (*holelistptr)->hole.right);
372 }
373 nextholelist = (*holelistptr)->next;
374 (*holelistptr)->next = NULL;
375 holelistFree(holelistptr, blkmem);
376
377 /* connect the linked list after removing the hole */
378 *lastnextptr = nextholelist;
379
380 /* get next hole */
381 *holelistptr = nextholelist;
382 }
383 else
384 {
385 /* the holes do not overlap: update lastholelist and lastrightptr */
386 lastrightptr = &(*holelistptr)->hole.right;
387 lastnextptr = &(*holelistptr)->next;
388
389 /* get next hole */
390 holelistptr = &(*holelistptr)->next;
391 }
392 }
393
394#ifndef NDEBUG
395 {
396 /* check that holes are merged */
397 SCIP_Real lastright;
398
399 lastright = dom->lb; /* lower bound is the right bound of the hole (-infinity,lb) */
400 holelistptr = &dom->holelist;
401
402 while( *holelistptr != NULL )
403 {
404 /* check the the last right interval is smaller or equal to the current left interval (none overlapping) */
405 assert( SCIPsetIsLE(set, lastright, (*holelistptr)->hole.left) );
406
407 /* check the hole property (check that the hole is not empty) */
408 assert( SCIPsetIsLT(set, (*holelistptr)->hole.left, (*holelistptr)->hole.right) );
409 lastright = (*holelistptr)->hole.right;
410
411 /* get next hole */
412 holelistptr = &(*holelistptr)->next;
413 }
414
415 /* check the the last right interval is smaller or equal to the upper bound (none overlapping) */
416 assert( SCIPsetIsLE(set, lastright, dom->ub) );
417 }
418#endif
419}
420
421/*
422 * domain change methods
423 */
424
425/** ensures, that bound change info array for lower bound changes can store at least num entries */
426static
428 SCIP_VAR* var, /**< problem variable */
429 BMS_BLKMEM* blkmem, /**< block memory */
430 SCIP_SET* set, /**< global SCIP settings */
431 int num /**< minimum number of entries to store */
432 )
433{
434 assert(var != NULL);
435 assert(var->nlbchginfos <= var->lbchginfossize);
436 assert(SCIPvarIsTransformed(var));
437
438 if( num > var->lbchginfossize )
439 {
440 int newsize;
441
442 newsize = SCIPsetCalcMemGrowSize(set, num);
443 SCIP_ALLOC( BMSreallocBlockMemoryArray(blkmem, &var->lbchginfos, var->lbchginfossize, newsize) );
444 var->lbchginfossize = newsize;
445 }
446 assert(num <= var->lbchginfossize);
447
448 return SCIP_OKAY;
449}
450
451/** ensures, that bound change info array for upper bound changes can store at least num entries */
452static
454 SCIP_VAR* var, /**< problem variable */
455 BMS_BLKMEM* blkmem, /**< block memory */
456 SCIP_SET* set, /**< global SCIP settings */
457 int num /**< minimum number of entries to store */
458 )
459{
460 assert(var != NULL);
461 assert(var->nubchginfos <= var->ubchginfossize);
462 assert(SCIPvarIsTransformed(var));
463
464 if( num > var->ubchginfossize )
465 {
466 int newsize;
467
468 newsize = SCIPsetCalcMemGrowSize(set, num);
469 SCIP_ALLOC( BMSreallocBlockMemoryArray(blkmem, &var->ubchginfos, var->ubchginfossize, newsize) );
470 var->ubchginfossize = newsize;
471 }
472 assert(num <= var->ubchginfossize);
473
474 return SCIP_OKAY;
475}
476
477/** adds domain change info to the variable's lower bound change info array */
478static
480 SCIP_VAR* var, /**< problem variable */
481 BMS_BLKMEM* blkmem, /**< block memory */
482 SCIP_SET* set, /**< global SCIP settings */
483 SCIP_Real oldbound, /**< old value for bound */
484 SCIP_Real newbound, /**< new value for bound */
485 int depth, /**< depth in the tree, where the bound change takes place */
486 int pos, /**< position of the bound change in its bound change array */
487 SCIP_VAR* infervar, /**< variable that was changed (parent of var, or var itself) */
488 SCIP_CONS* infercons, /**< constraint that inferred this bound change, or NULL */
489 SCIP_PROP* inferprop, /**< propagator that deduced the bound change, or NULL */
490 int inferinfo, /**< user information for inference to help resolving the conflict */
491 SCIP_BOUNDTYPE inferboundtype, /**< type of bound for inference var: lower or upper bound */
492 SCIP_BOUNDCHGTYPE boundchgtype /**< bound change type: branching decision or inferred bound change */
493 )
494{
495 assert(var != NULL);
496 assert(SCIPsetIsLT(set, oldbound, newbound));
499 assert(!SCIPvarIsBinary(var) || SCIPsetIsEQ(set, oldbound, 0.0));
500 assert(!SCIPvarIsBinary(var) || SCIPsetIsEQ(set, newbound, 1.0));
501 assert(boundchgtype == SCIP_BOUNDCHGTYPE_BRANCHING || infervar != NULL);
502 assert((boundchgtype == SCIP_BOUNDCHGTYPE_CONSINFER) == (infercons != NULL));
503 assert(boundchgtype == SCIP_BOUNDCHGTYPE_PROPINFER || inferprop == NULL);
504
505 SCIPsetDebugMsg(set, "adding lower bound change info to var <%s>[%g,%g]: depth=%d, pos=%d, infer%s=<%s>, inferinfo=%d, %g -> %g\n",
506 SCIPvarGetName(var), var->locdom.lb, var->locdom.ub, depth, pos, infercons != NULL ? "cons" : "prop",
507 infercons != NULL ? SCIPconsGetName(infercons) : (inferprop != NULL ? SCIPpropGetName(inferprop) : "-"), inferinfo,
508 oldbound, newbound);
509
510 SCIP_CALL( varEnsureLbchginfosSize(var, blkmem, set, var->nlbchginfos+1) );
511 var->lbchginfos[var->nlbchginfos].oldbound = oldbound;
512 var->lbchginfos[var->nlbchginfos].newbound = newbound;
513 var->lbchginfos[var->nlbchginfos].var = var;
514 var->lbchginfos[var->nlbchginfos].bdchgidx.depth = depth;
515 var->lbchginfos[var->nlbchginfos].bdchgidx.pos = pos;
516 var->lbchginfos[var->nlbchginfos].pos = var->nlbchginfos; /*lint !e732*/
517 var->lbchginfos[var->nlbchginfos].boundchgtype = boundchgtype; /*lint !e641*/
518 var->lbchginfos[var->nlbchginfos].boundtype = SCIP_BOUNDTYPE_LOWER; /*lint !e641*/
520 var->lbchginfos[var->nlbchginfos].inferboundtype = inferboundtype; /*lint !e641*/
521 var->lbchginfos[var->nlbchginfos].inferencedata.var = infervar;
522 var->lbchginfos[var->nlbchginfos].inferencedata.info = inferinfo;
523
524 /**@note The "pos" data member of the bound change info has a size of 27 bits */
525 assert(var->nlbchginfos < 1 << 27);
526
527 switch( boundchgtype )
528 {
530 break;
532 assert(infercons != NULL);
533 var->lbchginfos[var->nlbchginfos].inferencedata.reason.cons = infercons;
534 break;
536 var->lbchginfos[var->nlbchginfos].inferencedata.reason.prop = inferprop;
537 break;
538 default:
539 SCIPerrorMessage("invalid bound change type %d\n", boundchgtype);
540 return SCIP_INVALIDDATA;
541 }
542
543 var->nlbchginfos++;
544
545 assert(var->nlbchginfos < 2
547 &var->lbchginfos[var->nlbchginfos-1].bdchgidx));
548
549 return SCIP_OKAY;
550}
551
552/** adds domain change info to the variable's upper bound change info array */
553static
555 SCIP_VAR* var, /**< problem variable */
556 BMS_BLKMEM* blkmem, /**< block memory */
557 SCIP_SET* set, /**< global SCIP settings */
558 SCIP_Real oldbound, /**< old value for bound */
559 SCIP_Real newbound, /**< new value for bound */
560 int depth, /**< depth in the tree, where the bound change takes place */
561 int pos, /**< position of the bound change in its bound change array */
562 SCIP_VAR* infervar, /**< variable that was changed (parent of var, or var itself) */
563 SCIP_CONS* infercons, /**< constraint that inferred this bound change, or NULL */
564 SCIP_PROP* inferprop, /**< propagator that deduced the bound change, or NULL */
565 int inferinfo, /**< user information for inference to help resolving the conflict */
566 SCIP_BOUNDTYPE inferboundtype, /**< type of bound for inference var: lower or upper bound */
567 SCIP_BOUNDCHGTYPE boundchgtype /**< bound change type: branching decision or inferred bound change */
568 )
569{
570 assert(var != NULL);
571 assert(SCIPsetIsGT(set, oldbound, newbound));
574 assert(!SCIPvarIsBinary(var) || SCIPsetIsEQ(set, oldbound, 1.0));
575 assert(!SCIPvarIsBinary(var) || SCIPsetIsEQ(set, newbound, 0.0));
576 assert(boundchgtype == SCIP_BOUNDCHGTYPE_BRANCHING || infervar != NULL);
577 assert((boundchgtype == SCIP_BOUNDCHGTYPE_CONSINFER) == (infercons != NULL));
578 assert(boundchgtype == SCIP_BOUNDCHGTYPE_PROPINFER || inferprop == NULL);
579
580 SCIPsetDebugMsg(set, "adding upper bound change info to var <%s>[%g,%g]: depth=%d, pos=%d, infer%s=<%s>, inferinfo=%d, %g -> %g\n",
581 SCIPvarGetName(var), var->locdom.lb, var->locdom.ub, depth, pos, infercons != NULL ? "cons" : "prop",
582 infercons != NULL ? SCIPconsGetName(infercons) : (inferprop != NULL ? SCIPpropGetName(inferprop) : "-"), inferinfo,
583 oldbound, newbound);
584
585 SCIP_CALL( varEnsureUbchginfosSize(var, blkmem, set, var->nubchginfos+1) );
586 var->ubchginfos[var->nubchginfos].oldbound = oldbound;
587 var->ubchginfos[var->nubchginfos].newbound = newbound;
588 var->ubchginfos[var->nubchginfos].var = var;
589 var->ubchginfos[var->nubchginfos].bdchgidx.depth = depth;
590 var->ubchginfos[var->nubchginfos].bdchgidx.pos = pos;
591 var->ubchginfos[var->nubchginfos].pos = var->nubchginfos; /*lint !e732*/
592 var->ubchginfos[var->nubchginfos].boundchgtype = boundchgtype; /*lint !e641*/
593 var->ubchginfos[var->nubchginfos].boundtype = SCIP_BOUNDTYPE_UPPER; /*lint !e641*/
595 var->ubchginfos[var->nubchginfos].inferboundtype = inferboundtype; /*lint !e641*/
596 var->ubchginfos[var->nubchginfos].inferencedata.var = infervar;
597 var->ubchginfos[var->nubchginfos].inferencedata.info = inferinfo;
598
599 /**@note The "pos" data member of the bound change info has a size of 27 bits */
600 assert(var->nubchginfos < 1 << 27);
601
602 switch( boundchgtype )
603 {
605 break;
607 assert(infercons != NULL);
608 var->ubchginfos[var->nubchginfos].inferencedata.reason.cons = infercons;
609 break;
611 var->ubchginfos[var->nubchginfos].inferencedata.reason.prop = inferprop;
612 break;
613 default:
614 SCIPerrorMessage("invalid bound change type %d\n", boundchgtype);
615 return SCIP_INVALIDDATA;
616 }
617
618 var->nubchginfos++;
619
620 assert(var->nubchginfos < 2
622 &var->ubchginfos[var->nubchginfos-1].bdchgidx));
623
624 return SCIP_OKAY;
625}
626
627/** applies single bound change */
629 SCIP_BOUNDCHG* boundchg, /**< bound change to apply */
630 BMS_BLKMEM* blkmem, /**< block memory */
631 SCIP_SET* set, /**< global SCIP settings */
632 SCIP_STAT* stat, /**< problem statistics */
633 SCIP_LP* lp, /**< current LP data */
634 SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
635 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
636 int depth, /**< depth in the tree, where the bound change takes place */
637 int pos, /**< position of the bound change in its bound change array */
638 SCIP_Bool* cutoff /**< pointer to store whether an infeasible bound change was detected */
639 )
640{
641 SCIP_VAR* var;
642
643 assert(boundchg != NULL);
644 assert(stat != NULL);
645 assert(depth > 0);
646 assert(pos >= 0);
647 assert(cutoff != NULL);
648
649 *cutoff = FALSE;
650
651 /* ignore redundant bound changes */
652 if( boundchg->redundant )
653 return SCIP_OKAY;
654
655 var = boundchg->var;
656 assert(var != NULL);
658 assert(!SCIPvarIsIntegral(var) || SCIPsetIsFeasIntegral(set, boundchg->newbound));
659
660 /* apply bound change */
661 switch( boundchg->boundtype )
662 {
664 /* check, if the bound change is still active (could be replaced by inference due to repropagation of higher node) */
665 if( SCIPsetIsGT(set, boundchg->newbound, var->locdom.lb) )
666 {
667 if( SCIPsetIsLE(set, boundchg->newbound, var->locdom.ub) )
668 {
669 /* add the bound change info to the variable's bound change info array */
670 switch( boundchg->boundchgtype )
671 {
673 SCIPsetDebugMsg(set, " -> branching: new lower bound of <%s>[%g,%g]: %g\n",
674 SCIPvarGetName(var), var->locdom.lb, var->locdom.ub, boundchg->newbound);
675 SCIP_CALL( varAddLbchginfo(var, blkmem, set, var->locdom.lb, boundchg->newbound, depth, pos,
677 stat->lastbranchvar = var;
679 stat->lastbranchvalue = boundchg->newbound;
680 break;
681
683 assert(boundchg->data.inferencedata.reason.cons != NULL);
684 SCIPsetDebugMsg(set, " -> constraint <%s> inference: new lower bound of <%s>[%g,%g]: %g\n",
685 SCIPconsGetName(boundchg->data.inferencedata.reason.cons),
686 SCIPvarGetName(var), var->locdom.lb, var->locdom.ub, boundchg->newbound);
687 SCIP_CALL( varAddLbchginfo(var, blkmem, set, var->locdom.lb, boundchg->newbound, depth, pos,
688 boundchg->data.inferencedata.var, boundchg->data.inferencedata.reason.cons, NULL,
689 boundchg->data.inferencedata.info,
691 break;
692
694 SCIPsetDebugMsg(set, " -> propagator <%s> inference: new lower bound of <%s>[%g,%g]: %g\n",
695 boundchg->data.inferencedata.reason.prop != NULL
696 ? SCIPpropGetName(boundchg->data.inferencedata.reason.prop) : "-",
697 SCIPvarGetName(var), var->locdom.lb, var->locdom.ub, boundchg->newbound);
698 SCIP_CALL( varAddLbchginfo(var, blkmem, set, var->locdom.lb, boundchg->newbound, depth, pos,
699 boundchg->data.inferencedata.var, NULL, boundchg->data.inferencedata.reason.prop,
700 boundchg->data.inferencedata.info,
702 break;
703
704 default:
705 SCIPerrorMessage("invalid bound change type %d\n", boundchg->boundchgtype);
706 return SCIP_INVALIDDATA;
707 }
708
709 /* change local bound of variable */
710 SCIP_CALL( SCIPvarChgLbLocal(var, blkmem, set, stat, lp, branchcand, eventqueue, boundchg->newbound) );
711 }
712 else
713 {
714 SCIPsetDebugMsg(set, " -> cutoff: new lower bound of <%s>[%g,%g]: %g\n",
715 SCIPvarGetName(var), var->locdom.lb, var->locdom.ub, boundchg->newbound);
716 *cutoff = TRUE;
717 boundchg->redundant = TRUE; /* bound change has not entered the lbchginfos array of the variable! */
718 }
719 }
720 else
721 {
722 /* mark bound change to be inactive */
723 SCIPsetDebugMsg(set, " -> inactive %s: new lower bound of <%s>[%g,%g]: %g\n",
724 (SCIP_BOUNDCHGTYPE)boundchg->boundchgtype == SCIP_BOUNDCHGTYPE_BRANCHING ? "branching" : "inference",
725 SCIPvarGetName(var), var->locdom.lb, var->locdom.ub, boundchg->newbound);
726 boundchg->redundant = TRUE;
727 }
728 break;
729
731 /* check, if the bound change is still active (could be replaced by inference due to repropagation of higher node) */
732 if( SCIPsetIsLT(set, boundchg->newbound, var->locdom.ub) )
733 {
734 if( SCIPsetIsGE(set, boundchg->newbound, var->locdom.lb) )
735 {
736 /* add the bound change info to the variable's bound change info array */
737 switch( boundchg->boundchgtype )
738 {
740 SCIPsetDebugMsg(set, " -> branching: new upper bound of <%s>[%g,%g]: %g\n",
741 SCIPvarGetName(var), var->locdom.lb, var->locdom.ub, boundchg->newbound);
742 SCIP_CALL( varAddUbchginfo(var, blkmem, set, var->locdom.ub, boundchg->newbound, depth, pos,
744 stat->lastbranchvar = var;
746 stat->lastbranchvalue = boundchg->newbound;
747 break;
748
750 assert(boundchg->data.inferencedata.reason.cons != NULL);
751 SCIPsetDebugMsg(set, " -> constraint <%s> inference: new upper bound of <%s>[%g,%g]: %g\n",
752 SCIPconsGetName(boundchg->data.inferencedata.reason.cons),
753 SCIPvarGetName(var), var->locdom.lb, var->locdom.ub, boundchg->newbound);
754 SCIP_CALL( varAddUbchginfo(var, blkmem, set, var->locdom.ub, boundchg->newbound, depth, pos,
755 boundchg->data.inferencedata.var, boundchg->data.inferencedata.reason.cons, NULL,
756 boundchg->data.inferencedata.info,
758 break;
759
761 SCIPsetDebugMsg(set, " -> propagator <%s> inference: new upper bound of <%s>[%g,%g]: %g\n",
762 boundchg->data.inferencedata.reason.prop != NULL
763 ? SCIPpropGetName(boundchg->data.inferencedata.reason.prop) : "-",
764 SCIPvarGetName(var), var->locdom.lb, var->locdom.ub, boundchg->newbound);
765 SCIP_CALL( varAddUbchginfo(var, blkmem, set, var->locdom.ub, boundchg->newbound, depth, pos,
766 boundchg->data.inferencedata.var, NULL, boundchg->data.inferencedata.reason.prop,
767 boundchg->data.inferencedata.info,
769 break;
770
771 default:
772 SCIPerrorMessage("invalid bound change type %d\n", boundchg->boundchgtype);
773 return SCIP_INVALIDDATA;
774 }
775
776 /* change local bound of variable */
777 SCIP_CALL( SCIPvarChgUbLocal(var, blkmem, set, stat, lp, branchcand, eventqueue, boundchg->newbound) );
778 }
779 else
780 {
781 SCIPsetDebugMsg(set, " -> cutoff: new upper bound of <%s>[%g,%g]: %g\n",
782 SCIPvarGetName(var), var->locdom.lb, var->locdom.ub, boundchg->newbound);
783 *cutoff = TRUE;
784 boundchg->redundant = TRUE; /* bound change has not entered the ubchginfos array of the variable! */
785 }
786 }
787 else
788 {
789 /* mark bound change to be inactive */
790 SCIPsetDebugMsg(set, " -> inactive %s: new upper bound of <%s>[%g,%g]: %g\n",
791 (SCIP_BOUNDCHGTYPE)boundchg->boundchgtype == SCIP_BOUNDCHGTYPE_BRANCHING ? "branching" : "inference",
792 SCIPvarGetName(var), var->locdom.lb, var->locdom.ub, boundchg->newbound);
793 boundchg->redundant = TRUE;
794 }
795 break;
796
797 default:
798 SCIPerrorMessage("unknown bound type\n");
799 return SCIP_INVALIDDATA;
800 }
801
802 /* update the branching and inference history */
803 if( !boundchg->applied && !boundchg->redundant )
804 {
805 assert(var == boundchg->var);
806
808 {
809 SCIP_CALL( SCIPvarIncNBranchings(var, blkmem, set, stat,
812 }
813 else if( stat->lastbranchvar != NULL )
814 {
815 /**@todo if last branching variable is unknown, retrieve it from the nodes' boundchg arrays */
816 SCIP_CALL( SCIPvarIncInferenceSum(stat->lastbranchvar, blkmem, set, stat, stat->lastbranchdir, stat->lastbranchvalue, 1.0) );
817 }
818 boundchg->applied = TRUE;
819 }
820
821 return SCIP_OKAY;
822}
823
824/** undoes single bound change */
826 SCIP_BOUNDCHG* boundchg, /**< bound change to remove */
827 BMS_BLKMEM* blkmem, /**< block memory */
828 SCIP_SET* set, /**< global SCIP settings */
829 SCIP_STAT* stat, /**< problem statistics */
830 SCIP_LP* lp, /**< current LP data */
831 SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
832 SCIP_EVENTQUEUE* eventqueue /**< event queue */
833 )
834{
835 SCIP_VAR* var;
836
837 assert(boundchg != NULL);
838 assert(stat != NULL);
839
840 /* ignore redundant bound changes */
841 if( boundchg->redundant )
842 return SCIP_OKAY;
843
844 var = boundchg->var;
845 assert(var != NULL);
847
848 /* undo bound change: apply the previous bound change of variable */
849 switch( boundchg->boundtype )
850 {
852 var->nlbchginfos--;
853 assert(var->nlbchginfos >= 0);
854 assert(var->lbchginfos != NULL);
855 assert( SCIPsetIsFeasEQ(set, var->lbchginfos[var->nlbchginfos].newbound, var->locdom.lb) ); /*lint !e777*/
856 assert( SCIPsetIsFeasLE(set, boundchg->newbound, var->locdom.lb) ); /* current lb might be larger to intermediate global bound change */
857
858 SCIPsetDebugMsg(set, "removed lower bound change info of var <%s>[%g,%g]: depth=%d, pos=%d, %g -> %g\n",
859 SCIPvarGetName(var), var->locdom.lb, var->locdom.ub,
862
863 /* reinstall the previous local bound */
864 SCIP_CALL( SCIPvarChgLbLocal(boundchg->var, blkmem, set, stat, lp, branchcand, eventqueue,
865 var->lbchginfos[var->nlbchginfos].oldbound) );
866
867 /* in case all bound changes are removed the local bound should match the global bound */
868 assert(var->nlbchginfos > 0 || SCIPsetIsFeasEQ(set, var->locdom.lb, var->glbdom.lb));
869
870 break;
871
873 var->nubchginfos--;
874 assert(var->nubchginfos >= 0);
875 assert(var->ubchginfos != NULL);
876 assert( SCIPsetIsFeasEQ(set, var->ubchginfos[var->nubchginfos].newbound, var->locdom.ub) ); /*lint !e777*/
877 assert( SCIPsetIsFeasGE(set, boundchg->newbound, var->locdom.ub) ); /* current ub might be smaller to intermediate global bound change */
878
879 SCIPsetDebugMsg(set, "removed upper bound change info of var <%s>[%g,%g]: depth=%d, pos=%d, %g -> %g\n",
880 SCIPvarGetName(var), var->locdom.lb, var->locdom.ub,
883
884 /* reinstall the previous local bound */
885 SCIP_CALL( SCIPvarChgUbLocal(boundchg->var, blkmem, set, stat, lp, branchcand, eventqueue,
886 var->ubchginfos[var->nubchginfos].oldbound) );
887
888 /* in case all bound changes are removed the local bound should match the global bound */
889 assert(var->nubchginfos > 0 || SCIPsetIsFeasEQ(set, var->locdom.ub, var->glbdom.ub));
890
891 break;
892
893 default:
894 SCIPerrorMessage("unknown bound type\n");
895 return SCIP_INVALIDDATA;
896 }
897
898 /* update last branching variable */
900 {
901 stat->lastbranchvar = NULL;
903 }
904
905 return SCIP_OKAY;
906}
907
908/** applies single bound change to the global problem by changing the global bound of the corresponding variable */
909static
911 SCIP_BOUNDCHG* boundchg, /**< bound change to apply */
912 BMS_BLKMEM* blkmem, /**< block memory */
913 SCIP_SET* set, /**< global SCIP settings */
914 SCIP_STAT* stat, /**< problem statistics */
915 SCIP_LP* lp, /**< current LP data */
916 SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
917 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
918 SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
919 SCIP_Bool* cutoff /**< pointer to store whether an infeasible bound change was detected */
920 )
921{
922 SCIP_VAR* var;
923 SCIP_Real newbound;
924 SCIP_BOUNDTYPE boundtype;
925
926 assert(boundchg != NULL);
927 assert(cutoff != NULL);
928
929 *cutoff = FALSE;
930
931 /* ignore redundant bound changes */
932 if( boundchg->redundant )
933 return SCIP_OKAY;
934
935 var = SCIPboundchgGetVar(boundchg);
936 newbound = SCIPboundchgGetNewbound(boundchg);
937 boundtype = SCIPboundchgGetBoundtype(boundchg);
938
939 /* check if the bound change is redundant which can happen due to a (better) global bound change which was performed
940 * after that bound change was applied
941 *
942 * @note a global bound change is not captured by the redundant member of the bound change data structure
943 */
944 if( (boundtype == SCIP_BOUNDTYPE_LOWER && SCIPsetIsFeasLE(set, newbound, SCIPvarGetLbGlobal(var)))
945 || (boundtype == SCIP_BOUNDTYPE_UPPER && SCIPsetIsFeasGE(set, newbound, SCIPvarGetUbGlobal(var))) )
946 {
947 return SCIP_OKAY;
948 }
949
950 SCIPsetDebugMsg(set, "applying global bound change: <%s>[%g,%g] %s %g\n",
952 boundtype == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=", newbound);
953
954 /* check for cutoff */
955 if( (boundtype == SCIP_BOUNDTYPE_LOWER && SCIPsetIsFeasGT(set, newbound, SCIPvarGetUbGlobal(var)))
956 || (boundtype == SCIP_BOUNDTYPE_UPPER && SCIPsetIsFeasLT(set, newbound, SCIPvarGetLbGlobal(var))) )
957 {
958 *cutoff = TRUE;
959 return SCIP_OKAY;
960 }
961
962 /* apply bound change */
963 SCIP_CALL( SCIPvarChgBdGlobal(var, blkmem, set, stat, lp, branchcand, eventqueue, cliquetable, newbound, boundtype) );
964
965 return SCIP_OKAY;
966}
967
968/** captures branching and inference data of bound change */
969static
971 SCIP_BOUNDCHG* boundchg /**< bound change to remove */
972 )
973{
974 assert(boundchg != NULL);
975
976 /* capture variable associated with the bound change */
977 assert(boundchg->var != NULL);
978 SCIPvarCapture(boundchg->var);
979
980 switch( boundchg->boundchgtype )
981 {
984 break;
985
987 assert(boundchg->data.inferencedata.var != NULL);
988 assert(boundchg->data.inferencedata.reason.cons != NULL);
989 SCIPconsCapture(boundchg->data.inferencedata.reason.cons);
990 break;
991
992 default:
993 SCIPerrorMessage("invalid bound change type\n");
994 return SCIP_INVALIDDATA;
995 }
996
997 return SCIP_OKAY;
998}
999
1000/** releases branching and inference data of bound change */
1001static
1003 SCIP_BOUNDCHG* boundchg, /**< bound change to remove */
1004 BMS_BLKMEM* blkmem, /**< block memory */
1005 SCIP_SET* set, /**< global SCIP settings */
1006 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
1007 SCIP_LP* lp /**< current LP data */
1008
1009 )
1010{
1011 assert(boundchg != NULL);
1012
1013 switch( boundchg->boundchgtype )
1014 {
1017 break;
1018
1020 assert(boundchg->data.inferencedata.var != NULL);
1021 assert(boundchg->data.inferencedata.reason.cons != NULL);
1022 SCIP_CALL( SCIPconsRelease(&boundchg->data.inferencedata.reason.cons, blkmem, set) );
1023 break;
1024
1025 default:
1026 SCIPerrorMessage("invalid bound change type\n");
1027 return SCIP_INVALIDDATA;
1028 }
1029
1030 /* release variable */
1031 assert(boundchg->var != NULL);
1032 SCIP_CALL( SCIPvarRelease(&boundchg->var, blkmem, set, eventqueue, lp) );
1033
1034 return SCIP_OKAY;
1035}
1036
1037/** creates empty domain change data with dynamic arrays */
1038static
1040 SCIP_DOMCHG** domchg, /**< pointer to domain change data */
1041 BMS_BLKMEM* blkmem /**< block memory */
1042 )
1043{
1044 assert(domchg != NULL);
1045 assert(blkmem != NULL);
1046
1047 SCIP_ALLOC( BMSallocBlockMemorySize(blkmem, domchg, sizeof(SCIP_DOMCHGDYN)) );
1048 (*domchg)->domchgdyn.domchgtype = SCIP_DOMCHGTYPE_DYNAMIC; /*lint !e641*/
1049 (*domchg)->domchgdyn.nboundchgs = 0;
1050 (*domchg)->domchgdyn.boundchgs = NULL;
1051 (*domchg)->domchgdyn.nholechgs = 0;
1052 (*domchg)->domchgdyn.holechgs = NULL;
1053 (*domchg)->domchgdyn.boundchgssize = 0;
1054 (*domchg)->domchgdyn.holechgssize = 0;
1055
1056 return SCIP_OKAY;
1057}
1058
1059/** frees domain change data */
1061 SCIP_DOMCHG** domchg, /**< pointer to domain change */
1062 BMS_BLKMEM* blkmem, /**< block memory */
1063 SCIP_SET* set, /**< global SCIP settings */
1064 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
1065 SCIP_LP* lp /**< current LP data */
1066 )
1067{
1068 assert(domchg != NULL);
1069 assert(blkmem != NULL);
1070
1071 if( *domchg != NULL )
1072 {
1073 int i;
1074
1075 /* release variables, branching and inference data associated with the bound changes */
1076 for( i = 0; i < (int)(*domchg)->domchgbound.nboundchgs; ++i )
1077 {
1078 SCIP_CALL( boundchgReleaseData(&(*domchg)->domchgbound.boundchgs[i], blkmem, set, eventqueue, lp) );
1079 }
1080
1081 /* free memory for bound and hole changes */
1082 switch( (*domchg)->domchgdyn.domchgtype )
1083 {
1085 BMSfreeBlockMemoryArrayNull(blkmem, &(*domchg)->domchgbound.boundchgs, (*domchg)->domchgbound.nboundchgs);
1086 BMSfreeBlockMemorySize(blkmem, domchg, sizeof(SCIP_DOMCHGBOUND));
1087 break;
1089 BMSfreeBlockMemoryArrayNull(blkmem, &(*domchg)->domchgboth.boundchgs, (*domchg)->domchgboth.nboundchgs);
1090 BMSfreeBlockMemoryArrayNull(blkmem, &(*domchg)->domchgboth.holechgs, (*domchg)->domchgboth.nholechgs);
1091 BMSfreeBlockMemorySize(blkmem, domchg, sizeof(SCIP_DOMCHGBOTH));
1092 break;
1094 BMSfreeBlockMemoryArrayNull(blkmem, &(*domchg)->domchgdyn.boundchgs, (*domchg)->domchgdyn.boundchgssize);
1095 BMSfreeBlockMemoryArrayNull(blkmem, &(*domchg)->domchgdyn.holechgs, (*domchg)->domchgdyn.holechgssize);
1096 BMSfreeBlockMemorySize(blkmem, domchg, sizeof(SCIP_DOMCHGDYN));
1097 break;
1098 default:
1099 SCIPerrorMessage("invalid domain change type\n");
1100 return SCIP_INVALIDDATA;
1101 }
1102 }
1103
1104 return SCIP_OKAY;
1105}
1106
1107/** converts a static domain change data into a dynamic one */
1108static
1110 SCIP_DOMCHG** domchg, /**< pointer to domain change data */
1111 BMS_BLKMEM* blkmem /**< block memory */
1112 )
1113{
1114 assert(domchg != NULL);
1115 assert(blkmem != NULL);
1116
1117 SCIPdebugMessage("making domain change data %p pointing to %p dynamic\n", (void*)domchg, (void*)*domchg);
1118
1119 if( *domchg == NULL )
1120 {
1121 SCIP_CALL( domchgCreate(domchg, blkmem) );
1122 }
1123 else
1124 {
1125 switch( (*domchg)->domchgdyn.domchgtype )
1126 {
1128 SCIP_ALLOC( BMSreallocBlockMemorySize(blkmem, domchg, sizeof(SCIP_DOMCHGBOUND), sizeof(SCIP_DOMCHGDYN)) );
1129 (*domchg)->domchgdyn.nholechgs = 0;
1130 (*domchg)->domchgdyn.holechgs = NULL;
1131 (*domchg)->domchgdyn.boundchgssize = (int) (*domchg)->domchgdyn.nboundchgs;
1132 (*domchg)->domchgdyn.holechgssize = 0;
1133 (*domchg)->domchgdyn.domchgtype = SCIP_DOMCHGTYPE_DYNAMIC; /*lint !e641*/
1134 break;
1136 SCIP_ALLOC( BMSreallocBlockMemorySize(blkmem, domchg, sizeof(SCIP_DOMCHGBOTH), sizeof(SCIP_DOMCHGDYN)) );
1137 (*domchg)->domchgdyn.boundchgssize = (int) (*domchg)->domchgdyn.nboundchgs;
1138 (*domchg)->domchgdyn.holechgssize = (*domchg)->domchgdyn.nholechgs;
1139 (*domchg)->domchgdyn.domchgtype = SCIP_DOMCHGTYPE_DYNAMIC; /*lint !e641*/
1140 break;
1142 break;
1143 default:
1144 SCIPerrorMessage("invalid domain change type\n");
1145 return SCIP_INVALIDDATA;
1146 }
1147 }
1148#ifndef NDEBUG
1149 {
1150 int i;
1151 for( i = 0; i < (int)(*domchg)->domchgbound.nboundchgs; ++i )
1152 assert(SCIPvarGetType((*domchg)->domchgbound.boundchgs[i].var) == SCIP_VARTYPE_CONTINUOUS
1153 || EPSISINT((*domchg)->domchgbound.boundchgs[i].newbound, 1e-06));
1154 }
1155#endif
1156
1157 return SCIP_OKAY;
1158}
1159
1160/** converts a dynamic domain change data into a static one, using less memory than for a dynamic one */
1162 SCIP_DOMCHG** domchg, /**< pointer to domain change data */
1163 BMS_BLKMEM* blkmem, /**< block memory */
1164 SCIP_SET* set, /**< global SCIP settings */
1165 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
1166 SCIP_LP* lp /**< current LP data */
1167 )
1168{
1169 assert(domchg != NULL);
1170 assert(blkmem != NULL);
1171
1172 SCIPsetDebugMsg(set, "making domain change data %p pointing to %p static\n", (void*)domchg, (void*)*domchg);
1173
1174 if( *domchg != NULL )
1175 {
1176 switch( (*domchg)->domchgdyn.domchgtype )
1177 {
1179 if( (*domchg)->domchgbound.nboundchgs == 0 )
1180 {
1181 SCIP_CALL( SCIPdomchgFree(domchg, blkmem, set, eventqueue, lp) );
1182 }
1183 break;
1185 if( (*domchg)->domchgboth.nholechgs == 0 )
1186 {
1187 if( (*domchg)->domchgbound.nboundchgs == 0 )
1188 {
1189 SCIP_CALL( SCIPdomchgFree(domchg, blkmem, set, eventqueue, lp) );
1190 }
1191 else
1192 {
1193 SCIP_ALLOC( BMSreallocBlockMemorySize(blkmem, domchg, sizeof(SCIP_DOMCHGBOTH), sizeof(SCIP_DOMCHGBOUND)) );
1194 (*domchg)->domchgdyn.domchgtype = SCIP_DOMCHGTYPE_BOUND; /*lint !e641*/
1195 }
1196 }
1197 break;
1199 if( (*domchg)->domchgboth.nholechgs == 0 )
1200 {
1201 if( (*domchg)->domchgbound.nboundchgs == 0 )
1202 {
1203 SCIP_CALL( SCIPdomchgFree(domchg, blkmem, set, eventqueue, lp) );
1204 }
1205 else
1206 {
1207 /* shrink dynamic size arrays to their minimal sizes */
1208 SCIP_ALLOC( BMSreallocBlockMemoryArray(blkmem, &(*domchg)->domchgdyn.boundchgs, \
1209 (*domchg)->domchgdyn.boundchgssize, (*domchg)->domchgdyn.nboundchgs) ); /*lint !e571*/
1210 BMSfreeBlockMemoryArrayNull(blkmem, &(*domchg)->domchgdyn.holechgs, (*domchg)->domchgdyn.holechgssize);
1211
1212 /* convert into static domain change */
1213 SCIP_ALLOC( BMSreallocBlockMemorySize(blkmem, domchg, sizeof(SCIP_DOMCHGDYN), sizeof(SCIP_DOMCHGBOUND)) );
1214 (*domchg)->domchgdyn.domchgtype = SCIP_DOMCHGTYPE_BOUND; /*lint !e641*/
1215 }
1216 }
1217 else
1218 {
1219 /* shrink dynamic size arrays to their minimal sizes */
1220 SCIP_ALLOC( BMSreallocBlockMemoryArray(blkmem, &(*domchg)->domchgdyn.boundchgs, \
1221 (*domchg)->domchgdyn.boundchgssize, (*domchg)->domchgdyn.nboundchgs) ); /*lint !e571*/
1222 SCIP_ALLOC( BMSreallocBlockMemoryArray(blkmem, &(*domchg)->domchgdyn.holechgs, \
1223 (*domchg)->domchgdyn.holechgssize, (*domchg)->domchgdyn.nholechgs) );
1224
1225 /* convert into static domain change */
1226 SCIP_ALLOC( BMSreallocBlockMemorySize(blkmem, domchg, sizeof(SCIP_DOMCHGDYN), sizeof(SCIP_DOMCHGBOTH)) );
1227 (*domchg)->domchgdyn.domchgtype = SCIP_DOMCHGTYPE_BOTH; /*lint !e641*/
1228 }
1229 break;
1230 default:
1231 SCIPerrorMessage("invalid domain change type\n");
1232 return SCIP_INVALIDDATA;
1233 }
1234#ifndef NDEBUG
1235 if( *domchg != NULL )
1236 {
1237 int i;
1238 for( i = 0; i < (int)(*domchg)->domchgbound.nboundchgs; ++i )
1239 assert(SCIPvarGetType((*domchg)->domchgbound.boundchgs[i].var) == SCIP_VARTYPE_CONTINUOUS
1240 || SCIPsetIsFeasIntegral(set, (*domchg)->domchgbound.boundchgs[i].newbound));
1241 }
1242#endif
1243 }
1244
1245 return SCIP_OKAY;
1246}
1247
1248/** ensures, that boundchgs array can store at least num entries */
1249static
1251 SCIP_DOMCHG* domchg, /**< domain change data structure */
1252 BMS_BLKMEM* blkmem, /**< block memory */
1253 SCIP_SET* set, /**< global SCIP settings */
1254 int num /**< minimum number of entries to store */
1255 )
1256{
1257 assert(domchg != NULL);
1258 assert(domchg->domchgdyn.domchgtype == SCIP_DOMCHGTYPE_DYNAMIC); /*lint !e641*/
1259
1260 if( num > domchg->domchgdyn.boundchgssize )
1261 {
1262 int newsize;
1263
1264 newsize = SCIPsetCalcMemGrowSize(set, num);
1265 SCIP_ALLOC( BMSreallocBlockMemoryArray(blkmem, &domchg->domchgdyn.boundchgs, domchg->domchgdyn.boundchgssize, newsize) );
1266 domchg->domchgdyn.boundchgssize = newsize;
1267 }
1268 assert(num <= domchg->domchgdyn.boundchgssize);
1269
1270 return SCIP_OKAY;
1271}
1272
1273/** ensures, that holechgs array can store at least num additional entries */
1274static
1276 SCIP_DOMCHG* domchg, /**< domain change data structure */
1277 BMS_BLKMEM* blkmem, /**< block memory */
1278 SCIP_SET* set, /**< global SCIP settings */
1279 int num /**< minimum number of additional entries to store */
1280 )
1281{
1282 assert(domchg != NULL);
1283 assert(domchg->domchgdyn.domchgtype == SCIP_DOMCHGTYPE_DYNAMIC); /*lint !e641*/
1284
1285 if( num > domchg->domchgdyn.holechgssize )
1286 {
1287 int newsize;
1288
1289 newsize = SCIPsetCalcMemGrowSize(set, num);
1290 SCIP_ALLOC( BMSreallocBlockMemoryArray(blkmem, &domchg->domchgdyn.holechgs, domchg->domchgdyn.holechgssize, newsize) );
1291 domchg->domchgdyn.holechgssize = newsize;
1292 }
1293 assert(num <= domchg->domchgdyn.holechgssize);
1294
1295 return SCIP_OKAY;
1296}
1297
1298/** applies domain change */
1300 SCIP_DOMCHG* domchg, /**< domain change to apply */
1301 BMS_BLKMEM* blkmem, /**< block memory */
1302 SCIP_SET* set, /**< global SCIP settings */
1303 SCIP_STAT* stat, /**< problem statistics */
1304 SCIP_LP* lp, /**< current LP data */
1305 SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
1306 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
1307 int depth, /**< depth in the tree, where the domain change takes place */
1308 SCIP_Bool* cutoff /**< pointer to store whether an infeasible domain change was detected */
1309 )
1310{
1311 int i;
1312
1313 assert(cutoff != NULL);
1314
1315 *cutoff = FALSE;
1316
1317 SCIPsetDebugMsg(set, "applying domain changes at %p in depth %d\n", (void*)domchg, depth);
1318
1319 if( domchg == NULL )
1320 return SCIP_OKAY;
1321
1322 /* apply bound changes */
1323 for( i = 0; i < (int)domchg->domchgbound.nboundchgs; ++i )
1324 {
1325 SCIP_CALL( SCIPboundchgApply(&domchg->domchgbound.boundchgs[i], blkmem, set, stat, lp,
1326 branchcand, eventqueue, depth, i, cutoff) );
1327 if( *cutoff )
1328 break;
1329 }
1330 SCIPsetDebugMsg(set, " -> %u bound changes (cutoff %u)\n", domchg->domchgbound.nboundchgs, *cutoff);
1331
1332 /* mark all bound changes after a cutoff redundant */
1333 for( ; i < (int)domchg->domchgbound.nboundchgs; ++i )
1334 domchg->domchgbound.boundchgs[i].redundant = TRUE;
1335
1336 /* apply holelist changes */
1337 if( domchg->domchgdyn.domchgtype != SCIP_DOMCHGTYPE_BOUND ) /*lint !e641*/
1338 {
1339 for( i = 0; i < domchg->domchgboth.nholechgs; ++i )
1340 *(domchg->domchgboth.holechgs[i].ptr) = domchg->domchgboth.holechgs[i].newlist;
1341 SCIPsetDebugMsg(set, " -> %d hole changes\n", domchg->domchgboth.nholechgs);
1342 }
1343
1344 return SCIP_OKAY;
1345}
1346
1347/** undoes domain change */
1349 SCIP_DOMCHG* domchg, /**< domain change to remove */
1350 BMS_BLKMEM* blkmem, /**< block memory */
1351 SCIP_SET* set, /**< global SCIP settings */
1352 SCIP_STAT* stat, /**< problem statistics */
1353 SCIP_LP* lp, /**< current LP data */
1354 SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
1355 SCIP_EVENTQUEUE* eventqueue /**< event queue */
1356 )
1357{
1358 int i;
1359
1360 SCIPsetDebugMsg(set, "undoing domain changes at %p\n", (void*)domchg);
1361 if( domchg == NULL )
1362 return SCIP_OKAY;
1363
1364 /* undo holelist changes */
1365 if( domchg->domchgdyn.domchgtype != SCIP_DOMCHGTYPE_BOUND ) /*lint !e641*/
1366 {
1367 for( i = domchg->domchgboth.nholechgs-1; i >= 0; --i )
1368 *(domchg->domchgboth.holechgs[i].ptr) = domchg->domchgboth.holechgs[i].oldlist;
1369 SCIPsetDebugMsg(set, " -> %d hole changes\n", domchg->domchgboth.nholechgs);
1370 }
1371
1372 /* undo bound changes */
1373 for( i = domchg->domchgbound.nboundchgs-1; i >= 0; --i )
1374 {
1375 SCIP_CALL( SCIPboundchgUndo(&domchg->domchgbound.boundchgs[i], blkmem, set, stat, lp, branchcand, eventqueue) );
1376 }
1377 SCIPsetDebugMsg(set, " -> %u bound changes\n", domchg->domchgbound.nboundchgs);
1378
1379 return SCIP_OKAY;
1380}
1381
1382/** applies domain change to the global problem */
1384 SCIP_DOMCHG* domchg, /**< domain change to apply */
1385 BMS_BLKMEM* blkmem, /**< block memory */
1386 SCIP_SET* set, /**< global SCIP settings */
1387 SCIP_STAT* stat, /**< problem statistics */
1388 SCIP_LP* lp, /**< current LP data */
1389 SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
1390 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
1391 SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
1392 SCIP_Bool* cutoff /**< pointer to store whether an infeasible domain change was detected */
1393 )
1394{
1395 int i;
1396
1397 assert(cutoff != NULL);
1398
1399 *cutoff = FALSE;
1400
1401 if( domchg == NULL )
1402 return SCIP_OKAY;
1403
1404 SCIPsetDebugMsg(set, "applying domain changes at %p to the global problem\n", (void*)domchg);
1405
1406 /* apply bound changes */
1407 for( i = 0; i < (int)domchg->domchgbound.nboundchgs; ++i )
1408 {
1409 SCIP_CALL( boundchgApplyGlobal(&domchg->domchgbound.boundchgs[i], blkmem, set, stat, lp,
1410 branchcand, eventqueue, cliquetable, cutoff) );
1411 if( *cutoff )
1412 break;
1413 }
1414 SCIPsetDebugMsg(set, " -> %u global bound changes\n", domchg->domchgbound.nboundchgs);
1415
1416 /**@todo globally apply holelist changes - how can this be done without confusing pointer updates? */
1417
1418 return SCIP_OKAY;
1419}
1420
1421/** adds bound change to domain changes */
1423 SCIP_DOMCHG** domchg, /**< pointer to domain change data structure */
1424 BMS_BLKMEM* blkmem, /**< block memory */
1425 SCIP_SET* set, /**< global SCIP settings */
1426 SCIP_VAR* var, /**< variable to change the bounds for */
1427 SCIP_Real newbound, /**< new value for bound */
1428 SCIP_BOUNDTYPE boundtype, /**< type of bound for var: lower or upper bound */
1429 SCIP_BOUNDCHGTYPE boundchgtype, /**< type of bound change: branching decision or inference */
1430 SCIP_Real lpsolval, /**< solval of variable in last LP on path to node, or SCIP_INVALID if unknown */
1431 SCIP_VAR* infervar, /**< variable that was changed (parent of var, or var itself), or NULL */
1432 SCIP_CONS* infercons, /**< constraint that deduced the bound change, or NULL */
1433 SCIP_PROP* inferprop, /**< propagator that deduced the bound change, or NULL */
1434 int inferinfo, /**< user information for inference to help resolving the conflict */
1435 SCIP_BOUNDTYPE inferboundtype /**< type of bound for inference var: lower or upper bound */
1436 )
1437{
1438 SCIP_BOUNDCHG* boundchg;
1439
1440 assert(domchg != NULL);
1441 assert(var != NULL);
1444 assert(!SCIPvarIsBinary(var) || SCIPsetIsEQ(set, newbound, boundtype == SCIP_BOUNDTYPE_LOWER ? 1.0 : 0.0));
1445 assert(boundchgtype == SCIP_BOUNDCHGTYPE_BRANCHING || infervar != NULL);
1446 assert((boundchgtype == SCIP_BOUNDCHGTYPE_CONSINFER) == (infercons != NULL));
1447 assert(boundchgtype == SCIP_BOUNDCHGTYPE_PROPINFER || inferprop == NULL);
1448
1449 SCIPsetDebugMsg(set, "adding %s bound change <%s: %g> of variable <%s> to domain change at %p pointing to %p\n",
1450 boundtype == SCIP_BOUNDTYPE_LOWER ? "lower" : "upper", boundchgtype == SCIP_BOUNDCHGTYPE_BRANCHING ? "branching" : "inference",
1451 newbound, var->name, (void*)domchg, (void*)*domchg);
1452
1453 /* if domain change data doesn't exist, create it;
1454 * if domain change is static, convert it into dynamic change
1455 */
1456 if( *domchg == NULL )
1457 {
1458 SCIP_CALL( domchgCreate(domchg, blkmem) );
1459 }
1460 else if( (*domchg)->domchgdyn.domchgtype != SCIP_DOMCHGTYPE_DYNAMIC ) /*lint !e641*/
1461 {
1462 SCIP_CALL( domchgMakeDynamic(domchg, blkmem) );
1463 }
1464 assert(*domchg != NULL && (*domchg)->domchgdyn.domchgtype == SCIP_DOMCHGTYPE_DYNAMIC); /*lint !e641*/
1465
1466 /* get memory for additional bound change */
1467 SCIP_CALL( domchgEnsureBoundchgsSize(*domchg, blkmem, set, (*domchg)->domchgdyn.nboundchgs+1) );
1468
1469 /* fill in the bound change data */
1470 boundchg = &(*domchg)->domchgdyn.boundchgs[(*domchg)->domchgdyn.nboundchgs];
1471 boundchg->var = var;
1472 switch( boundchgtype )
1473 {
1475 boundchg->data.branchingdata.lpsolval = lpsolval;
1476 break;
1478 assert(infercons != NULL);
1479 boundchg->data.inferencedata.var = infervar;
1480 boundchg->data.inferencedata.reason.cons = infercons;
1481 boundchg->data.inferencedata.info = inferinfo;
1482 break;
1484 boundchg->data.inferencedata.var = infervar;
1485 boundchg->data.inferencedata.reason.prop = inferprop;
1486 boundchg->data.inferencedata.info = inferinfo;
1487 break;
1488 default:
1489 SCIPerrorMessage("invalid bound change type %d\n", boundchgtype);
1490 return SCIP_INVALIDDATA;
1491 }
1492
1493 boundchg->newbound = newbound;
1494 boundchg->boundchgtype = boundchgtype; /*lint !e641*/
1495 boundchg->boundtype = boundtype; /*lint !e641*/
1496 boundchg->inferboundtype = inferboundtype; /*lint !e641*/
1497 boundchg->applied = FALSE;
1498 boundchg->redundant = FALSE;
1499 (*domchg)->domchgdyn.nboundchgs++;
1500
1501 /* capture branching and inference data associated with the bound changes */
1502 SCIP_CALL( boundchgCaptureData(boundchg) );
1503
1504#ifdef SCIP_DISABLED_CODE /* expensive debug check */
1505#ifdef SCIP_MORE_DEBUG
1506 {
1507 int i;
1508 for( i = 0; i < (int)(*domchg)->domchgbound.nboundchgs; ++i )
1509 assert(SCIPvarGetType((*domchg)->domchgbound.boundchgs[i].var) == SCIP_VARTYPE_CONTINUOUS
1510 || SCIPsetIsFeasIntegral(set, (*domchg)->domchgbound.boundchgs[i].newbound));
1511 }
1512#endif
1513#endif
1514
1515 return SCIP_OKAY;
1516}
1517
1518/** adds hole change to domain changes */
1520 SCIP_DOMCHG** domchg, /**< pointer to domain change data structure */
1521 BMS_BLKMEM* blkmem, /**< block memory */
1522 SCIP_SET* set, /**< global SCIP settings */
1523 SCIP_HOLELIST** ptr, /**< changed list pointer */
1524 SCIP_HOLELIST* newlist, /**< new value of list pointer */
1525 SCIP_HOLELIST* oldlist /**< old value of list pointer */
1526 )
1527{
1528 SCIP_HOLECHG* holechg;
1529
1530 assert(domchg != NULL);
1531 assert(ptr != NULL);
1532
1533 /* if domain change data doesn't exist, create it;
1534 * if domain change is static, convert it into dynamic change
1535 */
1536 if( *domchg == NULL )
1537 {
1538 SCIP_CALL( domchgCreate(domchg, blkmem) );
1539 }
1540 else if( (*domchg)->domchgdyn.domchgtype != SCIP_DOMCHGTYPE_DYNAMIC ) /*lint !e641*/
1541 {
1542 SCIP_CALL( domchgMakeDynamic(domchg, blkmem) );
1543 }
1544 assert(*domchg != NULL && (*domchg)->domchgdyn.domchgtype == SCIP_DOMCHGTYPE_DYNAMIC); /*lint !e641*/
1545
1546 /* get memory for additional hole change */
1547 SCIP_CALL( domchgEnsureHolechgsSize(*domchg, blkmem, set, (*domchg)->domchgdyn.nholechgs+1) );
1548
1549 /* fill in the hole change data */
1550 holechg = &(*domchg)->domchgdyn.holechgs[(*domchg)->domchgdyn.nholechgs];
1551 holechg->ptr = ptr;
1552 holechg->newlist = newlist;
1553 holechg->oldlist = oldlist;
1554 (*domchg)->domchgdyn.nholechgs++;
1555
1556 return SCIP_OKAY;
1557}
1558
1559
1560
1561
1562/*
1563 * methods for variables
1564 */
1565
1566/** returns adjusted lower bound value, which is rounded for integral variable types */
1567static
1569 SCIP_SET* set, /**< global SCIP settings */
1570 SCIP_VARTYPE vartype, /**< type of variable */
1571 SCIP_Real lb /**< lower bound to adjust */
1572 )
1573{
1574 if( lb < 0.0 && SCIPsetIsInfinity(set, -lb) )
1575 return -SCIPsetInfinity(set);
1576 else if( lb > 0.0 && SCIPsetIsInfinity(set, lb) )
1577 return SCIPsetInfinity(set);
1578 else if( vartype != SCIP_VARTYPE_CONTINUOUS )
1579 return SCIPsetFeasCeil(set, lb);
1580 else if( lb > 0.0 && lb < SCIPsetEpsilon(set) )
1581 return 0.0;
1582 else
1583 return lb;
1584}
1585
1586/** returns adjusted upper bound value, which is rounded for integral variable types */
1587static
1589 SCIP_SET* set, /**< global SCIP settings */
1590 SCIP_VARTYPE vartype, /**< type of variable */
1591 SCIP_Real ub /**< upper bound to adjust */
1592 )
1593{
1594 if( ub > 0.0 && SCIPsetIsInfinity(set, ub) )
1595 return SCIPsetInfinity(set);
1596 else if( ub < 0.0 && SCIPsetIsInfinity(set, -ub) )
1597 return -SCIPsetInfinity(set);
1598 else if( vartype != SCIP_VARTYPE_CONTINUOUS )
1599 return SCIPsetFeasFloor(set, ub);
1600 else if( ub < 0.0 && ub > -SCIPsetEpsilon(set) )
1601 return 0.0;
1602 else
1603 return ub;
1604}
1605
1606/** removes (redundant) cliques, implications and variable bounds of variable from all other variables' implications and variable
1607 * bounds arrays, and optionally removes them also from the variable itself
1608 */
1610 SCIP_VAR* var, /**< problem variable */
1611 BMS_BLKMEM* blkmem, /**< block memory */
1612 SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
1613 SCIP_SET* set, /**< global SCIP settings */
1614 SCIP_Bool irrelevantvar, /**< has the variable become irrelevant? */
1615 SCIP_Bool onlyredundant, /**< should only the redundant implications and variable bounds be removed? */
1616 SCIP_Bool removefromvar /**< should the implications and variable bounds be removed from the var itself? */
1617 )
1618{
1619 SCIP_Real lb;
1620 SCIP_Real ub;
1621
1622 assert(var != NULL);
1624 assert(SCIPvarIsActive(var) || SCIPvarGetType(var) != SCIP_VARTYPE_BINARY);
1625
1626 lb = SCIPvarGetLbGlobal(var);
1627 ub = SCIPvarGetUbGlobal(var);
1628
1629 SCIPsetDebugMsg(set, "removing %s implications and vbounds of %s<%s>[%g,%g]\n",
1630 onlyredundant ? "redundant" : "all", irrelevantvar ? "irrelevant " : "", SCIPvarGetName(var), lb, ub);
1631
1632 /* remove implications of (fixed) binary variable */
1633 if( var->implics != NULL && (!onlyredundant || lb > 0.5 || ub < 0.5) )
1634 {
1635 SCIP_Bool varfixing;
1636
1637 assert(SCIPvarIsBinary(var));
1638
1639 varfixing = FALSE;
1640 do
1641 {
1642 SCIP_VAR** implvars;
1643 SCIP_BOUNDTYPE* impltypes;
1644 int nimpls;
1645 int i;
1646
1647 nimpls = SCIPimplicsGetNImpls(var->implics, varfixing);
1648 implvars = SCIPimplicsGetVars(var->implics, varfixing);
1649 impltypes = SCIPimplicsGetTypes(var->implics, varfixing);
1650
1651 for( i = 0; i < nimpls; i++ )
1652 {
1653 SCIP_VAR* implvar;
1654 SCIP_BOUNDTYPE impltype;
1655
1656 implvar = implvars[i];
1657 impltype = impltypes[i];
1658 assert(implvar != var);
1659
1660 /* remove for all implications z == 0 / 1 ==> x <= p / x >= p (x not binary)
1661 * the following variable bound from x's variable bounds
1662 * x <= b*z+d (z in vubs of x) , for z == 0 / 1 ==> x <= p
1663 * x >= b*z+d (z in vlbs of x) , for z == 0 / 1 ==> x >= p
1664 */
1665 if( impltype == SCIP_BOUNDTYPE_UPPER )
1666 {
1667 if( implvar->vubs != NULL ) /* implvar may have been aggregated in the mean time */
1668 {
1669 SCIPsetDebugMsg(set, "deleting variable bound: <%s> == %u ==> <%s> <= %g\n",
1670 SCIPvarGetName(var), varfixing, SCIPvarGetName(implvar),
1671 SCIPimplicsGetBounds(var->implics, varfixing)[i]);
1672 SCIP_CALL( SCIPvboundsDel(&implvar->vubs, blkmem, var, varfixing) );
1673 implvar->closestvblpcount = -1;
1674 var->closestvblpcount = -1;
1675 }
1676 }
1677 else
1678 {
1679 if( implvar->vlbs != NULL ) /* implvar may have been aggregated in the mean time */
1680 {
1681 SCIPsetDebugMsg(set, "deleting variable bound: <%s> == %u ==> <%s> >= %g\n",
1682 SCIPvarGetName(var), varfixing, SCIPvarGetName(implvar),
1683 SCIPimplicsGetBounds(var->implics, varfixing)[i]);
1684 SCIP_CALL( SCIPvboundsDel(&implvar->vlbs, blkmem, var, !varfixing) );
1685 implvar->closestvblpcount = -1;
1686 var->closestvblpcount = -1;
1687 }
1688 }
1689 }
1690 varfixing = !varfixing;
1691 }
1692 while( varfixing == TRUE );
1693
1694 if( removefromvar )
1695 {
1696 /* free the implications data structures */
1697 SCIPimplicsFree(&var->implics, blkmem);
1698 }
1699 }
1700
1701 /* remove the (redundant) variable lower bounds */
1702 if( var->vlbs != NULL )
1703 {
1704 SCIP_VAR** vars;
1705 SCIP_Real* coefs;
1706 SCIP_Real* constants;
1707 int nvbds;
1708 int newnvbds;
1709 int i;
1710
1711 nvbds = SCIPvboundsGetNVbds(var->vlbs);
1712 vars = SCIPvboundsGetVars(var->vlbs);
1713 coefs = SCIPvboundsGetCoefs(var->vlbs);
1714 constants = SCIPvboundsGetConstants(var->vlbs);
1715
1716 /* remove for all variable bounds x >= b*z+d the following implication from z's implications
1717 * z == ub ==> x >= b*ub + d , if b > 0
1718 * z == lb ==> x >= b*lb + d , if b < 0
1719 */
1720 newnvbds = 0;
1721 for( i = 0; i < nvbds; i++ )
1722 {
1723 SCIP_VAR* implvar;
1724 SCIP_Real coef;
1725
1726 assert(newnvbds <= i);
1727
1728 implvar = vars[i];
1729 assert(implvar != NULL);
1730
1731 coef = coefs[i];
1732 assert(!SCIPsetIsZero(set, coef));
1733
1734 /* check, if we want to remove the variable bound */
1735 if( onlyredundant )
1736 {
1737 SCIP_Real vbound;
1738
1739 vbound = MAX(coef * SCIPvarGetUbGlobal(implvar), coef * SCIPvarGetLbGlobal(implvar)) + constants[i]; /*lint !e666*/
1740 if( SCIPsetIsFeasGT(set, vbound, lb) )
1741 {
1742 /* the variable bound is not redundant: keep it */
1743 if( removefromvar )
1744 {
1745 if( newnvbds < i )
1746 {
1747 vars[newnvbds] = implvar;
1748 coefs[newnvbds] = coef;
1749 constants[newnvbds] = constants[i];
1750 }
1751 newnvbds++;
1752 }
1753 continue;
1754 }
1755 }
1756
1757 /* remove the corresponding implication */
1758 if( implvar->implics != NULL ) /* variable may have been aggregated in the mean time */
1759 {
1760 SCIPsetDebugMsg(set, "deleting implication: <%s> == %d ==> <%s> >= %g\n",
1761 SCIPvarGetName(implvar), (coef > 0.0), SCIPvarGetName(var), MAX(coef, 0.0) + constants[i]);
1762 SCIP_CALL( SCIPimplicsDel(&implvar->implics, blkmem, set, (coef > 0.0), var, SCIP_BOUNDTYPE_LOWER) );
1763 }
1764 if( coef > 0.0 && implvar->vubs != NULL ) /* implvar may have been aggregated in the mean time */
1765 {
1766 SCIPsetDebugMsg(set, "deleting variable upper bound from <%s> involving variable %s\n",
1767 SCIPvarGetName(implvar), SCIPvarGetName(var));
1768 SCIP_CALL( SCIPvboundsDel(&implvar->vubs, blkmem, var, FALSE) );
1769 implvar->closestvblpcount = -1;
1770 var->closestvblpcount = -1;
1771 }
1772 else if( coef < 0.0 && implvar->vlbs != NULL ) /* implvar may have been aggregated in the mean time */
1773 {
1774 SCIPsetDebugMsg(set, "deleting variable lower bound from <%s> involving variable %s\n",
1775 SCIPvarGetName(implvar), SCIPvarGetName(var));
1776 SCIP_CALL( SCIPvboundsDel(&implvar->vlbs, blkmem, var, TRUE) );
1777 implvar->closestvblpcount = -1;
1778 var->closestvblpcount = -1;
1779 }
1780 }
1781
1782 if( removefromvar )
1783 {
1784 /* update the number of variable bounds */
1785 SCIPvboundsShrink(&var->vlbs, blkmem, newnvbds);
1786 var->closestvblpcount = -1;
1787 }
1788 }
1789
1790 /**@todo in general, variable bounds like x >= b*z + d corresponding to an implication like z = ub ==> x >= b*ub + d
1791 * might be missing because we only add variable bounds with reasonably small value of b. thus, we currently
1792 * cannot remove such variables x from z's implications.
1793 */
1794
1795 /* remove the (redundant) variable upper bounds */
1796 if( var->vubs != NULL )
1797 {
1798 SCIP_VAR** vars;
1799 SCIP_Real* coefs;
1800 SCIP_Real* constants;
1801 int nvbds;
1802 int newnvbds;
1803 int i;
1804
1805 nvbds = SCIPvboundsGetNVbds(var->vubs);
1806 vars = SCIPvboundsGetVars(var->vubs);
1807 coefs = SCIPvboundsGetCoefs(var->vubs);
1808 constants = SCIPvboundsGetConstants(var->vubs);
1809
1810 /* remove for all variable bounds x <= b*z+d the following implication from z's implications
1811 * z == lb ==> x <= b*lb + d , if b > 0
1812 * z == ub ==> x <= b*ub + d , if b < 0
1813 */
1814 newnvbds = 0;
1815 for( i = 0; i < nvbds; i++ )
1816 {
1817 SCIP_VAR* implvar;
1818 SCIP_Real coef;
1819
1820 assert(newnvbds <= i);
1821
1822 implvar = vars[i];
1823 assert(implvar != NULL);
1824
1825 coef = coefs[i];
1826 assert(!SCIPsetIsZero(set, coef));
1827
1828 /* check, if we want to remove the variable bound */
1829 if( onlyredundant )
1830 {
1831 SCIP_Real vbound;
1832
1833 vbound = MIN(coef * SCIPvarGetUbGlobal(implvar), coef * SCIPvarGetLbGlobal(implvar)) + constants[i]; /*lint !e666*/
1834 if( SCIPsetIsFeasLT(set, vbound, ub) )
1835 {
1836 /* the variable bound is not redundant: keep it */
1837 if( removefromvar )
1838 {
1839 if( newnvbds < i )
1840 {
1841 vars[newnvbds] = implvar;
1842 coefs[newnvbds] = coefs[i];
1843 constants[newnvbds] = constants[i];
1844 }
1845 newnvbds++;
1846 }
1847 continue;
1848 }
1849 }
1850
1851 /* remove the corresponding implication */
1852 if( implvar->implics != NULL ) /* variable may have been aggregated in the mean time */
1853 {
1854 SCIPsetDebugMsg(set, "deleting implication: <%s> == %d ==> <%s> <= %g\n",
1855 SCIPvarGetName(implvar), (coef < 0.0), SCIPvarGetName(var), MIN(coef, 0.0) + constants[i]);
1856 SCIP_CALL( SCIPimplicsDel(&implvar->implics, blkmem, set, (coef < 0.0), var, SCIP_BOUNDTYPE_UPPER) );
1857 }
1858 if( coef < 0.0 && implvar->vubs != NULL ) /* implvar may have been aggregated in the mean time */
1859 {
1860 SCIPsetDebugMsg(set, "deleting variable upper bound from <%s> involving variable %s\n",
1861 SCIPvarGetName(implvar), SCIPvarGetName(var));
1862 SCIP_CALL( SCIPvboundsDel(&implvar->vubs, blkmem, var, TRUE) );
1863 implvar->closestvblpcount = -1;
1864 var->closestvblpcount = -1;
1865 }
1866 else if( coef > 0.0 && implvar->vlbs != NULL ) /* implvar may have been aggregated in the mean time */
1867 {
1868 SCIPsetDebugMsg(set, "deleting variable lower bound from <%s> involving variable %s\n",
1869 SCIPvarGetName(implvar), SCIPvarGetName(var));
1870 SCIP_CALL( SCIPvboundsDel(&implvar->vlbs, blkmem, var, FALSE) );
1871 implvar->closestvblpcount = -1;
1872 var->closestvblpcount = -1;
1873 }
1874 }
1875
1876 if( removefromvar )
1877 {
1878 /* update the number of variable bounds */
1879 SCIPvboundsShrink(&var->vubs, blkmem, newnvbds);
1880 var->closestvblpcount = -1;
1881 }
1882 }
1883
1884 /* remove the variable from all cliques */
1885 if( SCIPvarIsBinary(var) )
1886 SCIPcliquelistRemoveFromCliques(var->cliquelist, cliquetable, var, irrelevantvar);
1887
1888 /**@todo variable bounds like x <= b*z + d with z general integer are not removed from x's vbd arrays, because
1889 * z has no link (like in the binary case) to x
1890 */
1891
1892 return SCIP_OKAY;
1893}
1894
1895/** sets the variable name */
1896static
1898 SCIP_VAR* var, /**< problem variable */
1899 BMS_BLKMEM* blkmem, /**< block memory */
1900 SCIP_STAT* stat, /**< problem statistics, or NULL */
1901 const char* name /**< name of variable, or NULL for automatic name creation */
1902 )
1903{
1904 assert(blkmem != NULL);
1905 assert(var != NULL);
1906
1907 if( name == NULL )
1908 {
1909 char s[SCIP_MAXSTRLEN];
1910
1911 assert(stat != NULL);
1912
1913 (void) SCIPsnprintf(s, SCIP_MAXSTRLEN, "_var%d_", stat->nvaridx);
1914 SCIP_ALLOC( BMSduplicateBlockMemoryArray(blkmem, &var->name, s, strlen(s)+1) );
1915 }
1916 else
1917 {
1918 SCIP_ALLOC( BMSduplicateBlockMemoryArray(blkmem, &var->name, name, strlen(name)+1) );
1919 }
1920
1921 return SCIP_OKAY;
1922}
1923
1924
1925/** creates variable; if variable is of integral type, fractional bounds are automatically rounded; an integer variable
1926 * with bounds zero and one is automatically converted into a binary variable
1927 */
1928static
1930 SCIP_VAR** var, /**< pointer to variable data */
1931 BMS_BLKMEM* blkmem, /**< block memory */
1932 SCIP_SET* set, /**< global SCIP settings */
1933 SCIP_STAT* stat, /**< problem statistics */
1934 const char* name, /**< name of variable, or NULL for automatic name creation */
1935 SCIP_Real lb, /**< lower bound of variable */
1936 SCIP_Real ub, /**< upper bound of variable */
1937 SCIP_Real obj, /**< objective function value */
1938 SCIP_VARTYPE vartype, /**< type of variable */
1939 SCIP_Bool initial, /**< should var's column be present in the initial root LP? */
1940 SCIP_Bool removable, /**< is var's column removable from the LP (due to aging or cleanup)? */
1941 SCIP_DECL_VARCOPY ((*varcopy)), /**< copies variable data if wanted to subscip, or NULL */
1942 SCIP_DECL_VARDELORIG ((*vardelorig)), /**< frees user data of original variable, or NULL */
1943 SCIP_DECL_VARTRANS ((*vartrans)), /**< creates transformed user data by transforming original user data, or NULL */
1944 SCIP_DECL_VARDELTRANS ((*vardeltrans)), /**< frees user data of transformed variable, or NULL */
1945 SCIP_VARDATA* vardata /**< user data for this specific variable */
1946 )
1947{
1948 int i;
1949
1950 assert(var != NULL);
1951 assert(blkmem != NULL);
1952 assert(stat != NULL);
1953
1954 /* adjust bounds of variable */
1955 lb = adjustedLb(set, vartype, lb);
1956 ub = adjustedUb(set, vartype, ub);
1957
1958 /* convert [0,1]-integers into binary variables and check that binary variables have correct bounds */
1959 if( (SCIPsetIsEQ(set, lb, 0.0) || SCIPsetIsEQ(set, lb, 1.0))
1960 && (SCIPsetIsEQ(set, ub, 0.0) || SCIPsetIsEQ(set, ub, 1.0)) )
1961 {
1962 if( vartype == SCIP_VARTYPE_INTEGER )
1963 vartype = SCIP_VARTYPE_BINARY;
1964 }
1965 else
1966 {
1967 if( vartype == SCIP_VARTYPE_BINARY )
1968 {
1969 SCIPerrorMessage("invalid bounds [%.2g,%.2g] for binary variable <%s>\n", lb, ub, name);
1970 return SCIP_INVALIDDATA;
1971 }
1972 }
1973
1974 assert(vartype != SCIP_VARTYPE_BINARY || SCIPsetIsEQ(set, lb, 0.0) || SCIPsetIsEQ(set, lb, 1.0));
1975 assert(vartype != SCIP_VARTYPE_BINARY || SCIPsetIsEQ(set, ub, 0.0) || SCIPsetIsEQ(set, ub, 1.0));
1976
1977 SCIP_ALLOC( BMSallocBlockMemory(blkmem, var) );
1978
1979 /* set variable's name */
1980 SCIP_CALL( varSetName(*var, blkmem, stat, name) );
1981
1982#ifndef NDEBUG
1983 (*var)->scip = set->scip;
1984#endif
1985 (*var)->obj = obj;
1986 (*var)->unchangedobj = obj;
1987 (*var)->branchfactor = 1.0;
1988 (*var)->rootsol = 0.0;
1989 (*var)->bestrootsol = 0.0;
1990 (*var)->bestrootredcost = 0.0;
1991 (*var)->bestrootlpobjval = SCIP_INVALID;
1992 (*var)->relaxsol = 0.0;
1993 (*var)->nlpsol = 0.0;
1994 (*var)->primsolavg = 0.5 * (lb + ub);
1995 (*var)->conflictlb = SCIP_REAL_MIN;
1996 (*var)->conflictub = SCIP_REAL_MAX;
1997 (*var)->conflictrelaxedlb = (*var)->conflictlb;
1998 (*var)->conflictrelaxedub = (*var)->conflictub;
1999 (*var)->lazylb = -SCIPsetInfinity(set);
2000 (*var)->lazyub = SCIPsetInfinity(set);
2001 (*var)->glbdom.holelist = NULL;
2002 (*var)->glbdom.lb = lb;
2003 (*var)->glbdom.ub = ub;
2004 (*var)->locdom.holelist = NULL;
2005 (*var)->locdom.lb = lb;
2006 (*var)->locdom.ub = ub;
2007 (*var)->varcopy = varcopy;
2008 (*var)->vardelorig = vardelorig;
2009 (*var)->vartrans = vartrans;
2010 (*var)->vardeltrans = vardeltrans;
2011 (*var)->vardata = vardata;
2012 (*var)->parentvars = NULL;
2013 (*var)->negatedvar = NULL;
2014 (*var)->vlbs = NULL;
2015 (*var)->vubs = NULL;
2016 (*var)->implics = NULL;
2017 (*var)->cliquelist = NULL;
2018 (*var)->eventfilter = NULL;
2019 (*var)->lbchginfos = NULL;
2020 (*var)->ubchginfos = NULL;
2021 (*var)->index = stat->nvaridx;
2022 (*var)->probindex = -1;
2023 (*var)->pseudocandindex = -1;
2024 (*var)->eventqueueindexobj = -1;
2025 (*var)->eventqueueindexlb = -1;
2026 (*var)->eventqueueindexub = -1;
2027 (*var)->parentvarssize = 0;
2028 (*var)->nparentvars = 0;
2029 (*var)->nuses = 0;
2030 (*var)->branchpriority = 0;
2031 (*var)->branchdirection = SCIP_BRANCHDIR_AUTO; /*lint !e641*/
2032 (*var)->lbchginfossize = 0;
2033 (*var)->nlbchginfos = 0;
2034 (*var)->ubchginfossize = 0;
2035 (*var)->nubchginfos = 0;
2036 (*var)->conflictlbcount = 0;
2037 (*var)->conflictubcount = 0;
2038 (*var)->closestvlbidx = -1;
2039 (*var)->closestvubidx = -1;
2040 (*var)->closestvblpcount = -1;
2041 (*var)->initial = initial;
2042 (*var)->removable = removable;
2043 (*var)->deleted = FALSE;
2044 (*var)->donotaggr = FALSE;
2045 (*var)->donotmultaggr = FALSE;
2046 (*var)->vartype = vartype; /*lint !e641*/
2047 (*var)->pseudocostflag = FALSE;
2048 (*var)->eventqueueimpl = FALSE;
2049 (*var)->deletable = FALSE;
2050 (*var)->delglobalstructs = FALSE;
2051 (*var)->relaxationonly = FALSE;
2052
2053 for( i = 0; i < NLOCKTYPES; i++ )
2054 {
2055 (*var)->nlocksdown[i] = 0;
2056 (*var)->nlocksup[i] = 0;
2057 }
2058
2059 stat->nvaridx++;
2060
2061 /* create branching and inference history entries */
2062 SCIP_CALL( SCIPhistoryCreate(&(*var)->history, blkmem) );
2063 SCIP_CALL( SCIPhistoryCreate(&(*var)->historycrun, blkmem) );
2064
2065 /* the value based history is only created on demand */
2066 (*var)->valuehistory = NULL;
2067
2068 return SCIP_OKAY;
2069}
2070
2071/** creates and captures an original problem variable; an integer variable with bounds
2072 * zero and one is automatically converted into a binary variable
2073 */
2075 SCIP_VAR** var, /**< pointer to variable data */
2076 BMS_BLKMEM* blkmem, /**< block memory */
2077 SCIP_SET* set, /**< global SCIP settings */
2078 SCIP_STAT* stat, /**< problem statistics */
2079 const char* name, /**< name of variable, or NULL for automatic name creation */
2080 SCIP_Real lb, /**< lower bound of variable */
2081 SCIP_Real ub, /**< upper bound of variable */
2082 SCIP_Real obj, /**< objective function value */
2083 SCIP_VARTYPE vartype, /**< type of variable */
2084 SCIP_Bool initial, /**< should var's column be present in the initial root LP? */
2085 SCIP_Bool removable, /**< is var's column removable from the LP (due to aging or cleanup)? */
2086 SCIP_DECL_VARDELORIG ((*vardelorig)), /**< frees user data of original variable, or NULL */
2087 SCIP_DECL_VARTRANS ((*vartrans)), /**< creates transformed user data by transforming original user data, or NULL */
2088 SCIP_DECL_VARDELTRANS ((*vardeltrans)), /**< frees user data of transformed variable, or NULL */
2089 SCIP_DECL_VARCOPY ((*varcopy)), /**< copies variable data if wanted to subscip, or NULL */
2090 SCIP_VARDATA* vardata /**< user data for this specific variable */
2091 )
2092{
2093 assert(var != NULL);
2094 assert(blkmem != NULL);
2095 assert(stat != NULL);
2096
2097 /* create variable */
2098 SCIP_CALL( varCreate(var, blkmem, set, stat, name, lb, ub, obj, vartype, initial, removable,
2099 varcopy, vardelorig, vartrans, vardeltrans, vardata) );
2100
2101 /* set variable status and data */
2102 (*var)->varstatus = SCIP_VARSTATUS_ORIGINAL; /*lint !e641*/
2103 (*var)->data.original.origdom.holelist = NULL;
2104 (*var)->data.original.origdom.lb = lb;
2105 (*var)->data.original.origdom.ub = ub;
2106 (*var)->data.original.transvar = NULL;
2107
2108 /* capture variable */
2109 SCIPvarCapture(*var);
2110
2111 return SCIP_OKAY;
2112}
2113
2114/** creates and captures a loose variable belonging to the transformed problem; an integer variable with bounds
2115 * zero and one is automatically converted into a binary variable
2116 */
2118 SCIP_VAR** var, /**< pointer to variable data */
2119 BMS_BLKMEM* blkmem, /**< block memory */
2120 SCIP_SET* set, /**< global SCIP settings */
2121 SCIP_STAT* stat, /**< problem statistics */
2122 const char* name, /**< name of variable, or NULL for automatic name creation */
2123 SCIP_Real lb, /**< lower bound of variable */
2124 SCIP_Real ub, /**< upper bound of variable */
2125 SCIP_Real obj, /**< objective function value */
2126 SCIP_VARTYPE vartype, /**< type of variable */
2127 SCIP_Bool initial, /**< should var's column be present in the initial root LP? */
2128 SCIP_Bool removable, /**< is var's column removable from the LP (due to aging or cleanup)? */
2129 SCIP_DECL_VARDELORIG ((*vardelorig)), /**< frees user data of original variable, or NULL */
2130 SCIP_DECL_VARTRANS ((*vartrans)), /**< creates transformed user data by transforming original user data, or NULL */
2131 SCIP_DECL_VARDELTRANS ((*vardeltrans)), /**< frees user data of transformed variable, or NULL */
2132 SCIP_DECL_VARCOPY ((*varcopy)), /**< copies variable data if wanted to subscip, or NULL */
2133 SCIP_VARDATA* vardata /**< user data for this specific variable */
2134 )
2135{
2136 assert(var != NULL);
2137 assert(blkmem != NULL);
2138
2139 /* create variable */
2140 SCIP_CALL( varCreate(var, blkmem, set, stat, name, lb, ub, obj, vartype, initial, removable,
2141 varcopy, vardelorig, vartrans, vardeltrans, vardata) );
2142
2143 /* create event filter for transformed variable */
2144 SCIP_CALL( SCIPeventfilterCreate(&(*var)->eventfilter, blkmem) );
2145
2146 /* set variable status and data */
2147 (*var)->varstatus = SCIP_VARSTATUS_LOOSE; /*lint !e641*/
2148
2149 /* capture variable */
2150 SCIPvarCapture(*var);
2151
2152 return SCIP_OKAY;
2153}
2154
2155/** copies and captures a variable from source to target SCIP; an integer variable with bounds zero and one is
2156 * automatically converted into a binary variable; in case the variable data cannot be copied the variable is not
2157 * copied at all
2158 */
2160 SCIP_VAR** var, /**< pointer to store the target variable */
2161 BMS_BLKMEM* blkmem, /**< block memory */
2162 SCIP_SET* set, /**< global SCIP settings */
2163 SCIP_STAT* stat, /**< problem statistics */
2164 SCIP* sourcescip, /**< source SCIP data structure */
2165 SCIP_VAR* sourcevar, /**< source variable */
2166 SCIP_HASHMAP* varmap, /**< a hashmap to store the mapping of source variables corresponding
2167 * target variables */
2168 SCIP_HASHMAP* consmap, /**< a hashmap to store the mapping of source constraints to the corresponding
2169 * target constraints */
2170 SCIP_Bool global /**< should global or local bounds be used? */
2171 )
2172{
2173 SCIP_VARDATA* targetdata;
2174 SCIP_RESULT result;
2175 SCIP_Real lb;
2176 SCIP_Real ub;
2177
2178 assert(set != NULL);
2179 assert(blkmem != NULL);
2180 assert(stat != NULL);
2181 assert(sourcescip != NULL);
2182 assert(sourcevar != NULL);
2183 assert(var != NULL);
2184 assert(set->stage == SCIP_STAGE_PROBLEM);
2185 assert(varmap != NULL);
2186 assert(consmap != NULL);
2187
2188 /** @todo copy hole lists */
2189 assert(global || SCIPvarGetHolelistLocal(sourcevar) == NULL);
2190 assert(!global || SCIPvarGetHolelistGlobal(sourcevar) == NULL);
2191
2192 result = SCIP_DIDNOTRUN;
2193 targetdata = NULL;
2194
2195 if( SCIPvarGetStatus(sourcevar) == SCIP_VARSTATUS_ORIGINAL )
2196 {
2197 lb = SCIPvarGetLbOriginal(sourcevar);
2198 ub = SCIPvarGetUbOriginal(sourcevar);
2199 }
2200 else
2201 {
2202 lb = global ? SCIPvarGetLbGlobal(sourcevar) : SCIPvarGetLbLocal(sourcevar);
2203 ub = global ? SCIPvarGetUbGlobal(sourcevar) : SCIPvarGetUbLocal(sourcevar);
2204 }
2205
2206 /* creates and captures the variable in the target SCIP and initialize callback methods and variable data to NULL */
2207 SCIP_CALL( SCIPvarCreateOriginal(var, blkmem, set, stat, SCIPvarGetName(sourcevar),
2208 lb, ub, SCIPvarGetObj(sourcevar), SCIPvarGetType(sourcevar),
2209 SCIPvarIsInitial(sourcevar), SCIPvarIsRemovable(sourcevar),
2210 NULL, NULL, NULL, NULL, NULL) );
2211 assert(*var != NULL);
2212
2213 /* directly copy donot(mult)aggr flag */
2214 (*var)->donotaggr = sourcevar->donotaggr;
2215 (*var)->donotmultaggr = sourcevar->donotmultaggr;
2216
2217 /* insert variable into mapping between source SCIP and the target SCIP */
2218 assert(!SCIPhashmapExists(varmap, sourcevar));
2219 SCIP_CALL( SCIPhashmapInsert(varmap, sourcevar, *var) );
2220
2221 /* in case there exists variable data and the variable data copy callback, try to copy variable data */
2222 if( sourcevar->vardata != NULL && sourcevar->varcopy != NULL )
2223 {
2224 SCIP_CALL( sourcevar->varcopy(set->scip, sourcescip, sourcevar, sourcevar->vardata,
2225 varmap, consmap, (*var), &targetdata, &result) );
2226
2227 /* evaluate result */
2228 if( result != SCIP_DIDNOTRUN && result != SCIP_SUCCESS )
2229 {
2230 SCIPerrorMessage("variable data copying method returned invalid result <%d>\n", result);
2231 return SCIP_INVALIDRESULT;
2232 }
2233
2234 assert(targetdata == NULL || result == SCIP_SUCCESS);
2235
2236 /* if copying was successful, add the created variable data to the variable as well as all callback methods */
2237 if( result == SCIP_SUCCESS )
2238 {
2239 (*var)->varcopy = sourcevar->varcopy;
2240 (*var)->vardelorig = sourcevar->vardelorig;
2241 (*var)->vartrans = sourcevar->vartrans;
2242 (*var)->vardeltrans = sourcevar->vardeltrans;
2243 (*var)->vardata = targetdata;
2244 }
2245 }
2246
2247 /* we initialize histories of the variables by copying the source variable-information */
2248 if( set->history_allowtransfer )
2249 {
2250 SCIPvarMergeHistories((*var), sourcevar, stat);
2251 }
2252
2253 /* in case the copying was successfully, add the created variable data to the variable as well as all callback
2254 * methods
2255 */
2256 if( result == SCIP_SUCCESS )
2257 {
2258 (*var)->varcopy = sourcevar->varcopy;
2259 (*var)->vardelorig = sourcevar->vardelorig;
2260 (*var)->vartrans = sourcevar->vartrans;
2261 (*var)->vardeltrans = sourcevar->vardeltrans;
2262 (*var)->vardata = targetdata;
2263 }
2264
2265 SCIPsetDebugMsg(set, "created copy <%s> of variable <%s>\n", SCIPvarGetName(*var), SCIPvarGetName(sourcevar));
2266
2267 return SCIP_OKAY;
2268}
2269
2270/** parse given string for a SCIP_Real bound */
2271static
2273 SCIP_SET* set, /**< global SCIP settings */
2274 const char* str, /**< string to parse */
2275 SCIP_Real* value, /**< pointer to store the parsed value */
2276 char** endptr /**< pointer to store the final string position if successfully parsed */
2277 )
2278{
2279 /* first check for infinity value */
2280 if( strncmp(str, "+inf", 4) == 0 )
2281 {
2282 *value = SCIPsetInfinity(set);
2283 (*endptr) = (char*)str + 4;
2284 }
2285 else if( strncmp(str, "-inf", 4) == 0 )
2286 {
2287 *value = -SCIPsetInfinity(set);
2288 (*endptr) = (char*)str + 4;
2289 }
2290 else
2291 {
2292 if( !SCIPstrToRealValue(str, value, endptr) )
2293 {
2294 SCIPerrorMessage("expected value: %s.\n", str);
2295 return SCIP_READERROR;
2296 }
2297 }
2298
2299 return SCIP_OKAY;
2300}
2301
2302/** parse the characters as bounds */
2303static
2305 SCIP_SET* set, /**< global SCIP settings */
2306 const char* str, /**< string to parse */
2307 char* type, /**< bound type (global, local, or lazy) */
2308 SCIP_Real* lb, /**< pointer to store the lower bound */
2309 SCIP_Real* ub, /**< pointer to store the upper bound */
2310 char** endptr /**< pointer to store the final string position if successfully parsed (or NULL if an error occured) */
2311 )
2312{
2313 char token[SCIP_MAXSTRLEN];
2314 char* tmpend;
2315
2316 SCIPsetDebugMsg(set, "parsing bounds: '%s'\n", str);
2317
2318 /* get bound type */
2319 SCIPstrCopySection(str, ' ', ' ', type, SCIP_MAXSTRLEN, endptr);
2320 if ( *endptr == str
2321 || ( strncmp(type, "original", 8) != 0 && strncmp(type, "global", 6) != 0 && strncmp(type, "local", 5) != 0 && strncmp(type, "lazy", 4) != 0 ) )
2322 {
2323 SCIPsetDebugMsg(set, "unkown bound type\n");
2324 *endptr = NULL;
2325 return SCIP_OKAY;
2326 }
2327
2328 SCIPsetDebugMsg(set, "parsed bound type <%s>\n", type);
2329
2330 /* get lower bound */
2331 SCIPstrCopySection(str, '[', ',', token, SCIP_MAXSTRLEN, endptr);
2332 str = *endptr;
2333 SCIP_CALL( parseValue(set, token, lb, &tmpend) );
2334
2335 /* get upper bound */
2336 SCIP_CALL( parseValue(set, str, ub, endptr) );
2337
2338 SCIPsetDebugMsg(set, "parsed bounds: [%g,%g]\n", *lb, *ub);
2339
2340 /* skip end of bounds */
2341 while ( **endptr != '\0' && (**endptr == ']' || **endptr == ',') )
2342 ++(*endptr);
2343
2344 return SCIP_OKAY;
2345}
2346
2347/** parses a given string for a variable informations */
2348static
2350 SCIP_SET* set, /**< global SCIP settings */
2351 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
2352 const char* str, /**< string to parse */
2353 char* name, /**< pointer to store the variable name */
2354 SCIP_Real* lb, /**< pointer to store the lower bound */
2355 SCIP_Real* ub, /**< pointer to store the upper bound */
2356 SCIP_Real* obj, /**< pointer to store the objective coefficient */
2357 SCIP_VARTYPE* vartype, /**< pointer to store the variable type */
2358 SCIP_Real* lazylb, /**< pointer to store if the lower bound is lazy */
2359 SCIP_Real* lazyub, /**< pointer to store if the upper bound is lazy */
2360 SCIP_Bool local, /**< should the local bound be applied */
2361 char** endptr, /**< pointer to store the final string position if successfully */
2362 SCIP_Bool* success /**< pointer store if the paring process was successful */
2363 )
2364{
2365 SCIP_Real parsedlb;
2366 SCIP_Real parsedub;
2367 char token[SCIP_MAXSTRLEN];
2368 char* strptr;
2369 int i;
2370
2371 assert(lb != NULL);
2372 assert(ub != NULL);
2373 assert(obj != NULL);
2374 assert(vartype != NULL);
2375 assert(lazylb != NULL);
2376 assert(lazyub != NULL);
2377 assert(success != NULL);
2378
2379 (*success) = TRUE;
2380
2381 /* copy variable type */
2382 SCIPstrCopySection(str, '[', ']', token, SCIP_MAXSTRLEN, endptr);
2383 assert(*endptr != str);
2384 SCIPsetDebugMsg(set, "parsed variable type <%s>\n", token);
2385
2386 /* get variable type */
2387 if( strncmp(token, "binary", 3) == 0 )
2388 (*vartype) = SCIP_VARTYPE_BINARY;
2389 else if( strncmp(token, "integer", 3) == 0 )
2390 (*vartype) = SCIP_VARTYPE_INTEGER;
2391 else if( strncmp(token, "implicit", 3) == 0 )
2392 (*vartype) = SCIP_VARTYPE_IMPLINT;
2393 else if( strncmp(token, "continuous", 3) == 0 )
2394 (*vartype) = SCIP_VARTYPE_CONTINUOUS;
2395 else
2396 {
2397 SCIPmessagePrintWarning(messagehdlr, "unknown variable type\n");
2398 (*success) = FALSE;
2399 return SCIP_OKAY;
2400 }
2401
2402 /* move string pointer behind variable type */
2403 str = *endptr;
2404
2405 /* get variable name */
2406 SCIPstrCopySection(str, '<', '>', name, SCIP_MAXSTRLEN, endptr);
2407 assert(*endptr != str);
2408 SCIPsetDebugMsg(set, "parsed variable name <%s>\n", name);
2409
2410 /* move string pointer behind variable name */
2411 str = *endptr;
2412
2413 /* cut out objective coefficient */
2414 SCIPstrCopySection(str, '=', ',', token, SCIP_MAXSTRLEN, endptr);
2415
2416 /* move string pointer behind objective coefficient */
2417 str = *endptr;
2418
2419 /* get objective coefficient */
2420 if( !SCIPstrToRealValue(token, obj, endptr) )
2421 {
2422 *endptr = NULL;
2423 return SCIP_READERROR;
2424 }
2425
2426 SCIPsetDebugMsg(set, "parsed objective coefficient <%g>\n", *obj);
2427
2428 /* parse global/original bounds */
2429 SCIP_CALL( parseBounds(set, str, token, lb, ub, endptr) );
2430 if ( *endptr == NULL )
2431 {
2432 SCIPerrorMessage("Expected bound type: %s.\n", token);
2433 return SCIP_READERROR;
2434 }
2435 assert(strncmp(token, "global", 6) == 0 || strncmp(token, "original", 8) == 0);
2436
2437 /* initialize the lazy bound */
2438 *lazylb = -SCIPsetInfinity(set);
2439 *lazyub = SCIPsetInfinity(set);
2440
2441 /* store pointer */
2442 strptr = *endptr;
2443
2444 /* possibly parse optional local and lazy bounds */
2445 for( i = 0; i < 2 && *endptr != NULL && **endptr != '\0'; ++i )
2446 {
2447 /* start after previous bounds */
2448 strptr = *endptr;
2449
2450 /* parse global bounds */
2451 SCIP_CALL( parseBounds(set, strptr, token, &parsedlb, &parsedub, endptr) );
2452
2453 /* stop if parsing of bounds failed */
2454 if( *endptr == NULL )
2455 break;
2456
2457 if( strncmp(token, "local", 5) == 0 && local )
2458 {
2459 *lb = parsedlb;
2460 *ub = parsedub;
2461 }
2462 else if( strncmp(token, "lazy", 4) == 0 )
2463 {
2464 *lazylb = parsedlb;
2465 *lazyub = parsedub;
2466 }
2467 }
2468
2469 /* restore pointer */
2470 if ( *endptr == NULL )
2471 *endptr = strptr;
2472
2473 /* check bounds for binary variables */
2474 if ( (*vartype) == SCIP_VARTYPE_BINARY )
2475 {
2476 if ( SCIPsetIsLT(set, *lb, 0.0) || SCIPsetIsGT(set, *ub, 1.0) )
2477 {
2478 SCIPerrorMessage("Parsed invalid bounds for binary variable <%s>: [%f, %f].\n", name, *lb, *ub);
2479 return SCIP_READERROR;
2480 }
2481 if ( !SCIPsetIsInfinity(set, -(*lazylb)) && !SCIPsetIsInfinity(set, *lazyub) &&
2482 ( SCIPsetIsLT(set, *lazylb, 0.0) || SCIPsetIsGT(set, *lazyub, 1.0) ) )
2483 {
2484 SCIPerrorMessage("Parsed invalid lazy bounds for binary variable <%s>: [%f, %f].\n", name, *lazylb, *lazyub);
2485 return SCIP_READERROR;
2486 }
2487 }
2488
2489 return SCIP_OKAY;
2490}
2491
2492/** parses variable information (in cip format) out of a string; if the parsing process was successful an original
2493 * variable is created and captured; if variable is of integral type, fractional bounds are automatically rounded; an
2494 * integer variable with bounds zero and one is automatically converted into a binary variable
2495 */
2497 SCIP_VAR** var, /**< pointer to variable data */
2498 BMS_BLKMEM* blkmem, /**< block memory */
2499 SCIP_SET* set, /**< global SCIP settings */
2500 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
2501 SCIP_STAT* stat, /**< problem statistics */
2502 const char* str, /**< string to parse */
2503 SCIP_Bool initial, /**< should var's column be present in the initial root LP? */
2504 SCIP_Bool removable, /**< is var's column removable from the LP (due to aging or cleanup)? */
2505 SCIP_DECL_VARCOPY ((*varcopy)), /**< copies variable data if wanted to subscip, or NULL */
2506 SCIP_DECL_VARDELORIG ((*vardelorig)), /**< frees user data of original variable */
2507 SCIP_DECL_VARTRANS ((*vartrans)), /**< creates transformed user data by transforming original user data */
2508 SCIP_DECL_VARDELTRANS ((*vardeltrans)), /**< frees user data of transformed variable */
2509 SCIP_VARDATA* vardata, /**< user data for this specific variable */
2510 char** endptr, /**< pointer to store the final string position if successfully */
2511 SCIP_Bool* success /**< pointer store if the paring process was successful */
2512 )
2513{
2514 char name[SCIP_MAXSTRLEN];
2515 SCIP_Real lb;
2516 SCIP_Real ub;
2517 SCIP_Real obj;
2518 SCIP_VARTYPE vartype;
2519 SCIP_Real lazylb;
2520 SCIP_Real lazyub;
2521
2522 assert(var != NULL);
2523 assert(blkmem != NULL);
2524 assert(stat != NULL);
2525 assert(endptr != NULL);
2526 assert(success != NULL);
2527
2528 /* parse string in cip format for variable information */
2529 SCIP_CALL( varParse(set, messagehdlr, str, name, &lb, &ub, &obj, &vartype, &lazylb, &lazyub, FALSE, endptr, success) );
2530
2531 if( *success ) /*lint !e774*/
2532 {
2533 /* create variable */
2534 SCIP_CALL( varCreate(var, blkmem, set, stat, name, lb, ub, obj, vartype, initial, removable,
2535 varcopy, vardelorig, vartrans, vardeltrans, vardata) );
2536
2537 /* set variable status and data */
2538 (*var)->varstatus = SCIP_VARSTATUS_ORIGINAL; /*lint !e641*/
2539 (*var)->data.original.origdom.holelist = NULL;
2540 (*var)->data.original.origdom.lb = lb;
2541 (*var)->data.original.origdom.ub = ub;
2542 (*var)->data.original.transvar = NULL;
2543
2544 /* set lazy status of variable bounds */
2545 (*var)->lazylb = lazylb;
2546 (*var)->lazyub = lazyub;
2547
2548 /* capture variable */
2549 SCIPvarCapture(*var);
2550 }
2551
2552 return SCIP_OKAY;
2553}
2554
2555/** parses variable information (in cip format) out of a string; if the parsing process was successful a loose variable
2556 * belonging to the transformed problem is created and captured; if variable is of integral type, fractional bounds are
2557 * automatically rounded; an integer variable with bounds zero and one is automatically converted into a binary
2558 * variable
2559 */
2561 SCIP_VAR** var, /**< pointer to variable data */
2562 BMS_BLKMEM* blkmem, /**< block memory */
2563 SCIP_SET* set, /**< global SCIP settings */
2564 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
2565 SCIP_STAT* stat, /**< problem statistics */
2566 const char* str, /**< string to parse */
2567 SCIP_Bool initial, /**< should var's column be present in the initial root LP? */
2568 SCIP_Bool removable, /**< is var's column removable from the LP (due to aging or cleanup)? */
2569 SCIP_DECL_VARCOPY ((*varcopy)), /**< copies variable data if wanted to subscip, or NULL */
2570 SCIP_DECL_VARDELORIG ((*vardelorig)), /**< frees user data of original variable */
2571 SCIP_DECL_VARTRANS ((*vartrans)), /**< creates transformed user data by transforming original user data */
2572 SCIP_DECL_VARDELTRANS ((*vardeltrans)), /**< frees user data of transformed variable */
2573 SCIP_VARDATA* vardata, /**< user data for this specific variable */
2574 char** endptr, /**< pointer to store the final string position if successfully */
2575 SCIP_Bool* success /**< pointer store if the paring process was successful */
2576 )
2577{
2578 char name[SCIP_MAXSTRLEN];
2579 SCIP_Real lb;
2580 SCIP_Real ub;
2581 SCIP_Real obj;
2582 SCIP_VARTYPE vartype;
2583 SCIP_Real lazylb;
2584 SCIP_Real lazyub;
2585
2586 assert(var != NULL);
2587 assert(blkmem != NULL);
2588 assert(endptr != NULL);
2589 assert(success != NULL);
2590
2591 /* parse string in cip format for variable information */
2592 SCIP_CALL( varParse(set, messagehdlr, str, name, &lb, &ub, &obj, &vartype, &lazylb, &lazyub, TRUE, endptr, success) );
2593
2594 if( *success ) /*lint !e774*/
2595 {
2596 /* create variable */
2597 SCIP_CALL( varCreate(var, blkmem, set, stat, name, lb, ub, obj, vartype, initial, removable,
2598 varcopy, vardelorig, vartrans, vardeltrans, vardata) );
2599
2600 /* create event filter for transformed variable */
2601 SCIP_CALL( SCIPeventfilterCreate(&(*var)->eventfilter, blkmem) );
2602
2603 /* set variable status and data */
2604 (*var)->varstatus = SCIP_VARSTATUS_LOOSE; /*lint !e641*/
2605
2606 /* set lazy status of variable bounds */
2607 (*var)->lazylb = lazylb;
2608 (*var)->lazyub = lazyub;
2609
2610 /* capture variable */
2611 SCIPvarCapture(*var);
2612 }
2613
2614 return SCIP_OKAY;
2615}
2616
2617/** ensures, that parentvars array of var can store at least num entries */
2618static
2620 SCIP_VAR* var, /**< problem variable */
2621 BMS_BLKMEM* blkmem, /**< block memory */
2622 SCIP_SET* set, /**< global SCIP settings */
2623 int num /**< minimum number of entries to store */
2624 )
2625{
2626 assert(var->nparentvars <= var->parentvarssize);
2627
2628 if( num > var->parentvarssize )
2629 {
2630 int newsize;
2631
2632 newsize = SCIPsetCalcMemGrowSize(set, num);
2633 SCIP_ALLOC( BMSreallocBlockMemoryArray(blkmem, &var->parentvars, var->parentvarssize, newsize) );
2634 var->parentvarssize = newsize;
2635 }
2636 assert(num <= var->parentvarssize);
2637
2638 return SCIP_OKAY;
2639}
2640
2641/** adds variable to parent list of a variable and captures parent variable */
2642static
2644 SCIP_VAR* var, /**< variable to add parent to */
2645 BMS_BLKMEM* blkmem, /**< block memory of transformed problem */
2646 SCIP_SET* set, /**< global SCIP settings */
2647 SCIP_VAR* parentvar /**< parent variable to add */
2648 )
2649{
2650 assert(var != NULL);
2651 assert(parentvar != NULL);
2652
2653 /* the direct original counterpart must be stored as first parent */
2654 assert(var->nparentvars == 0 || SCIPvarGetStatus(parentvar) != SCIP_VARSTATUS_ORIGINAL);
2655
2656 SCIPsetDebugMsg(set, "adding parent <%s>[%p] to variable <%s>[%p] in slot %d\n",
2657 parentvar->name, (void*)parentvar, var->name, (void*)var, var->nparentvars);
2658
2659 SCIP_CALL( varEnsureParentvarsSize(var, blkmem, set, var->nparentvars+1) );
2660
2661 var->parentvars[var->nparentvars] = parentvar;
2662 var->nparentvars++;
2663
2664 SCIPvarCapture(parentvar);
2665
2666 return SCIP_OKAY;
2667}
2668
2669/** deletes and releases all variables from the parent list of a variable, frees the memory of parents array */
2670static
2672 SCIP_VAR** var, /**< pointer to variable */
2673 BMS_BLKMEM* blkmem, /**< block memory */
2674 SCIP_SET* set, /**< global SCIP settings */
2675 SCIP_EVENTQUEUE* eventqueue, /**< event queue (or NULL, if it's an original variable) */
2676 SCIP_LP* lp /**< current LP data (or NULL, if it's an original variable) */
2677 )
2678{
2679 SCIP_VAR* parentvar;
2680 int i;
2681
2682 SCIPsetDebugMsg(set, "free parents of <%s>\n", (*var)->name);
2683
2684 /* release the parent variables and remove the link from the parent variable to the child */
2685 for( i = 0; i < (*var)->nparentvars; ++i )
2686 {
2687 assert((*var)->parentvars != NULL);
2688 parentvar = (*var)->parentvars[i];
2689 assert(parentvar != NULL);
2690
2691 switch( SCIPvarGetStatus(parentvar) )
2692 {
2694 assert(parentvar->data.original.transvar == *var);
2695 assert(&parentvar->data.original.transvar != var);
2696 parentvar->data.original.transvar = NULL;
2697 break;
2698
2700 assert(parentvar->data.aggregate.var == *var);
2701 assert(&parentvar->data.aggregate.var != var);
2702 parentvar->data.aggregate.var = NULL;
2703 break;
2704
2705#ifdef SCIP_DISABLED_CODE
2706 /* The following code is unclear: should the current variable be removed from its parents? */
2708 assert(parentvar->data.multaggr.vars != NULL);
2709 for( v = 0; v < parentvar->data.multaggr.nvars && parentvar->data.multaggr.vars[v] != *var; ++v )
2710 {}
2711 assert(v < parentvar->data.multaggr.nvars && parentvar->data.multaggr.vars[v] == *var);
2712 if( v < parentvar->data.multaggr.nvars-1 )
2713 {
2714 parentvar->data.multaggr.vars[v] = parentvar->data.multaggr.vars[parentvar->data.multaggr.nvars-1];
2715 parentvar->data.multaggr.scalars[v] = parentvar->data.multaggr.scalars[parentvar->data.multaggr.nvars-1];
2716 }
2717 parentvar->data.multaggr.nvars--;
2718 break;
2719#endif
2720
2722 assert(parentvar->negatedvar == *var);
2723 assert((*var)->negatedvar == parentvar);
2724 parentvar->negatedvar = NULL;
2725 (*var)->negatedvar = NULL;
2726 break;
2727
2728 default:
2729 SCIPerrorMessage("parent variable is neither ORIGINAL, AGGREGATED nor NEGATED\n");
2730 return SCIP_INVALIDDATA;
2731 } /*lint !e788*/
2732
2733 SCIP_CALL( SCIPvarRelease(&(*var)->parentvars[i], blkmem, set, eventqueue, lp) );
2734 }
2735
2736 /* free parentvars array */
2737 BMSfreeBlockMemoryArrayNull(blkmem, &(*var)->parentvars, (*var)->parentvarssize);
2738
2739 return SCIP_OKAY;
2740}
2741
2742/** frees a variable */
2743static
2745 SCIP_VAR** var, /**< pointer to variable */
2746 BMS_BLKMEM* blkmem, /**< block memory */
2747 SCIP_SET* set, /**< global SCIP settings */
2748 SCIP_EVENTQUEUE* eventqueue, /**< event queue (may be NULL, if it's not a column variable) */
2749 SCIP_LP* lp /**< current LP data (may be NULL, if it's not a column variable) */
2750 )
2751{
2752 assert(var != NULL);
2753 assert(*var != NULL);
2754 assert(SCIPvarGetStatus(*var) != SCIP_VARSTATUS_COLUMN || &(*var)->data.col->var != var);
2755 assert((*var)->nuses == 0);
2756 assert((*var)->probindex == -1);
2757 assert((*var)->nlocksup[SCIP_LOCKTYPE_MODEL] == 0);
2758 assert((*var)->nlocksdown[SCIP_LOCKTYPE_MODEL] == 0);
2759
2760 SCIPsetDebugMsg(set, "free variable <%s> with status=%d\n", (*var)->name, SCIPvarGetStatus(*var));
2761
2762 switch( SCIPvarGetStatus(*var) )
2763 {
2765 assert((*var)->data.original.transvar == NULL); /* cannot free variable, if transformed variable is still existing */
2766 holelistFree(&(*var)->data.original.origdom.holelist, blkmem);
2767 assert((*var)->data.original.origdom.holelist == NULL);
2768 break;
2770 break;
2772 SCIP_CALL( SCIPcolFree(&(*var)->data.col, blkmem, set, eventqueue, lp) ); /* free corresponding LP column */
2773 break;
2776 break;
2778 BMSfreeBlockMemoryArray(blkmem, &(*var)->data.multaggr.vars, (*var)->data.multaggr.varssize);
2779 BMSfreeBlockMemoryArray(blkmem, &(*var)->data.multaggr.scalars, (*var)->data.multaggr.varssize);
2780 break;
2782 break;
2783 default:
2784 SCIPerrorMessage("unknown variable status\n");
2785 return SCIP_INVALIDDATA;
2786 }
2787
2788 /* release all parent variables and free the parentvars array */
2789 SCIP_CALL( varFreeParents(var, blkmem, set, eventqueue, lp) );
2790
2791 /* free user data */
2793 {
2794 if( (*var)->vardelorig != NULL )
2795 {
2796 SCIP_CALL( (*var)->vardelorig(set->scip, *var, &(*var)->vardata) );
2797 }
2798 }
2799 else
2800 {
2801 if( (*var)->vardeltrans != NULL )
2802 {
2803 SCIP_CALL( (*var)->vardeltrans(set->scip, *var, &(*var)->vardata) );
2804 }
2805 }
2806
2807 /* free event filter */
2808 if( (*var)->eventfilter != NULL )
2809 {
2810 SCIP_CALL( SCIPeventfilterFree(&(*var)->eventfilter, blkmem, set) );
2811 }
2812 assert((*var)->eventfilter == NULL);
2813
2814 /* free hole lists */
2815 holelistFree(&(*var)->glbdom.holelist, blkmem);
2816 holelistFree(&(*var)->locdom.holelist, blkmem);
2817 assert((*var)->glbdom.holelist == NULL);
2818 assert((*var)->locdom.holelist == NULL);
2819
2820 /* free variable bounds data structures */
2821 SCIPvboundsFree(&(*var)->vlbs, blkmem);
2822 SCIPvboundsFree(&(*var)->vubs, blkmem);
2823
2824 /* free implications data structures */
2825 SCIPimplicsFree(&(*var)->implics, blkmem);
2826
2827 /* free clique list data structures */
2828 SCIPcliquelistFree(&(*var)->cliquelist, blkmem);
2829
2830 /* free bound change information arrays */
2831 BMSfreeBlockMemoryArrayNull(blkmem, &(*var)->lbchginfos, (*var)->lbchginfossize);
2832 BMSfreeBlockMemoryArrayNull(blkmem, &(*var)->ubchginfos, (*var)->ubchginfossize);
2833
2834 /* free branching and inference history entries */
2835 SCIPhistoryFree(&(*var)->history, blkmem);
2836 SCIPhistoryFree(&(*var)->historycrun, blkmem);
2837 SCIPvaluehistoryFree(&(*var)->valuehistory, blkmem);
2838
2839 /* free variable data structure */
2840 BMSfreeBlockMemoryArray(blkmem, &(*var)->name, strlen((*var)->name)+1);
2841 BMSfreeBlockMemory(blkmem, var);
2842
2843 return SCIP_OKAY;
2844}
2845
2846/** increases usage counter of variable */
2848 SCIP_VAR* var /**< variable */
2849 )
2850{
2851 assert(var != NULL);
2852 assert(var->nuses >= 0);
2853
2854 SCIPdebugMessage("capture variable <%s> with nuses=%d\n", var->name, var->nuses);
2855 var->nuses++;
2856
2857#ifdef DEBUGUSES_VARNAME
2858 if( strcmp(var->name, DEBUGUSES_VARNAME) == 0
2859#ifdef DEBUGUSES_PROBNAME
2860 && ((var->scip->transprob != NULL && strcmp(SCIPprobGetName(var->scip->transprob), DEBUGUSES_PROBNAME) == 0) ||
2861 strcmp(SCIPprobGetName(var->scip->origprob), DEBUGUSES_PROBNAME) == 0)
2862#endif
2863 )
2864 {
2865 printf("Captured variable " DEBUGUSES_VARNAME " in SCIP %p, now %d uses; captured at\n", (void*)var->scip, var->nuses);
2866 print_backtrace();
2867 }
2868#endif
2869}
2870
2871/** decreases usage counter of variable, and frees memory if necessary */
2873 SCIP_VAR** var, /**< pointer to variable */
2874 BMS_BLKMEM* blkmem, /**< block memory */
2875 SCIP_SET* set, /**< global SCIP settings */
2876 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
2877 SCIP_LP* lp /**< current LP data (or NULL, if it's an original variable) */
2878 )
2879{
2880 assert(var != NULL);
2881 assert(*var != NULL);
2882 assert((*var)->nuses >= 1);
2883 assert(blkmem != NULL);
2884 assert((*var)->scip == set->scip);
2885
2886 SCIPsetDebugMsg(set, "release variable <%s> with nuses=%d\n", (*var)->name, (*var)->nuses);
2887 (*var)->nuses--;
2888
2889#ifdef DEBUGUSES_VARNAME
2890 if( strcmp((*var)->name, DEBUGUSES_VARNAME) == 0
2891#ifdef DEBUGUSES_PROBNAME
2892 && (((*var)->scip->transprob != NULL && strcmp(SCIPprobGetName((*var)->scip->transprob), DEBUGUSES_PROBNAME) == 0) ||
2893 strcmp(SCIPprobGetName((*var)->scip->origprob), DEBUGUSES_PROBNAME) == 0)
2894#endif
2895 )
2896 {
2897 printf("Released variable " DEBUGUSES_VARNAME " in SCIP %p, now %d uses; released at\n", (void*)(*var)->scip, (*var)->nuses);
2898 print_backtrace();
2899 }
2900#endif
2901
2902 if( (*var)->nuses == 0 )
2903 {
2904 SCIP_CALL( varFree(var, blkmem, set, eventqueue, lp) );
2905 }
2906
2907 *var = NULL;
2908
2909 return SCIP_OKAY;
2910}
2911
2912/** change variable name */
2914 SCIP_VAR* var, /**< problem variable */
2915 BMS_BLKMEM* blkmem, /**< block memory */
2916 const char* name /**< name of variable */
2917 )
2918{
2919 assert(name != NULL);
2920
2921 /* remove old variable name */
2922 BMSfreeBlockMemoryArray(blkmem, &var->name, strlen(var->name)+1);
2923
2924 /* set new variable name */
2925 SCIP_CALL( varSetName(var, blkmem, NULL, name) );
2926
2927 return SCIP_OKAY;
2928}
2929
2930/** initializes variable data structure for solving */
2932 SCIP_VAR* var /**< problem variable */
2933 )
2934{
2935 assert(var != NULL);
2936
2938 var->conflictlbcount = 0;
2939 var->conflictubcount = 0;
2940}
2941
2942/** outputs the given bounds into the file stream */
2943static
2945 SCIP_SET* set, /**< global SCIP settings */
2946 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
2947 FILE* file, /**< output file (or NULL for standard output) */
2948 SCIP_Real lb, /**< lower bound */
2949 SCIP_Real ub, /**< upper bound */
2950 const char* name /**< bound type name */
2951 )
2952{
2953 assert(set != NULL);
2954
2955 SCIPmessageFPrintInfo(messagehdlr, file, ", %s=", name);
2956 if( SCIPsetIsInfinity(set, lb) )
2957 SCIPmessageFPrintInfo(messagehdlr, file, "[+inf,");
2958 else if( SCIPsetIsInfinity(set, -lb) )
2959 SCIPmessageFPrintInfo(messagehdlr, file, "[-inf,");
2960 else
2961 SCIPmessageFPrintInfo(messagehdlr, file, "[%.15g,", lb);
2962 if( SCIPsetIsInfinity(set, ub) )
2963 SCIPmessageFPrintInfo(messagehdlr, file, "+inf]");
2964 else if( SCIPsetIsInfinity(set, -ub) )
2965 SCIPmessageFPrintInfo(messagehdlr, file, "-inf]");
2966 else
2967 SCIPmessageFPrintInfo(messagehdlr, file, "%.15g]", ub);
2968}
2969
2970/** prints hole list to file stream */
2971static
2973 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
2974 FILE* file, /**< output file (or NULL for standard output) */
2975 SCIP_HOLELIST* holelist, /**< hole list pointer to hole of interest */
2976 const char* name /**< hole type name */
2977 )
2978{ /*lint --e{715}*/
2979 SCIP_Real left;
2980 SCIP_Real right;
2981
2982 if( holelist == NULL )
2983 return;
2984
2985 left = SCIPholelistGetLeft(holelist);
2986 right = SCIPholelistGetRight(holelist);
2987
2988 /* display first hole */
2989 SCIPmessageFPrintInfo(messagehdlr, file, ", %s=(%g,%g)", name, left, right);
2990 holelist = SCIPholelistGetNext(holelist);
2991
2992 while(holelist != NULL )
2993 {
2994 left = SCIPholelistGetLeft(holelist);
2995 right = SCIPholelistGetRight(holelist);
2996
2997 /* display hole */
2998 SCIPmessageFPrintInfo(messagehdlr, file, "(%g,%g)", left, right);
2999
3000 /* get next hole */
3001 holelist = SCIPholelistGetNext(holelist);
3002 }
3003}
3004
3005/** outputs variable information into file stream */
3007 SCIP_VAR* var, /**< problem variable */
3008 SCIP_SET* set, /**< global SCIP settings */
3009 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
3010 FILE* file /**< output file (or NULL for standard output) */
3011 )
3012{
3013 SCIP_HOLELIST* holelist;
3014 SCIP_Real lb;
3015 SCIP_Real ub;
3016 int i;
3017
3018 assert(var != NULL);
3019 assert(var->scip == set->scip);
3020
3021 /* type of variable */
3022 switch( SCIPvarGetType(var) )
3023 {
3025 SCIPmessageFPrintInfo(messagehdlr, file, " [binary]");
3026 break;
3028 SCIPmessageFPrintInfo(messagehdlr, file, " [integer]");
3029 break;
3031 SCIPmessageFPrintInfo(messagehdlr, file, " [implicit]");
3032 break;
3034 SCIPmessageFPrintInfo(messagehdlr, file, " [continuous]");
3035 break;
3036 default:
3037 SCIPerrorMessage("unknown variable type\n");
3038 SCIPABORT();
3039 return SCIP_ERROR; /*lint !e527*/
3040 }
3041
3042 /* name */
3043 SCIPmessageFPrintInfo(messagehdlr, file, " <%s>:", var->name);
3044
3045 /* objective value */
3046 SCIPmessageFPrintInfo(messagehdlr, file, " obj=%.15g", var->obj);
3047
3048 /* bounds (global bounds for transformed variables, original bounds for original variables) */
3049 if( !SCIPvarIsTransformed(var) )
3050 {
3051 /* output original bound */
3052 lb = SCIPvarGetLbOriginal(var);
3053 ub = SCIPvarGetUbOriginal(var);
3054 printBounds(set, messagehdlr, file, lb, ub, "original bounds");
3055
3056 /* output lazy bound */
3057 lb = SCIPvarGetLbLazy(var);
3058 ub = SCIPvarGetUbLazy(var);
3059
3060 /* only display the lazy bounds if they are different from [-infinity,infinity] */
3061 if( !SCIPsetIsInfinity(set, -lb) || !SCIPsetIsInfinity(set, ub) )
3062 printBounds(set, messagehdlr, file, lb, ub, "lazy bounds");
3063
3064 holelist = SCIPvarGetHolelistOriginal(var);
3065 printHolelist(messagehdlr, file, holelist, "original holes");
3066 }
3067 else
3068 {
3069 /* output global bound */
3070 lb = SCIPvarGetLbGlobal(var);
3071 ub = SCIPvarGetUbGlobal(var);
3072 printBounds(set, messagehdlr, file, lb, ub, "global bounds");
3073
3074 /* output local bound */
3075 lb = SCIPvarGetLbLocal(var);
3076 ub = SCIPvarGetUbLocal(var);
3077 printBounds(set, messagehdlr, file, lb, ub, "local bounds");
3078
3079 /* output lazy bound */
3080 lb = SCIPvarGetLbLazy(var);
3081 ub = SCIPvarGetUbLazy(var);
3082
3083 /* only display the lazy bounds if they are different from [-infinity,infinity] */
3084 if( !SCIPsetIsInfinity(set, -lb) || !SCIPsetIsInfinity(set, ub) )
3085 printBounds(set, messagehdlr, file, lb, ub, "lazy bounds");
3086
3087 /* global hole list */
3088 holelist = SCIPvarGetHolelistGlobal(var);
3089 printHolelist(messagehdlr, file, holelist, "global holes");
3090
3091 /* local hole list */
3092 holelist = SCIPvarGetHolelistLocal(var);
3093 printHolelist(messagehdlr, file, holelist, "local holes");
3094 }
3095
3096 /* fixings and aggregations */
3097 switch( SCIPvarGetStatus(var) )
3098 {
3102 break;
3103
3105 SCIPmessageFPrintInfo(messagehdlr, file, ", fixed:");
3106 if( SCIPsetIsInfinity(set, var->glbdom.lb) )
3107 SCIPmessageFPrintInfo(messagehdlr, file, "+inf");
3108 else if( SCIPsetIsInfinity(set, -var->glbdom.lb) )
3109 SCIPmessageFPrintInfo(messagehdlr, file, "-inf");
3110 else
3111 SCIPmessageFPrintInfo(messagehdlr, file, "%.15g", var->glbdom.lb);
3112 break;
3113
3115 SCIPmessageFPrintInfo(messagehdlr, file, ", aggregated:");
3117 SCIPmessageFPrintInfo(messagehdlr, file, " %.15g", var->data.aggregate.constant);
3118 SCIPmessageFPrintInfo(messagehdlr, file, " %+.15g<%s>", var->data.aggregate.scalar, SCIPvarGetName(var->data.aggregate.var));
3119 break;
3120
3122 SCIPmessageFPrintInfo(messagehdlr, file, ", aggregated:");
3123 if( var->data.multaggr.nvars == 0 || !SCIPsetIsZero(set, var->data.multaggr.constant) )
3124 SCIPmessageFPrintInfo(messagehdlr, file, " %.15g", var->data.multaggr.constant);
3125 for( i = 0; i < var->data.multaggr.nvars; ++i )
3126 SCIPmessageFPrintInfo(messagehdlr, file, " %+.15g<%s>", var->data.multaggr.scalars[i], SCIPvarGetName(var->data.multaggr.vars[i]));
3127 break;
3128
3130 SCIPmessageFPrintInfo(messagehdlr, file, ", negated: %.15g - <%s>", var->data.negate.constant, SCIPvarGetName(var->negatedvar));
3131 break;
3132
3133 default:
3134 SCIPerrorMessage("unknown variable status\n");
3135 SCIPABORT();
3136 return SCIP_ERROR; /*lint !e527*/
3137 }
3138
3139 SCIPmessageFPrintInfo(messagehdlr, file, "\n");
3140
3141 return SCIP_OKAY;
3142}
3143
3144/** issues a VARUNLOCKED event on the given variable */
3145static
3147 SCIP_VAR* var, /**< problem variable to change */
3148 BMS_BLKMEM* blkmem, /**< block memory */
3149 SCIP_SET* set, /**< global SCIP settings */
3150 SCIP_EVENTQUEUE* eventqueue /**< event queue */
3151 )
3152{
3153 SCIP_EVENT* event;
3154
3155 assert(var != NULL);
3156 assert(var->nlocksdown[SCIP_LOCKTYPE_MODEL] <= 1 && var->nlocksup[SCIP_LOCKTYPE_MODEL] <= 1);
3157 assert(var->scip == set->scip);
3158
3159 /* issue VARUNLOCKED event on variable */
3160 SCIP_CALL( SCIPeventCreateVarUnlocked(&event, blkmem, var) );
3161 SCIP_CALL( SCIPeventqueueAdd(eventqueue, blkmem, set, NULL, NULL, NULL, NULL, &event) );
3162
3163 return SCIP_OKAY;
3164}
3165
3166/** modifies lock numbers for rounding */
3168 SCIP_VAR* var, /**< problem variable */
3169 BMS_BLKMEM* blkmem, /**< block memory */
3170 SCIP_SET* set, /**< global SCIP settings */
3171 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
3172 SCIP_LOCKTYPE locktype, /**< type of the variable locks */
3173 int addnlocksdown, /**< increase in number of rounding down locks */
3174 int addnlocksup /**< increase in number of rounding up locks */
3175 )
3176{
3177 SCIP_VAR* lockvar;
3178
3179 assert(var != NULL);
3180 assert((int)locktype >= 0 && (int)locktype < (int)NLOCKTYPES); /*lint !e685 !e568 !e587 !e650*/
3181 assert(var->nlocksup[locktype] >= 0);
3182 assert(var->nlocksdown[locktype] >= 0);
3183 assert(var->scip == set->scip);
3184
3185 if( addnlocksdown == 0 && addnlocksup == 0 )
3186 return SCIP_OKAY;
3187
3188#ifdef SCIP_DEBUG
3189 SCIPsetDebugMsg(set, "add rounding locks %d/%d to variable <%s> (locks=%d/%d, type=%u)\n",
3190 addnlocksdown, addnlocksup, var->name, var->nlocksdown[locktype], var->nlocksup[locktype], locktype);
3191#endif
3192
3193 lockvar = var;
3194
3195 while( TRUE ) /*lint !e716 */
3196 {
3197 assert(lockvar != NULL);
3198
3199 switch( SCIPvarGetStatus(lockvar) )
3200 {
3202 if( lockvar->data.original.transvar != NULL )
3203 {
3204 lockvar = lockvar->data.original.transvar;
3205 break;
3206 }
3207 else
3208 {
3209 lockvar->nlocksdown[locktype] += addnlocksdown;
3210 lockvar->nlocksup[locktype] += addnlocksup;
3211
3212 assert(lockvar->nlocksdown[locktype] >= 0);
3213 assert(lockvar->nlocksup[locktype] >= 0);
3214
3215 return SCIP_OKAY;
3216 }
3220 lockvar->nlocksdown[locktype] += addnlocksdown;
3221 lockvar->nlocksup[locktype] += addnlocksup;
3222
3223 assert(lockvar->nlocksdown[locktype] >= 0);
3224 assert(lockvar->nlocksup[locktype] >= 0);
3225
3226 if( locktype == SCIP_LOCKTYPE_MODEL && lockvar->nlocksdown[locktype] <= 1
3227 && lockvar->nlocksup[locktype] <= 1 )
3228 {
3229 SCIP_CALL( varEventVarUnlocked(lockvar, blkmem, set, eventqueue) );
3230 }
3231
3232 return SCIP_OKAY;
3234 assert(!lockvar->donotaggr);
3235
3236 if( lockvar->data.aggregate.scalar < 0.0 )
3237 {
3238 int tmp = addnlocksup;
3239
3240 addnlocksup = addnlocksdown;
3241 addnlocksdown = tmp;
3242 }
3243
3244 lockvar = lockvar->data.aggregate.var;
3245 break;
3247 {
3248 int v;
3249
3250 assert(!lockvar->donotmultaggr);
3251
3252 lockvar->nlocksdown[locktype] += addnlocksdown;
3253 lockvar->nlocksup[locktype] += addnlocksup;
3254
3255 assert(lockvar->nlocksdown[locktype] >= 0);
3256 assert(lockvar->nlocksup[locktype] >= 0);
3257
3258 for( v = lockvar->data.multaggr.nvars - 1; v >= 0; --v )
3259 {
3260 if( lockvar->data.multaggr.scalars[v] > 0.0 )
3261 {
3262 SCIP_CALL( SCIPvarAddLocks(lockvar->data.multaggr.vars[v], blkmem, set, eventqueue, locktype, addnlocksdown,
3263 addnlocksup) );
3264 }
3265 else
3266 {
3267 SCIP_CALL( SCIPvarAddLocks(lockvar->data.multaggr.vars[v], blkmem, set, eventqueue, locktype, addnlocksup,
3268 addnlocksdown) );
3269 }
3270 }
3271 return SCIP_OKAY;
3272 }
3274 {
3275 int tmp = addnlocksup;
3276
3277 assert(lockvar->negatedvar != NULL);
3279 assert(lockvar->negatedvar->negatedvar == lockvar);
3280
3281 addnlocksup = addnlocksdown;
3282 addnlocksdown = tmp;
3283
3284 lockvar = lockvar->negatedvar;
3285 break;
3286 }
3287 default:
3288 SCIPerrorMessage("unknown variable status\n");
3289 return SCIP_INVALIDDATA;
3290 }
3291 }
3292}
3293
3294/** gets number of locks for rounding down of a special type */
3296 SCIP_VAR* var, /**< problem variable */
3297 SCIP_LOCKTYPE locktype /**< type of variable locks */
3298 )
3299{
3300 int nlocks;
3301 int i;
3302
3303 assert(var != NULL);
3304 assert((int)locktype >= 0 && (int)locktype < (int)NLOCKTYPES); /*lint !e685 !e568 !e587 !e650*/
3305 assert(var->nlocksdown[locktype] >= 0);
3306
3307 switch( SCIPvarGetStatus(var) )
3308 {
3310 if( var->data.original.transvar != NULL )
3311 return SCIPvarGetNLocksDownType(var->data.original.transvar, locktype);
3312 else
3313 return var->nlocksdown[locktype];
3314
3318 return var->nlocksdown[locktype];
3319
3321 assert(!var->donotaggr);
3322 if( var->data.aggregate.scalar > 0.0 )
3323 return SCIPvarGetNLocksDownType(var->data.aggregate.var, locktype);
3324 else
3325 return SCIPvarGetNLocksUpType(var->data.aggregate.var, locktype);
3326
3328 assert(!var->donotmultaggr);
3329 nlocks = 0;
3330 for( i = 0; i < var->data.multaggr.nvars; ++i )
3331 {
3332 if( var->data.multaggr.scalars[i] > 0.0 )
3333 nlocks += SCIPvarGetNLocksDownType(var->data.multaggr.vars[i], locktype);
3334 else
3335 nlocks += SCIPvarGetNLocksUpType(var->data.multaggr.vars[i], locktype);
3336 }
3337 return nlocks;
3338
3340 assert(var->negatedvar != NULL);
3342 assert(var->negatedvar->negatedvar == var);
3343 return SCIPvarGetNLocksUpType(var->negatedvar, locktype);
3344
3345 default:
3346 SCIPerrorMessage("unknown variable status\n");
3347 SCIPABORT();
3348 return INT_MAX; /*lint !e527*/
3349 }
3350}
3351
3352/** gets number of locks for rounding up of a special type */
3354 SCIP_VAR* var, /**< problem variable */
3355 SCIP_LOCKTYPE locktype /**< type of variable locks */
3356 )
3357{
3358 int nlocks;
3359 int i;
3360
3361 assert(var != NULL);
3362 assert((int)locktype >= 0 && (int)locktype < (int)NLOCKTYPES); /*lint !e685 !e568 !e587 !e650*/
3363 assert(var->nlocksup[locktype] >= 0);
3364
3365 switch( SCIPvarGetStatus(var) )
3366 {
3368 if( var->data.original.transvar != NULL )
3369 return SCIPvarGetNLocksUpType(var->data.original.transvar, locktype);
3370 else
3371 return var->nlocksup[locktype];
3372
3376 return var->nlocksup[locktype];
3377
3379 assert(!var->donotaggr);
3380 if( var->data.aggregate.scalar > 0.0 )
3381 return SCIPvarGetNLocksUpType(var->data.aggregate.var, locktype);
3382 else
3383 return SCIPvarGetNLocksDownType(var->data.aggregate.var, locktype);
3384
3386 assert(!var->donotmultaggr);
3387 nlocks = 0;
3388 for( i = 0; i < var->data.multaggr.nvars; ++i )
3389 {
3390 if( var->data.multaggr.scalars[i] > 0.0 )
3391 nlocks += SCIPvarGetNLocksUpType(var->data.multaggr.vars[i], locktype);
3392 else
3393 nlocks += SCIPvarGetNLocksDownType(var->data.multaggr.vars[i], locktype);
3394 }
3395 return nlocks;
3396
3398 assert(var->negatedvar != NULL);
3400 assert(var->negatedvar->negatedvar == var);
3401 return SCIPvarGetNLocksDownType(var->negatedvar, locktype);
3402
3403 default:
3404 SCIPerrorMessage("unknown variable status\n");
3405 SCIPABORT();
3406 return INT_MAX; /*lint !e527*/
3407 }
3408}
3409
3410/** gets number of locks for rounding down
3411 *
3412 * @note This method will always return variable locks of type model
3413 *
3414 * @note It is recommented to use SCIPvarGetNLocksDownType()
3415 */
3417 SCIP_VAR* var /**< problem variable */
3418 )
3419{
3421}
3422
3423/** gets number of locks for rounding up
3424 *
3425 * @note This method will always return variable locks of type model
3426 *
3427 * @note It is recommented to use SCIPvarGetNLocksUpType()
3428 */
3430 SCIP_VAR* var /**< problem variable */
3431 )
3432{
3434}
3435
3436/** is it possible, to round variable down and stay feasible?
3437 *
3438 * @note This method will always check w.r.t variable locks of type model
3439 */
3441 SCIP_VAR* var /**< problem variable */
3442 )
3443{
3445}
3446
3447/** is it possible, to round variable up and stay feasible?
3448 *
3449 * @note This method will always check w.r.t. variable locks of type model
3450 */
3452 SCIP_VAR* var /**< problem variable */
3453 )
3454{
3455 return (SCIPvarGetNLocksUpType(var, SCIP_LOCKTYPE_MODEL) == 0);
3456}
3457
3458/** gets and captures transformed variable of a given variable; if the variable is not yet transformed,
3459 * a new transformed variable for this variable is created
3460 */
3462 SCIP_VAR* origvar, /**< original problem variable */
3463 BMS_BLKMEM* blkmem, /**< block memory of transformed problem */
3464 SCIP_SET* set, /**< global SCIP settings */
3465 SCIP_STAT* stat, /**< problem statistics */
3466 SCIP_OBJSENSE objsense, /**< objective sense of original problem; transformed is always MINIMIZE */
3467 SCIP_VAR** transvar /**< pointer to store the transformed variable */
3468 )
3469{
3470 char name[SCIP_MAXSTRLEN];
3471
3472 assert(origvar != NULL);
3473 assert(origvar->scip == set->scip);
3474 assert(SCIPvarGetStatus(origvar) == SCIP_VARSTATUS_ORIGINAL);
3475 assert(SCIPsetIsEQ(set, origvar->glbdom.lb, origvar->locdom.lb));
3476 assert(SCIPsetIsEQ(set, origvar->glbdom.ub, origvar->locdom.ub));
3477 assert(origvar->vlbs == NULL);
3478 assert(origvar->vubs == NULL);
3479 assert(transvar != NULL);
3480
3481 /* check if variable is already transformed */
3482 if( origvar->data.original.transvar != NULL )
3483 {
3484 *transvar = origvar->data.original.transvar;
3485 SCIPvarCapture(*transvar);
3486 }
3487 else
3488 {
3489 int i;
3490
3491 /* create transformed variable */
3492 (void) SCIPsnprintf(name, SCIP_MAXSTRLEN, "t_%s", origvar->name);
3493 SCIP_CALL( SCIPvarCreateTransformed(transvar, blkmem, set, stat, name,
3494 origvar->glbdom.lb, origvar->glbdom.ub, (SCIP_Real)objsense * origvar->obj,
3495 SCIPvarGetType(origvar), origvar->initial, origvar->removable,
3496 origvar->vardelorig, origvar->vartrans, origvar->vardeltrans, origvar->varcopy, NULL) );
3497
3498 /* copy the branch factor and priority */
3499 (*transvar)->branchfactor = origvar->branchfactor;
3500 (*transvar)->branchpriority = origvar->branchpriority;
3501 (*transvar)->branchdirection = origvar->branchdirection; /*lint !e732*/
3502
3503 /* duplicate hole lists */
3504 SCIP_CALL( holelistDuplicate(&(*transvar)->glbdom.holelist, blkmem, set, origvar->glbdom.holelist) );
3505 SCIP_CALL( holelistDuplicate(&(*transvar)->locdom.holelist, blkmem, set, origvar->locdom.holelist) );
3506
3507 /* link original and transformed variable */
3508 origvar->data.original.transvar = *transvar;
3509 SCIP_CALL( varAddParent(*transvar, blkmem, set, origvar) );
3510
3511 /* copy rounding locks */
3512 for( i = 0; i < NLOCKTYPES; i++ )
3513 {
3514 (*transvar)->nlocksdown[i] = origvar->nlocksdown[i];
3515 (*transvar)->nlocksup[i] = origvar->nlocksup[i];
3516 assert((*transvar)->nlocksdown[i] >= 0);
3517 assert((*transvar)->nlocksup[i] >= 0);
3518 }
3519
3520 /* copy donot(mult)aggr status */
3521 (*transvar)->donotaggr = origvar->donotaggr;
3522 (*transvar)->donotmultaggr = origvar->donotmultaggr;
3523
3524 /* copy lazy bounds */
3525 (*transvar)->lazylb = origvar->lazylb;
3526 (*transvar)->lazyub = origvar->lazyub;
3527
3528 /* transfer eventual variable statistics; do not update global statistics, because this has been done
3529 * when original variable was created
3530 */
3531 SCIPhistoryUnite((*transvar)->history, origvar->history, FALSE);
3532
3533 /* transform user data */
3534 if( origvar->vartrans != NULL )
3535 {
3536 SCIP_CALL( origvar->vartrans(set->scip, origvar, origvar->vardata, *transvar, &(*transvar)->vardata) );
3537 }
3538 else
3539 (*transvar)->vardata = origvar->vardata;
3540 }
3541
3542 SCIPsetDebugMsg(set, "transformed variable: <%s>[%p] -> <%s>[%p]\n", origvar->name, (void*)origvar, (*transvar)->name, (void*)*transvar);
3543
3544 return SCIP_OKAY;
3545}
3546
3547/** gets corresponding transformed variable of an original or negated original variable */
3549 SCIP_VAR* origvar, /**< original problem variable */
3550 BMS_BLKMEM* blkmem, /**< block memory of transformed problem */
3551 SCIP_SET* set, /**< global SCIP settings */
3552 SCIP_STAT* stat, /**< problem statistics */
3553 SCIP_VAR** transvar /**< pointer to store the transformed variable, or NULL if not existing yet */
3554 )
3555{
3556 assert(origvar != NULL);
3558 assert(origvar->scip == set->scip);
3559
3561 {
3562 assert(origvar->negatedvar != NULL);
3564
3565 if( origvar->negatedvar->data.original.transvar == NULL )
3566 *transvar = NULL;
3567 else
3568 {
3569 SCIP_CALL( SCIPvarNegate(origvar->negatedvar->data.original.transvar, blkmem, set, stat, transvar) );
3570 }
3571 }
3572 else
3573 *transvar = origvar->data.original.transvar;
3574
3575 return SCIP_OKAY;
3576}
3577
3578/** converts loose transformed variable into column variable, creates LP column */
3580 SCIP_VAR* var, /**< problem variable */
3581 BMS_BLKMEM* blkmem, /**< block memory */
3582 SCIP_SET* set, /**< global SCIP settings */
3583 SCIP_STAT* stat, /**< problem statistics */
3584 SCIP_PROB* prob, /**< problem data */
3585 SCIP_LP* lp /**< current LP data */
3586 )
3587{
3588 assert(var != NULL);
3589 assert(SCIPvarGetStatus(var) == SCIP_VARSTATUS_LOOSE);
3590 assert(var->scip == set->scip);
3591
3592 SCIPsetDebugMsg(set, "creating column for variable <%s>\n", var->name);
3593
3594 /* switch variable status */
3595 var->varstatus = SCIP_VARSTATUS_COLUMN; /*lint !e641*/
3596
3597 /* create column of variable */
3598 SCIP_CALL( SCIPcolCreate(&var->data.col, blkmem, set, stat, var, 0, NULL, NULL, var->removable) );
3599
3600 if( var->probindex != -1 )
3601 {
3602 /* inform problem about the variable's status change */
3603 SCIP_CALL( SCIPprobVarChangedStatus(prob, blkmem, set, NULL, NULL, var) );
3604
3605 /* inform LP, that problem variable is now a column variable and no longer loose */
3606 SCIP_CALL( SCIPlpUpdateVarColumn(lp, set, var) );
3607 }
3608
3609 return SCIP_OKAY;
3610}
3611
3612/** converts column transformed variable back into loose variable, frees LP column */
3614 SCIP_VAR* var, /**< problem variable */
3615 BMS_BLKMEM* blkmem, /**< block memory */
3616 SCIP_SET* set, /**< global SCIP settings */
3617 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
3618 SCIP_PROB* prob, /**< problem data */
3619 SCIP_LP* lp /**< current LP data */
3620 )
3621{
3622 assert(var != NULL);
3624 assert(var->scip == set->scip);
3625 assert(var->data.col != NULL);
3626 assert(var->data.col->lppos == -1);
3627 assert(var->data.col->lpipos == -1);
3628
3629 SCIPsetDebugMsg(set, "deleting column for variable <%s>\n", var->name);
3630
3631 /* free column of variable */
3632 SCIP_CALL( SCIPcolFree(&var->data.col, blkmem, set, eventqueue, lp) );
3633
3634 /* switch variable status */
3635 var->varstatus = SCIP_VARSTATUS_LOOSE; /*lint !e641*/
3636
3637 if( var->probindex != -1 )
3638 {
3639 /* inform problem about the variable's status change */
3640 SCIP_CALL( SCIPprobVarChangedStatus(prob, blkmem, set, NULL, NULL, var) );
3641
3642 /* inform LP, that problem variable is now a loose variable and no longer a column */
3643 SCIP_CALL( SCIPlpUpdateVarLoose(lp, set, var) );
3644 }
3645
3646 return SCIP_OKAY;
3647}
3648
3649/** issues a VARFIXED event on the given variable and all its parents (except ORIGINAL parents);
3650 * the event issuing on the parents is necessary, because unlike with bound changes, the parent variables
3651 * are not informed about a fixing of an active variable they are pointing to
3652 */
3653static
3655 SCIP_VAR* var, /**< problem variable to change */
3656 BMS_BLKMEM* blkmem, /**< block memory */
3657 SCIP_SET* set, /**< global SCIP settings */
3658 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
3659 int fixeventtype /**< is this event a fixation(0), an aggregation(1), or a
3660 * multi-aggregation(2)
3661 */
3662 )
3663{
3664 SCIP_EVENT* event;
3665 SCIP_VARSTATUS varstatus;
3666 int i;
3667
3668 assert(var != NULL);
3669 assert(var->scip == set->scip);
3670 assert(0 <= fixeventtype && fixeventtype <= 2);
3671
3672 /* issue VARFIXED event on variable */
3673 SCIP_CALL( SCIPeventCreateVarFixed(&event, blkmem, var) );
3674 SCIP_CALL( SCIPeventqueueAdd(eventqueue, blkmem, set, NULL, NULL, NULL, NULL, &event) );
3675
3676#ifndef NDEBUG
3677 for( i = var->nparentvars -1; i >= 0; --i )
3678 {
3680 }
3681#endif
3682
3683 switch( fixeventtype )
3684 {
3685 case 0:
3686 /* process all parents of a fixed variable */
3687 for( i = var->nparentvars - 1; i >= 0; --i )
3688 {
3689 varstatus = SCIPvarGetStatus(var->parentvars[i]);
3690
3691 assert(varstatus != SCIP_VARSTATUS_FIXED);
3692
3693 /* issue event on all not yet fixed parent variables, (that should already issued this event) except the original
3694 * one
3695 */
3696 if( varstatus != SCIP_VARSTATUS_ORIGINAL )
3697 {
3698 SCIP_CALL( varEventVarFixed(var->parentvars[i], blkmem, set, eventqueue, fixeventtype) );
3699 }
3700 }
3701 break;
3702 case 1:
3703 /* process all parents of a aggregated variable */
3704 for( i = var->nparentvars - 1; i >= 0; --i )
3705 {
3706 varstatus = SCIPvarGetStatus(var->parentvars[i]);
3707
3708 assert(varstatus != SCIP_VARSTATUS_FIXED);
3709
3710 /* issue event for not aggregated parent variable, because for these and its parents the var event was already
3711 * issued(, except the original one)
3712 *
3713 * @note that even before an aggregated parent variable, there might be variables, for which the vent was not
3714 * yet issued
3715 */
3716 if( varstatus == SCIP_VARSTATUS_AGGREGATED )
3717 continue;
3718
3719 if( varstatus != SCIP_VARSTATUS_ORIGINAL )
3720 {
3721 SCIP_CALL( varEventVarFixed(var->parentvars[i], blkmem, set, eventqueue, fixeventtype) );
3722 }
3723 }
3724 break;
3725 case 2:
3726 /* process all parents of a aggregated variable */
3727 for( i = var->nparentvars - 1; i >= 0; --i )
3728 {
3729 varstatus = SCIPvarGetStatus(var->parentvars[i]);
3730
3731 assert(varstatus != SCIP_VARSTATUS_FIXED);
3732
3733 /* issue event on all parent variables except the original one */
3734 if( varstatus != SCIP_VARSTATUS_ORIGINAL )
3735 {
3736 SCIP_CALL( varEventVarFixed(var->parentvars[i], blkmem, set, eventqueue, fixeventtype) );
3737 }
3738 }
3739 break;
3740 default:
3741 SCIPerrorMessage("unknown variable fixation event origin\n");
3742 return SCIP_INVALIDDATA;
3743 }
3744
3745 return SCIP_OKAY;
3746}
3747
3748/** converts variable into fixed variable */
3750 SCIP_VAR* var, /**< problem variable */
3751 BMS_BLKMEM* blkmem, /**< block memory */
3752 SCIP_SET* set, /**< global SCIP settings */
3753 SCIP_STAT* stat, /**< problem statistics */
3754 SCIP_PROB* transprob, /**< tranformed problem data */
3755 SCIP_PROB* origprob, /**< original problem data */
3756 SCIP_PRIMAL* primal, /**< primal data */
3757 SCIP_TREE* tree, /**< branch and bound tree */
3758 SCIP_REOPT* reopt, /**< reoptimization data structure */
3759 SCIP_LP* lp, /**< current LP data */
3760 SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
3761 SCIP_EVENTFILTER* eventfilter, /**< event filter for global (not variable dependent) events */
3762 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
3763 SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
3764 SCIP_Real fixedval, /**< value to fix variable at */
3765 SCIP_Bool* infeasible, /**< pointer to store whether the fixing is infeasible */
3766 SCIP_Bool* fixed /**< pointer to store whether the fixing was performed (variable was unfixed) */
3767 )
3768{
3769 SCIP_Real obj;
3770 SCIP_Real childfixedval;
3771
3772 assert(var != NULL);
3773 assert(var->scip == set->scip);
3774 assert(SCIPsetIsEQ(set, var->glbdom.lb, var->locdom.lb));
3775 assert(SCIPsetIsEQ(set, var->glbdom.ub, var->locdom.ub));
3776 assert(infeasible != NULL);
3777 assert(fixed != NULL);
3778
3779 SCIPsetDebugMsg(set, "fix variable <%s>[%g,%g] to %g\n", var->name, var->glbdom.lb, var->glbdom.ub, fixedval);
3780
3781 *infeasible = FALSE;
3782 *fixed = FALSE;
3783
3785 {
3786 *infeasible = !SCIPsetIsFeasEQ(set, fixedval, var->locdom.lb);
3787 SCIPsetDebugMsg(set, " -> variable already fixed to %g (fixedval=%g): infeasible=%u\n", var->locdom.lb, fixedval, *infeasible);
3788 return SCIP_OKAY;
3789 }
3790 else if( (SCIPvarGetType(var) != SCIP_VARTYPE_CONTINUOUS && !SCIPsetIsFeasIntegral(set, fixedval))
3791 || SCIPsetIsFeasLT(set, fixedval, var->locdom.lb)
3792 || SCIPsetIsFeasGT(set, fixedval, var->locdom.ub) )
3793 {
3794 SCIPsetDebugMsg(set, " -> fixing infeasible: locdom=[%g,%g], fixedval=%g\n", var->locdom.lb, var->locdom.ub, fixedval);
3795 *infeasible = TRUE;
3796 return SCIP_OKAY;
3797 }
3798
3799 switch( SCIPvarGetStatus(var) )
3800 {
3802 if( var->data.original.transvar == NULL )
3803 {
3804 SCIPerrorMessage("cannot fix an untransformed original variable\n");
3805 return SCIP_INVALIDDATA;
3806 }
3807 SCIP_CALL( SCIPvarFix(var->data.original.transvar, blkmem, set, stat, transprob, origprob, primal, tree, reopt,
3808 lp, branchcand, eventfilter, eventqueue, cliquetable, fixedval, infeasible, fixed) );
3809 break;
3810
3812 assert(!SCIPeventqueueIsDelayed(eventqueue)); /* otherwise, the pseudo objective value update gets confused */
3813
3814 /* set the fixed variable's objective value to 0.0 */
3815 obj = var->obj;
3816 SCIP_CALL( SCIPvarChgObj(var, blkmem, set, transprob, primal, lp, eventqueue, 0.0) );
3817
3818 /* since we change the variable type form loose to fixed, we have to adjust the number of loose
3819 * variables in the LP data structure; the loose objective value (looseobjval) in the LP data structure, however,
3820 * gets adjusted automatically, due to the event SCIP_EVENTTYPE_OBJCHANGED which dropped in the moment where the
3821 * objective of this variable is set to zero
3822 */
3824
3825 /* change variable's bounds to fixed value (thereby removing redundant implications and variable bounds) */
3826 holelistFree(&var->glbdom.holelist, blkmem);
3827 holelistFree(&var->locdom.holelist, blkmem);
3828 SCIP_CALL( SCIPvarChgLbGlobal(var, blkmem, set, stat, lp, branchcand, eventqueue, cliquetable, fixedval) );
3829 SCIP_CALL( SCIPvarChgUbGlobal(var, blkmem, set, stat, lp, branchcand, eventqueue, cliquetable, fixedval) );
3830
3831 if( var->glbdom.lb != var->glbdom.ub ) /*lint !e777*/
3832 {
3833 /* explicitly set variable's bounds if the fixed value was in epsilon range of the old bound (so above call didn't set bound) */
3835 {
3836 /* if not continuous variable, then make sure variable is fixed to integer value */
3837 assert(SCIPsetIsIntegral(set, fixedval));
3838 fixedval = SCIPsetRound(set, fixedval);
3839 }
3840 var->glbdom.lb = fixedval;
3841 var->glbdom.ub = fixedval;
3842 }
3843
3844 /* ensure local domain is fixed to same value as global domain */
3845 var->locdom.lb = var->glbdom.lb;
3846 var->locdom.ub = var->glbdom.ub;
3847
3848 /* delete implications and variable bounds information */
3849 SCIP_CALL( SCIPvarRemoveCliquesImplicsVbs(var, blkmem, cliquetable, set, FALSE, FALSE, TRUE) );
3850 assert(var->vlbs == NULL);
3851 assert(var->vubs == NULL);
3852 assert(var->implics == NULL);
3853
3854 /* clear the history of the variable */
3857
3858 /* convert variable into fixed variable */
3859 var->varstatus = SCIP_VARSTATUS_FIXED; /*lint !e641*/
3860
3861 /* inform problem about the variable's status change */
3862 if( var->probindex != -1 )
3863 {
3864 SCIP_CALL( SCIPprobVarChangedStatus(transprob, blkmem, set, branchcand, cliquetable, var) );
3865 }
3866
3867 /* reset the objective value of the fixed variable, thus adjusting the problem's objective offset */
3868 SCIP_CALL( SCIPvarAddObj(var, blkmem, set, stat, transprob, origprob, primal, tree, reopt, lp, eventfilter, eventqueue, obj) );
3869
3870 /* issue VARFIXED event */
3871 SCIP_CALL( varEventVarFixed(var, blkmem, set, eventqueue, 0) );
3872
3873 *fixed = TRUE;
3874 break;
3875
3877 SCIPerrorMessage("cannot fix a column variable\n");
3878 return SCIP_INVALIDDATA;
3879
3881 SCIPerrorMessage("cannot fix a fixed variable again\n"); /*lint !e527*/
3882 SCIPABORT(); /* case is already handled in earlier if condition */
3883 return SCIP_INVALIDDATA; /*lint !e527*/
3884
3886 /* fix aggregation variable y in x = a*y + c, instead of fixing x directly */
3887 assert(SCIPsetIsZero(set, var->obj));
3888 assert(!SCIPsetIsZero(set, var->data.aggregate.scalar));
3889 if( SCIPsetIsInfinity(set, fixedval) || SCIPsetIsInfinity(set, -fixedval) )
3890 childfixedval = (var->data.aggregate.scalar < 0.0 ? -fixedval : fixedval);
3891 else
3892 childfixedval = (fixedval - var->data.aggregate.constant)/var->data.aggregate.scalar;
3893 SCIP_CALL( SCIPvarFix(var->data.aggregate.var, blkmem, set, stat, transprob, origprob, primal, tree, reopt, lp,
3894 branchcand, eventfilter, eventqueue, cliquetable, childfixedval, infeasible, fixed) );
3895 break;
3896
3898 SCIPerrorMessage("cannot fix a multiple aggregated variable\n");
3899 SCIPABORT();
3900 return SCIP_INVALIDDATA; /*lint !e527*/
3901
3903 /* fix negation variable x in x' = offset - x, instead of fixing x' directly */
3904 assert(SCIPsetIsZero(set, var->obj));
3905 assert(var->negatedvar != NULL);
3907 assert(var->negatedvar->negatedvar == var);
3908 SCIP_CALL( SCIPvarFix(var->negatedvar, blkmem, set, stat, transprob, origprob, primal, tree, reopt, lp,
3909 branchcand, eventfilter, eventqueue, cliquetable, var->data.negate.constant - fixedval, infeasible, fixed) );
3910 break;
3911
3912 default:
3913 SCIPerrorMessage("unknown variable status\n");
3914 return SCIP_INVALIDDATA;
3915 }
3916
3917 return SCIP_OKAY;
3918}
3919
3920/** transforms given variables, scalars and constant to the corresponding active variables, scalars and constant
3921 *
3922 * If the number of needed active variables is greater than the available slots in the variable array, nothing happens except
3923 * that the required size is stored in the corresponding variable; hence, if afterwards the required size is greater than the
3924 * available slots (varssize), nothing happens; otherwise, the active variable representation is stored in the arrays.
3925 *
3926 * The reason for this approach is that we cannot reallocate memory, since we do not know how the
3927 * memory has been allocated (e.g., by a C++ 'new' or SCIP functions).
3928 */
3930 SCIP_SET* set, /**< global SCIP settings */
3931 SCIP_VAR** vars, /**< variable array to get active variables */
3932 SCIP_Real* scalars, /**< scalars a_1, ..., a_n in linear sum a_1*x_1 + ... + a_n*x_n + c */
3933 int* nvars, /**< pointer to number of variables and values in vars and scalars array */
3934 int varssize, /**< available slots in vars and scalars array */
3935 SCIP_Real* constant, /**< pointer to constant c in linear sum a_1*x_1 + ... + a_n*x_n + c */
3936 int* requiredsize, /**< pointer to store the required array size for the active variables */
3937 SCIP_Bool mergemultiples /**< should multiple occurrences of a var be replaced by a single coeff? */
3938 )
3939{
3940 SCIP_VAR** activevars;
3941 SCIP_Real* activescalars;
3942 int nactivevars;
3943 SCIP_Real activeconstant;
3944 SCIP_Bool activeconstantinf;
3945 int activevarssize;
3946
3947 SCIP_VAR* var;
3948 SCIP_Real scalar;
3949 int v;
3950 int k;
3951
3952 SCIP_VAR** tmpvars;
3953 SCIP_VAR** multvars;
3954 SCIP_Real* tmpscalars;
3955 SCIP_Real* multscalars;
3956 int tmpvarssize;
3957 int ntmpvars;
3958 int nmultvars;
3959
3960 SCIP_VAR* multvar;
3961 SCIP_Real multscalar;
3962 SCIP_Real multconstant;
3963 int pos;
3964
3965 int noldtmpvars;
3966
3967 SCIP_VAR** tmpvars2;
3968 SCIP_Real* tmpscalars2;
3969 int tmpvarssize2;
3970 int ntmpvars2;
3971
3972 SCIP_Bool sortagain = FALSE;
3973
3974 assert(set != NULL);
3975 assert(nvars != NULL);
3976 assert(scalars != NULL || *nvars == 0);
3977 assert(constant != NULL);
3978 assert(requiredsize != NULL);
3979 assert(*nvars <= varssize);
3980
3981 *requiredsize = 0;
3982
3983 if( *nvars == 0 )
3984 return SCIP_OKAY;
3985
3986 assert(vars != NULL);
3987
3988 /* handle the "easy" case of just one variable and avoid memory allocation if the variable is already active */
3989 if( *nvars == 1 && (vars[0]->varstatus == ((int) SCIP_VARSTATUS_COLUMN) || vars[0]->varstatus == ((int) SCIP_VARSTATUS_LOOSE)) )
3990 {
3991 *requiredsize = 1;
3992
3993 return SCIP_OKAY;
3994 }
3995
3996 nactivevars = 0;
3997 activeconstant = 0.0;
3998 activeconstantinf = FALSE;
3999 activevarssize = (*nvars) * 2;
4000 ntmpvars = *nvars;
4001 tmpvarssize = *nvars;
4002
4003 tmpvarssize2 = 1;
4004
4005 /* allocate temporary memory */
4006 SCIP_CALL( SCIPsetAllocBufferArray(set, &tmpvars2, tmpvarssize2) );
4007 SCIP_CALL( SCIPsetAllocBufferArray(set, &tmpscalars2, tmpvarssize2) );
4008 SCIP_CALL( SCIPsetAllocBufferArray(set, &activevars, activevarssize) );
4009 SCIP_CALL( SCIPsetAllocBufferArray(set, &activescalars, activevarssize) );
4010 SCIP_CALL( SCIPsetDuplicateBufferArray(set, &tmpvars, vars, ntmpvars) );
4011 SCIP_CALL( SCIPsetDuplicateBufferArray(set, &tmpscalars, scalars, ntmpvars) );
4012
4013 /* to avoid unnecessary expanding of variable arrays while disaggregating several variables multiple times combine same variables
4014 * first, first get all corresponding variables with status loose, column, multaggr or fixed
4015 */
4016 for( v = ntmpvars - 1; v >= 0; --v )
4017 {
4018 var = tmpvars[v];
4019 scalar = tmpscalars[v];
4020
4021 assert(var != NULL);
4022 /* transforms given variable, scalar and constant to the corresponding active, fixed, or
4023 * multi-aggregated variable, scalar and constant; if the variable resolves to a fixed
4024 * variable, "scalar" will be 0.0 and the value of the sum will be stored in "constant".
4025 */
4026 SCIP_CALL( SCIPvarGetProbvarSum(&var, set, &scalar, &activeconstant) );
4027 assert(var != NULL);
4028
4029 assert(SCIPsetIsInfinity(set, activeconstant) == (activeconstant == SCIPsetInfinity(set))); /*lint !e777*/
4030 assert(SCIPsetIsInfinity(set, -activeconstant) == (activeconstant == -SCIPsetInfinity(set))); /*lint !e777*/
4031
4032 activeconstantinf = SCIPsetIsInfinity(set, activeconstant) || SCIPsetIsInfinity(set, -activeconstant);
4033
4038
4039 tmpvars[v] = var;
4040 tmpscalars[v] = scalar;
4041 }
4042 noldtmpvars = ntmpvars;
4043
4044 /* sort all variables to combine equal variables easily */
4045 SCIPsortPtrReal((void**)tmpvars, tmpscalars, SCIPvarComp, noldtmpvars);
4046 ntmpvars = 0;
4047 for( v = 1; v < noldtmpvars; ++v )
4048 {
4049 /* combine same variables */
4050 if( SCIPvarCompare(tmpvars[v], tmpvars[ntmpvars]) == 0 )
4051 {
4052 tmpscalars[ntmpvars] += tmpscalars[v];
4053 }
4054 else
4055 {
4056 ++ntmpvars;
4057 if( v > ntmpvars )
4058 {
4059 tmpscalars[ntmpvars] = tmpscalars[v];
4060 tmpvars[ntmpvars] = tmpvars[v];
4061 }
4062 }
4063 }
4064 ++ntmpvars;
4065
4066#ifdef SCIP_MORE_DEBUG
4067 for( v = 1; v < ntmpvars; ++v )
4068 assert(SCIPvarCompare(tmpvars[v], tmpvars[v-1]) > 0);
4069#endif
4070
4071 /* collect for each variable the representation in active variables */
4072 while( ntmpvars >= 1 )
4073 {
4074 --ntmpvars;
4075 ntmpvars2 = 0;
4076 var = tmpvars[ntmpvars];
4077 scalar = tmpscalars[ntmpvars];
4078
4079 assert(var != NULL);
4080
4081 /* TODO: maybe we should test here on SCIPsetIsZero() instead of 0.0 */
4082 if( scalar == 0.0 )
4083 continue;
4084
4089
4090 switch( SCIPvarGetStatus(var) )
4091 {
4094 /* x = a*y + c */
4095 if( nactivevars >= activevarssize )
4096 {
4097 activevarssize *= 2;
4098 SCIP_CALL( SCIPsetReallocBufferArray(set, &activevars, activevarssize) );
4099 SCIP_CALL( SCIPsetReallocBufferArray(set, &activescalars, activevarssize) );
4100 assert(nactivevars < activevarssize);
4101 }
4102 activevars[nactivevars] = var;
4103 activescalars[nactivevars] = scalar;
4104 nactivevars++;
4105 break;
4106
4108 /* x = a_1*y_1 + ... + a_n*y_n + c */
4109 nmultvars = var->data.multaggr.nvars;
4110 multvars = var->data.multaggr.vars;
4111 multscalars = var->data.multaggr.scalars;
4112 sortagain = TRUE;
4113
4114 if( nmultvars + ntmpvars > tmpvarssize )
4115 {
4116 while( nmultvars + ntmpvars > tmpvarssize )
4117 tmpvarssize *= 2;
4118 SCIP_CALL( SCIPsetReallocBufferArray(set, &tmpvars, tmpvarssize) );
4119 SCIP_CALL( SCIPsetReallocBufferArray(set, &tmpscalars, tmpvarssize) );
4120 assert(nmultvars + ntmpvars <= tmpvarssize);
4121 }
4122
4123 if( nmultvars > tmpvarssize2 )
4124 {
4125 while( nmultvars > tmpvarssize2 )
4126 tmpvarssize2 *= 2;
4127 SCIP_CALL( SCIPsetReallocBufferArray(set, &tmpvars2, tmpvarssize2) );
4128 SCIP_CALL( SCIPsetReallocBufferArray(set, &tmpscalars2, tmpvarssize2) );
4129 assert(nmultvars <= tmpvarssize2);
4130 }
4131
4132 --nmultvars;
4133
4134 for( ; nmultvars >= 0; --nmultvars )
4135 {
4136 multvar = multvars[nmultvars];
4137 multscalar = multscalars[nmultvars];
4138 multconstant = 0;
4139
4140 assert(multvar != NULL);
4141 SCIP_CALL( SCIPvarGetProbvarSum(&multvar, set, &multscalar, &multconstant) );
4142 assert(multvar != NULL);
4143
4148
4149 if( !activeconstantinf )
4150 {
4151 assert(!SCIPsetIsInfinity(set, scalar) && !SCIPsetIsInfinity(set, -scalar));
4152
4153 if( SCIPsetIsInfinity(set, multconstant) || SCIPsetIsInfinity(set, -multconstant) )
4154 {
4155 assert(scalar != 0.0);
4156 if( scalar * multconstant > 0.0 )
4157 {
4158 activeconstant = SCIPsetInfinity(set);
4159 activeconstantinf = TRUE;
4160 }
4161 else
4162 {
4163 activeconstant = -SCIPsetInfinity(set);
4164 activeconstantinf = TRUE;
4165 }
4166 }
4167 else
4168 activeconstant += scalar * multconstant;
4169 }
4170#ifndef NDEBUG
4171 else
4172 {
4173 assert(!SCIPsetIsInfinity(set, activeconstant) || !(scalar * multconstant < 0.0 &&
4174 (SCIPsetIsInfinity(set, multconstant) || SCIPsetIsInfinity(set, -multconstant))));
4175 assert(!SCIPsetIsInfinity(set, -activeconstant) || !(scalar * multconstant > 0.0 &&
4176 (SCIPsetIsInfinity(set, multconstant) || SCIPsetIsInfinity(set, -multconstant))));
4177 }
4178#endif
4179
4180 if( SCIPsortedvecFindPtr((void**)tmpvars, SCIPvarComp, multvar, ntmpvars, &pos) )
4181 {
4182 assert(SCIPvarCompare(tmpvars[pos], multvar) == 0);
4183 tmpscalars[pos] += scalar * multscalar;
4184 }
4185 else
4186 {
4187 tmpvars2[ntmpvars2] = multvar;
4188 tmpscalars2[ntmpvars2] = scalar * multscalar;
4189 ++(ntmpvars2);
4190 assert(ntmpvars2 <= tmpvarssize2);
4191 }
4192 }
4193
4194 if( ntmpvars2 > 0 )
4195 {
4196 /* sort all variables to combine equal variables easily */
4197 SCIPsortPtrReal((void**)tmpvars2, tmpscalars2, SCIPvarComp, ntmpvars2);
4198 pos = 0;
4199 for( v = 1; v < ntmpvars2; ++v )
4200 {
4201 /* combine same variables */
4202 if( SCIPvarCompare(tmpvars2[v], tmpvars2[pos]) == 0 )
4203 {
4204 tmpscalars2[pos] += tmpscalars2[v];
4205 }
4206 else
4207 {
4208 ++pos;
4209 if( v > pos )
4210 {
4211 tmpscalars2[pos] = tmpscalars2[v];
4212 tmpvars2[pos] = tmpvars2[v];
4213 }
4214 }
4215 }
4216 ntmpvars2 = pos + 1;
4217#ifdef SCIP_MORE_DEBUG
4218 for( v = 1; v < ntmpvars2; ++v )
4219 {
4220 assert(SCIPvarCompare(tmpvars2[v], tmpvars2[v-1]) > 0);
4221 }
4222 for( v = 1; v < ntmpvars; ++v )
4223 {
4224 assert(SCIPvarCompare(tmpvars[v], tmpvars[v-1]) > 0);
4225 }
4226#endif
4227 v = ntmpvars - 1;
4228 k = ntmpvars2 - 1;
4229 pos = ntmpvars + ntmpvars2 - 1;
4230 ntmpvars += ntmpvars2;
4231
4232 while( v >= 0 && k >= 0 )
4233 {
4234 assert(pos >= 0);
4235 assert(SCIPvarCompare(tmpvars[v], tmpvars2[k]) != 0);
4236 if( SCIPvarCompare(tmpvars[v], tmpvars2[k]) >= 0 )
4237 {
4238 tmpvars[pos] = tmpvars[v];
4239 tmpscalars[pos] = tmpscalars[v];
4240 --v;
4241 }
4242 else
4243 {
4244 tmpvars[pos] = tmpvars2[k];
4245 tmpscalars[pos] = tmpscalars2[k];
4246 --k;
4247 }
4248 --pos;
4249 assert(pos >= 0);
4250 }
4251 while( v >= 0 )
4252 {
4253 assert(pos >= 0);
4254 tmpvars[pos] = tmpvars[v];
4255 tmpscalars[pos] = tmpscalars[v];
4256 --v;
4257 --pos;
4258 }
4259 while( k >= 0 )
4260 {
4261 assert(pos >= 0);
4262 tmpvars[pos] = tmpvars2[k];
4263 tmpscalars[pos] = tmpscalars2[k];
4264 --k;
4265 --pos;
4266 }
4267 }
4268#ifdef SCIP_MORE_DEBUG
4269 for( v = 1; v < ntmpvars; ++v )
4270 {
4271 assert(SCIPvarCompare(tmpvars[v], tmpvars[v-1]) > 0);
4272 }
4273#endif
4274
4275 if( !activeconstantinf )
4276 {
4277 assert(!SCIPsetIsInfinity(set, scalar) && !SCIPsetIsInfinity(set, -scalar));
4278
4279 multconstant = SCIPvarGetMultaggrConstant(var);
4280
4281 if( SCIPsetIsInfinity(set, multconstant) || SCIPsetIsInfinity(set, -multconstant) )
4282 {
4283 assert(scalar != 0.0);
4284 if( scalar * multconstant > 0.0 )
4285 {
4286 activeconstant = SCIPsetInfinity(set);
4287 activeconstantinf = TRUE;
4288 }
4289 else
4290 {
4291 activeconstant = -SCIPsetInfinity(set);
4292 activeconstantinf = TRUE;
4293 }
4294 }
4295 else
4296 activeconstant += scalar * multconstant;
4297 }
4298#ifndef NDEBUG
4299 else
4300 {
4301 multconstant = SCIPvarGetMultaggrConstant(var);
4302 assert(!SCIPsetIsInfinity(set, activeconstant) || !(scalar * multconstant < 0.0 &&
4303 (SCIPsetIsInfinity(set, multconstant) || SCIPsetIsInfinity(set, -multconstant))));
4304 assert(!SCIPsetIsInfinity(set, -activeconstant) || !(scalar * multconstant > 0.0 &&
4305 (SCIPsetIsInfinity(set, multconstant) || SCIPsetIsInfinity(set, -multconstant))));
4306 }
4307#endif
4308 break;
4309
4314 default:
4315 /* case x = c, but actually we should not be here, since SCIPvarGetProbvarSum() returns a scalar of 0.0 for
4316 * fixed variables and is handled already
4317 */
4318 assert(SCIPvarGetStatus(var) == SCIP_VARSTATUS_FIXED);
4319 assert(SCIPsetIsZero(set, var->glbdom.lb) && SCIPsetIsEQ(set, var->glbdom.lb, var->glbdom.ub));
4320 }
4321 }
4322
4323 if( mergemultiples )
4324 {
4325 if( sortagain )
4326 {
4327 /* sort variable and scalar array by variable index */
4328 SCIPsortPtrReal((void**)activevars, activescalars, SCIPvarComp, nactivevars);
4329
4330 /* eliminate duplicates and count required size */
4331 v = nactivevars - 1;
4332 while( v > 0 )
4333 {
4334 /* combine both variable since they are the same */
4335 if( SCIPvarCompare(activevars[v - 1], activevars[v]) == 0 )
4336 {
4337 if( activescalars[v - 1] + activescalars[v] != 0.0 )
4338 {
4339 activescalars[v - 1] += activescalars[v];
4340 --nactivevars;
4341 activevars[v] = activevars[nactivevars];
4342 activescalars[v] = activescalars[nactivevars];
4343 }
4344 else
4345 {
4346 --nactivevars;
4347 activevars[v] = activevars[nactivevars];
4348 activescalars[v] = activescalars[nactivevars];
4349 --nactivevars;
4350 --v;
4351 activevars[v] = activevars[nactivevars];
4352 activescalars[v] = activescalars[nactivevars];
4353 }
4354 }
4355 --v;
4356 }
4357 }
4358 /* the variables were added in reverse order, we revert the order now;
4359 * this should not be necessary, but not doing this changes the behavior sometimes
4360 */
4361 else
4362 {
4363 SCIP_VAR* tmpvar;
4364 SCIP_Real tmpscalar;
4365
4366 for( v = 0; v < nactivevars / 2; ++v )
4367 {
4368 tmpvar = activevars[v];
4369 tmpscalar = activescalars[v];
4370 activevars[v] = activevars[nactivevars - 1 - v];
4371 activescalars[v] = activescalars[nactivevars - 1 - v];
4372 activevars[nactivevars - 1 - v] = tmpvar;
4373 activescalars[nactivevars - 1 - v] = tmpscalar;
4374 }
4375 }
4376 }
4377 *requiredsize = nactivevars;
4378
4379 if( varssize >= *requiredsize )
4380 {
4381 assert(vars != NULL);
4382
4383 *nvars = *requiredsize;
4384
4385 if( !SCIPsetIsInfinity(set, *constant) && !SCIPsetIsInfinity(set, -(*constant)) )
4386 {
4387 /* if the activeconstant is infinite, the constant pointer gets the same value, otherwise add the value */
4388 if( activeconstantinf )
4389 (*constant) = activeconstant;
4390 else
4391 (*constant) += activeconstant;
4392 }
4393#ifndef NDEBUG
4394 else
4395 {
4396 assert(!SCIPsetIsInfinity(set, (*constant)) || !SCIPsetIsInfinity(set, -activeconstant));
4397 assert(!SCIPsetIsInfinity(set, -(*constant)) || !SCIPsetIsInfinity(set, activeconstant));
4398 }
4399#endif
4400
4401 /* copy active variable and scalar array to the given arrays */
4402 for( v = 0; v < *nvars; ++v )
4403 {
4404 vars[v] = activevars[v];
4405 scalars[v] = activescalars[v]; /*lint !e613*/
4406 }
4407 }
4408
4409 assert(SCIPsetIsInfinity(set, *constant) == ((*constant) == SCIPsetInfinity(set))); /*lint !e777*/
4410 assert(SCIPsetIsInfinity(set, -(*constant)) == ((*constant) == -SCIPsetInfinity(set))); /*lint !e777*/
4411
4412 SCIPsetFreeBufferArray(set, &tmpscalars);
4413 SCIPsetFreeBufferArray(set, &tmpvars);
4414 SCIPsetFreeBufferArray(set, &activescalars);
4415 SCIPsetFreeBufferArray(set, &activevars);
4416 SCIPsetFreeBufferArray(set, &tmpscalars2);
4417 SCIPsetFreeBufferArray(set, &tmpvars2);
4418
4419 return SCIP_OKAY;
4420}
4421
4422
4423/** flattens aggregation graph of multi-aggregated variable in order to avoid exponential recursion later on */
4425 SCIP_VAR* var, /**< problem variable */
4426 BMS_BLKMEM* blkmem, /**< block memory */
4427 SCIP_SET* set, /**< global SCIP settings */
4428 SCIP_EVENTQUEUE* eventqueue /**< event queue */
4429 )
4430{
4431 int nlocksup[NLOCKTYPES];
4432 int nlocksdown[NLOCKTYPES];
4433 SCIP_Real multconstant;
4434 int multvarssize;
4435 int nmultvars;
4436 int multrequiredsize;
4437 int i;
4438
4439 assert( var != NULL );
4440 assert( SCIPvarGetStatus(var) == SCIP_VARSTATUS_MULTAGGR );
4441 assert(var->scip == set->scip);
4442
4443 /* in order to update the locks on the active representation of the multi-aggregated variable, we remove all locks
4444 * on the current representation now and re-add the locks once the variable graph has been flattened, which
4445 * may lead to duplicate occurences of the same variable being merged
4446 *
4447 * Here is an example. Assume we have the multi-aggregation z = x + y.
4448 * z occures with positive coefficient in a <= constraint c1, so it has an uplock from there.
4449 * When the multi-aggregation is performed, all locks are added to the active representation,
4450 * so x and y both get an uplock from c1. However, z was not yet replaced by x + y in c1.
4451 * Next, a negation y = 1 - x is identified. Again, locks are moved, so that the uplock of y originating
4452 * from c1 is added to x as a downlock. Thus, x has both an up- and downlock from c1.
4453 * The multi-aggregation changes to z = x + 1 - x, which corresponds to the locks.
4454 * However, before z is replaced by that sum, SCIPvarFlattenAggregationGraph() is called
4455 * which changes z = x + y = x + 1 - x = 1, since it merges multiple occurences of the same variable.
4456 * The up- and downlock of x, however, is not removed when replacing z in c1 by its active representation,
4457 * because it is just 1 now. Therefore, we need to update locks when flattening the aggregation graph.
4458 * For this, the multi-aggregated variable knows its locks in addition to adding them to the active
4459 * representation, which corresponds to the locks from constraints where the variable was not replaced yet.
4460 * By removing the locks here, based on the old representation and adding them again after flattening,
4461 * we ensure that the locks are correct afterwards if coefficients were merged.
4462 */
4463 for( i = 0; i < NLOCKTYPES; ++i )
4464 {
4465 nlocksup[i] = var->nlocksup[i];
4466 nlocksdown[i] = var->nlocksdown[i];
4467
4468 SCIP_CALL( SCIPvarAddLocks(var, blkmem, set, eventqueue, (SCIP_LOCKTYPE) i, -nlocksdown[i], -nlocksup[i]) );
4469 }
4470
4471 multconstant = var->data.multaggr.constant;
4472 nmultvars = var->data.multaggr.nvars;
4473 multvarssize = var->data.multaggr.varssize;
4474
4475 SCIP_CALL( SCIPvarGetActiveRepresentatives(set, var->data.multaggr.vars, var->data.multaggr.scalars, &nmultvars, multvarssize, &multconstant, &multrequiredsize, TRUE) );
4476
4477 if( multrequiredsize > multvarssize )
4478 {
4479 SCIP_ALLOC( BMSreallocBlockMemoryArray(blkmem, &(var->data.multaggr.vars), multvarssize, multrequiredsize) );
4480 SCIP_ALLOC( BMSreallocBlockMemoryArray(blkmem, &(var->data.multaggr.scalars), multvarssize, multrequiredsize) );
4481 multvarssize = multrequiredsize;
4482 SCIP_CALL( SCIPvarGetActiveRepresentatives(set, var->data.multaggr.vars, var->data.multaggr.scalars, &nmultvars, multvarssize, &multconstant, &multrequiredsize, TRUE) );
4483 assert( multrequiredsize <= multvarssize );
4484 }
4485 /**@note After the flattening the multi aggregation might resolve to be in fact an aggregation (or even a fixing?).
4486 * This issue is not resolved right now, since var->data.multaggr.nvars < 2 should not cause troubles. However, one
4487 * may loose performance hereby, since aggregated variables are easier to handle.
4488 *
4489 * Note, that there are two cases where SCIPvarFlattenAggregationGraph() is called: The easier one is that it is
4490 * called while installing the multi-aggregation. in principle, the described issue could be handled straightforward
4491 * in this case by aggregating or fixing the variable instead. The more complicated case is the one, when the
4492 * multi-aggregation is used, e.g., in linear presolving (and the variable is already declared to be multi-aggregated).
4493 *
4494 * By now, it is not allowed to fix or aggregate multi-aggregated variables which would be necessary in this case.
4495 *
4496 * The same issue appears in the SCIPvarGetProbvar...() methods.
4497 */
4498
4499 var->data.multaggr.constant = multconstant;
4500 var->data.multaggr.nvars = nmultvars;
4501 var->data.multaggr.varssize = multvarssize;
4502
4503 for( i = 0; i < NLOCKTYPES; ++i )
4504 {
4505 SCIP_CALL( SCIPvarAddLocks(var, blkmem, set, eventqueue, (SCIP_LOCKTYPE) i, nlocksdown[i], nlocksup[i]) );
4506 }
4507
4508 return SCIP_OKAY;
4509}
4510
4511/** merge two variable histories together; a typical use case is that \p othervar is an image of the target variable
4512 * in a SCIP copy. Method should be applied with care, especially because no internal checks are performed whether
4513 * the history merge is reasonable
4514 *
4515 * @note Do not use this method if the two variables originate from two SCIP's with different objective functions, since
4516 * this corrupts the variable pseudo costs
4517 * @note Apply with care; no internal checks are performed if the two variables should be merged
4518 */
4520 SCIP_VAR* targetvar, /**< the variable that should contain both histories afterwards */
4521 SCIP_VAR* othervar, /**< the variable whose history is to be merged with that of the target variable */
4522 SCIP_STAT* stat /**< problem statistics */
4523 )
4524{
4525 /* merge only the history of the current run into the target history */
4526 SCIPhistoryUnite(targetvar->history, othervar->historycrun, FALSE);
4527
4528 /* apply the changes also to the global history */
4529 SCIPhistoryUnite(stat->glbhistory, othervar->historycrun, FALSE);
4530}
4531
4532/** sets the history of a variable; this method is typically used within reoptimization to keep and update the variable
4533 * history over several iterations
4534 */
4536 SCIP_VAR* var, /**< variable */
4537 SCIP_HISTORY* history, /**< the history which is to set */
4538 SCIP_STAT* stat /**< problem statistics */
4539 )
4540{
4541 /* merge only the history of the current run into the target history */
4542 SCIPhistoryUnite(var->history, history, FALSE);
4543
4544 /* apply the changes also to the global history */
4545 SCIPhistoryUnite(stat->glbhistory, history, FALSE);
4546}
4547
4548/** tightens the bounds of both variables in aggregation x = a*y + c */
4549static
4551 SCIP_VAR* var, /**< problem variable */
4552 BMS_BLKMEM* blkmem, /**< block memory */
4553 SCIP_SET* set, /**< global SCIP settings */
4554 SCIP_STAT* stat, /**< problem statistics */
4555 SCIP_PROB* transprob, /**< tranformed problem data */
4556 SCIP_PROB* origprob, /**< original problem data */
4557 SCIP_PRIMAL* primal, /**< primal data */
4558 SCIP_TREE* tree, /**< branch and bound tree */
4559 SCIP_REOPT* reopt, /**< reoptimization data structure */
4560 SCIP_LP* lp, /**< current LP data */
4561 SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
4562 SCIP_EVENTFILTER* eventfilter, /**< event filter for global (not variable dependent) events */
4563 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
4564 SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
4565 SCIP_VAR* aggvar, /**< variable y in aggregation x = a*y + c */
4566 SCIP_Real scalar, /**< multiplier a in aggregation x = a*y + c */
4567 SCIP_Real constant, /**< constant shift c in aggregation x = a*y + c */
4568 SCIP_Bool* infeasible, /**< pointer to store whether the aggregation is infeasible */
4569 SCIP_Bool* fixed /**< pointer to store whether the variables were fixed */
4570 )
4571{
4572 SCIP_Real varlb;
4573 SCIP_Real varub;
4574 SCIP_Real aggvarlb;
4575 SCIP_Real aggvarub;
4576 SCIP_Bool aggvarbdschanged;
4577
4578 assert(var != NULL);
4579 assert(var->scip == set->scip);
4580 assert(aggvar != NULL);
4581 assert(!SCIPsetIsZero(set, scalar));
4582 assert(infeasible != NULL);
4583 assert(fixed != NULL);
4584
4585 *infeasible = FALSE;
4586 *fixed = FALSE;
4587
4588 SCIPsetDebugMsg(set, "updating bounds of variables in aggregation <%s> == %g*<%s> %+g\n", var->name, scalar, aggvar->name, constant);
4589 SCIPsetDebugMsg(set, " old bounds: <%s> [%g,%g] <%s> [%g,%g]\n",
4590 var->name, var->glbdom.lb, var->glbdom.ub, aggvar->name, aggvar->glbdom.lb, aggvar->glbdom.ub);
4591
4592 /* loop as long additional changes may be found */
4593 do
4594 {
4595 aggvarbdschanged = FALSE;
4596
4597 /* update the bounds of the aggregated variable x in x = a*y + c */
4598 if( scalar > 0.0 )
4599 {
4600 if( SCIPsetIsInfinity(set, -aggvar->glbdom.lb) )
4601 varlb = -SCIPsetInfinity(set);
4602 else
4603 varlb = aggvar->glbdom.lb * scalar + constant;
4604 if( SCIPsetIsInfinity(set, aggvar->glbdom.ub) )
4605 varub = SCIPsetInfinity(set);
4606 else
4607 varub = aggvar->glbdom.ub * scalar + constant;
4608 }
4609 else
4610 {
4611 if( SCIPsetIsInfinity(set, -aggvar->glbdom.lb) )
4612 varub = SCIPsetInfinity(set);
4613 else
4614 varub = aggvar->glbdom.lb * scalar + constant;
4615 if( SCIPsetIsInfinity(set, aggvar->glbdom.ub) )
4616 varlb = -SCIPsetInfinity(set);
4617 else
4618 varlb = aggvar->glbdom.ub * scalar + constant;
4619 }
4620 varlb = MAX(varlb, var->glbdom.lb);
4621 varub = MIN(varub, var->glbdom.ub);
4622 SCIPvarAdjustLb(var, set, &varlb);
4623 SCIPvarAdjustUb(var, set, &varub);
4624
4625 /* check the new bounds */
4626 if( SCIPsetIsGT(set, varlb, varub) )
4627 {
4628 /* the aggregation is infeasible */
4629 *infeasible = TRUE;
4630 return SCIP_OKAY;
4631 }
4632 else if( SCIPsetIsEQ(set, varlb, varub) )
4633 {
4634 /* the aggregated variable is fixed -> fix both variables */
4635 SCIP_CALL( SCIPvarFix(var, blkmem, set, stat, transprob, origprob, primal, tree, reopt, lp, branchcand,
4636 eventfilter, eventqueue, cliquetable, varlb, infeasible, fixed) );
4637 if( !(*infeasible) )
4638 {
4639 SCIP_Bool aggfixed;
4640
4641 SCIP_CALL( SCIPvarFix(aggvar, blkmem, set, stat, transprob, origprob, primal, tree, reopt, lp, branchcand,
4642 eventfilter, eventqueue, cliquetable, (varlb-constant)/scalar, infeasible, &aggfixed) );
4643 assert(*fixed == aggfixed);
4644 }
4645 return SCIP_OKAY;
4646 }
4647 else
4648 {
4649 if( SCIPsetIsGT(set, varlb, var->glbdom.lb) )
4650 {
4651 SCIP_CALL( SCIPvarChgLbGlobal(var, blkmem, set, stat, lp, branchcand, eventqueue, cliquetable, varlb) );
4652 }
4653 if( SCIPsetIsLT(set, varub, var->glbdom.ub) )
4654 {
4655 SCIP_CALL( SCIPvarChgUbGlobal(var, blkmem, set, stat, lp, branchcand, eventqueue, cliquetable, varub) );
4656 }
4657
4658 /* update the hole list of the aggregation variable */
4659 /**@todo update hole list of aggregation variable */
4660 }
4661
4662 /* update the bounds of the aggregation variable y in x = a*y + c -> y = (x-c)/a */
4663 if( scalar > 0.0 )
4664 {
4665 if( SCIPsetIsInfinity(set, -var->glbdom.lb) )
4666 aggvarlb = -SCIPsetInfinity(set);
4667 else
4668 aggvarlb = (var->glbdom.lb - constant) / scalar;
4669 if( SCIPsetIsInfinity(set, var->glbdom.ub) )
4670 aggvarub = SCIPsetInfinity(set);
4671 else
4672 aggvarub = (var->glbdom.ub - constant) / scalar;
4673 }
4674 else
4675 {
4676 if( SCIPsetIsInfinity(set, -var->glbdom.lb) )
4677 aggvarub = SCIPsetInfinity(set);
4678 else
4679 aggvarub = (var->glbdom.lb - constant) / scalar;
4680 if( SCIPsetIsInfinity(set, var->glbdom.ub) )
4681 aggvarlb = -SCIPsetInfinity(set);
4682 else
4683 aggvarlb = (var->glbdom.ub - constant) / scalar;
4684 }
4685 aggvarlb = MAX(aggvarlb, aggvar->glbdom.lb);
4686 aggvarub = MIN(aggvarub, aggvar->glbdom.ub);
4687 SCIPvarAdjustLb(aggvar, set, &aggvarlb);
4688 SCIPvarAdjustUb(aggvar, set, &aggvarub);
4689
4690 /* check the new bounds */
4691 if( SCIPsetIsGT(set, aggvarlb, aggvarub) )
4692 {
4693 /* the aggregation is infeasible */
4694 *infeasible = TRUE;
4695 return SCIP_OKAY;
4696 }
4697 else if( SCIPsetIsEQ(set, aggvarlb, aggvarub) )
4698 {
4699 /* the aggregation variable is fixed -> fix both variables */
4700 SCIP_CALL( SCIPvarFix(aggvar, blkmem, set, stat, transprob, origprob, primal, tree, reopt, lp, branchcand,
4701 eventfilter, eventqueue, cliquetable, aggvarlb, infeasible, fixed) );
4702 if( !(*infeasible) )
4703 {
4704 SCIP_Bool varfixed;
4705
4706 SCIP_CALL( SCIPvarFix(var, blkmem, set, stat, transprob, origprob, primal, tree, reopt, lp, branchcand,
4707 eventfilter, eventqueue, cliquetable, aggvarlb * scalar + constant, infeasible, &varfixed) );
4708 assert(*fixed == varfixed);
4709 }
4710 return SCIP_OKAY;
4711 }
4712 else
4713 {
4714 SCIP_Real oldbd;
4715 if( SCIPsetIsGT(set, aggvarlb, aggvar->glbdom.lb) )
4716 {
4717 oldbd = aggvar->glbdom.lb;
4718 SCIP_CALL( SCIPvarChgLbGlobal(aggvar, blkmem, set, stat, lp, branchcand, eventqueue, cliquetable, aggvarlb) );
4719 aggvarbdschanged = !SCIPsetIsEQ(set, oldbd, aggvar->glbdom.lb);
4720 }
4721 if( SCIPsetIsLT(set, aggvarub, aggvar->glbdom.ub) )
4722 {
4723 oldbd = aggvar->glbdom.ub;
4724 SCIP_CALL( SCIPvarChgUbGlobal(aggvar, blkmem, set, stat, lp, branchcand, eventqueue, cliquetable, aggvarub) );
4725 aggvarbdschanged = aggvarbdschanged || !SCIPsetIsEQ(set, oldbd, aggvar->glbdom.ub);
4726 }
4727
4728 /* update the hole list of the aggregation variable */
4729 /**@todo update hole list of aggregation variable */
4730 }
4731 }
4732 while( aggvarbdschanged );
4733
4734 SCIPsetDebugMsg(set, " new bounds: <%s> [%g,%g] <%s> [%g,%g]\n",
4735 var->name, var->glbdom.lb, var->glbdom.ub, aggvar->name, aggvar->glbdom.lb, aggvar->glbdom.ub);
4736
4737 return SCIP_OKAY;
4738}
4739
4740/** converts loose variable into aggregated variable */
4742 SCIP_VAR* var, /**< loose problem variable */
4743 BMS_BLKMEM* blkmem, /**< block memory */
4744 SCIP_SET* set, /**< global SCIP settings */
4745 SCIP_STAT* stat, /**< problem statistics */
4746 SCIP_PROB* transprob, /**< tranformed problem data */
4747 SCIP_PROB* origprob, /**< original problem data */
4748 SCIP_PRIMAL* primal, /**< primal data */
4749 SCIP_TREE* tree, /**< branch and bound tree */
4750 SCIP_REOPT* reopt, /**< reoptimization data structure */
4751 SCIP_LP* lp, /**< current LP data */
4752 SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
4753 SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
4754 SCIP_EVENTFILTER* eventfilter, /**< event filter for global (not variable dependent) events */
4755 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
4756 SCIP_VAR* aggvar, /**< loose variable y in aggregation x = a*y + c */
4757 SCIP_Real scalar, /**< multiplier a in aggregation x = a*y + c */
4758 SCIP_Real constant, /**< constant shift c in aggregation x = a*y + c */
4759 SCIP_Bool* infeasible, /**< pointer to store whether the aggregation is infeasible */
4760 SCIP_Bool* aggregated /**< pointer to store whether the aggregation was successful */
4761 )
4762{
4763 SCIP_VAR** vars;
4764 SCIP_Real* coefs;
4765 SCIP_Real* constants;
4766 SCIP_Real obj;
4767 SCIP_Real branchfactor;
4768 SCIP_Bool fixed;
4769 int branchpriority;
4770 int nlocksdown[NLOCKTYPES];
4771 int nlocksup[NLOCKTYPES];
4772 int nvbds;
4773 int i;
4774 int j;
4775
4776 assert(var != NULL);
4777 assert(aggvar != NULL);
4778 assert(var->scip == set->scip);
4779 assert(var->glbdom.lb == var->locdom.lb); /*lint !e777*/
4780 assert(var->glbdom.ub == var->locdom.ub); /*lint !e777*/
4781 assert(SCIPvarGetStatus(var) == SCIP_VARSTATUS_LOOSE);
4782 assert(!SCIPeventqueueIsDelayed(eventqueue)); /* otherwise, the pseudo objective value update gets confused */
4783 assert(infeasible != NULL);
4784 assert(aggregated != NULL);
4785
4786 *infeasible = FALSE;
4787 *aggregated = FALSE;
4788
4789 /* get active problem variable of aggregation variable */
4790 SCIP_CALL( SCIPvarGetProbvarSum(&aggvar, set, &scalar, &constant) );
4791
4792 /* aggregation is a fixing, if the scalar is zero */
4793 if( SCIPsetIsZero(set, scalar) )
4794 {
4795 SCIP_CALL( SCIPvarFix(var, blkmem, set, stat, transprob, origprob, primal, tree, reopt, lp, branchcand, eventfilter,
4796 eventqueue, cliquetable, constant, infeasible, aggregated) );
4797 goto TERMINATE;
4798 }
4799
4800 /* don't perform the aggregation if the aggregation variable is multi-aggregated itself */
4802 return SCIP_OKAY;
4803
4804 /**@todo currently we don't perform the aggregation if the aggregation variable has a non-empty hole list; this
4805 * should be changed in the future
4806 */
4807 if( SCIPvarGetHolelistGlobal(var) != NULL )
4808 return SCIP_OKAY;
4809
4810 /* if the variable is not allowed to be aggregated */
4811 if( SCIPvarDoNotAggr(var) )
4812 {
4813 SCIPsetDebugMsg(set, "variable is not allowed to be aggregated.\n");
4814 return SCIP_OKAY;
4815 }
4816
4817 assert(aggvar->glbdom.lb == aggvar->locdom.lb); /*lint !e777*/
4818 assert(aggvar->glbdom.ub == aggvar->locdom.ub); /*lint !e777*/
4819 assert(SCIPvarGetStatus(aggvar) == SCIP_VARSTATUS_LOOSE);
4820
4821 SCIPsetDebugMsg(set, "aggregate variable <%s>[%g,%g] == %g*<%s>[%g,%g] %+g\n", var->name, var->glbdom.lb, var->glbdom.ub,
4822 scalar, aggvar->name, aggvar->glbdom.lb, aggvar->glbdom.ub, constant);
4823
4824 /* if variable and aggregation variable are equal, the variable can be fixed: x == a*x + c => x == c/(1-a) */
4825 if( var == aggvar )
4826 {
4827 if( SCIPsetIsEQ(set, scalar, 1.0) )
4828 *infeasible = !SCIPsetIsZero(set, constant);
4829 else
4830 {
4831 SCIP_CALL( SCIPvarFix(var, blkmem, set, stat, transprob, origprob, primal, tree, reopt, lp, branchcand,
4832 eventfilter, eventqueue, cliquetable, constant/(1.0-scalar), infeasible, aggregated) );
4833 }
4834 goto TERMINATE;
4835 }
4836
4837 /* tighten the bounds of aggregated and aggregation variable */
4838 SCIP_CALL( varUpdateAggregationBounds(var, blkmem, set, stat, transprob, origprob, primal, tree, reopt, lp,
4839 branchcand, eventfilter, eventqueue, cliquetable, aggvar, scalar, constant, infeasible, &fixed) );
4840 if( *infeasible || fixed )
4841 {
4842 *aggregated = fixed;
4843 goto TERMINATE;
4844 }
4845
4846 /* delete implications and variable bounds of the aggregated variable from other variables, but keep them in the
4847 * aggregated variable
4848 */
4849 SCIP_CALL( SCIPvarRemoveCliquesImplicsVbs(var, blkmem, cliquetable, set, FALSE, FALSE, FALSE) );
4850
4851 /* set the aggregated variable's objective value to 0.0 */
4852 obj = var->obj;
4853 SCIP_CALL( SCIPvarChgObj(var, blkmem, set, transprob, primal, lp, eventqueue, 0.0) );
4854
4855 /* unlock all locks */
4856 for( i = 0; i < NLOCKTYPES; i++ )
4857 {
4858 nlocksdown[i] = var->nlocksdown[i];
4859 nlocksup[i] = var->nlocksup[i];
4860
4861 var->nlocksdown[i] = 0;
4862 var->nlocksup[i] = 0;
4863 }
4864
4865 /* check, if variable should be used as NEGATED variable of the aggregation variable */
4866 if( SCIPvarIsBinary(var) && SCIPvarIsBinary(aggvar)
4867 && var->negatedvar == NULL && aggvar->negatedvar == NULL
4868 && SCIPsetIsEQ(set, scalar, -1.0) && SCIPsetIsEQ(set, constant, 1.0) )
4869 {
4870 /* link both variables as negation pair */
4871 var->varstatus = SCIP_VARSTATUS_NEGATED; /*lint !e641*/
4872 var->data.negate.constant = 1.0;
4873 var->negatedvar = aggvar;
4874 aggvar->negatedvar = var;
4875
4876 /* copy donot(mult)aggr status */
4877 aggvar->donotaggr |= var->donotaggr;
4878 aggvar->donotmultaggr |= var->donotmultaggr;
4879
4880 /* mark both variables to be non-deletable */
4883 }
4884 else
4885 {
4886 /* convert variable into aggregated variable */
4887 var->varstatus = SCIP_VARSTATUS_AGGREGATED; /*lint !e641*/
4888 var->data.aggregate.var = aggvar;
4889 var->data.aggregate.scalar = scalar;
4890 var->data.aggregate.constant = constant;
4891
4892 /* copy donot(mult)aggr status */
4893 aggvar->donotaggr |= var->donotaggr;
4894 aggvar->donotmultaggr |= var->donotmultaggr;
4895
4896 /* mark both variables to be non-deletable */
4899 }
4900
4901 /* make aggregated variable a parent of the aggregation variable */
4902 SCIP_CALL( varAddParent(aggvar, blkmem, set, var) );
4903
4904 /* relock the variable, thus increasing the locks of the aggregation variable */
4905 for( i = 0; i < NLOCKTYPES; i++ )
4906 {
4907 SCIP_CALL( SCIPvarAddLocks(var, blkmem, set, eventqueue, (SCIP_LOCKTYPE) i, nlocksdown[i], nlocksup[i]) );
4908 }
4909
4910 /* move the variable bounds to the aggregation variable:
4911 * - add all variable bounds again to the variable, thus adding it to the aggregation variable
4912 * - free the variable bounds data structures
4913 */
4914 if( var->vlbs != NULL )
4915 {
4916 nvbds = SCIPvboundsGetNVbds(var->vlbs);
4917 vars = SCIPvboundsGetVars(var->vlbs);
4918 coefs = SCIPvboundsGetCoefs(var->vlbs);
4919 constants = SCIPvboundsGetConstants(var->vlbs);
4920 for( i = 0; i < nvbds && !(*infeasible); ++i )
4921 {
4922 SCIP_CALL( SCIPvarAddVlb(var, blkmem, set, stat, transprob, origprob, tree, reopt, lp, cliquetable, branchcand,
4923 eventqueue, vars[i], coefs[i], constants[i], FALSE, infeasible, NULL) );
4924 }
4925 }
4926 if( var->vubs != NULL )
4927 {
4928 nvbds = SCIPvboundsGetNVbds(var->vubs);
4929 vars = SCIPvboundsGetVars(var->vubs);
4930 coefs = SCIPvboundsGetCoefs(var->vubs);
4931 constants = SCIPvboundsGetConstants(var->vubs);
4932 for( i = 0; i < nvbds && !(*infeasible); ++i )
4933 {
4934 SCIP_CALL( SCIPvarAddVub(var, blkmem, set, stat, transprob, origprob, tree, reopt, lp, cliquetable, branchcand,
4935 eventqueue, vars[i], coefs[i], constants[i], FALSE, infeasible, NULL) );
4936 }
4937 }
4938 SCIPvboundsFree(&var->vlbs, blkmem);
4939 SCIPvboundsFree(&var->vubs, blkmem);
4940
4941 /* move the implications to the aggregation variable:
4942 * - add all implications again to the variable, thus adding it to the aggregation variable
4943 * - free the implications data structures
4944 */
4945 if( var->implics != NULL && SCIPvarGetType(aggvar) == SCIP_VARTYPE_BINARY )
4946 {
4947 assert(SCIPvarIsBinary(var));
4948 for( i = 0; i < 2; ++i )
4949 {
4950 SCIP_VAR** implvars;
4951 SCIP_BOUNDTYPE* impltypes;
4952 SCIP_Real* implbounds;
4953 int nimpls;
4954
4955 nimpls = SCIPimplicsGetNImpls(var->implics, (SCIP_Bool)i);
4956 implvars = SCIPimplicsGetVars(var->implics, (SCIP_Bool)i);
4957 impltypes = SCIPimplicsGetTypes(var->implics, (SCIP_Bool)i);
4958 implbounds = SCIPimplicsGetBounds(var->implics, (SCIP_Bool)i);
4959
4960 for( j = 0; j < nimpls && !(*infeasible); ++j )
4961 {
4962 /* @todo can't we omit transitive closure, because it should already have been done when adding the
4963 * implication to the aggregated variable?
4964 */
4965 SCIP_CALL( SCIPvarAddImplic(var, blkmem, set, stat, transprob, origprob, tree, reopt, lp, cliquetable,
4966 branchcand, eventqueue, (SCIP_Bool)i, implvars[j], impltypes[j], implbounds[j], FALSE, infeasible,
4967 NULL) );
4968 assert(nimpls == SCIPimplicsGetNImpls(var->implics, (SCIP_Bool)i));
4969 }
4970 }
4971 }
4972 SCIPimplicsFree(&var->implics, blkmem);
4973
4974 /* add the history entries to the aggregation variable and clear the history of the aggregated variable */
4975 SCIPhistoryUnite(aggvar->history, var->history, scalar < 0.0);
4976 SCIPhistoryUnite(aggvar->historycrun, var->historycrun, scalar < 0.0);
4979
4980 /* update flags of aggregation variable */
4981 aggvar->removable &= var->removable;
4982
4983 /* update branching factors and priorities of both variables to be the maximum of both variables */
4984 branchfactor = MAX(aggvar->branchfactor, var->branchfactor);
4985 branchpriority = MAX(aggvar->branchpriority, var->branchpriority);
4986 SCIP_CALL( SCIPvarChgBranchFactor(aggvar, set, branchfactor) );
4987 SCIP_CALL( SCIPvarChgBranchPriority(aggvar, branchpriority) );
4988 SCIP_CALL( SCIPvarChgBranchFactor(var, set, branchfactor) );
4989 SCIP_CALL( SCIPvarChgBranchPriority(var, branchpriority) );
4990
4991 /* update branching direction of both variables to agree to a single direction */
4992 if( scalar >= 0.0 )
4993 {
4995 {
4997 }
4999 {
5001 }
5002 else if( var->branchdirection != aggvar->branchdirection )
5003 {
5005 }
5006 }
5007 else
5008 {
5010 {
5012 }
5014 {
5016 }
5017 else if( var->branchdirection != aggvar->branchdirection )
5018 {
5020 }
5021 }
5022
5023 if( var->probindex != -1 )
5024 {
5025 /* inform problem about the variable's status change */
5026 SCIP_CALL( SCIPprobVarChangedStatus(transprob, blkmem, set, branchcand, cliquetable, var) );
5027 }
5028
5029 /* reset the objective value of the aggregated variable, thus adjusting the objective value of the aggregation
5030 * variable and the problem's objective offset
5031 */
5032 SCIP_CALL( SCIPvarAddObj(var, blkmem, set, stat, transprob, origprob, primal, tree, reopt, lp, eventfilter, eventqueue, obj) );
5033
5034 /* issue VARFIXED event */
5035 SCIP_CALL( varEventVarFixed(var, blkmem, set, eventqueue, 1) );
5036
5037 *aggregated = TRUE;
5038
5039TERMINATE:
5040 /* check aggregation on debugging solution */
5041 if( *infeasible || *aggregated )
5042 SCIP_CALL( SCIPdebugCheckAggregation(set, var, &aggvar, &scalar, constant, 1) ); /*lint !e506 !e774*/
5043
5044 return SCIP_OKAY;
5045}
5046
5047/** Tries to aggregate an equality a*x + b*y == c consisting of two (implicit) integral active problem variables x and
5048 * y. An integer aggregation (i.e. integral coefficients a' and b', such that a'*x + b'*y == c') is searched.
5049 *
5050 * This can lead to the detection of infeasibility (e.g. if c' is fractional), or to a rejection of the aggregation
5051 * (denoted by aggregated == FALSE), if the resulting integer coefficients are too large and thus numerically instable.
5052 */
5053static
5055 SCIP_SET* set, /**< global SCIP settings */
5056 BMS_BLKMEM* blkmem, /**< block memory */
5057 SCIP_STAT* stat, /**< problem statistics */
5058 SCIP_PROB* transprob, /**< tranformed problem data */
5059 SCIP_PROB* origprob, /**< original problem data */
5060 SCIP_PRIMAL* primal, /**< primal data */
5061 SCIP_TREE* tree, /**< branch and bound tree */
5062 SCIP_REOPT* reopt, /**< reoptimization data structure */
5063 SCIP_LP* lp, /**< current LP data */
5064 SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
5065 SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
5066 SCIP_EVENTFILTER* eventfilter, /**< event filter for global (not variable dependent) events */
5067 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
5068 SCIP_VAR* varx, /**< integral variable x in equality a*x + b*y == c */
5069 SCIP_VAR* vary, /**< integral variable y in equality a*x + b*y == c */
5070 SCIP_Real scalarx, /**< multiplier a in equality a*x + b*y == c */
5071 SCIP_Real scalary, /**< multiplier b in equality a*x + b*y == c */
5072 SCIP_Real rhs, /**< right hand side c in equality a*x + b*y == c */
5073 SCIP_Bool* infeasible, /**< pointer to store whether the aggregation is infeasible */
5074 SCIP_Bool* aggregated /**< pointer to store whether the aggregation was successful */
5075 )
5076{
5077 SCIP_VAR* aggvar;
5078 char aggvarname[SCIP_MAXSTRLEN];
5079 SCIP_Longint scalarxn = 0;
5080 SCIP_Longint scalarxd = 0;
5081 SCIP_Longint scalaryn = 0;
5082 SCIP_Longint scalaryd = 0;
5085 SCIP_Longint c;
5086 SCIP_Longint scm;
5087 SCIP_Longint gcd;
5088 SCIP_Longint currentclass;
5089 SCIP_Longint classstep;
5090 SCIP_Longint xsol;
5091 SCIP_Longint ysol;
5092 SCIP_Bool success;
5093 SCIP_VARTYPE vartype;
5094
5095#define MAXDNOM 1000000LL
5096
5097 assert(set != NULL);
5098 assert(blkmem != NULL);
5099 assert(stat != NULL);
5100 assert(transprob != NULL);
5101 assert(origprob != NULL);
5102 assert(tree != NULL);
5103 assert(lp != NULL);
5104 assert(cliquetable != NULL);
5105 assert(branchcand != NULL);
5106 assert(eventqueue != NULL);
5107 assert(varx != NULL);
5108 assert(vary != NULL);
5109 assert(varx != vary);
5110 assert(infeasible != NULL);
5111 assert(aggregated != NULL);
5113 assert(SCIPvarGetStatus(varx) == SCIP_VARSTATUS_LOOSE);
5115 assert(SCIPvarGetStatus(vary) == SCIP_VARSTATUS_LOOSE);
5117 assert(!SCIPsetIsZero(set, scalarx));
5118 assert(!SCIPsetIsZero(set, scalary));
5119
5120 *infeasible = FALSE;
5121 *aggregated = FALSE;
5122
5123 /* if the variable is not allowed to be aggregated */
5124 if( SCIPvarDoNotAggr(varx) )
5125 {
5126 SCIPsetDebugMsg(set, "variable is not allowed to be aggregated.\n");
5127 return SCIP_OKAY;
5128 }
5129
5130 /* get rational representation of coefficients */
5131 success = SCIPrealToRational(scalarx, -SCIPsetEpsilon(set), SCIPsetEpsilon(set), MAXDNOM, &scalarxn, &scalarxd);
5132 if( success )
5133 success = SCIPrealToRational(scalary, -SCIPsetEpsilon(set), SCIPsetEpsilon(set), MAXDNOM, &scalaryn, &scalaryd);
5134 if( !success )
5135 return SCIP_OKAY;
5136 assert(scalarxd >= 1);
5137 assert(scalaryd >= 1);
5138
5139 /* multiply equality with smallest common denominator */
5140 scm = SCIPcalcSmaComMul(scalarxd, scalaryd);
5141 a = (scm/scalarxd)*scalarxn;
5142 b = (scm/scalaryd)*scalaryn;
5143 rhs *= scm;
5144
5145 /* divide equality by the greatest common divisor of a and b */
5146 gcd = SCIPcalcGreComDiv(ABS(a), ABS(b));
5147 a /= gcd;
5148 b /= gcd;
5149 rhs /= gcd;
5150 assert(a != 0);
5151 assert(b != 0);
5152
5153 /* check, if right hand side is integral */
5154 if( !SCIPsetIsFeasIntegral(set, rhs) )
5155 {
5156 *infeasible = TRUE;
5157 return SCIP_OKAY;
5158 }
5159 c = (SCIP_Longint)(SCIPsetFeasFloor(set, rhs));
5160
5161 /* check that the scalar and constant in the aggregation are not too large to avoid numerical problems */
5162 if( REALABS((SCIP_Real)(c/a)) > SCIPsetGetHugeValue(set) * SCIPsetFeastol(set) /*lint !e653*/
5163 || REALABS((SCIP_Real)(b)) > SCIPsetGetHugeValue(set) * SCIPsetFeastol(set) /*lint !e653*/
5164 || REALABS((SCIP_Real)(a)) > SCIPsetGetHugeValue(set) * SCIPsetFeastol(set) ) /*lint !e653*/
5165 {
5166 return SCIP_OKAY;
5167 }
5168
5169 /* check, if we are in an easy case with either |a| = 1 or |b| = 1 */
5170 if( (a == 1 || a == -1) && SCIPvarGetType(vary) == SCIP_VARTYPE_INTEGER )
5171 {
5172 /* aggregate x = - b/a*y + c/a */
5173 /*lint --e{653}*/
5174 SCIP_CALL( SCIPvarAggregate(varx, blkmem, set, stat, transprob, origprob, primal, tree, reopt, lp, cliquetable,
5175 branchcand, eventfilter, eventqueue, vary, (SCIP_Real)(-b/a), (SCIP_Real)(c/a), infeasible, aggregated) );
5176 assert(*aggregated);
5177 return SCIP_OKAY;
5178 }
5179 if( (b == 1 || b == -1) && SCIPvarGetType(varx) == SCIP_VARTYPE_INTEGER )
5180 {
5181 /* aggregate y = - a/b*x + c/b */
5182 /*lint --e{653}*/
5183 SCIP_CALL( SCIPvarAggregate(vary, blkmem, set, stat, transprob, origprob, primal, tree, reopt, lp, cliquetable,
5184 branchcand, eventfilter, eventqueue, varx, (SCIP_Real)(-a/b), (SCIP_Real)(c/b), infeasible, aggregated) );
5185 assert(*aggregated);
5186 return SCIP_OKAY;
5187 }
5188
5189 /* Both variables are integers, their coefficients are not multiples of each other, and they don't have any
5190 * common divisor. Let (x',y') be a solution of the equality
5191 * a*x + b*y == c -> a*x == c - b*y
5192 * Then x = -b*z + x', y = a*z + y' with z integral gives all solutions to the equality.
5193 */
5194
5195 /* find initial solution (x',y'):
5196 * - find y' such that c - b*y' is a multiple of a
5197 * - start in equivalence class c%a
5198 * - step through classes, where each step increases class number by (-b)%a, until class 0 is visited
5199 * - if equivalence class 0 is visited, we are done: y' equals the number of steps taken
5200 * - because a and b don't have a common divisor, each class is visited at most once, and at most a-1 steps are needed
5201 * - calculate x' with x' = (c - b*y')/a (which must be integral)
5202 *
5203 * Algorithm works for a > 0 only.
5204 */
5205 if( a < 0 )
5206 {
5207 a = -a;
5208 b = -b;
5209 c = -c;
5210 }
5211 assert(a > 0);
5212
5213 /* search upwards from ysol = 0 */
5214 ysol = 0;
5215 currentclass = c % a;
5216 if( currentclass < 0 )
5217 currentclass += a;
5218 assert(0 <= currentclass && currentclass < a);
5219
5220 classstep = (-b) % a;
5221
5222 if( classstep < 0 )
5223 classstep += a;
5224 assert(0 <= classstep && classstep < a);
5225
5226 while( currentclass != 0 )
5227 {
5228 assert(0 <= currentclass && currentclass < a);
5229 currentclass += classstep;
5230 if( currentclass >= a )
5231 currentclass -= a;
5232 ysol++;
5233 }
5234 assert(ysol < a);
5235 assert(((c - b*ysol) % a) == 0);
5236
5237 xsol = (c - b*ysol)/a;
5238
5239 /* determine variable type for new artificial variable:
5240 *
5241 * if both variables are implicit integer the new variable can be implicit too, because the integer implication on
5242 * these both variables should be enforced by some other variables, otherwise the new variable needs to be of
5243 * integral type
5244 */
5247
5248 /* feasible solutions are (x,y) = (x',y') + z*(-b,a)
5249 * - create new integer variable z with infinite bounds
5250 * - aggregate variable x = -b*z + x'
5251 * - aggregate variable y = a*z + y'
5252 * - the bounds of z are calculated automatically during aggregation
5253 */
5254 (void) SCIPsnprintf(aggvarname, SCIP_MAXSTRLEN, "agg%d", stat->nvaridx);
5255 SCIP_CALL( SCIPvarCreateTransformed(&aggvar, blkmem, set, stat,
5256 aggvarname, -SCIPsetInfinity(set), SCIPsetInfinity(set), 0.0, vartype,
5258 NULL, NULL, NULL, NULL, NULL) );
5259
5260 SCIP_CALL( SCIPprobAddVar(transprob, blkmem, set, lp, branchcand, eventfilter, eventqueue, aggvar) );
5261
5262 SCIP_CALL( SCIPvarAggregate(varx, blkmem, set, stat, transprob, origprob, primal, tree, reopt, lp, cliquetable,
5263 branchcand, eventfilter, eventqueue, aggvar, (SCIP_Real)(-b), (SCIP_Real)xsol, infeasible, aggregated) );
5264 assert(*aggregated || *infeasible);
5265
5266 if( !(*infeasible) )
5267 {
5268 SCIP_CALL( SCIPvarAggregate(vary, blkmem, set, stat, transprob, origprob, primal, tree, reopt, lp, cliquetable,
5269 branchcand, eventfilter, eventqueue, aggvar, (SCIP_Real)a, (SCIP_Real)ysol, infeasible, aggregated) );
5270 assert(*aggregated || *infeasible);
5271 }
5272
5273 /* release z */
5274 SCIP_CALL( SCIPvarRelease(&aggvar, blkmem, set, eventqueue, lp) );
5275
5276 return SCIP_OKAY; /*lint !e438*/
5277}
5278
5279/** performs second step of SCIPaggregateVars():
5280 * the variable to be aggregated is chosen among active problem variables x' and y', preferring a less strict variable
5281 * type as aggregation variable (i.e. continuous variables are preferred over implicit integers, implicit integers
5282 * or integers over binaries). If none of the variables is continuous, it is tried to find an integer
5283 * aggregation (i.e. integral coefficients a'' and b'', such that a''*x' + b''*y' == c''). This can lead to
5284 * the detection of infeasibility (e.g. if c'' is fractional), or to a rejection of the aggregation (denoted by
5285 * aggregated == FALSE), if the resulting integer coefficients are too large and thus numerically instable.
5286 *
5287 * @todo check for fixings, infeasibility, bound changes, or domain holes:
5288 * a) if there is no easy aggregation and we have one binary variable and another integer/implicit/binary variable
5289 * b) for implicit integer variables with fractional aggregation scalar (we cannot (for technical reasons) and do
5290 * not want to aggregate implicit integer variables, since we loose the corresponding divisibility property)
5291 */
5293 SCIP_SET* set, /**< global SCIP settings */
5294 BMS_BLKMEM* blkmem, /**< block memory */
5295 SCIP_STAT* stat, /**< problem statistics */
5296 SCIP_PROB* transprob, /**< tranformed problem data */
5297 SCIP_PROB* origprob, /**< original problem data */
5298 SCIP_PRIMAL* primal, /**< primal data */
5299 SCIP_TREE* tree, /**< branch and bound tree */
5300 SCIP_REOPT* reopt, /**< reoptimization data structure */
5301 SCIP_LP* lp, /**< current LP data */
5302 SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
5303 SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
5304 SCIP_EVENTFILTER* eventfilter, /**< event filter for global (not variable dependent) events */
5305 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
5306 SCIP_VAR* varx, /**< variable x in equality a*x + b*y == c */
5307 SCIP_VAR* vary, /**< variable y in equality a*x + b*y == c */
5308 SCIP_Real scalarx, /**< multiplier a in equality a*x + b*y == c */
5309 SCIP_Real scalary, /**< multiplier b in equality a*x + b*y == c */
5310 SCIP_Real rhs, /**< right hand side c in equality a*x + b*y == c */
5311 SCIP_Bool* infeasible, /**< pointer to store whether the aggregation is infeasible */
5312 SCIP_Bool* aggregated /**< pointer to store whether the aggregation was successful */
5313 )
5314{
5315 SCIP_Bool easyaggr;
5316
5317 assert(set != NULL);
5318 assert(blkmem != NULL);
5319 assert(stat != NULL);
5320 assert(transprob != NULL);
5321 assert(origprob != NULL);
5322 assert(tree != NULL);
5323 assert(lp != NULL);
5324 assert(cliquetable != NULL);
5325 assert(branchcand != NULL);
5326 assert(eventqueue != NULL);
5327 assert(varx != NULL);
5328 assert(vary != NULL);
5329 assert(varx != vary);
5330 assert(infeasible != NULL);
5331 assert(aggregated != NULL);
5333 assert(SCIPvarGetStatus(varx) == SCIP_VARSTATUS_LOOSE);
5334 assert(SCIPvarGetStatus(vary) == SCIP_VARSTATUS_LOOSE);
5335 assert(!SCIPsetIsZero(set, scalarx));
5336 assert(!SCIPsetIsZero(set, scalary));
5337
5338 *infeasible = FALSE;
5339 *aggregated = FALSE;
5340
5341 if( SCIPsetIsZero(set, scalarx / scalary) || SCIPsetIsZero(set, scalary / scalarx) )
5342 return SCIP_OKAY;
5343
5344 /* prefer aggregating the variable of more general type (preferred aggregation variable is varx) */
5345 if( SCIPvarGetType(vary) > SCIPvarGetType(varx) ||
5346 (SCIPvarGetType(vary) == SCIPvarGetType(varx) && !SCIPvarIsBinary(vary) && SCIPvarIsBinary(varx)) )
5347 {
5348 SCIP_VAR* var;
5349 SCIP_Real scalar;
5350
5351 /* switch the variables, such that varx is the variable of more general type (cont > implint > int > bin) */
5352 var = vary;
5353 vary = varx;
5354 varx = var;
5355 scalar = scalary;
5356 scalary = scalarx;
5357 scalarx = scalar;
5358 }
5359
5360 /* don't aggregate if the aggregation would lead to a binary variable aggregated to a non-binary variable */
5361 if( SCIPvarIsBinary(varx) && !SCIPvarIsBinary(vary) )
5362 return SCIP_OKAY;
5363
5364 assert(SCIPvarGetType(varx) >= SCIPvarGetType(vary));
5365
5366 /* figure out, which variable should be aggregated */
5367 easyaggr = FALSE;
5368
5369 /* check if it is an easy aggregation */
5371 {
5372 easyaggr = TRUE;
5373 }
5374 else if( SCIPsetIsFeasIntegral(set, scalary/scalarx) )
5375 {
5376 easyaggr = TRUE;
5377 }
5378 else if( SCIPsetIsFeasIntegral(set, scalarx/scalary) && SCIPvarGetType(vary) == SCIPvarGetType(varx) )
5379 {
5380 /* we have an easy aggregation if we flip the variables x and y */
5381 SCIP_VAR* var;
5382 SCIP_Real scalar;
5383
5384 /* switch the variables, such that varx is the aggregated variable */
5385 var = vary;
5386 vary = varx;
5387 varx = var;
5388 scalar = scalary;
5389 scalary = scalarx;
5390 scalarx = scalar;
5391 easyaggr = TRUE;
5392 }
5393 else if( SCIPvarGetType(varx) == SCIP_VARTYPE_CONTINUOUS )
5394 {
5395 /* the aggregation is still easy if both variables are continuous */
5396 assert(SCIPvarGetType(vary) == SCIP_VARTYPE_CONTINUOUS); /* otherwise we are in the first case */
5397 easyaggr = TRUE;
5398 }
5399
5400 /* did we find an "easy" aggregation? */
5401 if( easyaggr )
5402 {
5403 SCIP_Real scalar;
5404 SCIP_Real constant;
5405
5406 assert(SCIPvarGetType(varx) >= SCIPvarGetType(vary));
5407
5408 /* calculate aggregation scalar and constant: a*x + b*y == c => x == -b/a * y + c/a */
5409 scalar = -scalary/scalarx;
5410 constant = rhs/scalarx;
5411
5412 if( REALABS(constant) > SCIPsetGetHugeValue(set) * SCIPsetFeastol(set) ) /*lint !e653*/
5413 return SCIP_OKAY;
5414
5415 /* check aggregation for integer feasibility */
5418 && SCIPsetIsFeasIntegral(set, scalar) && !SCIPsetIsFeasIntegral(set, constant) )
5419 {
5420 *infeasible = TRUE;
5421 return SCIP_OKAY;
5422 }
5423
5424 /* if the aggregation scalar is fractional, we cannot (for technical reasons) and do not want to aggregate implicit integer variables,
5425 * since then we would loose the corresponding divisibility property
5426 */
5427 assert(SCIPvarGetType(varx) != SCIP_VARTYPE_IMPLINT || SCIPsetIsFeasIntegral(set, scalar));
5428
5429 /* aggregate the variable */
5430 SCIP_CALL( SCIPvarAggregate(varx, blkmem, set, stat, transprob, origprob, primal, tree, reopt, lp, cliquetable,
5431 branchcand, eventfilter, eventqueue, vary, scalar, constant, infeasible, aggregated) );
5432 assert(*aggregated || *infeasible || SCIPvarDoNotAggr(varx));
5433 }
5436 {
5437 /* the variables are both integral: we have to try to find an integer aggregation */
5438 SCIP_CALL( tryAggregateIntVars(set, blkmem, stat, transprob, origprob, primal, tree, reopt, lp, cliquetable,
5439 branchcand, eventfilter, eventqueue, varx, vary, scalarx, scalary, rhs, infeasible, aggregated) );
5440 }
5441
5442 return SCIP_OKAY;
5443}
5444
5445/** converts variable into multi-aggregated variable */
5447 SCIP_VAR* var, /**< problem variable */
5448 BMS_BLKMEM* blkmem, /**< block memory */
5449 SCIP_SET* set, /**< global SCIP settings */
5450 SCIP_STAT* stat, /**< problem statistics */
5451 SCIP_PROB* transprob, /**< tranformed problem data */
5452 SCIP_PROB* origprob, /**< original problem data */
5453 SCIP_PRIMAL* primal, /**< primal data */
5454 SCIP_TREE* tree, /**< branch and bound tree */
5455 SCIP_REOPT* reopt, /**< reoptimization data structure */
5456 SCIP_LP* lp, /**< current LP data */
5457 SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
5458 SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
5459 SCIP_EVENTFILTER* eventfilter, /**< event filter for global (not variable dependent) events */
5460 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
5461 int naggvars, /**< number n of variables in aggregation x = a_1*y_1 + ... + a_n*y_n + c */
5462 SCIP_VAR** aggvars, /**< variables y_i in aggregation x = a_1*y_1 + ... + a_n*y_n + c */
5463 SCIP_Real* scalars, /**< multipliers a_i in aggregation x = a_1*y_1 + ... + a_n*y_n + c */
5464 SCIP_Real constant, /**< constant shift c in aggregation x = a_1*y_1 + ... + a_n*y_n + c */
5465 SCIP_Bool* infeasible, /**< pointer to store whether the aggregation is infeasible */
5466 SCIP_Bool* aggregated /**< pointer to store whether the aggregation was successful */
5467 )
5468{
5469 SCIP_VAR** tmpvars;
5470 SCIP_Real* tmpscalars;
5471 SCIP_Real obj;
5472 SCIP_Real branchfactor;
5473 int branchpriority;
5474 SCIP_BRANCHDIR branchdirection;
5475 int nlocksdown[NLOCKTYPES];
5476 int nlocksup[NLOCKTYPES];
5477 int v;
5478 SCIP_Real tmpconstant;
5479 SCIP_Real tmpscalar;
5480 int ntmpvars;
5481 int tmpvarssize;
5482 int tmprequiredsize;
5483 int i;
5484
5485 assert(var != NULL);
5486 assert(var->scip == set->scip);
5487 assert(var->glbdom.lb == var->locdom.lb); /*lint !e777*/
5488 assert(var->glbdom.ub == var->locdom.ub); /*lint !e777*/
5489 assert(naggvars == 0 || aggvars != NULL);
5490 assert(naggvars == 0 || scalars != NULL);
5491 assert(infeasible != NULL);
5492 assert(aggregated != NULL);
5493
5494 SCIPsetDebugMsg(set, "trying multi-aggregating variable <%s> == ...%d vars... %+g\n", var->name, naggvars, constant);
5495
5496 *infeasible = FALSE;
5497 *aggregated = FALSE;
5498
5499 switch( SCIPvarGetStatus(var) )
5500 {
5502 if( var->data.original.transvar == NULL )
5503 {
5504 SCIPerrorMessage("cannot multi-aggregate an untransformed original variable\n");
5505 return SCIP_INVALIDDATA;
5506 }
5507 SCIP_CALL( SCIPvarMultiaggregate(var->data.original.transvar, blkmem, set, stat, transprob, origprob, primal, tree,
5508 reopt, lp, cliquetable, branchcand, eventfilter, eventqueue, naggvars, aggvars, scalars, constant, infeasible, aggregated) );
5509 break;
5510
5512 assert(!SCIPeventqueueIsDelayed(eventqueue)); /* otherwise, the pseudo objective value update gets confused */
5513
5514 /* check if we would create a self-reference */
5515 ntmpvars = naggvars;
5516 tmpvarssize = naggvars;
5517 tmpconstant = constant;
5518 SCIP_ALLOC( BMSduplicateBlockMemoryArray(blkmem, &tmpvars, aggvars, ntmpvars) );
5519 SCIP_ALLOC( BMSduplicateBlockMemoryArray(blkmem, &tmpscalars, scalars, ntmpvars) );
5520
5521 /* get all active variables for multi-aggregation */
5522 SCIP_CALL( SCIPvarGetActiveRepresentatives(set, tmpvars, tmpscalars, &ntmpvars, tmpvarssize, &tmpconstant, &tmprequiredsize, FALSE) );
5523 if( tmprequiredsize > tmpvarssize )
5524 {
5525 SCIP_ALLOC( BMSreallocBlockMemoryArray(blkmem, &tmpvars, tmpvarssize, tmprequiredsize) );
5526 SCIP_ALLOC( BMSreallocBlockMemoryArray(blkmem, &tmpscalars, tmpvarssize, tmprequiredsize) );
5527 tmpvarssize = tmprequiredsize;
5528 SCIP_CALL( SCIPvarGetActiveRepresentatives(set, tmpvars, tmpscalars, &ntmpvars, tmpvarssize, &tmpconstant, &tmprequiredsize, FALSE) );
5529 assert( tmprequiredsize <= tmpvarssize );
5530 }
5531
5532 tmpscalar = 0.0;
5533
5534 /* iterate over all active variables of the multi-aggregation and filter all variables which are equal to the
5535 * possible multi-aggregated variable
5536 */
5537 for( v = ntmpvars - 1; v >= 0; --v )
5538 {
5539 assert(tmpvars[v] != NULL);
5540 assert(SCIPvarGetStatus(tmpvars[v]) == SCIP_VARSTATUS_LOOSE);
5541
5542 if( tmpvars[v]->index == var->index )
5543 {
5544 tmpscalar += tmpscalars[v];
5545 tmpvars[v] = tmpvars[ntmpvars - 1];
5546 tmpscalars[v] = tmpscalars[ntmpvars - 1];
5547 --ntmpvars;
5548 }
5549 }
5550
5551 /* this means that x = x + a_1*y_1 + ... + a_n*y_n + c */
5552 if( SCIPsetIsEQ(set, tmpscalar, 1.0) )
5553 {
5554 if( ntmpvars == 0 )
5555 {
5556 if( SCIPsetIsZero(set, tmpconstant) ) /* x = x */
5557 {
5558 SCIPsetDebugMsg(set, "Possible multi-aggregation was completely resolved and detected to be redundant.\n");
5559 goto TERMINATE;
5560 }
5561 else /* 0 = c and c != 0 */
5562 {
5563 SCIPsetDebugMsg(set, "Multi-aggregation was completely resolved and led to infeasibility.\n");
5564 *infeasible = TRUE;
5565 goto TERMINATE;
5566 }
5567 }
5568 else if( ntmpvars == 1 ) /* 0 = a*y + c => y = -c/a */
5569 {
5570 assert(tmpscalars[0] != 0.0);
5571 assert(tmpvars[0] != NULL);
5572
5573 SCIPsetDebugMsg(set, "Possible multi-aggregation led to fixing of variable <%s> to %g.\n", SCIPvarGetName(tmpvars[0]), -constant/tmpscalars[0]);
5574 SCIP_CALL( SCIPvarFix(tmpvars[0], blkmem, set, stat, transprob, origprob, primal, tree, reopt, lp,
5575 branchcand, eventfilter, eventqueue, cliquetable, -constant/tmpscalars[0], infeasible, aggregated) );
5576 goto TERMINATE;
5577 }
5578 else if( ntmpvars == 2 ) /* 0 = a_1*y_1 + a_2*y_2 + c => y_1 = -a_2/a_1 * y_2 - c/a_1 */
5579 {
5580 /* both variables are different active problem variables, and both scalars are non-zero: try to aggregate them */
5581 SCIPsetDebugMsg(set, "Possible multi-aggregation led to aggregation of variables <%s> and <%s> with scalars %g and %g and constant %g.\n",
5582 SCIPvarGetName(tmpvars[0]), SCIPvarGetName(tmpvars[1]), tmpscalars[0], tmpscalars[1], -tmpconstant);
5583
5584 SCIP_CALL( SCIPvarTryAggregateVars(set, blkmem, stat, transprob, origprob, primal, tree, reopt, lp,
5585 cliquetable, branchcand, eventfilter, eventqueue, tmpvars[0], tmpvars[1], tmpscalars[0],
5586 tmpscalars[1], -tmpconstant, infeasible, aggregated) );
5587
5588 goto TERMINATE;
5589 }
5590 else
5591 /* @todo: it is possible to multi-aggregate another variable, does it make sense?,
5592 * rest looks like 0 = a_1*y_1 + ... + a_n*y_n + c and has at least three variables
5593 */
5594 goto TERMINATE;
5595 }
5596 /* this means that x = b*x + a_1*y_1 + ... + a_n*y_n + c */
5597 else if( !SCIPsetIsZero(set, tmpscalar) )
5598 {
5599 tmpscalar = 1 - tmpscalar;
5600 tmpconstant /= tmpscalar;
5601 for( v = ntmpvars - 1; v >= 0; --v )
5602 tmpscalars[v] /= tmpscalar;
5603 }
5604
5605 /* check, if we are in one of the simple cases */
5606 if( ntmpvars == 0 )
5607 {
5608 SCIPsetDebugMsg(set, "Possible multi-aggregation led to fixing of variable <%s> to %g.\n", SCIPvarGetName(var), tmpconstant);
5609 SCIP_CALL( SCIPvarFix(var, blkmem, set, stat, transprob, origprob, primal, tree, reopt, lp, branchcand,
5610 eventfilter, eventqueue, cliquetable, tmpconstant, infeasible, aggregated) );
5611 goto TERMINATE;
5612 }
5613
5614 /* if only one aggregation variable is left, we perform a normal aggregation instead of a multi-aggregation */
5615 if( ntmpvars == 1 )
5616 {
5617 SCIPsetDebugMsg(set, "Possible multi-aggregation led to aggregation of variables <%s> and <%s> with scalars %g and %g and constant %g.\n",
5618 SCIPvarGetName(var), SCIPvarGetName(tmpvars[0]), 1.0, -tmpscalars[0], tmpconstant);
5619
5620 SCIP_CALL( SCIPvarTryAggregateVars(set, blkmem, stat, transprob, origprob, primal, tree, reopt, lp,
5621 cliquetable, branchcand, eventfilter, eventqueue, var, tmpvars[0], 1.0, -tmpscalars[0], tmpconstant,
5622 infeasible, aggregated) );
5623
5624 goto TERMINATE;
5625 }
5626
5627 /**@todo currently we don't perform the multi aggregation if the multi aggregation variable has a non
5628 * empty hole list; this should be changed in the future */
5629 if( SCIPvarGetHolelistGlobal(var) != NULL )
5630 goto TERMINATE;
5631
5632 /* if the variable is not allowed to be multi-aggregated */
5633 if( SCIPvarDoNotMultaggr(var) )
5634 {
5635 SCIPsetDebugMsg(set, "variable is not allowed to be multi-aggregated.\n");
5636 goto TERMINATE;
5637 }
5638
5639 /* if the variable to be multi-aggregated has implications or variable bounds (i.e. is the implied variable or
5640 * variable bound variable of another variable), we have to remove it from the other variables implications or
5641 * variable bounds
5642 */
5643 SCIP_CALL( SCIPvarRemoveCliquesImplicsVbs(var, blkmem, cliquetable, set, FALSE, FALSE, TRUE) );
5644 assert(var->vlbs == NULL);
5645 assert(var->vubs == NULL);
5646 assert(var->implics == NULL);
5647
5648 /* set the aggregated variable's objective value to 0.0 */
5649 obj = var->obj;
5650 SCIP_CALL( SCIPvarChgObj(var, blkmem, set, transprob, primal, lp, eventqueue, 0.0) );
5651
5652 /* since we change the variable type form loose to multi aggregated, we have to adjust the number of loose
5653 * variables in the LP data structure; the loose objective value (looseobjval) in the LP data structure, however,
5654 * gets adjusted automatically, due to the event SCIP_EVENTTYPE_OBJCHANGED which dropped in the moment where the
5655 * objective of this variable is set to zero
5656 */
5658
5659 /* unlock all rounding locks */
5660 for( i = 0; i < NLOCKTYPES; i++ )
5661 {
5662 nlocksdown[i] = var->nlocksdown[i];
5663 nlocksup[i] = var->nlocksup[i];
5664
5665 var->nlocksdown[i] = 0;
5666 var->nlocksup[i] = 0;
5667 }
5668
5669 /* convert variable into multi-aggregated variable */
5670 var->varstatus = SCIP_VARSTATUS_MULTAGGR; /*lint !e641*/
5671 SCIP_ALLOC( BMSduplicateBlockMemoryArray(blkmem, &var->data.multaggr.vars, tmpvars, ntmpvars) );
5672 SCIP_ALLOC( BMSduplicateBlockMemoryArray(blkmem, &var->data.multaggr.scalars, tmpscalars, ntmpvars) );
5673 var->data.multaggr.constant = tmpconstant;
5674 var->data.multaggr.nvars = ntmpvars;
5675 var->data.multaggr.varssize = ntmpvars;
5676
5677 /* mark variable to be non-deletable */
5679
5680 /* relock the variable, thus increasing the locks of the aggregation variables */
5681 for( i = 0; i < NLOCKTYPES; i++ )
5682 {
5683 SCIP_CALL( SCIPvarAddLocks(var, blkmem, set, eventqueue, (SCIP_LOCKTYPE) i, nlocksdown[i], nlocksup[i]) );
5684 }
5685
5686 /* update flags and branching factors and priorities of aggregation variables;
5687 * update preferred branching direction of all aggregation variables that don't have a preferred direction yet
5688 */
5689 branchfactor = var->branchfactor;
5690 branchpriority = var->branchpriority;
5691 branchdirection = (SCIP_BRANCHDIR)var->branchdirection;
5692
5693 for( v = 0; v < ntmpvars; ++v )
5694 {
5695 assert(tmpvars[v] != NULL);
5696 tmpvars[v]->removable &= var->removable;
5697 branchfactor = MAX(tmpvars[v]->branchfactor, branchfactor);
5698 branchpriority = MAX(tmpvars[v]->branchpriority, branchpriority);
5699
5700 /* mark variable to be non-deletable */
5701 SCIPvarMarkNotDeletable(tmpvars[v]);
5702 }
5703 for( v = 0; v < ntmpvars; ++v )
5704 {
5705 SCIP_CALL( SCIPvarChgBranchFactor(tmpvars[v], set, branchfactor) );
5706 SCIP_CALL( SCIPvarChgBranchPriority(tmpvars[v], branchpriority) );
5707 if( (SCIP_BRANCHDIR)tmpvars[v]->branchdirection == SCIP_BRANCHDIR_AUTO )
5708 {
5709 if( tmpscalars[v] >= 0.0 )
5710 {
5711 SCIP_CALL( SCIPvarChgBranchDirection(tmpvars[v], branchdirection) );
5712 }
5713 else
5714 {
5715 SCIP_CALL( SCIPvarChgBranchDirection(tmpvars[v], SCIPbranchdirOpposite(branchdirection)) );
5716 }
5717 }
5718 }
5719 SCIP_CALL( SCIPvarChgBranchFactor(var, set, branchfactor) );
5720 SCIP_CALL( SCIPvarChgBranchPriority(var, branchpriority) );
5721
5722 if( var->probindex != -1 )
5723 {
5724 /* inform problem about the variable's status change */
5725 SCIP_CALL( SCIPprobVarChangedStatus(transprob, blkmem, set, branchcand, cliquetable, var) );
5726 }
5727
5728 /* issue VARFIXED event */
5729 SCIP_CALL( varEventVarFixed(var, blkmem, set, eventqueue, 2) );
5730
5731 /* reset the objective value of the aggregated variable, thus adjusting the objective value of the aggregation
5732 * variables and the problem's objective offset
5733 */
5734 SCIP_CALL( SCIPvarAddObj(var, blkmem, set, stat, transprob, origprob, primal, tree, reopt, lp, eventfilter, eventqueue, obj) );
5735
5736 *aggregated = TRUE;
5737
5738 TERMINATE:
5739 BMSfreeBlockMemoryArray(blkmem, &tmpscalars, tmpvarssize);
5740 BMSfreeBlockMemoryArray(blkmem, &tmpvars, tmpvarssize);
5741
5742 break;
5743
5745 SCIPerrorMessage("cannot multi-aggregate a column variable\n");
5746 return SCIP_INVALIDDATA;
5747
5749 SCIPerrorMessage("cannot multi-aggregate a fixed variable\n");
5750 return SCIP_INVALIDDATA;
5751
5753 SCIPerrorMessage("cannot multi-aggregate an aggregated variable\n");
5754 return SCIP_INVALIDDATA;
5755
5757 SCIPerrorMessage("cannot multi-aggregate a multiple aggregated variable again\n");
5758 return SCIP_INVALIDDATA;
5759
5761 /* aggregate negation variable x in x' = offset - x, instead of aggregating x' directly:
5762 * x' = a_1*y_1 + ... + a_n*y_n + c -> x = offset - x' = offset - a_1*y_1 - ... - a_n*y_n - c
5763 */
5764 assert(SCIPsetIsZero(set, var->obj));
5765 assert(var->negatedvar != NULL);
5767 assert(var->negatedvar->negatedvar == var);
5768
5769 /* switch the signs of the aggregation scalars */
5770 for( v = 0; v < naggvars; ++v )
5771 scalars[v] *= -1.0;
5772
5773 /* perform the multi aggregation on the negation variable */
5774 SCIP_CALL( SCIPvarMultiaggregate(var->negatedvar, blkmem, set, stat, transprob, origprob, primal, tree, reopt, lp,
5775 cliquetable, branchcand, eventfilter, eventqueue, naggvars, aggvars, scalars,
5776 var->data.negate.constant - constant, infeasible, aggregated) );
5777
5778 /* switch the signs of the aggregation scalars again, to reset them to their original values */
5779 for( v = 0; v < naggvars; ++v )
5780 scalars[v] *= -1.0;
5781 break;
5782
5783 default:
5784 SCIPerrorMessage("unknown variable status\n");
5785 return SCIP_INVALIDDATA;
5786 }
5787
5788 /* check multi-aggregation on debugging solution */
5789 if( *infeasible || *aggregated )
5790 SCIP_CALL( SCIPdebugCheckAggregation(set, var, aggvars, scalars, constant, naggvars) ); /*lint !e506 !e774*/
5791
5792 return SCIP_OKAY;
5793}
5794
5795/** transformed variables are resolved to their active, fixed, or multi-aggregated problem variable of a variable,
5796 * or for original variables the same variable is returned
5797 */
5798static
5800 SCIP_VAR* var /**< problem variable */
5801 )
5802{
5803 SCIP_VAR* retvar;
5804
5805 assert(var != NULL);
5806
5807 retvar = var;
5808
5809 SCIPdebugMessage("get active variable of <%s>\n", var->name);
5810
5811 while( TRUE ) /*lint !e716 */
5812 {
5813 assert(retvar != NULL);
5814
5815 switch( SCIPvarGetStatus(retvar) )
5816 {
5821 return retvar;
5822
5824 /* handle multi-aggregated variables depending on one variable only (possibly caused by SCIPvarFlattenAggregationGraph()) */
5825 if ( retvar->data.multaggr.nvars == 1 )
5826 retvar = retvar->data.multaggr.vars[0];
5827 else
5828 return retvar;
5829 break;
5830
5832 retvar = retvar->data.aggregate.var;
5833 break;
5834
5836 retvar = retvar->negatedvar;
5837 break;
5838
5839 default:
5840 SCIPerrorMessage("unknown variable status\n");
5841 SCIPABORT();
5842 return NULL; /*lint !e527*/
5843 }
5844 }
5845}
5846
5847/** returns whether variable is not allowed to be aggregated */
5849 SCIP_VAR* var /**< problem variable */
5850 )
5851{
5852 SCIP_VAR* retvar;
5853
5854 assert(var != NULL);
5855
5856 retvar = varGetActiveVar(var);
5857 assert(retvar != NULL);
5858
5859 switch( SCIPvarGetStatus(retvar) )
5860 {
5865 return retvar->donotaggr;
5866
5868 return FALSE;
5869
5872 default:
5873 /* aggregated and negated variables should be resolved by varGetActiveVar() */
5874 SCIPerrorMessage("wrong variable status\n");
5875 SCIPABORT();
5876 return FALSE; /*lint !e527 */
5877 }
5878}
5879
5880/** returns whether variable is not allowed to be multi-aggregated */
5882 SCIP_VAR* var /**< problem variable */
5883 )
5884{
5885 SCIP_VAR* retvar;
5886
5887 assert(var != NULL);
5888
5889 retvar = varGetActiveVar(var);
5890 assert(retvar != NULL);
5891
5892 switch( SCIPvarGetStatus(retvar) )
5893 {
5898 return retvar->donotmultaggr;
5899
5901 return FALSE;
5902
5905 default:
5906 /* aggregated and negated variables should be resolved by varGetActiveVar() */
5907 SCIPerrorMessage("wrong variable status\n");
5908 SCIPABORT();
5909 return FALSE; /*lint !e527 */
5910 }
5911}
5912
5913/** gets negated variable x' = offset - x of problem variable x; the negated variable is created if not yet existing;
5914 * the negation offset of binary variables is always 1, the offset of other variables is fixed to lb + ub when the
5915 * negated variable is created
5916 */
5918 SCIP_VAR* var, /**< problem variable to negate */
5919 BMS_BLKMEM* blkmem, /**< block memory of transformed problem */
5920 SCIP_SET* set, /**< global SCIP settings */
5921 SCIP_STAT* stat, /**< problem statistics */
5922 SCIP_VAR** negvar /**< pointer to store the negated variable */
5923 )
5924{
5925 assert(var != NULL);
5926 assert(var->scip == set->scip);
5927 assert(negvar != NULL);
5928
5929 /* check, if we already created the negated variable */
5930 if( var->negatedvar == NULL )
5931 {
5932 char negvarname[SCIP_MAXSTRLEN];
5933
5935
5936 SCIPsetDebugMsg(set, "creating negated variable of <%s>\n", var->name);
5937
5938 /* negation is only possible for bounded variables */
5940 {
5941 SCIPerrorMessage("cannot negate unbounded variable\n");
5942 return SCIP_INVALIDDATA;
5943 }
5944
5945 (void) SCIPsnprintf(negvarname, SCIP_MAXSTRLEN, "%s_neg", var->name);
5946
5947 /* create negated variable */
5948 SCIP_CALL( varCreate(negvar, blkmem, set, stat, negvarname, var->glbdom.lb, var->glbdom.ub, 0.0,
5949 SCIPvarGetType(var), var->initial, var->removable, NULL, NULL, NULL, NULL, NULL) );
5950 (*negvar)->varstatus = SCIP_VARSTATUS_NEGATED; /*lint !e641*/
5951 if( SCIPvarIsBinary(var) )
5952 (*negvar)->data.negate.constant = 1.0;
5953 else
5954 (*negvar)->data.negate.constant = var->glbdom.lb + var->glbdom.ub;
5955
5956 /* create event filter for transformed variable */
5957 if( SCIPvarIsTransformed(var) )
5958 {
5959 SCIP_CALL( SCIPeventfilterCreate(&(*negvar)->eventfilter, blkmem) );
5960 }
5961
5962 /* set the bounds corresponding to the negation variable */
5963 (*negvar)->glbdom.lb = (*negvar)->data.negate.constant - var->glbdom.ub;
5964 (*negvar)->glbdom.ub = (*negvar)->data.negate.constant - var->glbdom.lb;
5965 (*negvar)->locdom.lb = (*negvar)->data.negate.constant - var->locdom.ub;
5966 (*negvar)->locdom.ub = (*negvar)->data.negate.constant - var->locdom.lb;
5967 /**@todo create holes in the negated variable corresponding to the holes of the negation variable */
5968
5969 /* link the variables together */
5970 var->negatedvar = *negvar;
5971 (*negvar)->negatedvar = var;
5972
5973 /* mark both variables to be non-deletable */
5975 SCIPvarMarkNotDeletable(*negvar);
5976
5977 /* copy the branch factor and priority, and use the negative preferred branching direction */
5978 (*negvar)->branchfactor = var->branchfactor;
5979 (*negvar)->branchpriority = var->branchpriority;
5980 (*negvar)->branchdirection = SCIPbranchdirOpposite((SCIP_BRANCHDIR)var->branchdirection); /*lint !e641*/
5981
5982 /* copy donot(mult)aggr status */
5983 (*negvar)->donotaggr = var->donotaggr;
5984 (*negvar)->donotmultaggr = var->donotmultaggr;
5985
5986 /* copy lazy bounds (they have to be flipped) */
5987 (*negvar)->lazylb = (*negvar)->data.negate.constant - var->lazyub;
5988 (*negvar)->lazyub = (*negvar)->data.negate.constant - var->lazylb;
5989
5990 /* make negated variable a parent of the negation variable (negated variable is captured as a parent) */
5991 SCIP_CALL( varAddParent(var, blkmem, set, *negvar) );
5992 assert((*negvar)->nuses == 1);
5993 }
5994 assert(var->negatedvar != NULL);
5995
5996 /* return the negated variable */
5997 *negvar = var->negatedvar;
5998
5999 /* exactly one variable of the negation pair has to be marked as negated variable */
6001
6002 return SCIP_OKAY;
6003}
6004
6005/** informs variable that its position in problem's vars array changed */
6006static
6008 SCIP_VAR* var, /**< problem variable */
6009 int probindex /**< new problem index of variable (-1 for removal) */
6010 )
6011{
6012 assert(var != NULL);
6013 assert(probindex >= 0 || var->vlbs == NULL);
6014 assert(probindex >= 0 || var->vubs == NULL);
6015 assert(probindex >= 0 || var->implics == NULL);
6016
6017 var->probindex = probindex;
6019 {
6020 assert(var->data.col != NULL);
6021 var->data.col->var_probindex = probindex;
6022 }
6023}
6024
6025/** informs variable that its position in problem's vars array changed */
6027 SCIP_VAR* var, /**< problem variable */
6028 int probindex /**< new problem index of variable */
6029 )
6030{
6031 assert(var != NULL);
6032 assert(probindex >= 0);
6033
6034 varSetProbindex(var, probindex);
6035}
6036
6037/** gives the variable a new name
6038 *
6039 * @note the old pointer is overwritten, which might result in a memory leakage
6040 */
6042 SCIP_VAR* var, /**< problem variable */
6043 const char* name /**< new name of variable */
6044 )
6045{
6046 assert(var != NULL);
6047 assert(name != NULL);
6048
6049 var->name = (char*)name;
6050}
6051
6052/** informs variable that it will be removed from the problem; adjusts probindex and removes variable from the
6053 * implication graph;
6054 * If 'final' is TRUE, the thorough implication graph removal is not performed. Instead, only the
6055 * variable bounds and implication data structures of the variable are freed. Since in the final removal
6056 * of all variables from the transformed problem, this deletes the implication graph completely and is faster
6057 * than removing the variables one by one, each time updating all lists of the other variables.
6058 */
6060 SCIP_VAR* var, /**< problem variable */
6061 BMS_BLKMEM* blkmem, /**< block memory buffer */
6062 SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
6063 SCIP_SET* set, /**< global SCIP settings */
6064 SCIP_Bool final /**< is this the final removal of all problem variables? */
6065 )
6066{
6067 assert(SCIPvarGetProbindex(var) >= 0);
6068 assert(var->scip == set->scip);
6069
6070 /* if the variable is active in the transformed problem, remove it from the implication graph */
6071 if( SCIPvarIsTransformed(var)
6073 {
6074 if( final )
6075 {
6076 /* just destroy the data structures */
6077 SCIPvboundsFree(&var->vlbs, blkmem);
6078 SCIPvboundsFree(&var->vubs, blkmem);
6079 SCIPimplicsFree(&var->implics, blkmem);
6080 }
6081 else
6082 {
6083 /* unlink the variable from all other variables' lists and free the data structures */
6084 SCIP_CALL( SCIPvarRemoveCliquesImplicsVbs(var, blkmem, cliquetable, set, FALSE, FALSE, TRUE) );
6085 }
6086 }
6087
6088 /* mark the variable to be no longer a member of the problem */
6089 varSetProbindex(var, -1);
6090
6091 return SCIP_OKAY;
6092}
6093
6094/** marks the variable to be deleted from the problem */
6096 SCIP_VAR* var /**< problem variable */
6097 )
6098{
6099 assert(var != NULL);
6100 assert(var->probindex != -1);
6101
6102 var->deleted = TRUE;
6103}
6104
6105/** marks the variable to not to be aggregated */
6107 SCIP_VAR* var /**< problem variable */
6108 )
6109{
6110 SCIP_VAR* retvar;
6111
6112 assert(var != NULL);
6113
6114 retvar = varGetActiveVar(var);
6115 assert(retvar != NULL);
6116
6117 switch( SCIPvarGetStatus(retvar) )
6118 {
6123 retvar->donotaggr = TRUE;
6124 break;
6125
6127 SCIPerrorMessage("cannot mark a multi-aggregated variable to not be aggregated.\n");
6128 return SCIP_INVALIDDATA;
6129
6132 default:
6133 /* aggregated and negated variables should be resolved by varGetActiveVar() */
6134 SCIPerrorMessage("wrong variable status\n");
6135 return SCIP_INVALIDDATA;
6136 }
6137
6138 return SCIP_OKAY;
6139}
6140
6141/** marks the variable to not to be multi-aggregated */
6143 SCIP_VAR* var /**< problem variable */
6144 )
6145{
6146 SCIP_VAR* retvar;
6147
6148 assert(var != NULL);
6149
6150 retvar = varGetActiveVar(var);
6151 assert(retvar != NULL);
6152
6153 switch( SCIPvarGetStatus(retvar) )
6154 {
6159 retvar->donotmultaggr = TRUE;
6160 break;
6161
6163 SCIPerrorMessage("cannot mark a multi-aggregated variable to not be multi-aggregated.\n");
6164 return SCIP_INVALIDDATA;
6165
6168 default:
6169 /* aggregated and negated variables should be resolved by varGetActiveVar() */
6170 SCIPerrorMessage("wrong variable status\n");
6171 return SCIP_INVALIDDATA;
6172 }
6173
6174 return SCIP_OKAY;
6175}
6176
6177/** changes type of variable; cannot be called, if var belongs to a problem */
6179 SCIP_VAR* var, /**< problem variable to change */
6180 BMS_BLKMEM* blkmem, /**< block memory */
6181 SCIP_SET* set, /**< global SCIP settings */
6182 SCIP_PRIMAL* primal, /**< primal data */
6183 SCIP_LP* lp, /**< current LP data */
6184 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
6185 SCIP_VARTYPE vartype /**< new type of variable */
6186 )
6187{
6188 SCIP_EVENT* event;
6189 SCIP_VARTYPE oldtype;
6190
6191 assert(var != NULL);
6192
6193 SCIPdebugMessage("change type of <%s> from %d to %d\n", var->name, SCIPvarGetType(var), vartype);
6194
6195 if( var->probindex >= 0 )
6196 {
6197 SCIPerrorMessage("cannot change type of variable already in the problem\n");
6198 return SCIP_INVALIDDATA;
6199 }
6200
6201 oldtype = (SCIP_VARTYPE)var->vartype;
6202 var->vartype = vartype; /*lint !e641*/
6203
6205 {
6206 SCIP_CALL( SCIPeventCreateTypeChanged(&event, blkmem, var, oldtype, vartype) );
6207 SCIP_CALL( SCIPeventqueueAdd(eventqueue, blkmem, set, primal, lp, NULL, NULL, &event) );
6208 }
6209
6210 if( var->negatedvar != NULL )
6211 {
6212 assert(oldtype == (SCIP_VARTYPE)var->negatedvar->vartype
6213 || SCIPvarIsBinary(var) == SCIPvarIsBinary(var->negatedvar));
6214
6215 var->negatedvar->vartype = vartype; /*lint !e641*/
6216
6218 {
6219 SCIP_CALL( SCIPeventCreateTypeChanged(&event, blkmem, var->negatedvar, oldtype, vartype) );
6220 SCIP_CALL( SCIPeventqueueAdd(eventqueue, blkmem, set, primal, lp, NULL, NULL, &event) );
6221 }
6222 }
6223
6224 return SCIP_OKAY;
6225}
6226
6227/** appends OBJCHANGED event to the event queue */
6228static
6230 SCIP_VAR* var, /**< problem variable to change */
6231 BMS_BLKMEM* blkmem, /**< block memory */
6232 SCIP_SET* set, /**< global SCIP settings */
6233 SCIP_PRIMAL* primal, /**< primal data */
6234 SCIP_LP* lp, /**< current LP data */
6235 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
6236 SCIP_Real oldobj, /**< old objective value for variable */
6237 SCIP_Real newobj /**< new objective value for variable */
6238 )
6239{
6240 SCIP_EVENT* event;
6241
6242 assert(var != NULL);
6243 assert(var->scip == set->scip);
6244 assert(var->eventfilter != NULL);
6246 assert(SCIPvarIsTransformed(var));
6247
6248 /* In the case where the objcetive value of a variable is very close to epsilon, and it is aggregated
6249 * into a variable with a big objective value, round-off errors might make the assert oldobj != newobj fail.
6250 * Hence, we relax it by letting it pass if the variables are percieved the same and we use very large values
6251 * that make comparison with values close to epsilon inaccurate.
6252 */
6253 assert(!SCIPsetIsEQ(set, oldobj, newobj) ||
6254 (SCIPsetIsEQ(set, oldobj, newobj) && REALABS(newobj) > 1e+15 * SCIPsetEpsilon(set))
6255 );
6256
6257 SCIP_CALL( SCIPeventCreateObjChanged(&event, blkmem, var, oldobj, newobj) );
6258 SCIP_CALL( SCIPeventqueueAdd(eventqueue, blkmem, set, primal, lp, NULL, NULL, &event) );
6259
6260 return SCIP_OKAY;
6261}
6262
6263/** changes objective value of variable */
6265 SCIP_VAR* var, /**< variable to change */
6266 BMS_BLKMEM* blkmem, /**< block memory */
6267 SCIP_SET* set, /**< global SCIP settings */
6268 SCIP_PROB* prob, /**< problem data */
6269 SCIP_PRIMAL* primal, /**< primal data */
6270 SCIP_LP* lp, /**< current LP data */
6271 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
6272 SCIP_Real newobj /**< new objective value for variable */
6273 )
6274{
6275 SCIP_Real oldobj;
6276
6277 assert(var != NULL);
6278 assert(set != NULL);
6279 assert(var->scip == set->scip);
6280
6281 SCIPsetDebugMsg(set, "changing objective value of <%s> from %g to %g\n", var->name, var->obj, newobj);
6282
6283 if( !SCIPsetIsEQ(set, var->obj, newobj) )
6284 {
6285 switch( SCIPvarGetStatus(var) )
6286 {
6288 if( var->data.original.transvar != NULL )
6289 {
6290 assert(SCIPprobIsTransformed(prob));
6291
6292 SCIP_CALL( SCIPvarChgObj(var->data.original.transvar, blkmem, set, prob, primal, lp, eventqueue,
6293 (SCIP_Real) prob->objsense * newobj/prob->objscale) );
6294 }
6295 else
6296 assert(set->stage == SCIP_STAGE_PROBLEM);
6297
6298 var->obj = newobj;
6299 var->unchangedobj = newobj;
6300
6301 break;
6302
6305 oldobj = var->obj;
6306 var->obj = newobj;
6307
6308 /* update unchanged objective value of variable */
6309 if( !lp->divingobjchg )
6310 var->unchangedobj = newobj;
6311
6312 /* update the number of variables with non-zero objective coefficient;
6313 * we only want to do the update, if the variable is added to the problem;
6314 * since the objective of inactive variables cannot be changed, this corresponds to probindex != -1
6315 */
6316 if( SCIPvarIsActive(var) )
6317 SCIPprobUpdateNObjVars(prob, set, oldobj, var->obj);
6318
6319 SCIP_CALL( varEventObjChanged(var, blkmem, set, primal, lp, eventqueue, oldobj, var->obj) );
6320 break;
6321
6326 SCIPerrorMessage("cannot change objective value of a fixed, aggregated, multi-aggregated, or negated variable\n");
6327 return SCIP_INVALIDDATA;
6328
6329 default:
6330 SCIPerrorMessage("unknown variable status\n");
6331 return SCIP_INVALIDDATA;
6332 }
6333 }
6334
6335 return SCIP_OKAY;
6336}
6337
6338/** adds value to objective value of variable */
6340 SCIP_VAR* var, /**< variable to change */
6341 BMS_BLKMEM* blkmem, /**< block memory */
6342 SCIP_SET* set, /**< global SCIP settings */
6343 SCIP_STAT* stat, /**< problem statistics */
6344 SCIP_PROB* transprob, /**< transformed problem data */
6345 SCIP_PROB* origprob, /**< original problem data */
6346 SCIP_PRIMAL* primal, /**< primal data */
6347 SCIP_TREE* tree, /**< branch and bound tree */
6348 SCIP_REOPT* reopt, /**< reoptimization data structure */
6349 SCIP_LP* lp, /**< current LP data */
6350 SCIP_EVENTFILTER* eventfilter, /**< event filter for global (not variable dependent) events */
6351 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
6352 SCIP_Real addobj /**< additional objective value for variable */
6353 )
6354{
6355 assert(var != NULL);
6356 assert(set != NULL);
6357 assert(var->scip == set->scip);
6358 assert(set->stage < SCIP_STAGE_INITSOLVE);
6359
6360 SCIPsetDebugMsg(set, "adding %g to objective value %g of <%s>\n", addobj, var->obj, var->name);
6361
6362 if( !SCIPsetIsZero(set, addobj) )
6363 {
6364 SCIP_Real oldobj;
6365 int i;
6366
6367 switch( SCIPvarGetStatus(var) )
6368 {
6370 if( var->data.original.transvar != NULL )
6371 {
6372 SCIP_CALL( SCIPvarAddObj(var->data.original.transvar, blkmem, set, stat, transprob, origprob, primal, tree,
6373 reopt, lp, eventfilter, eventqueue, (SCIP_Real) transprob->objsense * addobj/transprob->objscale) );
6374 }
6375 else
6376 assert(set->stage == SCIP_STAGE_PROBLEM);
6377
6378 var->obj += addobj;
6379 var->unchangedobj += addobj;
6380 assert(SCIPsetIsEQ(set, var->obj, var->unchangedobj));
6381
6382 break;
6383
6386 oldobj = var->obj;
6387 var->obj += addobj;
6388
6389 /* update unchanged objective value of variable */
6390 if( !lp->divingobjchg )
6391 {
6392 var->unchangedobj += addobj;
6393 assert(SCIPsetIsEQ(set, var->obj, var->unchangedobj));
6394 }
6395
6396 /* update the number of variables with non-zero objective coefficient;
6397 * we only want to do the update, if the variable is added to the problem;
6398 * since the objective of inactive variables cannot be changed, this corresponds to probindex != -1
6399 */
6400 if( SCIPvarIsActive(var) )
6401 SCIPprobUpdateNObjVars(transprob, set, oldobj, var->obj);
6402
6403 SCIP_CALL( varEventObjChanged(var, blkmem, set, primal, lp, eventqueue, oldobj, var->obj) );
6404 break;
6405
6407 assert(SCIPsetIsEQ(set, var->locdom.lb, var->locdom.ub));
6408 SCIPprobAddObjoffset(transprob, var->locdom.lb * addobj);
6409 SCIP_CALL( SCIPprimalUpdateObjoffset(primal, blkmem, set, stat, eventfilter, eventqueue, transprob, origprob, tree, reopt, lp) );
6410 break;
6411
6413 assert(!var->donotaggr);
6414 /* x = a*y + c -> add a*addobj to obj. val. of y, and c*addobj to obj. offset of problem */
6415 SCIPprobAddObjoffset(transprob, var->data.aggregate.constant * addobj);
6416 SCIP_CALL( SCIPprimalUpdateObjoffset(primal, blkmem, set, stat, eventfilter, eventqueue, transprob, origprob, tree, reopt, lp) );
6417 SCIP_CALL( SCIPvarAddObj(var->data.aggregate.var, blkmem, set, stat, transprob, origprob, primal, tree, reopt,
6418 lp, eventfilter, eventqueue, var->data.aggregate.scalar * addobj) );
6419 break;
6420
6422 assert(!var->donotmultaggr);
6423 /* x = a_1*y_1 + ... + a_n*y_n + c -> add a_i*addobj to obj. val. of y_i, and c*addobj to obj. offset */
6424 SCIPprobAddObjoffset(transprob, var->data.multaggr.constant * addobj);
6425 SCIP_CALL( SCIPprimalUpdateObjoffset(primal, blkmem, set, stat, eventfilter, eventqueue, transprob, origprob, tree, reopt, lp) );
6426 for( i = 0; i < var->data.multaggr.nvars; ++i )
6427 {
6428 SCIP_CALL( SCIPvarAddObj(var->data.multaggr.vars[i], blkmem, set, stat, transprob, origprob, primal, tree,
6429 reopt, lp, eventfilter, eventqueue, var->data.multaggr.scalars[i] * addobj) );
6430 }
6431 break;
6432
6434 /* x' = offset - x -> add -addobj to obj. val. of x and offset*addobj to obj. offset of problem */
6435 assert(var->negatedvar != NULL);
6437 assert(var->negatedvar->negatedvar == var);
6438 SCIPprobAddObjoffset(transprob, var->data.negate.constant * addobj);
6439 SCIP_CALL( SCIPprimalUpdateObjoffset(primal, blkmem, set, stat, eventfilter, eventqueue, transprob, origprob, tree, reopt, lp) );
6440 SCIP_CALL( SCIPvarAddObj(var->negatedvar, blkmem, set, stat, transprob, origprob, primal, tree, reopt, lp,
6441 eventfilter, eventqueue, -addobj) );
6442 break;
6443
6444 default:
6445 SCIPerrorMessage("unknown variable status\n");
6446 return SCIP_INVALIDDATA;
6447 }
6448 }
6449
6450 return SCIP_OKAY;
6451}
6452
6453/** changes objective value of variable in current dive */
6455 SCIP_VAR* var, /**< problem variable to change */
6456 SCIP_SET* set, /**< global SCIP settings */
6457 SCIP_LP* lp, /**< current LP data */
6458 SCIP_Real newobj /**< new objective value for variable */
6459 )
6460{
6461 assert(var != NULL);
6462 assert(set != NULL);
6463 assert(var->scip == set->scip);
6464 assert(lp != NULL);
6465
6466 SCIPsetDebugMsg(set, "changing objective of <%s> to %g in current dive\n", var->name, newobj);
6467
6468 if( SCIPsetIsZero(set, newobj) )
6469 newobj = 0.0;
6470
6471 /* change objective value of attached variables */
6472 switch( SCIPvarGetStatus(var) )
6473 {
6475 assert(var->data.original.transvar != NULL);
6476 SCIP_CALL( SCIPvarChgObjDive(var->data.original.transvar, set, lp, newobj) );
6477 break;
6478
6480 assert(var->data.col != NULL);
6481 SCIP_CALL( SCIPcolChgObj(var->data.col, set, lp, newobj) );
6482 break;
6483
6486 /* nothing to do here: only the constant shift in objective function would change */
6487 break;
6488
6489 case SCIP_VARSTATUS_AGGREGATED: /* x = a*y + c -> y = (x-c)/a */
6490 assert(var->data.aggregate.var != NULL);
6491 assert(!SCIPsetIsZero(set, var->data.aggregate.scalar));
6492 SCIP_CALL( SCIPvarChgObjDive(var->data.aggregate.var, set, lp, newobj / var->data.aggregate.scalar) );
6493 /* the constant can be ignored, because it would only affect the objective shift */
6494 break;
6495
6497 SCIPerrorMessage("cannot change diving objective value of a multi-aggregated variable\n");
6498 return SCIP_INVALIDDATA;
6499
6500 case SCIP_VARSTATUS_NEGATED: /* x' = offset - x -> x = offset - x' */
6501 assert(var->negatedvar != NULL);
6503 assert(var->negatedvar->negatedvar == var);
6504 SCIP_CALL( SCIPvarChgObjDive(var->negatedvar, set, lp, -newobj) );
6505 /* the offset can be ignored, because it would only affect the objective shift */
6506 break;
6507
6508 default:
6509 SCIPerrorMessage("unknown variable status\n");
6510 return SCIP_INVALIDDATA;
6511 }
6512
6513 return SCIP_OKAY;
6514}
6515
6516/** adjust lower bound to integral value, if variable is integral */
6518 SCIP_VAR* var, /**< problem variable */
6519 SCIP_SET* set, /**< global SCIP settings */
6520 SCIP_Real* lb /**< pointer to lower bound to adjust */
6521 )
6522{
6523 assert(var != NULL);
6524 assert(set != NULL);
6525 assert(var->scip == set->scip);
6526 assert(lb != NULL);
6527
6528 SCIPsetDebugMsg(set, "adjust lower bound %g of <%s>\n", *lb, var->name);
6529
6530 *lb = adjustedLb(set, SCIPvarGetType(var), *lb);
6531}
6532
6533/** adjust upper bound to integral value, if variable is integral */
6535 SCIP_VAR* var, /**< problem variable */
6536 SCIP_SET* set, /**< global SCIP settings */
6537 SCIP_Real* ub /**< pointer to upper bound to adjust */
6538 )
6539{
6540 assert(var != NULL);
6541 assert(set != NULL);
6542 assert(var->scip == set->scip);
6543 assert(ub != NULL);
6544
6545 SCIPsetDebugMsg(set, "adjust upper bound %g of <%s>\n", *ub, var->name);
6546
6547 *ub = adjustedUb(set, SCIPvarGetType(var), *ub);
6548}
6549
6550/** adjust lower or upper bound to integral value, if variable is integral */
6552 SCIP_VAR* var, /**< problem variable */
6553 SCIP_SET* set, /**< global SCIP settings */
6554 SCIP_BOUNDTYPE boundtype, /**< type of bound to adjust */
6555 SCIP_Real* bd /**< pointer to bound to adjust */
6556 )
6557{
6558 assert(boundtype == SCIP_BOUNDTYPE_LOWER || boundtype == SCIP_BOUNDTYPE_UPPER);
6559
6560 if( boundtype == SCIP_BOUNDTYPE_LOWER )
6561 SCIPvarAdjustLb(var, set, bd);
6562 else
6563 SCIPvarAdjustUb(var, set, bd);
6564}
6565
6566/** changes lower bound of original variable in original problem */
6568 SCIP_VAR* var, /**< problem variable to change */
6569 SCIP_SET* set, /**< global SCIP settings */
6570 SCIP_Real newbound /**< new bound for variable */
6571 )
6572{
6573 int i;
6574
6575 assert(var != NULL);
6576 assert(!SCIPvarIsTransformed(var));
6578 assert(set != NULL);
6579 assert(var->scip == set->scip);
6580 assert(set->stage == SCIP_STAGE_PROBLEM);
6581
6582 /* check that the bound is feasible */
6584 /* adjust bound to integral value if variable is of integral type */
6585 newbound = adjustedLb(set, SCIPvarGetType(var), newbound);
6586
6587 if( SCIPsetIsZero(set, newbound) )
6588 newbound = 0.0;
6589
6590 /* original domains are only stored for ORIGINAL variables, not for NEGATED */
6592 {
6593 SCIPsetDebugMsg(set, "changing original lower bound of <%s> from %g to %g\n",
6594 var->name, var->data.original.origdom.lb, newbound);
6595
6596 if( SCIPsetIsEQ(set, var->data.original.origdom.lb, newbound) )
6597 return SCIP_OKAY;
6598
6599 /* change the bound */
6600 var->data.original.origdom.lb = newbound;
6601 }
6602 else if( SCIPvarGetStatus(var) == SCIP_VARSTATUS_NEGATED )
6603 {
6604 assert( var->negatedvar != NULL );
6605 SCIP_CALL( SCIPvarChgUbOriginal(var->negatedvar, set, var->data.negate.constant - newbound) );
6606 }
6607
6608 /* process parent variables */
6609 for( i = 0; i < var->nparentvars; ++i )
6610 {
6611 SCIP_VAR* parentvar;
6612
6613 parentvar = var->parentvars[i];
6614 assert(parentvar != NULL);
6615 assert(SCIPvarGetStatus(parentvar) == SCIP_VARSTATUS_NEGATED);
6616 assert(parentvar->negatedvar == var);
6617 assert(var->negatedvar == parentvar);
6618
6619 SCIP_CALL( SCIPvarChgUbOriginal(parentvar, set, parentvar->data.negate.constant - newbound) );
6620 }
6621
6622 return SCIP_OKAY;
6623}
6624
6625/** changes upper bound of original variable in original problem */
6627 SCIP_VAR* var, /**< problem variable to change */
6628 SCIP_SET* set, /**< global SCIP settings */
6629 SCIP_Real newbound /**< new bound for variable */
6630 )
6631{
6632 int i;
6633
6634 assert(var != NULL);
6635 assert(!SCIPvarIsTransformed(var));
6637 assert(set != NULL);
6638 assert(var->scip == set->scip);
6639 assert(set->stage == SCIP_STAGE_PROBLEM);
6640
6641 /* check that the bound is feasible */
6643 /* adjust bound to integral value if variable is of integral type */
6644 newbound = adjustedUb(set, SCIPvarGetType(var), newbound);
6645
6646 if( SCIPsetIsZero(set, newbound) )
6647 newbound = 0.0;
6648
6649 /* original domains are only stored for ORIGINAL variables, not for NEGATED */
6651 {
6652 SCIPsetDebugMsg(set, "changing original upper bound of <%s> from %g to %g\n",
6653 var->name, var->data.original.origdom.ub, newbound);
6654
6655 if( SCIPsetIsEQ(set, var->data.original.origdom.ub, newbound) )
6656 return SCIP_OKAY;
6657
6658 /* change the bound */
6659 var->data.original.origdom.ub = newbound;
6660 }
6661 else if( SCIPvarGetStatus(var) == SCIP_VARSTATUS_NEGATED )
6662 {
6663 assert( var->negatedvar != NULL );
6664 SCIP_CALL( SCIPvarChgLbOriginal(var->negatedvar, set, var->data.negate.constant - newbound) );
6665 }
6666
6667 /* process parent variables */
6668 for( i = 0; i < var->nparentvars; ++i )
6669 {
6670 SCIP_VAR* parentvar;
6671
6672 parentvar = var->parentvars[i];
6673 assert(parentvar != NULL);
6674 assert(SCIPvarGetStatus(parentvar) == SCIP_VARSTATUS_NEGATED);
6675 assert(parentvar->negatedvar == var);
6676 assert(var->negatedvar == parentvar);
6677
6678 SCIP_CALL( SCIPvarChgLbOriginal(parentvar, set, parentvar->data.negate.constant - newbound) );
6679 }
6680
6681 return SCIP_OKAY;
6682}
6683
6684/** appends GLBCHANGED event to the event queue */
6685static
6687 SCIP_VAR* var, /**< problem variable to change */
6688 BMS_BLKMEM* blkmem, /**< block memory */
6689 SCIP_SET* set, /**< global SCIP settings */
6690 SCIP_LP* lp, /**< current LP data */
6691 SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
6692 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
6693 SCIP_Real oldbound, /**< old lower bound for variable */
6694 SCIP_Real newbound /**< new lower bound for variable */
6695 )
6696{
6697 assert(var != NULL);
6698 assert(var->eventfilter != NULL);
6699 assert(SCIPvarIsTransformed(var));
6700 assert(!SCIPsetIsEQ(set, oldbound, newbound) || (newbound != oldbound && newbound * oldbound <= 0.0)); /*lint !e777*/
6701 assert(set != NULL);
6702 assert(var->scip == set->scip);
6703
6704 /* check, if the variable is being tracked for bound changes
6705 * COLUMN and LOOSE variables are tracked always, because global/root pseudo objective value has to be updated
6706 */
6707 if( (var->eventfilter->len > 0 && (var->eventfilter->eventmask & SCIP_EVENTTYPE_GLBCHANGED) != 0)
6710 {
6711 SCIP_EVENT* event;
6712
6713 SCIPsetDebugMsg(set, "issue GLBCHANGED event for variable <%s>: %g -> %g\n", var->name, oldbound, newbound);
6714
6715 SCIP_CALL( SCIPeventCreateGlbChanged(&event, blkmem, var, oldbound, newbound) );
6716 SCIP_CALL( SCIPeventqueueAdd(eventqueue, blkmem, set, NULL, lp, branchcand, NULL, &event) );
6717 }
6718
6719 return SCIP_OKAY;
6720}
6721
6722/** appends GUBCHANGED event to the event queue */
6723static
6725 SCIP_VAR* var, /**< problem variable to change */
6726 BMS_BLKMEM* blkmem, /**< block memory */
6727 SCIP_SET* set, /**< global SCIP settings */
6728 SCIP_LP* lp, /**< current LP data */
6729 SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
6730 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
6731 SCIP_Real oldbound, /**< old lower bound for variable */
6732 SCIP_Real newbound /**< new lower bound for variable */
6733 )
6734{
6735 assert(var != NULL);
6736 assert(var->eventfilter != NULL);
6737 assert(SCIPvarIsTransformed(var));
6738 assert(!SCIPsetIsEQ(set, oldbound, newbound) || (newbound != oldbound && newbound * oldbound <= 0.0)); /*lint !e777*/
6739 assert(set != NULL);
6740 assert(var->scip == set->scip);
6741
6742 /* check, if the variable is being tracked for bound changes
6743 * COLUMN and LOOSE variables are tracked always, because global/root pseudo objective value has to be updated
6744 */
6745 if( (var->eventfilter->len > 0 && (var->eventfilter->eventmask & SCIP_EVENTTYPE_GUBCHANGED) != 0)
6748 {
6749 SCIP_EVENT* event;
6750
6751 SCIPsetDebugMsg(set, "issue GUBCHANGED event for variable <%s>: %g -> %g\n", var->name, oldbound, newbound);
6752
6753 SCIP_CALL( SCIPeventCreateGubChanged(&event, blkmem, var, oldbound, newbound) );
6754 SCIP_CALL( SCIPeventqueueAdd(eventqueue, blkmem, set, NULL, lp, branchcand, NULL, &event) );
6755 }
6756
6757 return SCIP_OKAY;
6758}
6759
6760/** appends GHOLEADDED event to the event queue */
6761static
6763 SCIP_VAR* var, /**< problem variable to change */
6764 BMS_BLKMEM* blkmem, /**< block memory */
6765 SCIP_SET* set, /**< global SCIP settings */
6766 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
6767 SCIP_Real left, /**< left bound of open interval in new hole */
6768 SCIP_Real right /**< right bound of open interval in new hole */
6769 )
6770{
6771 assert(var != NULL);
6772 assert(var->eventfilter != NULL);
6773 assert(SCIPvarIsTransformed(var));
6774 assert(set != NULL);
6775 assert(var->scip == set->scip);
6776 assert(SCIPsetIsLT(set, left, right));
6777
6778 /* check, if the variable is being tracked for bound changes */
6779 if( (var->eventfilter->len > 0 && (var->eventfilter->eventmask & SCIP_EVENTTYPE_GHOLEADDED) != 0) )
6780 {
6781 SCIP_EVENT* event;
6782
6783 SCIPsetDebugMsg(set, "issue GHOLEADDED event for variable <%s>: (%.15g,%.15g)\n", var->name, left, right);
6784
6785 SCIP_CALL( SCIPeventCreateGholeAdded(&event, blkmem, var, left, right) );
6786 SCIP_CALL( SCIPeventqueueAdd(eventqueue, blkmem, set, NULL, NULL, NULL, NULL, &event) );
6787 }
6788
6789 return SCIP_OKAY;
6790}
6791
6792/** increases root bound change statistics after a global bound change */
6793static
6795 SCIP_VAR* var, /**< problem variable to change */
6796 SCIP_SET* set, /**< global SCIP settings */
6797 SCIP_STAT* stat /**< problem statistics */
6798 )
6799{
6800 assert(var != NULL);
6801 assert(set != NULL);
6802 assert(var->scip == set->scip);
6803 assert(stat != NULL);
6804
6805 if( SCIPvarIsActive(var) && SCIPvarIsTransformed(var) && set->stage == SCIP_STAGE_SOLVING )
6806 {
6807 stat->nrootboundchgs++;
6808 stat->nrootboundchgsrun++;
6809 if( SCIPvarIsIntegral(var) && SCIPvarGetLbGlobal(var) + 0.5 > SCIPvarGetUbGlobal(var) )
6810 {
6811 stat->nrootintfixings++;
6812 stat->nrootintfixingsrun++;
6813 }
6814 }
6815}
6816
6817/* forward declaration, because both methods call each other recursively */
6818
6819/* performs the current change in upper bound, changes all parents accordingly */
6820static
6822 SCIP_VAR* var, /**< problem variable to change */
6823 BMS_BLKMEM* blkmem, /**< block memory */
6824 SCIP_SET* set, /**< global SCIP settings */
6825 SCIP_STAT* stat, /**< problem statistics */
6826 SCIP_LP* lp, /**< current LP data, may be NULL for original variables */
6827 SCIP_BRANCHCAND* branchcand, /**< branching candidate storage, may be NULL for original variables */
6828 SCIP_EVENTQUEUE* eventqueue, /**< event queue, may be NULL for original variables */
6829 SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
6830 SCIP_Real newbound /**< new bound for variable */
6831 );
6832
6833/** performs the current change in lower bound, changes all parents accordingly */
6834static
6836 SCIP_VAR* var, /**< problem variable to change */
6837 BMS_BLKMEM* blkmem, /**< block memory */
6838 SCIP_SET* set, /**< global SCIP settings */
6839 SCIP_STAT* stat, /**< problem statistics */
6840 SCIP_LP* lp, /**< current LP data, may be NULL for original variables */
6841 SCIP_BRANCHCAND* branchcand, /**< branching candidate storage, may be NULL for original variables */
6842 SCIP_EVENTQUEUE* eventqueue, /**< event queue, may be NULL for original variables */
6843 SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
6844 SCIP_Real newbound /**< new bound for variable */
6845 )
6846{
6847 SCIP_VAR* parentvar;
6848 SCIP_Real oldbound;
6849 int i;
6850
6851 assert(var != NULL);
6852 /* local domains can violate global bounds but not more than feasibility epsilon */
6853 assert(SCIPsetIsFeasLE(set, var->glbdom.lb, var->locdom.lb));
6854 assert(SCIPsetIsFeasLE(set, var->locdom.ub, var->glbdom.ub));
6855 assert(blkmem != NULL);
6856 assert(set != NULL);
6857 assert(var->scip == set->scip);
6858 assert(stat != NULL);
6859
6860 /* adjust bound to integral value if variable is of integral type */
6861 newbound = adjustedLb(set, SCIPvarGetType(var), newbound);
6862
6863 /* check that the bound is feasible */
6864 if( SCIPsetGetStage(set) != SCIP_STAGE_PROBLEM && newbound > var->glbdom.ub )
6865 {
6866 /* due to numerics we only want to be feasible in feasibility tolerance */
6867 assert(SCIPsetIsFeasLE(set, newbound, var->glbdom.ub));
6868 newbound = var->glbdom.ub;
6869 }
6871
6872 assert(var->vartype != SCIP_VARTYPE_BINARY || SCIPsetIsEQ(set, newbound, 0.0) || SCIPsetIsEQ(set, newbound, 1.0)); /*lint !e641*/
6873
6874 SCIPsetDebugMsg(set, "process changing global lower bound of <%s> from %f to %f\n", var->name, var->glbdom.lb, newbound);
6875
6876 if( SCIPsetIsEQ(set, newbound, var->glbdom.lb) && !(newbound != var->glbdom.lb && newbound * var->glbdom.lb <= 0.0) ) /*lint !e777*/
6877 return SCIP_OKAY;
6878
6879 /* check bound on debugging solution */
6880 SCIP_CALL( SCIPdebugCheckLbGlobal(set->scip, var, newbound) ); /*lint !e506 !e774*/
6881
6882 /* change the bound */
6883 oldbound = var->glbdom.lb;
6884 assert(SCIPsetGetStage(set) == SCIP_STAGE_PROBLEM || SCIPsetIsFeasLE(set, newbound, var->glbdom.ub));
6885 var->glbdom.lb = newbound;
6886 assert( SCIPsetIsFeasLE(set, var->glbdom.lb, var->locdom.lb) );
6887 assert( SCIPsetIsFeasLE(set, var->locdom.ub, var->glbdom.ub) );
6888
6890 {
6891 /* merges overlapping holes into single holes, moves bounds respectively */
6892 domMerge(&var->glbdom, blkmem, set, &newbound, NULL);
6893 }
6894
6895 /* update the root bound changes counters */
6896 varIncRootboundchgs(var, set, stat);
6897
6898 /* update the lbchginfos array by replacing worse local bounds with the new global bound and changing the
6899 * redundant bound changes to be branching decisions
6900 */
6901 for( i = 0; i < var->nlbchginfos; ++i )
6902 {
6903 assert(var->lbchginfos[i].var == var);
6904
6905 if( var->lbchginfos[i].oldbound < var->glbdom.lb )
6906 {
6907 SCIPsetDebugMsg(set, " -> adjust lower bound change <%s>: %g -> %g due to new global lower bound %g\n",
6908 SCIPvarGetName(var), var->lbchginfos[i].oldbound, var->lbchginfos[i].newbound, var->glbdom.lb);
6909 var->lbchginfos[i].oldbound = var->glbdom.lb;
6910 if( SCIPsetIsLE(set, var->lbchginfos[i].newbound, var->glbdom.lb) )
6911 {
6912 /* this bound change is redundant due to the new global bound */
6913 var->lbchginfos[i].newbound = var->glbdom.lb;
6914 var->lbchginfos[i].boundchgtype = SCIP_BOUNDCHGTYPE_BRANCHING; /*lint !e641*/
6915 var->lbchginfos[i].redundant = TRUE;
6916 }
6917 else
6918 break; /* from now on, the remaining local bound changes are not redundant */
6919 }
6920 else
6921 break; /* from now on, the remaining local bound changes are not redundant */
6922 }
6923
6924 /* remove redundant implications and variable bounds */
6926 && (!set->reopt_enable || set->stage == SCIP_STAGE_PRESOLVING) )
6927 {
6928 SCIP_CALL( SCIPvarRemoveCliquesImplicsVbs(var, blkmem, cliquetable, set, FALSE, TRUE, TRUE) );
6929 }
6930
6931 /* issue bound change event */
6932 assert(SCIPvarIsTransformed(var) == (var->eventfilter != NULL));
6934 {
6935 SCIP_CALL( varEventGlbChanged(var, blkmem, set, lp, branchcand, eventqueue, oldbound, newbound) );
6936 }
6937
6938 /* process parent variables */
6939 for( i = 0; i < var->nparentvars; ++i )
6940 {
6941 parentvar = var->parentvars[i];
6942 assert(parentvar != NULL);
6943
6944 switch( SCIPvarGetStatus(parentvar) )
6945 {
6947 SCIP_CALL( varProcessChgLbGlobal(parentvar, blkmem, set, stat, lp, branchcand, eventqueue, cliquetable, newbound) );
6948 break;
6949
6954 SCIPerrorMessage("column, loose, fixed or multi-aggregated variable cannot be the parent of a variable\n");
6955 return SCIP_INVALIDDATA;
6956
6957 case SCIP_VARSTATUS_AGGREGATED: /* x = a*y + c -> y = (x-c)/a */
6958 assert(parentvar->data.aggregate.var == var);
6959 if( SCIPsetIsPositive(set, parentvar->data.aggregate.scalar) )
6960 {
6961 SCIP_Real parentnewbound;
6962
6963 /* a > 0 -> change lower bound of y */
6964 assert(SCIPsetIsInfinity(set, -parentvar->glbdom.lb) || SCIPsetIsInfinity(set, -oldbound)
6965 || SCIPsetIsFeasEQ(set, parentvar->glbdom.lb, oldbound * parentvar->data.aggregate.scalar + parentvar->data.aggregate.constant)
6966 || (SCIPsetIsZero(set, parentvar->glbdom.lb / parentvar->data.aggregate.scalar) && SCIPsetIsZero(set, oldbound)));
6967
6968 if( !SCIPsetIsInfinity(set, -newbound) && !SCIPsetIsInfinity(set, newbound) )
6969 parentnewbound = parentvar->data.aggregate.scalar * newbound + parentvar->data.aggregate.constant;
6970 else
6971 parentnewbound = newbound;
6972 SCIP_CALL( varProcessChgLbGlobal(parentvar, blkmem, set, stat, lp, branchcand, eventqueue, cliquetable, parentnewbound) );
6973 }
6974 else
6975 {
6976 SCIP_Real parentnewbound;
6977
6978 /* a < 0 -> change upper bound of y */
6979 assert(SCIPsetIsNegative(set, parentvar->data.aggregate.scalar));
6980 assert(SCIPsetIsInfinity(set, parentvar->glbdom.ub) || SCIPsetIsInfinity(set, -oldbound)
6981 || SCIPsetIsFeasEQ(set, parentvar->glbdom.ub, oldbound * parentvar->data.aggregate.scalar + parentvar->data.aggregate.constant)
6982 || (SCIPsetIsZero(set, parentvar->glbdom.ub / parentvar->data.aggregate.scalar) && SCIPsetIsZero(set, oldbound)));
6983
6984 if( !SCIPsetIsInfinity(set, -newbound) && !SCIPsetIsInfinity(set, newbound) )
6985 parentnewbound = parentvar->data.aggregate.scalar * newbound + parentvar->data.aggregate.constant;
6986 else
6987 parentnewbound = -newbound;
6988 SCIP_CALL( varProcessChgUbGlobal(parentvar, blkmem, set, stat, lp, branchcand, eventqueue, cliquetable, parentnewbound) );
6989 }
6990 break;
6991
6992 case SCIP_VARSTATUS_NEGATED: /* x' = offset - x -> x = offset - x' */
6993 assert(parentvar->negatedvar != NULL);
6994 assert(SCIPvarGetStatus(parentvar->negatedvar) != SCIP_VARSTATUS_NEGATED);
6995 assert(parentvar->negatedvar->negatedvar == parentvar);
6996 SCIP_CALL( varProcessChgUbGlobal(parentvar, blkmem, set, stat, lp, branchcand, eventqueue, cliquetable,
6997 parentvar->data.negate.constant - newbound) );
6998 break;
6999
7000 default:
7001 SCIPerrorMessage("unknown variable status\n");
7002 return SCIP_INVALIDDATA;
7003 }
7004 }
7005
7006 return SCIP_OKAY;
7007}
7008
7009/** performs the current change in upper bound, changes all parents accordingly */
7010static
7012 SCIP_VAR* var, /**< problem variable to change */
7013 BMS_BLKMEM* blkmem, /**< block memory */
7014 SCIP_SET* set, /**< global SCIP settings */
7015 SCIP_STAT* stat, /**< problem statistics */
7016 SCIP_LP* lp, /**< current LP data, may be NULL for original variables */
7017 SCIP_BRANCHCAND* branchcand, /**< branching candidate storage, may be NULL for original variables */
7018 SCIP_EVENTQUEUE* eventqueue, /**< event queue, may be NULL for original variables */
7019 SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
7020 SCIP_Real newbound /**< new bound for variable */
7021 )
7022{
7023 SCIP_VAR* parentvar;
7024 SCIP_Real oldbound;
7025 int i;
7026
7027 assert(var != NULL);
7028 /* local domains can violate global bounds but not more than feasibility epsilon */
7029 assert(SCIPsetIsFeasLE(set, var->glbdom.lb , var->locdom.lb));
7030 assert(SCIPsetIsFeasLE(set, var->locdom.ub, var->glbdom.ub));
7031 assert(blkmem != NULL);
7032 assert(set != NULL);
7033 assert(var->scip == set->scip);
7034 assert(stat != NULL);
7035
7036 /* adjust bound to integral value if variable is of integral type */
7037 newbound = adjustedUb(set, SCIPvarGetType(var), newbound);
7038
7039 /* check that the bound is feasible */
7040 if( SCIPsetGetStage(set) != SCIP_STAGE_PROBLEM && newbound < var->glbdom.lb )
7041 {
7042 /* due to numerics we only want to be feasible in feasibility tolerance */
7043 assert(SCIPsetIsFeasGE(set, newbound, var->glbdom.lb));
7044 newbound = var->glbdom.lb;
7045 }
7047
7048 assert(var->vartype != SCIP_VARTYPE_BINARY || SCIPsetIsEQ(set, newbound, 0.0) || SCIPsetIsEQ(set, newbound, 1.0)); /*lint !e641*/
7049
7050 SCIPsetDebugMsg(set, "process changing global upper bound of <%s> from %f to %f\n", var->name, var->glbdom.ub, newbound);
7051
7052 if( SCIPsetIsEQ(set, newbound, var->glbdom.ub) && !(newbound != var->glbdom.ub && newbound * var->glbdom.ub <= 0.0) ) /*lint !e777*/
7053 return SCIP_OKAY;
7054
7055 /* check bound on debugging solution */
7056 SCIP_CALL( SCIPdebugCheckUbGlobal(set->scip, var, newbound) ); /*lint !e506 !e774*/
7057
7058 /* change the bound */
7059 oldbound = var->glbdom.ub;
7060 assert(SCIPsetGetStage(set) == SCIP_STAGE_PROBLEM || SCIPsetIsFeasGE(set, newbound, var->glbdom.lb));
7061 var->glbdom.ub = newbound;
7062 assert( SCIPsetIsFeasLE(set, var->glbdom.lb, var->locdom.lb) );
7063 assert( SCIPsetIsFeasLE(set, var->locdom.ub, var->glbdom.ub) );
7064
7066 {
7067 /* merges overlapping holes into single holes, moves bounds respectively */
7068 domMerge(&var->glbdom, blkmem, set, NULL, &newbound);
7069 }
7070
7071 /* update the root bound changes counters */
7072 varIncRootboundchgs(var, set, stat);
7073
7074 /* update the ubchginfos array by replacing worse local bounds with the new global bound and changing the
7075 * redundant bound changes to be branching decisions
7076 */
7077 for( i = 0; i < var->nubchginfos; ++i )
7078 {
7079 assert(var->ubchginfos[i].var == var);
7080 if( var->ubchginfos[i].oldbound > var->glbdom.ub )
7081 {
7082 SCIPsetDebugMsg(set, " -> adjust upper bound change <%s>: %g -> %g due to new global upper bound %g\n",
7083 SCIPvarGetName(var), var->ubchginfos[i].oldbound, var->ubchginfos[i].newbound, var->glbdom.ub);
7084 var->ubchginfos[i].oldbound = var->glbdom.ub;
7085 if( SCIPsetIsGE(set, var->ubchginfos[i].newbound, var->glbdom.ub) )
7086 {
7087 /* this bound change is redundant due to the new global bound */
7088 var->ubchginfos[i].newbound = var->glbdom.ub;
7089 var->ubchginfos[i].boundchgtype = SCIP_BOUNDCHGTYPE_BRANCHING; /*lint !e641*/
7090 var->ubchginfos[i].redundant = TRUE;
7091 }
7092 else
7093 break; /* from now on, the remaining local bound changes are not redundant */
7094 }
7095 else
7096 break; /* from now on, the remaining local bound changes are not redundant */
7097 }
7098
7099 /* remove redundant implications and variable bounds */
7101 && (!set->reopt_enable || set->stage == SCIP_STAGE_PRESOLVING) )
7102 {
7103 SCIP_CALL( SCIPvarRemoveCliquesImplicsVbs(var, blkmem, cliquetable, set, FALSE, TRUE, TRUE) );
7104 }
7105
7106 /* issue bound change event */
7107 assert(SCIPvarIsTransformed(var) == (var->eventfilter != NULL));
7109 {
7110 SCIP_CALL( varEventGubChanged(var, blkmem, set, lp, branchcand, eventqueue, oldbound, newbound) );
7111 }
7112
7113 /* process parent variables */
7114 for( i = 0; i < var->nparentvars; ++i )
7115 {
7116 parentvar = var->parentvars[i];
7117 assert(parentvar != NULL);
7118
7119 switch( SCIPvarGetStatus(parentvar) )
7120 {
7122 SCIP_CALL( varProcessChgUbGlobal(parentvar, blkmem, set, stat, lp, branchcand, eventqueue, cliquetable, newbound) );
7123 break;
7124
7129 SCIPerrorMessage("column, loose, fixed or multi-aggregated variable cannot be the parent of a variable\n");
7130 return SCIP_INVALIDDATA;
7131
7132 case SCIP_VARSTATUS_AGGREGATED: /* x = a*y + c -> y = (x-c)/a */
7133 assert(parentvar->data.aggregate.var == var);
7134 if( SCIPsetIsPositive(set, parentvar->data.aggregate.scalar) )
7135 {
7136 SCIP_Real parentnewbound;
7137
7138 /* a > 0 -> change upper bound of y */
7139 assert(SCIPsetIsInfinity(set, parentvar->glbdom.ub) || SCIPsetIsInfinity(set, oldbound)
7140 || SCIPsetIsFeasEQ(set, parentvar->glbdom.ub,
7141 oldbound * parentvar->data.aggregate.scalar + parentvar->data.aggregate.constant));
7142 if( !SCIPsetIsInfinity(set, -newbound) && !SCIPsetIsInfinity(set, newbound) )
7143 parentnewbound = parentvar->data.aggregate.scalar * newbound + parentvar->data.aggregate.constant;
7144 else
7145 parentnewbound = newbound;
7146 SCIP_CALL( varProcessChgUbGlobal(parentvar, blkmem, set, stat, lp, branchcand, eventqueue, cliquetable, parentnewbound) );
7147 }
7148 else
7149 {
7150 SCIP_Real parentnewbound;
7151
7152 /* a < 0 -> change lower bound of y */
7153 assert(SCIPsetIsNegative(set, parentvar->data.aggregate.scalar));
7154 assert(SCIPsetIsInfinity(set, -parentvar->glbdom.lb) || SCIPsetIsInfinity(set, oldbound)
7155 || SCIPsetIsFeasEQ(set, parentvar->glbdom.lb,
7156 oldbound * parentvar->data.aggregate.scalar + parentvar->data.aggregate.constant));
7157 if( !SCIPsetIsInfinity(set, -newbound) && !SCIPsetIsInfinity(set, newbound) )
7158 parentnewbound = parentvar->data.aggregate.scalar * newbound + parentvar->data.aggregate.constant;
7159 else
7160 parentnewbound = -newbound;
7161 SCIP_CALL( varProcessChgLbGlobal(parentvar, blkmem, set, stat, lp, branchcand, eventqueue, cliquetable, parentnewbound) );
7162 }
7163 break;
7164
7165 case SCIP_VARSTATUS_NEGATED: /* x' = offset - x -> x = offset - x' */
7166 assert(parentvar->negatedvar != NULL);
7167 assert(SCIPvarGetStatus(parentvar->negatedvar) != SCIP_VARSTATUS_NEGATED);
7168 assert(parentvar->negatedvar->negatedvar == parentvar);
7169 SCIP_CALL( varProcessChgLbGlobal(parentvar, blkmem, set, stat, lp, branchcand, eventqueue, cliquetable,
7170 parentvar->data.negate.constant - newbound) );
7171 break;
7172
7173 default:
7174 SCIPerrorMessage("unknown variable status\n");
7175 return SCIP_INVALIDDATA;
7176 }
7177 }
7178
7179 return SCIP_OKAY;
7180}
7181
7182/** changes global lower bound of variable; if possible, adjusts bound to integral value;
7183 * updates local lower bound if the global bound is tighter
7184 */
7186 SCIP_VAR* var, /**< problem variable to change */
7187 BMS_BLKMEM* blkmem, /**< block memory */
7188 SCIP_SET* set, /**< global SCIP settings */
7189 SCIP_STAT* stat, /**< problem statistics */
7190 SCIP_LP* lp, /**< current LP data, may be NULL for original variables */
7191 SCIP_BRANCHCAND* branchcand, /**< branching candidate storage, may be NULL for original variables */
7192 SCIP_EVENTQUEUE* eventqueue, /**< event queue, may be NULL for original variables */
7193 SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
7194 SCIP_Real newbound /**< new bound for variable */
7195 )
7196{
7197 assert(var != NULL);
7198 assert(blkmem != NULL);
7199 assert(set != NULL);
7200 assert(var->scip == set->scip);
7201
7202 /* check that the bound is feasible; this must be w.r.t. feastol because SCIPvarFix() allows fixings that are outside
7203 * of the domain within feastol
7204 */
7205 assert(SCIPsetGetStage(set) == SCIP_STAGE_PROBLEM || !SCIPsetIsFeasGT(set, newbound, var->glbdom.ub));
7206
7207 /* adjust bound to integral value if variable is of integral type */
7208 newbound = adjustedLb(set, SCIPvarGetType(var), newbound);
7209
7210 /* check that the adjusted bound is feasible
7211 * @todo this does not have to be the case if the original problem was infeasible due to bounds and we are called
7212 * here because we reset bounds to their original value!
7213 */
7214 assert(SCIPsetGetStage(set) == SCIP_STAGE_PROBLEM || !SCIPsetIsFeasGT(set, newbound, var->glbdom.ub));
7215
7217 {
7218 /* we do not want to exceed the upperbound, which could have happened due to numerics */
7219 newbound = MIN(newbound, var->glbdom.ub);
7220 }
7222
7223 /* the new global bound has to be tighter except we are in the original problem; this must be w.r.t. feastol because
7224 * SCIPvarFix() allows fixings that are outside of the domain within feastol
7225 */
7226 assert(lp == NULL || SCIPsetIsFeasLE(set, var->glbdom.lb, newbound) || (set->reopt_enable && set->stage == SCIP_STAGE_PRESOLVED));
7227
7228 SCIPsetDebugMsg(set, "changing global lower bound of <%s> from %g to %g\n", var->name, var->glbdom.lb, newbound);
7229
7230 if( SCIPsetIsEQ(set, var->glbdom.lb, newbound) && !(newbound != var->glbdom.lb && newbound * var->glbdom.lb <= 0.0) ) /*lint !e777*/
7231 return SCIP_OKAY;
7232
7233 /* change bounds of attached variables */
7234 switch( SCIPvarGetStatus(var) )
7235 {
7237 if( var->data.original.transvar != NULL )
7238 {
7239 SCIP_CALL( SCIPvarChgLbGlobal(var->data.original.transvar, blkmem, set, stat, lp, branchcand, eventqueue,
7240 cliquetable, newbound) );
7241 }
7242 else
7243 {
7244 assert(set->stage == SCIP_STAGE_PROBLEM);
7245 if( newbound > SCIPvarGetLbLocal(var) )
7246 {
7247 SCIP_CALL( SCIPvarChgLbLocal(var, blkmem, set, stat, lp, branchcand, eventqueue, newbound) );
7248 }
7249 SCIP_CALL( varProcessChgLbGlobal(var, blkmem, set, stat, lp, branchcand, eventqueue, cliquetable, newbound) );
7250 }
7251 break;
7252
7255 if( newbound > SCIPvarGetLbLocal(var) )
7256 {
7257 SCIP_CALL( SCIPvarChgLbLocal(var, blkmem, set, stat, lp, branchcand, eventqueue, newbound) );
7258 }
7259 SCIP_CALL( varProcessChgLbGlobal(var, blkmem, set, stat, lp, branchcand, eventqueue, cliquetable, newbound) );
7260 break;
7261
7263 SCIPerrorMessage("cannot change the bounds of a fixed variable\n");
7264 return SCIP_INVALIDDATA;
7265
7266 case SCIP_VARSTATUS_AGGREGATED: /* x = a*y + c -> y = (x-c)/a */
7267 assert(var->data.aggregate.var != NULL);
7269 {
7270 SCIP_Real childnewbound;
7271
7272 /* a > 0 -> change lower bound of y */
7274 || SCIPsetIsFeasEQ(set, var->glbdom.lb,
7276 if( !SCIPsetIsInfinity(set, -newbound) && !SCIPsetIsInfinity(set, newbound) )
7277 childnewbound = (newbound - var->data.aggregate.constant)/var->data.aggregate.scalar;
7278 else
7279 childnewbound = newbound;
7280 SCIP_CALL( SCIPvarChgLbGlobal(var->data.aggregate.var, blkmem, set, stat, lp, branchcand, eventqueue, cliquetable,
7281 childnewbound) );
7282 }
7283 else if( SCIPsetIsNegative(set, var->data.aggregate.scalar) )
7284 {
7285 SCIP_Real childnewbound;
7286
7287 /* a < 0 -> change upper bound of y */
7289 || SCIPsetIsFeasEQ(set, var->glbdom.lb,
7291 if( !SCIPsetIsInfinity(set, -newbound) && !SCIPsetIsInfinity(set, newbound) )
7292 childnewbound = (newbound - var->data.aggregate.constant)/var->data.aggregate.scalar;
7293 else
7294 childnewbound = -newbound;
7295 SCIP_CALL( SCIPvarChgUbGlobal(var->data.aggregate.var, blkmem, set, stat, lp, branchcand, eventqueue, cliquetable,
7296 childnewbound) );
7297 }
7298 else
7299 {
7300 SCIPerrorMessage("scalar is zero in aggregation\n");
7301 return SCIP_INVALIDDATA;
7302 }
7303 break;
7304
7306 SCIPerrorMessage("cannot change the bounds of a multi-aggregated variable.\n");
7307 return SCIP_INVALIDDATA;
7308
7309 case SCIP_VARSTATUS_NEGATED: /* x' = offset - x -> x = offset - x' */
7310 assert(var->negatedvar != NULL);
7312 assert(var->negatedvar->negatedvar == var);
7313 SCIP_CALL( SCIPvarChgUbGlobal(var->negatedvar, blkmem, set, stat, lp, branchcand, eventqueue, cliquetable,
7314 var->data.negate.constant - newbound) );
7315 break;
7316
7317 default:
7318 SCIPerrorMessage("unknown variable status\n");
7319 return SCIP_INVALIDDATA;
7320 }
7321
7322 return SCIP_OKAY;
7323}
7324
7325/** changes global upper bound of variable; if possible, adjusts bound to integral value;
7326 * updates local upper bound if the global bound is tighter
7327 */
7329 SCIP_VAR* var, /**< problem variable to change */
7330 BMS_BLKMEM* blkmem, /**< block memory */
7331 SCIP_SET* set, /**< global SCIP settings */
7332 SCIP_STAT* stat, /**< problem statistics */
7333 SCIP_LP* lp, /**< current LP data, may be NULL for original variables */
7334 SCIP_BRANCHCAND* branchcand, /**< branching candidate storage, may be NULL for original variables */
7335 SCIP_EVENTQUEUE* eventqueue, /**< event queue, may be NULL for original variables */
7336 SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
7337 SCIP_Real newbound /**< new bound for variable */
7338 )
7339{
7340 assert(var != NULL);
7341 assert(blkmem != NULL);
7342 assert(set != NULL);
7343 assert(var->scip == set->scip);
7344
7345 /* check that the bound is feasible; this must be w.r.t. feastol because SCIPvarFix() allows fixings that are outside
7346 * of the domain within feastol
7347 */
7348 assert(SCIPsetGetStage(set) == SCIP_STAGE_PROBLEM || !SCIPsetIsFeasLT(set, newbound, var->glbdom.lb));
7349
7350 /* adjust bound to integral value if variable is of integral type */
7351 newbound = adjustedUb(set, SCIPvarGetType(var), newbound);
7352
7353 /* check that the adjusted bound is feasible
7354 * @todo this does not have to be the case if the original problem was infeasible due to bounds and we are called
7355 * here because we reset bounds to their original value!
7356 */
7357 assert(SCIPsetGetStage(set) == SCIP_STAGE_PROBLEM || !SCIPsetIsFeasLT(set, newbound, var->glbdom.lb));
7358
7360 {
7361 /* we do not want to undercut the lowerbound, which could have happened due to numerics */
7362 newbound = MAX(newbound, var->glbdom.lb);
7363 }
7365
7366 /* the new global bound has to be tighter except we are in the original problem; this must be w.r.t. feastol because
7367 * SCIPvarFix() allows fixings that are outside of the domain within feastol
7368 */
7369 assert(lp == NULL || SCIPsetIsFeasGE(set, var->glbdom.ub, newbound) || (set->reopt_enable && set->stage == SCIP_STAGE_PRESOLVED));
7370
7371 SCIPsetDebugMsg(set, "changing global upper bound of <%s> from %g to %g\n", var->name, var->glbdom.ub, newbound);
7372
7373 if( SCIPsetIsEQ(set, var->glbdom.ub, newbound) && !(newbound != var->glbdom.ub && newbound * var->glbdom.ub <= 0.0) ) /*lint !e777*/
7374 return SCIP_OKAY;
7375
7376 /* change bounds of attached variables */
7377 switch( SCIPvarGetStatus(var) )
7378 {
7380 if( var->data.original.transvar != NULL )
7381 {
7382 SCIP_CALL( SCIPvarChgUbGlobal(var->data.original.transvar, blkmem, set, stat, lp, branchcand, eventqueue, cliquetable,
7383 newbound) );
7384 }
7385 else
7386 {
7387 assert(set->stage == SCIP_STAGE_PROBLEM);
7388 if( newbound < SCIPvarGetUbLocal(var) )
7389 {
7390 SCIP_CALL( SCIPvarChgUbLocal(var, blkmem, set, stat, lp, branchcand, eventqueue, newbound) );
7391 }
7392 SCIP_CALL( varProcessChgUbGlobal(var, blkmem, set, stat, lp, branchcand, eventqueue, cliquetable, newbound) );
7393 }
7394 break;
7395
7398 if( newbound < SCIPvarGetUbLocal(var) )
7399 {
7400 SCIP_CALL( SCIPvarChgUbLocal(var, blkmem, set, stat, lp, branchcand, eventqueue, newbound) );
7401 }
7402 SCIP_CALL( varProcessChgUbGlobal(var, blkmem, set, stat, lp, branchcand, eventqueue, cliquetable, newbound) );
7403 break;
7404
7406 SCIPerrorMessage("cannot change the bounds of a fixed variable\n");
7407 return SCIP_INVALIDDATA;
7408
7409 case SCIP_VARSTATUS_AGGREGATED: /* x = a*y + c -> y = (x-c)/a */
7410 assert(var->data.aggregate.var != NULL);
7412 {
7413 SCIP_Real childnewbound;
7414
7415 /* a > 0 -> change lower bound of y */
7417 || SCIPsetIsFeasEQ(set, var->glbdom.ub,
7419 if( !SCIPsetIsInfinity(set, -newbound) && !SCIPsetIsInfinity(set, newbound) )
7420 childnewbound = (newbound - var->data.aggregate.constant)/var->data.aggregate.scalar;
7421 else
7422 childnewbound = newbound;
7423 SCIP_CALL( SCIPvarChgUbGlobal(var->data.aggregate.var, blkmem, set, stat, lp, branchcand, eventqueue, cliquetable,
7424 childnewbound) );
7425 }
7426 else if( SCIPsetIsNegative(set, var->data.aggregate.scalar) )
7427 {
7428 SCIP_Real childnewbound;
7429
7430 /* a < 0 -> change upper bound of y */
7432 || SCIPsetIsFeasEQ(set, var->glbdom.ub,
7434 if( !SCIPsetIsInfinity(set, -newbound) && !SCIPsetIsInfinity(set, newbound) )
7435 childnewbound = (newbound - var->data.aggregate.constant)/var->data.aggregate.scalar;
7436 else
7437 childnewbound = -newbound;
7438 SCIP_CALL( SCIPvarChgLbGlobal(var->data.aggregate.var, blkmem, set, stat, lp, branchcand, eventqueue, cliquetable,
7439 childnewbound) );
7440 }
7441 else
7442 {
7443 SCIPerrorMessage("scalar is zero in aggregation\n");
7444 return SCIP_INVALIDDATA;
7445 }
7446 break;
7447
7449 SCIPerrorMessage("cannot change the bounds of a multi-aggregated variable.\n");
7450 return SCIP_INVALIDDATA;
7451
7452 case SCIP_VARSTATUS_NEGATED: /* x' = offset - x -> x = offset - x' */
7453 assert(var->negatedvar != NULL);
7455 assert(var->negatedvar->negatedvar == var);
7456 SCIP_CALL( SCIPvarChgLbGlobal(var->negatedvar, blkmem, set, stat, lp, branchcand, eventqueue, cliquetable,
7457 var->data.negate.constant - newbound) );
7458 break;
7459
7460 default:
7461 SCIPerrorMessage("unknown variable status\n");
7462 return SCIP_INVALIDDATA;
7463 }
7464
7465 return SCIP_OKAY;
7466}
7467
7468/** changes lazy lower bound of the variable, this is only possible if the variable is not in the LP yet */
7470 SCIP_VAR* var, /**< problem variable */
7471 SCIP_SET* set, /**< global SCIP settings */
7472 SCIP_Real lazylb /**< the lazy lower bound to be set */
7473 )
7474{
7475 assert(var != NULL);
7476 assert(var->probindex != -1);
7477 assert(SCIPsetIsFeasGE(set, var->glbdom.ub, lazylb));
7478 assert(SCIPsetIsFeasGE(set, var->lazyub, lazylb));
7479 assert(set != NULL);
7480 assert(var->scip == set->scip);
7481
7482 /* variable should not be in the LP */
7484 return SCIP_INVALIDCALL;
7485
7486 var->lazylb = lazylb;
7487
7488 return SCIP_OKAY;
7489}
7490
7491/** changes lazy upper bound of the variable, this is only possible if the variable is not in the LP yet */
7493 SCIP_VAR* var, /**< problem variable */
7494 SCIP_SET* set, /**< global SCIP settings */
7495 SCIP_Real lazyub /**< the lazy lower bound to be set */
7496 )
7497{
7498 assert(var != NULL);
7499 assert(var->probindex != -1);
7500 assert(SCIPsetIsFeasGE(set, lazyub, var->glbdom.lb));
7501 assert(SCIPsetIsFeasGE(set, lazyub, var->lazylb));
7502 assert(set != NULL);
7503 assert(var->scip == set->scip);
7504
7505 /* variable should not be in the LP */
7507 return SCIP_INVALIDCALL;
7508
7509 var->lazyub = lazyub;
7510
7511 return SCIP_OKAY;
7512}
7513
7514
7515/** changes global bound of variable; if possible, adjusts bound to integral value;
7516 * updates local bound if the global bound is tighter
7517 */
7519 SCIP_VAR* var, /**< problem variable to change */
7520 BMS_BLKMEM* blkmem, /**< block memory */
7521 SCIP_SET* set, /**< global SCIP settings */
7522 SCIP_STAT* stat, /**< problem statistics */
7523 SCIP_LP* lp, /**< current LP data, may be NULL for original variables */
7524 SCIP_BRANCHCAND* branchcand, /**< branching candidate storage, may be NULL for original variables */
7525 SCIP_EVENTQUEUE* eventqueue, /**< event queue, may be NULL for original variables */
7526 SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
7527 SCIP_Real newbound, /**< new bound for variable */
7528 SCIP_BOUNDTYPE boundtype /**< type of bound: lower or upper bound */
7529 )
7530{
7531 /* apply bound change to the LP data */
7532 switch( boundtype )
7533 {
7535 return SCIPvarChgLbGlobal(var, blkmem, set, stat, lp, branchcand, eventqueue, cliquetable, newbound);
7537 return SCIPvarChgUbGlobal(var, blkmem, set, stat, lp, branchcand, eventqueue, cliquetable, newbound);
7538 default:
7539 SCIPerrorMessage("unknown bound type\n");
7540 return SCIP_INVALIDDATA;
7541 }
7542}
7543
7544/** appends LBTIGHTENED or LBRELAXED event to the event queue */
7545static
7547 SCIP_VAR* var, /**< problem variable to change */
7548 BMS_BLKMEM* blkmem, /**< block memory */
7549 SCIP_SET* set, /**< global SCIP settings */
7550 SCIP_LP* lp, /**< current LP data */
7551 SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
7552 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
7553 SCIP_Real oldbound, /**< old lower bound for variable */
7554 SCIP_Real newbound /**< new lower bound for variable */
7555 )
7556{
7557 assert(var != NULL);
7558 assert(var->eventfilter != NULL);
7559 assert(SCIPvarIsTransformed(var));
7560 assert(!SCIPsetIsEQ(set, oldbound, newbound) || newbound == var->glbdom.lb || (newbound != oldbound && newbound * oldbound <= 0.0)); /*lint !e777*/
7561 assert(set != NULL);
7562 assert(var->scip == set->scip);
7563
7564 /* check, if the variable is being tracked for bound changes
7565 * COLUMN and LOOSE variables are tracked always, because row activities and LP changes have to be updated
7566 */
7567 if( (var->eventfilter->len > 0 && (var->eventfilter->eventmask & SCIP_EVENTTYPE_LBCHANGED) != 0)
7570 {
7571 SCIP_EVENT* event;
7572
7573 SCIPsetDebugMsg(set, "issue LBCHANGED event for variable <%s>: %g -> %g\n", var->name, oldbound, newbound);
7574
7575 SCIP_CALL( SCIPeventCreateLbChanged(&event, blkmem, var, oldbound, newbound) );
7576 SCIP_CALL( SCIPeventqueueAdd(eventqueue, blkmem, set, NULL, lp, branchcand, NULL, &event) );
7577 }
7578
7579 return SCIP_OKAY;
7580}
7581
7582/** appends UBTIGHTENED or UBRELAXED event to the event queue */
7583static
7585 SCIP_VAR* var, /**< problem variable to change */
7586 BMS_BLKMEM* blkmem, /**< block memory */
7587 SCIP_SET* set, /**< global SCIP settings */
7588 SCIP_LP* lp, /**< current LP data */
7589 SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
7590 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
7591 SCIP_Real oldbound, /**< old upper bound for variable */
7592 SCIP_Real newbound /**< new upper bound for variable */
7593 )
7594{
7595 assert(var != NULL);
7596 assert(var->eventfilter != NULL);
7597 assert(SCIPvarIsTransformed(var));
7598 assert(!SCIPsetIsEQ(set, oldbound, newbound) || newbound == var->glbdom.ub || (newbound != oldbound && newbound * oldbound <= 0.0)); /*lint !e777*/
7599 assert(set != NULL);
7600 assert(var->scip == set->scip);
7601
7602 /* check, if the variable is being tracked for bound changes
7603 * COLUMN and LOOSE variables are tracked always, because row activities and LP changes have to be updated
7604 */
7605 if( (var->eventfilter->len > 0 && (var->eventfilter->eventmask & SCIP_EVENTTYPE_UBCHANGED) != 0)
7608 {
7609 SCIP_EVENT* event;
7610
7611 SCIPsetDebugMsg(set, "issue UBCHANGED event for variable <%s>: %g -> %g\n", var->name, oldbound, newbound);
7612
7613 SCIP_CALL( SCIPeventCreateUbChanged(&event, blkmem, var, oldbound, newbound) );
7614 SCIP_CALL( SCIPeventqueueAdd(eventqueue, blkmem, set, NULL, lp, branchcand, NULL, &event) );
7615 }
7616
7617 return SCIP_OKAY;
7618}
7619
7620/* forward declaration, because both methods call each other recursively */
7621
7622/* performs the current change in upper bound, changes all parents accordingly */
7623static
7625 SCIP_VAR* var, /**< problem variable to change */
7626 BMS_BLKMEM* blkmem, /**< block memory */
7627 SCIP_SET* set, /**< global SCIP settings */
7628 SCIP_STAT* stat, /**< problem statistics, or NULL if the bound change belongs to updating the parent variables */
7629 SCIP_LP* lp, /**< current LP data, may be NULL for original variables */
7630 SCIP_BRANCHCAND* branchcand, /**< branching candidate storage, may be NULL for original variables */
7631 SCIP_EVENTQUEUE* eventqueue, /**< event queue, may be NULL for original variables */
7632 SCIP_Real newbound /**< new bound for variable */
7633 );
7634
7635/** performs the current change in lower bound, changes all parents accordingly */
7636static
7638 SCIP_VAR* var, /**< problem variable to change */
7639 BMS_BLKMEM* blkmem, /**< block memory */
7640 SCIP_SET* set, /**< global SCIP settings */
7641 SCIP_STAT* stat, /**< problem statistics, or NULL if the bound change belongs to updating the parent variables */
7642 SCIP_LP* lp, /**< current LP data, may be NULL for original variables */
7643 SCIP_BRANCHCAND* branchcand, /**< branching candidate storage, may be NULL for original variables */
7644 SCIP_EVENTQUEUE* eventqueue, /**< event queue, may be NULL for original variables */
7645 SCIP_Real newbound /**< new bound for variable */
7646 )
7647{
7648 SCIP_VAR* parentvar;
7649 SCIP_Real oldbound;
7650 int i;
7651
7652 assert(var != NULL);
7653 assert(set != NULL);
7654 assert(var->scip == set->scip);
7655 assert((SCIPvarGetType(var) == SCIP_VARTYPE_BINARY && (SCIPsetIsZero(set, newbound) || SCIPsetIsEQ(set, newbound, 1.0)
7656 || SCIPsetIsEQ(set, newbound, var->locdom.ub)))
7658 || SCIPsetIsEQ(set, newbound, var->locdom.ub)))
7660
7661 /* check that the bound is feasible */
7662 assert(SCIPsetGetStage(set) == SCIP_STAGE_PROBLEM || SCIPsetIsLE(set, newbound, var->glbdom.ub));
7663 /* adjust bound to integral value if variable is of integral type */
7664 newbound = adjustedLb(set, SCIPvarGetType(var), newbound);
7665
7667 {
7668 /* we do not want to exceed the upper bound, which could have happened due to numerics */
7669 newbound = MIN(newbound, var->locdom.ub);
7670
7671 /* we do not want to undercut the global lower bound, which could have happened due to numerics */
7672 newbound = MAX(newbound, var->glbdom.lb);
7673 }
7675
7676 SCIPsetDebugMsg(set, "process changing lower bound of <%s> from %g to %g\n", var->name, var->locdom.lb, newbound);
7677
7678 if( SCIPsetIsEQ(set, newbound, var->glbdom.lb) && var->glbdom.lb != var->locdom.lb ) /*lint !e777*/
7679 newbound = var->glbdom.lb;
7680 else if( SCIPsetIsEQ(set, newbound, var->locdom.lb) && !(newbound != var->locdom.lb && newbound * var->locdom.lb <= 0.0) ) /*lint !e777*/
7681 return SCIP_OKAY;
7682
7683 /* change the bound */
7684 oldbound = var->locdom.lb;
7685 assert(SCIPsetGetStage(set) == SCIP_STAGE_PROBLEM || SCIPsetIsFeasLE(set, newbound, var->locdom.ub));
7686 var->locdom.lb = newbound;
7687
7688 /* update statistic; during the update steps of the parent variable we pass a NULL pointer to ensure that we only
7689 * once update the statistic
7690 */
7691 if( stat != NULL )
7692 SCIPstatIncrement(stat, set, domchgcount);
7693
7695 {
7696 /* merges overlapping holes into single holes, moves bounds respectively */
7697 domMerge(&var->locdom, blkmem, set, &newbound, NULL);
7698 }
7699
7700 /* issue bound change event */
7701 assert(SCIPvarIsTransformed(var) == (var->eventfilter != NULL));
7703 {
7704 SCIP_CALL( varEventLbChanged(var, blkmem, set, lp, branchcand, eventqueue, oldbound, newbound) );
7705 }
7706
7707 /* process parent variables */
7708 for( i = 0; i < var->nparentvars; ++i )
7709 {
7710 parentvar = var->parentvars[i];
7711 assert(parentvar != NULL);
7712
7713 switch( SCIPvarGetStatus(parentvar) )
7714 {
7716 SCIP_CALL( varProcessChgLbLocal(parentvar, blkmem, set, NULL, lp, branchcand, eventqueue, newbound) );
7717 break;
7718
7723 SCIPerrorMessage("column, loose, fixed or multi-aggregated variable cannot be the parent of a variable\n");
7724 return SCIP_INVALIDDATA;
7725
7726 case SCIP_VARSTATUS_AGGREGATED: /* x = a*y + c -> y = (x-c)/a */
7727 assert(parentvar->data.aggregate.var == var);
7728 if( SCIPsetIsPositive(set, parentvar->data.aggregate.scalar) )
7729 {
7730 SCIP_Real parentnewbound;
7731
7732 /* a > 0 -> change lower bound of y */
7733 assert(SCIPsetIsInfinity(set, -parentvar->locdom.lb) || SCIPsetIsInfinity(set, -oldbound)
7734 || SCIPsetIsFeasEQ(set, parentvar->locdom.lb, oldbound * parentvar->data.aggregate.scalar + parentvar->data.aggregate.constant)
7735 || (SCIPsetIsZero(set, parentvar->locdom.lb / parentvar->data.aggregate.scalar) && SCIPsetIsZero(set, oldbound)));
7736
7737 if( !SCIPsetIsInfinity(set, -newbound) && !SCIPsetIsInfinity(set, newbound) )
7738 {
7739 parentnewbound = parentvar->data.aggregate.scalar * newbound + parentvar->data.aggregate.constant;
7740 /* if parent's new lower bound exceeds its upper bound, then this could be due to numerical difficulties, e.g., if numbers are large
7741 * thus, at least a relative comparision of the new lower bound and the current upper bound should proof consistency
7742 * as a result, the parent's lower bound is set to it's upper bound, and not above
7743 */
7744 if( parentnewbound > parentvar->glbdom.ub )
7745 {
7746 /* due to numerics we only need to be feasible w.r.t. feasibility tolerance */
7747 assert(SCIPsetIsFeasLE(set, parentnewbound, parentvar->glbdom.ub));
7748 parentnewbound = parentvar->glbdom.ub;
7749 }
7750 }
7751 else
7752 parentnewbound = newbound;
7753 SCIP_CALL( varProcessChgLbLocal(parentvar, blkmem, set, NULL, lp, branchcand, eventqueue, parentnewbound) );
7754 }
7755 else
7756 {
7757 SCIP_Real parentnewbound;
7758
7759 /* a < 0 -> change upper bound of y */
7760 assert(SCIPsetIsNegative(set, parentvar->data.aggregate.scalar));
7761 assert(SCIPsetIsInfinity(set, parentvar->locdom.ub) || SCIPsetIsInfinity(set, -oldbound)
7762 || SCIPsetIsFeasEQ(set, parentvar->locdom.ub, oldbound * parentvar->data.aggregate.scalar + parentvar->data.aggregate.constant)
7763 || (SCIPsetIsZero(set, parentvar->locdom.ub / parentvar->data.aggregate.scalar) && SCIPsetIsZero(set, oldbound)));
7764
7765 if( !SCIPsetIsInfinity(set, -newbound) && !SCIPsetIsInfinity(set, newbound) )
7766 {
7767 parentnewbound = parentvar->data.aggregate.scalar * newbound + parentvar->data.aggregate.constant;
7768 /* if parent's new upper bound is below its lower bound, then this could be due to numerical difficulties, e.g., if numbers are large
7769 * thus, at least a relative comparision of the new upper bound and the current lower bound should proof consistency
7770 * as a result, the parent's upper bound is set to it's lower bound, and not below
7771 */
7772 if( parentnewbound < parentvar->glbdom.lb )
7773 {
7774 /* due to numerics we only need to be feasible w.r.t. feasibility tolerance */
7775 assert(SCIPsetIsFeasGE(set, parentnewbound, parentvar->glbdom.lb));
7776 parentnewbound = parentvar->glbdom.lb;
7777 }
7778 }
7779 else
7780 parentnewbound = -newbound;
7781 SCIP_CALL( varProcessChgUbLocal(parentvar, blkmem, set, NULL, lp, branchcand, eventqueue, parentnewbound) );
7782 }
7783 break;
7784
7785 case SCIP_VARSTATUS_NEGATED: /* x = offset - x' -> x' = offset - x */
7786 assert(parentvar->negatedvar != NULL);
7787 assert(SCIPvarGetStatus(parentvar->negatedvar) != SCIP_VARSTATUS_NEGATED);
7788 assert(parentvar->negatedvar->negatedvar == parentvar);
7789 SCIP_CALL( varProcessChgUbLocal(parentvar, blkmem, set, NULL, lp, branchcand, eventqueue,
7790 parentvar->data.negate.constant - newbound) );
7791 break;
7792
7793 default:
7794 SCIPerrorMessage("unknown variable status\n");
7795 return SCIP_INVALIDDATA;
7796 }
7797 }
7798
7799 return SCIP_OKAY;
7800}
7801
7802/** performs the current change in upper bound, changes all parents accordingly */
7803static
7805 SCIP_VAR* var, /**< problem variable to change */
7806 BMS_BLKMEM* blkmem, /**< block memory */
7807 SCIP_SET* set, /**< global SCIP settings */
7808 SCIP_STAT* stat, /**< problem statistics, or NULL if the bound change belongs to updating the parent variables */
7809 SCIP_LP* lp, /**< current LP data, may be NULL for original variables */
7810 SCIP_BRANCHCAND* branchcand, /**< branching candidate storage, may be NULL for original variables */
7811 SCIP_EVENTQUEUE* eventqueue, /**< event queue, may be NULL for original variables */
7812 SCIP_Real newbound /**< new bound for variable */
7813 )
7814{
7815 SCIP_VAR* parentvar;
7816 SCIP_Real oldbound;
7817 int i;
7818
7819 assert(var != NULL);
7820 assert(set != NULL);
7821 assert(var->scip == set->scip);
7822 assert((SCIPvarGetType(var) == SCIP_VARTYPE_BINARY && (SCIPsetIsZero(set, newbound) || SCIPsetIsEQ(set, newbound, 1.0)
7823 || SCIPsetIsEQ(set, newbound, var->locdom.lb)))
7825 || SCIPsetIsEQ(set, newbound, var->locdom.lb)))
7827
7828 /* check that the bound is feasible */
7829 assert(SCIPsetGetStage(set) == SCIP_STAGE_PROBLEM || SCIPsetIsGE(set, newbound, var->glbdom.lb));
7830 /* adjust bound to integral value if variable is of integral type */
7831 newbound = adjustedUb(set, SCIPvarGetType(var), newbound);
7832
7834 {
7835 /* we do not want to undercut the lower bound, which could have happened due to numerics */
7836 newbound = MAX(newbound, var->locdom.lb);
7837
7838 /* we do not want to exceed the global upper bound, which could have happened due to numerics */
7839 newbound = MIN(newbound, var->glbdom.ub);
7840 }
7842
7843 SCIPsetDebugMsg(set, "process changing upper bound of <%s> from %g to %g\n", var->name, var->locdom.ub, newbound);
7844
7845 if( SCIPsetIsEQ(set, newbound, var->glbdom.ub) && var->glbdom.ub != var->locdom.ub ) /*lint !e777*/
7846 newbound = var->glbdom.ub;
7847 else if( SCIPsetIsEQ(set, newbound, var->locdom.ub) && !(newbound != var->locdom.ub && newbound * var->locdom.ub <= 0.0) ) /*lint !e777*/
7848 return SCIP_OKAY;
7849
7850 /* change the bound */
7851 oldbound = var->locdom.ub;
7852 assert(SCIPsetGetStage(set) == SCIP_STAGE_PROBLEM || SCIPsetIsFeasGE(set, newbound, var->locdom.lb));
7853 var->locdom.ub = newbound;
7854
7855 /* update statistic; during the update steps of the parent variable we pass a NULL pointer to ensure that we only
7856 * once update the statistic
7857 */
7858 if( stat != NULL )
7859 SCIPstatIncrement(stat, set, domchgcount);
7860
7862 {
7863 /* merges overlapping holes into single holes, moves bounds respectively */
7864 domMerge(&var->locdom, blkmem, set, NULL, &newbound);
7865 }
7866
7867 /* issue bound change event */
7868 assert(SCIPvarIsTransformed(var) == (var->eventfilter != NULL));
7870 {
7871 SCIP_CALL( varEventUbChanged(var, blkmem, set, lp, branchcand, eventqueue, oldbound, newbound) );
7872 }
7873
7874 /* process parent variables */
7875 for( i = 0; i < var->nparentvars; ++i )
7876 {
7877 parentvar = var->parentvars[i];
7878 assert(parentvar != NULL);
7879
7880 switch( SCIPvarGetStatus(parentvar) )
7881 {
7883 SCIP_CALL( varProcessChgUbLocal(parentvar, blkmem, set, NULL, lp, branchcand, eventqueue, newbound) );
7884 break;
7885
7890 SCIPerrorMessage("column, loose, fixed or multi-aggregated variable cannot be the parent of a variable\n");
7891 return SCIP_INVALIDDATA;
7892
7893 case SCIP_VARSTATUS_AGGREGATED: /* x = a*y + c -> y = (x-c)/a */
7894 assert(parentvar->data.aggregate.var == var);
7895 if( SCIPsetIsPositive(set, parentvar->data.aggregate.scalar) )
7896 {
7897 SCIP_Real parentnewbound;
7898
7899 /* a > 0 -> change upper bound of x */
7900 assert(SCIPsetIsInfinity(set, parentvar->locdom.ub) || SCIPsetIsInfinity(set, oldbound)
7901 || SCIPsetIsFeasEQ(set, parentvar->locdom.ub,
7902 oldbound * parentvar->data.aggregate.scalar + parentvar->data.aggregate.constant));
7903 if( !SCIPsetIsInfinity(set, -newbound) && !SCIPsetIsInfinity(set, newbound) )
7904 {
7905 parentnewbound = parentvar->data.aggregate.scalar * newbound + parentvar->data.aggregate.constant;
7906 /* if parent's new upper bound is below its lower bound, then this could be due to numerical difficulties, e.g., if numbers are large
7907 * thus, at least a relative comparision of the new upper bound and the current lower bound should proof consistency
7908 * as a result, the parent's upper bound is set to it's lower bound, and not below
7909 */
7910 if( parentnewbound < parentvar->glbdom.lb )
7911 {
7912 /* due to numerics we only need to be feasible w.r.t. feasibility tolerance */
7913 assert(SCIPsetIsFeasGE(set, parentnewbound, parentvar->glbdom.lb));
7914 parentnewbound = parentvar->glbdom.lb;
7915 }
7916 }
7917 else
7918 parentnewbound = newbound;
7919 SCIP_CALL( varProcessChgUbLocal(parentvar, blkmem, set, NULL, lp, branchcand, eventqueue, parentnewbound) );
7920 }
7921 else
7922 {
7923 SCIP_Real parentnewbound;
7924
7925 /* a < 0 -> change lower bound of x */
7926 assert(SCIPsetIsNegative(set, parentvar->data.aggregate.scalar));
7927 assert(SCIPsetIsInfinity(set, -parentvar->locdom.lb) || SCIPsetIsInfinity(set, oldbound)
7928 || SCIPsetIsFeasEQ(set, parentvar->locdom.lb,
7929 oldbound * parentvar->data.aggregate.scalar + parentvar->data.aggregate.constant));
7930 if( !SCIPsetIsInfinity(set, -newbound) && !SCIPsetIsInfinity(set, newbound) )
7931 {
7932 parentnewbound = parentvar->data.aggregate.scalar * newbound + parentvar->data.aggregate.constant;
7933 /* if parent's new lower bound exceeds its upper bound, then this could be due to numerical difficulties, e.g., if numbers are large
7934 * thus, at least a relative comparision of the new lower bound and the current upper bound should proof consistency
7935 * as a result, the parent's lower bound is set to it's upper bound, and not above
7936 */
7937 if( parentnewbound > parentvar->glbdom.ub )
7938 {
7939 /* due to numerics we only need to be feasible w.r.t. feasibility tolerance */
7940 assert(SCIPsetIsFeasLE(set, parentnewbound, parentvar->glbdom.ub));
7941 parentnewbound = parentvar->glbdom.ub;
7942 }
7943 }
7944 else
7945 parentnewbound = -newbound;
7946 SCIP_CALL( varProcessChgLbLocal(parentvar, blkmem, set, NULL, lp, branchcand, eventqueue, parentnewbound) );
7947 }
7948 break;
7949
7950 case SCIP_VARSTATUS_NEGATED: /* x = offset - x' -> x' = offset - x */
7951 assert(parentvar->negatedvar != NULL);
7952 assert(SCIPvarGetStatus(parentvar->negatedvar) != SCIP_VARSTATUS_NEGATED);
7953 assert(parentvar->negatedvar->negatedvar == parentvar);
7954 SCIP_CALL( varProcessChgLbLocal(parentvar, blkmem, set, NULL, lp, branchcand, eventqueue,
7955 parentvar->data.negate.constant - newbound) );
7956 break;
7957
7958 default:
7959 SCIPerrorMessage("unknown variable status\n");
7960 return SCIP_INVALIDDATA;
7961 }
7962 }
7963
7964 return SCIP_OKAY;
7965}
7966
7967/** changes current local lower bound of variable; if possible, adjusts bound to integral value; stores inference
7968 * information in variable
7969 */
7971 SCIP_VAR* var, /**< problem variable to change */
7972 BMS_BLKMEM* blkmem, /**< block memory */
7973 SCIP_SET* set, /**< global SCIP settings */
7974 SCIP_STAT* stat, /**< problem statistics */
7975 SCIP_LP* lp, /**< current LP data, may be NULL for original variables */
7976 SCIP_BRANCHCAND* branchcand, /**< branching candidate storage, may be NULL for original variables */
7977 SCIP_EVENTQUEUE* eventqueue, /**< event queue, may be NULL for original variables */
7978 SCIP_Real newbound /**< new bound for variable */
7979 )
7980{
7981 assert(var != NULL);
7982 assert(blkmem != NULL);
7983 assert(set != NULL);
7984 assert(var->scip == set->scip);
7985
7986 /* check that the bound is feasible; this must be w.r.t. feastol because SCIPvarFix() allows fixings that are outside
7987 * of the domain within feastol
7988 */
7989 assert(SCIPsetGetStage(set) == SCIP_STAGE_PROBLEM || !SCIPsetIsFeasGT(set, newbound, var->locdom.ub));
7990
7991 /* adjust bound to integral value if variable is of integral type */
7992 newbound = adjustedLb(set, SCIPvarGetType(var), newbound);
7993
7994 /* check that the adjusted bound is feasible */
7995 assert(SCIPsetGetStage(set) == SCIP_STAGE_PROBLEM || !SCIPsetIsFeasGT(set, newbound, var->locdom.ub));
7996
7998 {
7999 /* we do not want to exceed the upperbound, which could have happened due to numerics */
8000 newbound = MIN(newbound, var->locdom.ub);
8001 }
8003
8004 SCIPsetDebugMsg(set, "changing lower bound of <%s>[%g,%g] to %g\n", var->name, var->locdom.lb, var->locdom.ub, newbound);
8005
8006 if( SCIPsetIsEQ(set, var->locdom.lb, newbound) && (!SCIPsetIsEQ(set, var->glbdom.lb, newbound) || var->locdom.lb == newbound) /*lint !e777*/
8007 && !(newbound != var->locdom.lb && newbound * var->locdom.lb <= 0.0) ) /*lint !e777*/
8008 return SCIP_OKAY;
8009
8010 /* change bounds of attached variables */
8011 switch( SCIPvarGetStatus(var) )
8012 {
8014 if( var->data.original.transvar != NULL )
8015 {
8016 SCIP_CALL( SCIPvarChgLbLocal(var->data.original.transvar, blkmem, set, stat, lp, branchcand, eventqueue,
8017 newbound) );
8018 }
8019 else
8020 {
8021 assert(set->stage == SCIP_STAGE_PROBLEM);
8022 SCIP_CALL( varProcessChgLbLocal(var, blkmem, set, stat, lp, branchcand, eventqueue, newbound) );
8023 }
8024 break;
8025
8028 SCIP_CALL( varProcessChgLbLocal(var, blkmem, set, stat, lp, branchcand, eventqueue, newbound) );
8029 break;
8030
8032 SCIPerrorMessage("cannot change the bounds of a fixed variable\n");
8033 return SCIP_INVALIDDATA;
8034
8035 case SCIP_VARSTATUS_AGGREGATED: /* x = a*y + c -> y = (x-c)/a */
8036 assert(var->data.aggregate.var != NULL);
8038 {
8039 SCIP_Real childnewbound;
8040
8041 /* a > 0 -> change lower bound of y */
8043 || SCIPsetIsFeasEQ(set, var->locdom.lb,
8045 if( !SCIPsetIsInfinity(set, -newbound) && !SCIPsetIsInfinity(set, newbound) )
8046 childnewbound = (newbound - var->data.aggregate.constant)/var->data.aggregate.scalar;
8047 else
8048 childnewbound = newbound;
8049 SCIP_CALL( SCIPvarChgLbLocal(var->data.aggregate.var, blkmem, set, stat, lp, branchcand, eventqueue,
8050 childnewbound) );
8051 }
8052 else if( SCIPsetIsNegative(set, var->data.aggregate.scalar) )
8053 {
8054 SCIP_Real childnewbound;
8055
8056 /* a < 0 -> change upper bound of y */
8058 || SCIPsetIsFeasEQ(set, var->locdom.lb,
8060 if( !SCIPsetIsInfinity(set, -newbound) && !SCIPsetIsInfinity(set, newbound) )
8061 childnewbound = (newbound - var->data.aggregate.constant)/var->data.aggregate.scalar;
8062 else
8063 childnewbound = -newbound;
8064 SCIP_CALL( SCIPvarChgUbLocal(var->data.aggregate.var, blkmem, set, stat, lp, branchcand, eventqueue,
8065 childnewbound) );
8066 }
8067 else
8068 {
8069 SCIPerrorMessage("scalar is zero in aggregation\n");
8070 return SCIP_INVALIDDATA;
8071 }
8072 break;
8073
8075 SCIPerrorMessage("cannot change the bounds of a multi-aggregated variable.\n");
8076 return SCIP_INVALIDDATA;
8077
8078 case SCIP_VARSTATUS_NEGATED: /* x' = offset - x -> x = offset - x' */
8079 assert(var->negatedvar != NULL);
8081 assert(var->negatedvar->negatedvar == var);
8082 SCIP_CALL( SCIPvarChgUbLocal(var->negatedvar, blkmem, set, stat, lp, branchcand, eventqueue,
8083 var->data.negate.constant - newbound) );
8084 break;
8085
8086 default:
8087 SCIPerrorMessage("unknown variable status\n");
8088 return SCIP_INVALIDDATA;
8089 }
8090
8091 return SCIP_OKAY;
8092}
8093
8094/** changes current local upper bound of variable; if possible, adjusts bound to integral value; stores inference
8095 * information in variable
8096 */
8098 SCIP_VAR* var, /**< problem variable to change */
8099 BMS_BLKMEM* blkmem, /**< block memory */
8100 SCIP_SET* set, /**< global SCIP settings */
8101 SCIP_STAT* stat, /**< problem statistics */
8102 SCIP_LP* lp, /**< current LP data, may be NULL for original variables */
8103 SCIP_BRANCHCAND* branchcand, /**< branching candidate storage, may be NULL for original variables */
8104 SCIP_EVENTQUEUE* eventqueue, /**< event queue, may be NULL for original variables */
8105 SCIP_Real newbound /**< new bound for variable */
8106 )
8107{
8108 assert(var != NULL);
8109 assert(blkmem != NULL);
8110 assert(set != NULL);
8111 assert(var->scip == set->scip);
8112
8113 /* check that the bound is feasible; this must be w.r.t. feastol because SCIPvarFix() allows fixings that are outside
8114 * of the domain within feastol
8115 */
8116 assert(SCIPsetGetStage(set) == SCIP_STAGE_PROBLEM || !SCIPsetIsFeasLT(set, newbound, var->locdom.lb));
8117
8118 /* adjust bound to integral value if variable is of integral type */
8119 newbound = adjustedUb(set, SCIPvarGetType(var), newbound);
8120
8121 /* check that the adjusted bound is feasible */
8122 assert(SCIPsetGetStage(set) == SCIP_STAGE_PROBLEM || !SCIPsetIsFeasLT(set, newbound, var->locdom.lb));
8123
8125 {
8126 /* we do not want to undercut the lowerbound, which could have happened due to numerics */
8127 newbound = MAX(newbound, var->locdom.lb);
8128 }
8130
8131 SCIPsetDebugMsg(set, "changing upper bound of <%s>[%g,%g] to %g\n", var->name, var->locdom.lb, var->locdom.ub, newbound);
8132
8133 if( SCIPsetIsEQ(set, var->locdom.ub, newbound) && (!SCIPsetIsEQ(set, var->glbdom.ub, newbound) || var->locdom.ub == newbound) /*lint !e777*/
8134 && !(newbound != var->locdom.ub && newbound * var->locdom.ub <= 0.0) ) /*lint !e777*/
8135 return SCIP_OKAY;
8136
8137 /* change bounds of attached variables */
8138 switch( SCIPvarGetStatus(var) )
8139 {
8141 if( var->data.original.transvar != NULL )
8142 {
8143 SCIP_CALL( SCIPvarChgUbLocal(var->data.original.transvar, blkmem, set, stat, lp, branchcand, eventqueue, newbound) );
8144 }
8145 else
8146 {
8147 assert(set->stage == SCIP_STAGE_PROBLEM);
8148 SCIP_CALL( varProcessChgUbLocal(var, blkmem, set, stat, lp, branchcand, eventqueue, newbound) );
8149 }
8150 break;
8151
8154 SCIP_CALL( varProcessChgUbLocal(var, blkmem, set, stat, lp, branchcand, eventqueue, newbound) );
8155 break;
8156
8158 SCIPerrorMessage("cannot change the bounds of a fixed variable\n");
8159 return SCIP_INVALIDDATA;
8160
8161 case SCIP_VARSTATUS_AGGREGATED: /* x = a*y + c -> y = (x-c)/a */
8162 assert(var->data.aggregate.var != NULL);
8164 {
8165 SCIP_Real childnewbound;
8166
8167 /* a > 0 -> change upper bound of y */
8169 || SCIPsetIsFeasEQ(set, var->locdom.ub,
8171 if( !SCIPsetIsInfinity(set, -newbound) && !SCIPsetIsInfinity(set, newbound) )
8172 childnewbound = (newbound - var->data.aggregate.constant)/var->data.aggregate.scalar;
8173 else
8174 childnewbound = newbound;
8175 SCIP_CALL( SCIPvarChgUbLocal(var->data.aggregate.var, blkmem, set, stat, lp, branchcand, eventqueue,
8176 childnewbound) );
8177 }
8178 else if( SCIPsetIsNegative(set, var->data.aggregate.scalar) )
8179 {
8180 SCIP_Real childnewbound;
8181
8182 /* a < 0 -> change lower bound of y */
8184 || SCIPsetIsFeasEQ(set, var->locdom.ub,
8186 if( !SCIPsetIsInfinity(set, -newbound) && !SCIPsetIsInfinity(set, newbound) )
8187 childnewbound = (newbound - var->data.aggregate.constant)/var->data.aggregate.scalar;
8188 else
8189 childnewbound = -newbound;
8190 SCIP_CALL( SCIPvarChgLbLocal(var->data.aggregate.var, blkmem, set, stat, lp, branchcand, eventqueue,
8191 childnewbound) );
8192 }
8193 else
8194 {
8195 SCIPerrorMessage("scalar is zero in aggregation\n");
8196 return SCIP_INVALIDDATA;
8197 }
8198 break;
8199
8201 SCIPerrorMessage("cannot change the bounds of a multi-aggregated variable.\n");
8202 return SCIP_INVALIDDATA;
8203
8204 case SCIP_VARSTATUS_NEGATED: /* x' = offset - x -> x = offset - x' */
8205 assert(var->negatedvar != NULL);
8207 assert(var->negatedvar->negatedvar == var);
8208 SCIP_CALL( SCIPvarChgLbLocal(var->negatedvar, blkmem, set, stat, lp, branchcand, eventqueue,
8209 var->data.negate.constant - newbound) );
8210 break;
8211
8212 default:
8213 SCIPerrorMessage("unknown variable status\n");
8214 return SCIP_INVALIDDATA;
8215 }
8216
8217 return SCIP_OKAY;
8218}
8219
8220/** changes current local bound of variable; if possible, adjusts bound to integral value; stores inference
8221 * information in variable
8222 */
8224 SCIP_VAR* var, /**< problem variable to change */
8225 BMS_BLKMEM* blkmem, /**< block memory */
8226 SCIP_SET* set, /**< global SCIP settings */
8227 SCIP_STAT* stat, /**< problem statistics */
8228 SCIP_LP* lp, /**< current LP data, may be NULL for original variables */
8229 SCIP_BRANCHCAND* branchcand, /**< branching candidate storage, may be NULL for original variables */
8230 SCIP_EVENTQUEUE* eventqueue, /**< event queue, may be NULL for original variables */
8231 SCIP_Real newbound, /**< new bound for variable */
8232 SCIP_BOUNDTYPE boundtype /**< type of bound: lower or upper bound */
8233 )
8234{
8235 /* apply bound change to the LP data */
8236 switch( boundtype )
8237 {
8239 return SCIPvarChgLbLocal(var, blkmem, set, stat, lp, branchcand, eventqueue, newbound);
8241 return SCIPvarChgUbLocal(var, blkmem, set, stat, lp, branchcand, eventqueue, newbound);
8242 default:
8243 SCIPerrorMessage("unknown bound type\n");
8244 return SCIP_INVALIDDATA;
8245 }
8246}
8247
8248/** changes lower bound of variable in current dive; if possible, adjusts bound to integral value */
8250 SCIP_VAR* var, /**< problem variable to change */
8251 SCIP_SET* set, /**< global SCIP settings */
8252 SCIP_LP* lp, /**< current LP data */
8253 SCIP_Real newbound /**< new bound for variable */
8254 )
8255{
8256 assert(var != NULL);
8257 assert(set != NULL);
8258 assert(var->scip == set->scip);
8259 assert(lp != NULL);
8260 assert(SCIPlpDiving(lp));
8261
8262 /* adjust bound for integral variables */
8263 SCIPvarAdjustLb(var, set, &newbound);
8264
8265 SCIPsetDebugMsg(set, "changing lower bound of <%s> to %g in current dive\n", var->name, newbound);
8266
8267 /* change bounds of attached variables */
8268 switch( SCIPvarGetStatus(var) )
8269 {
8271 assert(var->data.original.transvar != NULL);
8272 SCIP_CALL( SCIPvarChgLbDive(var->data.original.transvar, set, lp, newbound) );
8273 break;
8274
8276 assert(var->data.col != NULL);
8277 SCIP_CALL( SCIPcolChgLb(var->data.col, set, lp, newbound) );
8278 break;
8279
8281 SCIPerrorMessage("cannot change variable's bounds in dive for LOOSE variables\n");
8282 return SCIP_INVALIDDATA;
8283
8285 SCIPerrorMessage("cannot change the bounds of a fixed variable\n");
8286 return SCIP_INVALIDDATA;
8287
8288 case SCIP_VARSTATUS_AGGREGATED: /* x = a*y + c -> y = (x-c)/a */
8289 assert(var->data.aggregate.var != NULL);
8291 {
8292 SCIP_Real childnewbound;
8293
8294 /* a > 0 -> change lower bound of y */
8295 if( !SCIPsetIsInfinity(set, -newbound) && !SCIPsetIsInfinity(set, newbound) )
8296 childnewbound = (newbound - var->data.aggregate.constant)/var->data.aggregate.scalar;
8297 else
8298 childnewbound = newbound;
8299 SCIP_CALL( SCIPvarChgLbDive(var->data.aggregate.var, set, lp, childnewbound) );
8300 }
8301 else if( SCIPsetIsNegative(set, var->data.aggregate.scalar) )
8302 {
8303 SCIP_Real childnewbound;
8304
8305 /* a < 0 -> change upper bound of y */
8306 if( !SCIPsetIsInfinity(set, -newbound) && !SCIPsetIsInfinity(set, newbound) )
8307 childnewbound = (newbound - var->data.aggregate.constant)/var->data.aggregate.scalar;
8308 else
8309 childnewbound = -newbound;
8310 SCIP_CALL( SCIPvarChgUbDive(var->data.aggregate.var, set, lp, childnewbound) );
8311 }
8312 else
8313 {
8314 SCIPerrorMessage("scalar is zero in aggregation\n");
8315 return SCIP_INVALIDDATA;
8316 }
8317 break;
8318
8320 SCIPerrorMessage("cannot change the bounds of a multi-aggregated variable.\n");
8321 return SCIP_INVALIDDATA;
8322
8323 case SCIP_VARSTATUS_NEGATED: /* x' = offset - x -> x = offset - x' */
8324 assert(var->negatedvar != NULL);
8326 assert(var->negatedvar->negatedvar == var);
8327 SCIP_CALL( SCIPvarChgUbDive(var->negatedvar, set, lp, var->data.negate.constant - newbound) );
8328 break;
8329
8330 default:
8331 SCIPerrorMessage("unknown variable status\n");
8332 return SCIP_INVALIDDATA;
8333 }
8334
8335 return SCIP_OKAY;
8336}
8337
8338/** changes upper bound of variable in current dive; if possible, adjusts bound to integral value */
8340 SCIP_VAR* var, /**< problem variable to change */
8341 SCIP_SET* set, /**< global SCIP settings */
8342 SCIP_LP* lp, /**< current LP data */
8343 SCIP_Real newbound /**< new bound for variable */
8344 )
8345{
8346 assert(var != NULL);
8347 assert(set != NULL);
8348 assert(var->scip == set->scip);
8349 assert(lp != NULL);
8350 assert(SCIPlpDiving(lp));
8351
8352 /* adjust bound for integral variables */
8353 SCIPvarAdjustUb(var, set, &newbound);
8354
8355 SCIPsetDebugMsg(set, "changing upper bound of <%s> to %g in current dive\n", var->name, newbound);
8356
8357 /* change bounds of attached variables */
8358 switch( SCIPvarGetStatus(var) )
8359 {
8361 assert(var->data.original.transvar != NULL);
8362 SCIP_CALL( SCIPvarChgUbDive(var->data.original.transvar, set, lp, newbound) );
8363 break;
8364
8366 assert(var->data.col != NULL);
8367 SCIP_CALL( SCIPcolChgUb(var->data.col, set, lp, newbound) );
8368 break;
8369
8371 SCIPerrorMessage("cannot change variable's bounds in dive for LOOSE variables\n");
8372 return SCIP_INVALIDDATA;
8373
8375 SCIPerrorMessage("cannot change the bounds of a fixed variable\n");
8376 return SCIP_INVALIDDATA;
8377
8378 case SCIP_VARSTATUS_AGGREGATED: /* x = a*y + c -> y = (x-c)/a */
8379 assert(var->data.aggregate.var != NULL);
8381 {
8382 SCIP_Real childnewbound;
8383
8384 /* a > 0 -> change upper bound of y */
8385 if( !SCIPsetIsInfinity(set, -newbound) && !SCIPsetIsInfinity(set, newbound) )
8386 childnewbound = (newbound - var->data.aggregate.constant)/var->data.aggregate.scalar;
8387 else
8388 childnewbound = newbound;
8389 SCIP_CALL( SCIPvarChgUbDive(var->data.aggregate.var, set, lp, childnewbound) );
8390 }
8391 else if( SCIPsetIsNegative(set, var->data.aggregate.scalar) )
8392 {
8393 SCIP_Real childnewbound;
8394
8395 /* a < 0 -> change lower bound of y */
8396 if( !SCIPsetIsInfinity(set, -newbound) && !SCIPsetIsInfinity(set, newbound) )
8397 childnewbound = (newbound - var->data.aggregate.constant)/var->data.aggregate.scalar;
8398 else
8399 childnewbound = -newbound;
8400 SCIP_CALL( SCIPvarChgLbDive(var->data.aggregate.var, set, lp, childnewbound) );
8401 }
8402 else
8403 {
8404 SCIPerrorMessage("scalar is zero in aggregation\n");
8405 return SCIP_INVALIDDATA;
8406 }
8407 break;
8408
8410 SCIPerrorMessage("cannot change the bounds of a multi-aggregated variable.\n");
8411 return SCIP_INVALIDDATA;
8412
8413 case SCIP_VARSTATUS_NEGATED: /* x' = offset - x -> x = offset - x' */
8414 assert(var->negatedvar != NULL);
8416 assert(var->negatedvar->negatedvar == var);
8417 SCIP_CALL( SCIPvarChgLbDive(var->negatedvar, set, lp, var->data.negate.constant - newbound) );
8418 break;
8419
8420 default:
8421 SCIPerrorMessage("unknown variable status\n");
8422 return SCIP_INVALIDDATA;
8423 }
8424
8425 return SCIP_OKAY;
8426}
8427
8428/** for a multi-aggregated variable, gives the local lower bound computed by adding the local bounds from all
8429 * aggregation variables, this lower bound may be tighter than the one given by SCIPvarGetLbLocal, since the latter is
8430 * not updated if bounds of aggregation variables are changing
8431 *
8432 * calling this function for a non-multi-aggregated variable is not allowed
8433 */
8435 SCIP_VAR* var, /**< problem variable */
8436 SCIP_SET* set /**< global SCIP settings */
8437 )
8438{
8439 int i;
8440 SCIP_Real lb;
8441 SCIP_Real bnd;
8442 SCIP_VAR* aggrvar;
8443 SCIP_Bool posinf;
8444 SCIP_Bool neginf;
8445
8446 assert(var != NULL);
8447 assert(set != NULL);
8448 assert(var->scip == set->scip);
8450
8451 posinf = FALSE;
8452 neginf = FALSE;
8453 lb = var->data.multaggr.constant;
8454 for( i = var->data.multaggr.nvars-1 ; i >= 0 ; --i )
8455 {
8456 aggrvar = var->data.multaggr.vars[i];
8457 if( var->data.multaggr.scalars[i] > 0.0 )
8458 {
8460
8461 if( SCIPsetIsInfinity(set, bnd) )
8462 posinf = TRUE;
8463 else if( SCIPsetIsInfinity(set, -bnd) )
8464 neginf = TRUE;
8465 else
8466 lb += var->data.multaggr.scalars[i] * bnd;
8467 }
8468 else
8469 {
8471
8472 if( SCIPsetIsInfinity(set, -bnd) )
8473 posinf = TRUE;
8474 else if( SCIPsetIsInfinity(set, bnd) )
8475 neginf = TRUE;
8476 else
8477 lb += var->data.multaggr.scalars[i] * bnd;
8478 }
8479
8480 /* stop if two diffrent infinities (or a -infinity) were found and return local lower bound of multi aggregated
8481 * variable
8482 */
8483 if( neginf )
8484 return SCIPvarGetLbLocal(var);
8485 }
8486
8487 /* if positive infinity flag was set to true return infinity */
8488 if( posinf )
8489 return SCIPsetInfinity(set);
8490
8491 return (MAX(lb, SCIPvarGetLbLocal(var))); /*lint !e666*/
8492}
8493
8494/** for a multi-aggregated variable, gives the local upper bound computed by adding the local bounds from all
8495 * aggregation variables, this upper bound may be tighter than the one given by SCIPvarGetUbLocal, since the latter is
8496 * not updated if bounds of aggregation variables are changing
8497 *
8498 * calling this function for a non-multi-aggregated variable is not allowed
8499 */
8501 SCIP_VAR* var, /**< problem variable */
8502 SCIP_SET* set /**< global SCIP settings */
8503 )
8504{
8505 int i;
8506 SCIP_Real ub;
8507 SCIP_Real bnd;
8508 SCIP_VAR* aggrvar;
8509 SCIP_Bool posinf;
8510 SCIP_Bool neginf;
8511
8512 assert(var != NULL);
8513 assert(set != NULL);
8514 assert(var->scip == set->scip);
8516
8517 posinf = FALSE;
8518 neginf = FALSE;
8519 ub = var->data.multaggr.constant;
8520 for( i = var->data.multaggr.nvars-1 ; i >= 0 ; --i )
8521 {
8522 aggrvar = var->data.multaggr.vars[i];
8523 if( var->data.multaggr.scalars[i] > 0.0 )
8524 {
8526
8527 if( SCIPsetIsInfinity(set, bnd) )
8528 posinf = TRUE;
8529 else if( SCIPsetIsInfinity(set, -bnd) )
8530 neginf = TRUE;
8531 else
8532 ub += var->data.multaggr.scalars[i] * bnd;
8533 }
8534 else
8535 {
8537
8538 if( SCIPsetIsInfinity(set, -bnd) )
8539 posinf = TRUE;
8540 else if( SCIPsetIsInfinity(set, bnd) )
8541 neginf = TRUE;
8542 else
8543 ub += var->data.multaggr.scalars[i] * bnd;
8544 }
8545
8546 /* stop if two diffrent infinities (or a -infinity) were found and return local upper bound of multi aggregated
8547 * variable
8548 */
8549 if( posinf )
8550 return SCIPvarGetUbLocal(var);
8551 }
8552
8553 /* if negative infinity flag was set to true return -infinity */
8554 if( neginf )
8555 return -SCIPsetInfinity(set);
8556
8557 return (MIN(ub, SCIPvarGetUbLocal(var))); /*lint !e666*/
8558}
8559
8560/** for a multi-aggregated variable, gives the global lower bound computed by adding the global bounds from all
8561 * aggregation variables, this global bound may be tighter than the one given by SCIPvarGetLbGlobal, since the latter is
8562 * not updated if bounds of aggregation variables are changing
8563 *
8564 * calling this function for a non-multi-aggregated variable is not allowed
8565 */
8567 SCIP_VAR* var, /**< problem variable */
8568 SCIP_SET* set /**< global SCIP settings */
8569 )
8570{
8571 int i;
8572 SCIP_Real lb;
8573 SCIP_Real bnd;
8574 SCIP_VAR* aggrvar;
8575 SCIP_Bool posinf;
8576 SCIP_Bool neginf;
8577
8578 assert(var != NULL);
8579 assert(set != NULL);
8580 assert(var->scip == set->scip);
8582
8583 posinf = FALSE;
8584 neginf = FALSE;
8585 lb = var->data.multaggr.constant;
8586 for( i = var->data.multaggr.nvars-1 ; i >= 0 ; --i )
8587 {
8588 aggrvar = var->data.multaggr.vars[i];
8589 if( var->data.multaggr.scalars[i] > 0.0 )
8590 {
8592
8593 if( SCIPsetIsInfinity(set, bnd) )
8594 posinf = TRUE;
8595 else if( SCIPsetIsInfinity(set, -bnd) )
8596 neginf = TRUE;
8597 else
8598 lb += var->data.multaggr.scalars[i] * bnd;
8599 }
8600 else
8601 {
8603
8604 if( SCIPsetIsInfinity(set, -bnd) )
8605 posinf = TRUE;
8606 else if( SCIPsetIsInfinity(set, bnd) )
8607 neginf = TRUE;
8608 else
8609 lb += var->data.multaggr.scalars[i] * bnd;
8610 }
8611
8612 /* stop if two diffrent infinities (or a -infinity) were found and return global lower bound of multi aggregated
8613 * variable
8614 */
8615 if( neginf )
8616 return SCIPvarGetLbGlobal(var);
8617 }
8618
8619 /* if positive infinity flag was set to true return infinity */
8620 if( posinf )
8621 return SCIPsetInfinity(set);
8622
8623 return (MAX(lb, SCIPvarGetLbGlobal(var))); /*lint !e666*/
8624}
8625
8626/** for a multi-aggregated variable, gives the global upper bound computed by adding the global bounds from all
8627 * aggregation variables, this upper bound may be tighter than the one given by SCIPvarGetUbGlobal, since the latter is
8628 * not updated if bounds of aggregation variables are changing
8629 *
8630 * calling this function for a non-multi-aggregated variable is not allowed
8631 */
8633 SCIP_VAR* var, /**< problem variable */
8634 SCIP_SET* set /**< global SCIP settings */
8635 )
8636{
8637 int i;
8638 SCIP_Real ub;
8639 SCIP_Real bnd;
8640 SCIP_VAR* aggrvar;
8641 SCIP_Bool posinf;
8642 SCIP_Bool neginf;
8643
8644 assert(var != NULL);
8645 assert(set != NULL);
8646 assert(var->scip == set->scip);
8648
8649 posinf = FALSE;
8650 neginf = FALSE;
8651 ub = var->data.multaggr.constant;
8652 for( i = var->data.multaggr.nvars-1 ; i >= 0 ; --i )
8653 {
8654 aggrvar = var->data.multaggr.vars[i];
8655 if( var->data.multaggr.scalars[i] > 0.0 )
8656 {
8658
8659 if( SCIPsetIsInfinity(set, bnd) )
8660 posinf = TRUE;
8661 else if( SCIPsetIsInfinity(set, -bnd) )
8662 neginf = TRUE;
8663 else
8664 ub += var->data.multaggr.scalars[i] * bnd;
8665 }
8666 else
8667 {
8669
8670 if( SCIPsetIsInfinity(set, -bnd) )
8671 posinf = TRUE;
8672 else if( SCIPsetIsInfinity(set, bnd) )
8673 neginf = TRUE;
8674 else
8675 ub += var->data.multaggr.scalars[i] * bnd;
8676 }
8677
8678 /* stop if two diffrent infinities (or a -infinity) were found and return local upper bound of multi aggregated
8679 * variable
8680 */
8681 if( posinf )
8682 return SCIPvarGetUbGlobal(var);
8683 }
8684
8685 /* if negative infinity flag was set to true return -infinity */
8686 if( neginf )
8687 return -SCIPsetInfinity(set);
8688
8689 return (MIN(ub, SCIPvarGetUbGlobal(var))); /*lint !e666*/
8690}
8691
8692/** adds a hole to the original domain of the variable */
8694 SCIP_VAR* var, /**< problem variable */
8695 BMS_BLKMEM* blkmem, /**< block memory */
8696 SCIP_SET* set, /**< global SCIP settings */
8697 SCIP_Real left, /**< left bound of open interval in new hole */
8698 SCIP_Real right /**< right bound of open interval in new hole */
8699 )
8700{
8701 SCIP_Bool added;
8702
8703 assert(var != NULL);
8704 assert(!SCIPvarIsTransformed(var));
8707 assert(set != NULL);
8708 assert(var->scip == set->scip);
8709 assert(set->stage == SCIP_STAGE_PROBLEM);
8710
8711 SCIPsetDebugMsg(set, "adding original hole (%g,%g) to <%s>\n", left, right, var->name);
8712
8713 if( SCIPsetIsEQ(set, left, right) )
8714 return SCIP_OKAY;
8715
8716 /* the interval should not be empty */
8717 assert(SCIPsetIsLT(set, left, right));
8718
8719 /* the the interval bound should already be adjusted */
8720 assert(SCIPsetIsEQ(set, left, adjustedUb(set, SCIPvarGetType(var), left)));
8721 assert(SCIPsetIsEQ(set, right, adjustedLb(set, SCIPvarGetType(var), right)));
8722
8723 /* the the interval should lay between the lower and upper bound */
8724 assert(SCIPsetIsGE(set, left, SCIPvarGetLbOriginal(var)));
8725 assert(SCIPsetIsLE(set, right, SCIPvarGetUbOriginal(var)));
8726
8727 /* add domain hole */
8728 SCIP_CALL( domAddHole(&var->data.original.origdom, blkmem, set, left, right, &added) );
8729
8730 /* merges overlapping holes into single holes, moves bounds respectively if hole was added */
8731 if( added )
8732 {
8733 domMerge(&var->data.original.origdom, blkmem, set, NULL, NULL);
8734 }
8735
8736 /**@todo add hole in parent and child variables (just like with bound changes);
8737 * warning! original vars' holes are in original blkmem, transformed vars' holes in transformed blkmem
8738 */
8739
8740 return SCIP_OKAY;
8741}
8742
8743/** performs the current add of domain, changes all parents accordingly */
8744static
8746 SCIP_VAR* var, /**< problem variable */
8747 BMS_BLKMEM* blkmem, /**< block memory */
8748 SCIP_SET* set, /**< global SCIP settings */
8749 SCIP_STAT* stat, /**< problem statistics */
8750 SCIP_EVENTQUEUE* eventqueue, /**< event queue, may be NULL for original variables */
8751 SCIP_Real left, /**< left bound of open interval in new hole */
8752 SCIP_Real right, /**< right bound of open interval in new hole */
8753 SCIP_Bool* added /**< pointer to store whether the hole was added */
8754 )
8755{
8756 SCIP_VAR* parentvar;
8757 SCIP_Real newlb;
8758 SCIP_Real newub;
8759 int i;
8760
8761 assert(var != NULL);
8762 assert(added != NULL);
8763 assert(blkmem != NULL);
8764
8765 /* the interval should not be empty */
8766 assert(SCIPsetIsLT(set, left, right));
8767
8768 /* the interval bound should already be adjusted */
8769 assert(SCIPsetIsEQ(set, left, adjustedUb(set, SCIPvarGetType(var), left)));
8770 assert(SCIPsetIsEQ(set, right, adjustedLb(set, SCIPvarGetType(var), right)));
8771
8772 /* the interval should lay between the lower and upper bound */
8773 assert(SCIPsetIsGE(set, left, SCIPvarGetLbGlobal(var)));
8774 assert(SCIPsetIsLE(set, right, SCIPvarGetUbGlobal(var)));
8775
8776 /* @todo add debugging mechanism for holes when using a debugging solution */
8777
8778 /* add hole to hole list */
8779 SCIP_CALL( domAddHole(&var->glbdom, blkmem, set, left, right, added) );
8780
8781 /* check if the hole is redundant */
8782 if( !(*added) )
8783 return SCIP_OKAY;
8784
8785 /* current bounds */
8786 newlb = var->glbdom.lb;
8787 newub = var->glbdom.ub;
8788
8789 /* merge domain holes */
8790 domMerge(&var->glbdom, blkmem, set, &newlb, &newub);
8791
8792 /* the bound should not be changed */
8793 assert(SCIPsetIsEQ(set, newlb, var->glbdom.lb));
8794 assert(SCIPsetIsEQ(set, newub, var->glbdom.ub));
8795
8796 /* issue bound change event */
8797 assert(SCIPvarIsTransformed(var) == (var->eventfilter != NULL));
8798 if( var->eventfilter != NULL )
8799 {
8800 SCIP_CALL( varEventGholeAdded(var, blkmem, set, eventqueue, left, right) );
8801 }
8802
8803 /* process parent variables */
8804 for( i = 0; i < var->nparentvars; ++i )
8805 {
8806 SCIP_Real parentnewleft;
8807 SCIP_Real parentnewright;
8808 SCIP_Bool localadded;
8809
8810 parentvar = var->parentvars[i];
8811 assert(parentvar != NULL);
8812
8813 switch( SCIPvarGetStatus(parentvar) )
8814 {
8816 parentnewleft = left;
8817 parentnewright = right;
8818 break;
8819
8824 SCIPerrorMessage("column, loose, fixed or multi-aggregated variable cannot be the parent of a variable\n");
8825 return SCIP_INVALIDDATA;
8826
8827 case SCIP_VARSTATUS_AGGREGATED: /* x = a*y + c -> y = (x-c)/a */
8828 assert(parentvar->data.aggregate.var == var);
8829
8830 if( SCIPsetIsPositive(set, parentvar->data.aggregate.scalar) )
8831 {
8832 /* a > 0 -> change upper bound of x */
8833 parentnewleft = parentvar->data.aggregate.scalar * left + parentvar->data.aggregate.constant;
8834 parentnewright = parentvar->data.aggregate.scalar * right + parentvar->data.aggregate.constant;
8835 }
8836 else
8837 {
8838 /* a < 0 -> change lower bound of x */
8839 assert(SCIPsetIsNegative(set, parentvar->data.aggregate.scalar));
8840
8841 parentnewright = parentvar->data.aggregate.scalar * left + parentvar->data.aggregate.constant;
8842 parentnewleft = parentvar->data.aggregate.scalar * right + parentvar->data.aggregate.constant;
8843 }
8844 break;
8845
8846 case SCIP_VARSTATUS_NEGATED: /* x = offset - x' -> x' = offset - x */
8847 assert(parentvar->negatedvar != NULL);
8848 assert(SCIPvarGetStatus(parentvar->negatedvar) != SCIP_VARSTATUS_NEGATED);
8849 assert(parentvar->negatedvar->negatedvar == parentvar);
8850
8851 parentnewright = -left + parentvar->data.negate.constant;
8852 parentnewleft = -right + parentvar->data.negate.constant;
8853 break;
8854
8855 default:
8856 SCIPerrorMessage("unknown variable status\n");
8857 return SCIP_INVALIDDATA;
8858 }
8859
8860 SCIPsetDebugMsg(set, "add global hole (%g,%g) to parent variable <%s>\n", parentnewleft, parentnewright, SCIPvarGetName(parentvar));
8861
8862 /* perform hole added for parent variable */
8863 assert(blkmem != NULL);
8864 assert(SCIPsetIsLT(set, parentnewleft, parentnewright));
8865 SCIP_CALL( varProcessAddHoleGlobal(parentvar, blkmem, set, stat, eventqueue,
8866 parentnewleft, parentnewright, &localadded) );
8867 assert(localadded);
8868 }
8869
8870 return SCIP_OKAY;
8871}
8872
8873/** adds a hole to the variable's global and local domain */
8875 SCIP_VAR* var, /**< problem variable */
8876 BMS_BLKMEM* blkmem, /**< block memory */
8877 SCIP_SET* set, /**< global SCIP settings */
8878 SCIP_STAT* stat, /**< problem statistics */
8879 SCIP_EVENTQUEUE* eventqueue, /**< event queue, may be NULL for original variables */
8880 SCIP_Real left, /**< left bound of open interval in new hole */
8881 SCIP_Real right, /**< right bound of open interval in new hole */
8882 SCIP_Bool* added /**< pointer to store whether the hole was added */
8883 )
8884{
8885 SCIP_Real childnewleft;
8886 SCIP_Real childnewright;
8887
8888 assert(var != NULL);
8890 assert(blkmem != NULL);
8891 assert(added != NULL);
8892
8893 SCIPsetDebugMsg(set, "adding global hole (%g,%g) to <%s>\n", left, right, var->name);
8894
8895 /* the interval should not be empty */
8896 assert(SCIPsetIsLT(set, left, right));
8897
8898 /* the the interval bound should already be adjusted */
8899 assert(SCIPsetIsEQ(set, left, adjustedUb(set, SCIPvarGetType(var), left)));
8900 assert(SCIPsetIsEQ(set, right, adjustedLb(set, SCIPvarGetType(var), right)));
8901
8902 /* the the interval should lay between the lower and upper bound */
8903 assert(SCIPsetIsGE(set, left, SCIPvarGetLbGlobal(var)));
8904 assert(SCIPsetIsLE(set, right, SCIPvarGetUbGlobal(var)));
8905
8906 /* change bounds of attached variables */
8907 switch( SCIPvarGetStatus(var) )
8908 {
8910 if( var->data.original.transvar != NULL )
8911 {
8912 SCIP_CALL( SCIPvarAddHoleGlobal(var->data.original.transvar, blkmem, set, stat, eventqueue,
8913 left, right, added) );
8914 }
8915 else
8916 {
8917 assert(set->stage == SCIP_STAGE_PROBLEM);
8918
8919 SCIP_CALL( varProcessAddHoleGlobal(var, blkmem, set, stat, eventqueue, left, right, added) );
8920 if( *added )
8921 {
8922 SCIP_Bool localadded;
8923
8924 SCIP_CALL( SCIPvarAddHoleLocal(var, blkmem, set, stat, eventqueue, left, right, &localadded) );
8925 }
8926 }
8927 break;
8928
8931 SCIP_CALL( varProcessAddHoleGlobal(var, blkmem, set, stat, eventqueue, left, right, added) );
8932 if( *added )
8933 {
8934 SCIP_Bool localadded;
8935
8936 SCIP_CALL( SCIPvarAddHoleLocal(var, blkmem, set, stat, eventqueue, left, right, &localadded) );
8937 }
8938 break;
8939
8941 SCIPerrorMessage("cannot add hole of a fixed variable\n");
8942 return SCIP_INVALIDDATA;
8943
8944 case SCIP_VARSTATUS_AGGREGATED: /* x = a*y + c -> y = (x-c)/a */
8945 assert(var->data.aggregate.var != NULL);
8946
8948 {
8949 /* a > 0 -> change lower bound of y */
8950 childnewleft = (left - var->data.aggregate.constant)/var->data.aggregate.scalar;
8951 childnewright = (right - var->data.aggregate.constant)/var->data.aggregate.scalar;
8952 }
8953 else if( SCIPsetIsNegative(set, var->data.aggregate.scalar) )
8954 {
8955 childnewright = (left - var->data.aggregate.constant)/var->data.aggregate.scalar;
8956 childnewleft = (right - var->data.aggregate.constant)/var->data.aggregate.scalar;
8957 }
8958 else
8959 {
8960 SCIPerrorMessage("scalar is zero in aggregation\n");
8961 return SCIP_INVALIDDATA;
8962 }
8963 SCIP_CALL( SCIPvarAddHoleGlobal(var->data.aggregate.var, blkmem, set, stat, eventqueue,
8964 childnewleft, childnewright, added) );
8965 break;
8966
8968 SCIPerrorMessage("cannot add a hole of a multi-aggregated variable.\n");
8969 return SCIP_INVALIDDATA;
8970
8971 case SCIP_VARSTATUS_NEGATED: /* x' = offset - x -> x = offset - x' */
8972 assert(var->negatedvar != NULL);
8974 assert(var->negatedvar->negatedvar == var);
8975
8976 childnewright = -left + var->data.negate.constant;
8977 childnewleft = -right + var->data.negate.constant;
8978
8979 SCIP_CALL( SCIPvarAddHoleGlobal(var->negatedvar, blkmem, set, stat, eventqueue,
8980 childnewleft, childnewright, added) );
8981 break;
8982
8983 default:
8984 SCIPerrorMessage("unknown variable status\n");
8985 return SCIP_INVALIDDATA;
8986 }
8987
8988 return SCIP_OKAY;
8989}
8990
8991/** performs the current add of domain, changes all parents accordingly */
8992static
8994 SCIP_VAR* var, /**< problem variable */
8995 BMS_BLKMEM* blkmem, /**< block memory */
8996 SCIP_SET* set, /**< global SCIP settings */
8997 SCIP_STAT* stat, /**< problem statistics */
8998 SCIP_EVENTQUEUE* eventqueue, /**< event queue, may be NULL for original variables */
8999 SCIP_Real left, /**< left bound of open interval in new hole */
9000 SCIP_Real right, /**< right bound of open interval in new hole */
9001 SCIP_Bool* added /**< pointer to store whether the hole was added, or NULL */
9002 )
9003{
9004 SCIP_VAR* parentvar;
9005 SCIP_Real newlb;
9006 SCIP_Real newub;
9007 int i;
9008
9009 assert(var != NULL);
9010 assert(added != NULL);
9011 assert(blkmem != NULL);
9012
9013 /* the interval should not be empty */
9014 assert(SCIPsetIsLT(set, left, right));
9015
9016 /* the the interval bound should already be adjusted */
9017 assert(SCIPsetIsEQ(set, left, adjustedUb(set, SCIPvarGetType(var), left)));
9018 assert(SCIPsetIsEQ(set, right, adjustedLb(set, SCIPvarGetType(var), right)));
9019
9020 /* the the interval should lay between the lower and upper bound */
9021 assert(SCIPsetIsGE(set, left, SCIPvarGetLbLocal(var)));
9022 assert(SCIPsetIsLE(set, right, SCIPvarGetUbLocal(var)));
9023
9024 /* add hole to hole list */
9025 SCIP_CALL( domAddHole(&var->locdom, blkmem, set, left, right, added) );
9026
9027 /* check if the hole is redundant */
9028 if( !(*added) )
9029 return SCIP_OKAY;
9030
9031 /* current bounds */
9032 newlb = var->locdom.lb;
9033 newub = var->locdom.ub;
9034
9035 /* merge domain holes */
9036 domMerge(&var->locdom, blkmem, set, &newlb, &newub);
9037
9038 /* the bound should not be changed */
9039 assert(SCIPsetIsEQ(set, newlb, var->locdom.lb));
9040 assert(SCIPsetIsEQ(set, newub, var->locdom.ub));
9041
9042#ifdef SCIP_DISABLED_CODE
9043 /* issue LHOLEADDED event */
9044 SCIP_EVENT event;
9045 assert(var->eventfilter != NULL);
9047 SCIP_CALL( SCIPeventProcess(&event, set, NULL, NULL, NULL, var->eventfilter) );
9048#endif
9049
9050 /* process parent variables */
9051 for( i = 0; i < var->nparentvars; ++i )
9052 {
9053 SCIP_Real parentnewleft;
9054 SCIP_Real parentnewright;
9055 SCIP_Bool localadded;
9056
9057 parentvar = var->parentvars[i];
9058 assert(parentvar != NULL);
9059
9060 switch( SCIPvarGetStatus(parentvar) )
9061 {
9063 parentnewleft = left;
9064 parentnewright = right;
9065 break;
9066
9071 SCIPerrorMessage("column, loose, fixed or multi-aggregated variable cannot be the parent of a variable\n");
9072 return SCIP_INVALIDDATA;
9073
9074 case SCIP_VARSTATUS_AGGREGATED: /* x = a*y + c -> y = (x-c)/a */
9075 assert(parentvar->data.aggregate.var == var);
9076
9077 if( SCIPsetIsPositive(set, parentvar->data.aggregate.scalar) )
9078 {
9079 /* a > 0 -> change upper bound of x */
9080 parentnewleft = parentvar->data.aggregate.scalar * left + parentvar->data.aggregate.constant;
9081 parentnewright = parentvar->data.aggregate.scalar * right + parentvar->data.aggregate.constant;
9082 }
9083 else
9084 {
9085 /* a < 0 -> change lower bound of x */
9086 assert(SCIPsetIsNegative(set, parentvar->data.aggregate.scalar));
9087
9088 parentnewright = parentvar->data.aggregate.scalar * left + parentvar->data.aggregate.constant;
9089 parentnewleft = parentvar->data.aggregate.scalar * right + parentvar->data.aggregate.constant;
9090 }
9091 break;
9092
9093 case SCIP_VARSTATUS_NEGATED: /* x = offset - x' -> x' = offset - x */
9094 assert(parentvar->negatedvar != NULL);
9095 assert(SCIPvarGetStatus(parentvar->negatedvar) != SCIP_VARSTATUS_NEGATED);
9096 assert(parentvar->negatedvar->negatedvar == parentvar);
9097
9098 parentnewright = -left + parentvar->data.negate.constant;
9099 parentnewleft = -right + parentvar->data.negate.constant;
9100 break;
9101
9102 default:
9103 SCIPerrorMessage("unknown variable status\n");
9104 return SCIP_INVALIDDATA;
9105 }
9106
9107 SCIPsetDebugMsg(set, "add local hole (%g,%g) to parent variable <%s>\n", parentnewleft, parentnewright, SCIPvarGetName(parentvar));
9108
9109 /* perform hole added for parent variable */
9110 assert(blkmem != NULL);
9111 assert(SCIPsetIsLT(set, parentnewleft, parentnewright));
9112 SCIP_CALL( varProcessAddHoleLocal(parentvar, blkmem, set, stat, eventqueue,
9113 parentnewleft, parentnewright, &localadded) );
9114 assert(localadded);
9115 }
9116
9117 return SCIP_OKAY;
9118}
9119
9120/** adds a hole to the variable's current local domain */
9122 SCIP_VAR* var, /**< problem variable */
9123 BMS_BLKMEM* blkmem, /**< block memory */
9124 SCIP_SET* set, /**< global SCIP settings */
9125 SCIP_STAT* stat, /**< problem statistics */
9126 SCIP_EVENTQUEUE* eventqueue, /**< event queue, may be NULL for original variables */
9127 SCIP_Real left, /**< left bound of open interval in new hole */
9128 SCIP_Real right, /**< right bound of open interval in new hole */
9129 SCIP_Bool* added /**< pointer to store whether the hole was added */
9130 )
9131{
9132 SCIP_Real childnewleft;
9133 SCIP_Real childnewright;
9134
9135 assert(var != NULL);
9136
9137 SCIPsetDebugMsg(set, "adding local hole (%g,%g) to <%s>\n", left, right, var->name);
9138
9139 assert(set != NULL);
9140 assert(var->scip == set->scip);
9142 assert(blkmem != NULL);
9143 assert(added != NULL);
9144
9145 /* the interval should not be empty */
9146 assert(SCIPsetIsLT(set, left, right));
9147
9148 /* the the interval bound should already be adjusted */
9149 assert(SCIPsetIsEQ(set, left, adjustedUb(set, SCIPvarGetType(var), left)));
9150 assert(SCIPsetIsEQ(set, right, adjustedLb(set, SCIPvarGetType(var), right)));
9151
9152 /* the the interval should lay between the lower and upper bound */
9153 assert(SCIPsetIsGE(set, left, SCIPvarGetLbLocal(var)));
9154 assert(SCIPsetIsLE(set, right, SCIPvarGetUbLocal(var)));
9155
9156 /* change bounds of attached variables */
9157 switch( SCIPvarGetStatus(var) )
9158 {
9160 if( var->data.original.transvar != NULL )
9161 {
9162 SCIP_CALL( SCIPvarAddHoleLocal(var->data.original.transvar, blkmem, set, stat, eventqueue,
9163 left, right, added) );
9164 }
9165 else
9166 {
9167 assert(set->stage == SCIP_STAGE_PROBLEM);
9168 SCIPstatIncrement(stat, set, domchgcount);
9169 SCIP_CALL( varProcessAddHoleLocal(var, blkmem, set, stat, eventqueue, left, right, added) );
9170 }
9171 break;
9172
9175 SCIPstatIncrement(stat, set, domchgcount);
9176 SCIP_CALL( varProcessAddHoleLocal(var, blkmem, set, stat, eventqueue, left, right, added) );
9177 break;
9178
9180 SCIPerrorMessage("cannot add domain hole to a fixed variable\n");
9181 return SCIP_INVALIDDATA;
9182
9183 case SCIP_VARSTATUS_AGGREGATED: /* x = a*y + c -> y = (x-c)/a */
9184 assert(var->data.aggregate.var != NULL);
9185
9187 {
9188 /* a > 0 -> change lower bound of y */
9189 childnewleft = (left - var->data.aggregate.constant)/var->data.aggregate.scalar;
9190 childnewright = (right - var->data.aggregate.constant)/var->data.aggregate.scalar;
9191 }
9192 else if( SCIPsetIsNegative(set, var->data.aggregate.scalar) )
9193 {
9194 childnewright = (left - var->data.aggregate.constant)/var->data.aggregate.scalar;
9195 childnewleft = (right - var->data.aggregate.constant)/var->data.aggregate.scalar;
9196 }
9197 else
9198 {
9199 SCIPerrorMessage("scalar is zero in aggregation\n");
9200 return SCIP_INVALIDDATA;
9201 }
9202 SCIP_CALL( SCIPvarAddHoleLocal(var->data.aggregate.var, blkmem, set, stat, eventqueue,
9203 childnewleft, childnewright, added) );
9204 break;
9205
9207 SCIPerrorMessage("cannot add domain hole to a multi-aggregated variable.\n");
9208 return SCIP_INVALIDDATA;
9209
9210 case SCIP_VARSTATUS_NEGATED: /* x' = offset - x -> x = offset - x' */
9211 assert(var->negatedvar != NULL);
9213 assert(var->negatedvar->negatedvar == var);
9214
9215 childnewright = -left + var->data.negate.constant;
9216 childnewleft = -right + var->data.negate.constant;
9217
9218 SCIP_CALL( SCIPvarAddHoleLocal(var->negatedvar, blkmem, set, stat, eventqueue, childnewleft, childnewright, added) );
9219 break;
9220
9221 default:
9222 SCIPerrorMessage("unknown variable status\n");
9223 return SCIP_INVALIDDATA;
9224 }
9225
9226 return SCIP_OKAY;
9227}
9228
9229/** resets the global and local bounds of original variable to their original values */
9231 SCIP_VAR* var, /**< problem variable */
9232 BMS_BLKMEM* blkmem, /**< block memory */
9233 SCIP_SET* set, /**< global SCIP settings */
9234 SCIP_STAT* stat /**< problem statistics */
9235 )
9236{
9237 assert(var != NULL);
9238 assert(set != NULL);
9239 assert(var->scip == set->scip);
9240 assert(SCIPvarIsOriginal(var));
9241 /* resetting of bounds on original variables which have a transformed counterpart easily fails if, e.g.,
9242 * the transformed variable has been fixed */
9243 assert(SCIPvarGetTransVar(var) == NULL);
9244
9245 /* copy the original bounds back to the global and local bounds */
9246 SCIP_CALL( SCIPvarChgLbGlobal(var, blkmem, set, stat, NULL, NULL, NULL, NULL, var->data.original.origdom.lb) );
9247 SCIP_CALL( SCIPvarChgUbGlobal(var, blkmem, set, stat, NULL, NULL, NULL, NULL, var->data.original.origdom.ub) );
9248 SCIP_CALL( SCIPvarChgLbLocal(var, blkmem, set, stat, NULL, NULL, NULL, var->data.original.origdom.lb) );
9249 SCIP_CALL( SCIPvarChgUbLocal(var, blkmem, set, stat, NULL, NULL, NULL, var->data.original.origdom.ub) );
9250
9251 /* free the global and local holelists and duplicate the original ones */
9252 /**@todo this has also to be called recursively with methods similar to SCIPvarChgLbGlobal() */
9253 holelistFree(&var->glbdom.holelist, blkmem);
9254 holelistFree(&var->locdom.holelist, blkmem);
9257
9258 return SCIP_OKAY;
9259}
9260
9261/** issues a IMPLADDED event on the given variable */
9262static
9264 SCIP_VAR* var, /**< problem variable to change */
9265 BMS_BLKMEM* blkmem, /**< block memory */
9266 SCIP_SET* set, /**< global SCIP settings */
9267 SCIP_EVENTQUEUE* eventqueue /**< event queue */
9268 )
9269{
9270 SCIP_EVENT* event;
9271
9272 assert(var != NULL);
9273
9274 /* issue IMPLADDED event on variable */
9275 SCIP_CALL( SCIPeventCreateImplAdded(&event, blkmem, var) );
9276 SCIP_CALL( SCIPeventqueueAdd(eventqueue, blkmem, set, NULL, NULL, NULL, NULL, &event) );
9277
9278 return SCIP_OKAY;
9279}
9280
9281/** actually performs the addition of a variable bound to the variable's vbound arrays */
9282static
9284 SCIP_VAR* var, /**< problem variable x in x <= b*z + d or x >= b*z + d */
9285 BMS_BLKMEM* blkmem, /**< block memory */
9286 SCIP_SET* set, /**< global SCIP settings */
9287 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
9288 SCIP_BOUNDTYPE vbtype, /**< type of variable bound (LOWER or UPPER) */
9289 SCIP_VAR* vbvar, /**< variable z in x <= b*z + d or x >= b*z + d */
9290 SCIP_Real vbcoef, /**< coefficient b in x <= b*z + d or x >= b*z + d */
9291 SCIP_Real vbconstant /**< constant d in x <= b*z + d or x >= b*z + d */
9292 )
9293{
9294 SCIP_Bool added;
9295
9296 /* It can happen that the variable "var" and the variable "vbvar" are the same variable. For example if a variable
9297 * gets aggregated, the variable bounds (vbound) of that variable are copied to the other variable. A variable bound
9298 * variable of the aggregated variable might be the same as the one its gets aggregated too.
9299 *
9300 * If the variable "var" and the variable "vbvar" are the same, the variable bound which should be added here has to
9301 * be redundant. This is the case since an infeasibility should have be detected in the previous methods. As well as
9302 * the bounds of the variable which should be also already be tightened in the previous methods. Therefore, the
9303 * variable bound can be ignored.
9304 *
9305 * From the way the the variable bound system is implemented (detecting infeasibility, tighten bounds), the
9306 * equivalence of the variables should be checked here.
9307 */
9308 if( var == vbvar )
9309 {
9310 /* in this case the variable bound has to be redundant, this means for possible assignments to this variable; this
9311 * can be checked via the global bounds of the variable */
9312#ifndef NDEBUG
9313 SCIP_Real lb;
9314 SCIP_Real ub;
9315
9316 lb = SCIPvarGetLbGlobal(var);
9317 ub = SCIPvarGetUbGlobal(var);
9318
9319 if(vbtype == SCIP_BOUNDTYPE_LOWER)
9320 {
9321 if( vbcoef > 0.0 )
9322 {
9323 assert(SCIPsetIsGE(set, lb, lb * vbcoef + vbconstant) );
9324 assert(SCIPsetIsGE(set, ub, ub * vbcoef + vbconstant) );
9325 }
9326 else
9327 {
9328 assert(SCIPsetIsGE(set, lb, ub * vbcoef + vbconstant) );
9329 assert(SCIPsetIsGE(set, ub, lb * vbcoef + vbconstant) );
9330 }
9331 }
9332 else
9333 {
9334 assert(vbtype == SCIP_BOUNDTYPE_UPPER);
9335 if( vbcoef > 0.0 )
9336 {
9337 assert(SCIPsetIsLE(set, lb, lb * vbcoef + vbconstant) );
9338 assert(SCIPsetIsLE(set, ub, ub * vbcoef + vbconstant) );
9339 }
9340 else
9341 {
9342 assert(SCIPsetIsLE(set, lb, ub * vbcoef + vbconstant) );
9343 assert(SCIPsetIsLE(set, ub, lb * vbcoef + vbconstant) );
9344 }
9345 }
9346#endif
9347 SCIPsetDebugMsg(set, "redundant variable bound: <%s> %s %g<%s> %+g\n",
9348 SCIPvarGetName(var), vbtype == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=", vbcoef, SCIPvarGetName(vbvar), vbconstant);
9349
9350 return SCIP_OKAY;
9351 }
9352
9353 SCIPsetDebugMsg(set, "adding variable bound: <%s> %s %g<%s> %+g\n",
9354 SCIPvarGetName(var), vbtype == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=", vbcoef, SCIPvarGetName(vbvar), vbconstant);
9355
9356 /* check variable bound on debugging solution */
9357 SCIP_CALL( SCIPdebugCheckVbound(set, var, vbtype, vbvar, vbcoef, vbconstant) ); /*lint !e506 !e774*/
9358
9359 /* perform the addition */
9360 if( vbtype == SCIP_BOUNDTYPE_LOWER )
9361 {
9362 SCIP_CALL( SCIPvboundsAdd(&var->vlbs, blkmem, set, vbtype, vbvar, vbcoef, vbconstant, &added) );
9363 }
9364 else
9365 {
9366 SCIP_CALL( SCIPvboundsAdd(&var->vubs, blkmem, set, vbtype, vbvar, vbcoef, vbconstant, &added) );
9367 }
9368 var->closestvblpcount = -1;
9369
9370 if( added )
9371 {
9372 /* issue IMPLADDED event */
9373 SCIP_CALL( varEventImplAdded(var, blkmem, set, eventqueue) );
9374 }
9375
9376 return SCIP_OKAY;
9377}
9378
9379/** checks whether the given implication is redundant or infeasible w.r.t. the implied variables global bounds */
9380static
9382 SCIP_SET* set, /**< global SCIP settings */
9383 SCIP_VAR* implvar, /**< variable y in implication y <= b or y >= b */
9384 SCIP_BOUNDTYPE impltype, /**< type of implication y <= b (SCIP_BOUNDTYPE_UPPER) or y >= b (SCIP_BOUNDTYPE_LOWER) */
9385 SCIP_Real implbound, /**< bound b in implication y <= b or y >= b */
9386 SCIP_Bool* redundant, /**< pointer to store whether the implication is redundant */
9387 SCIP_Bool* infeasible /**< pointer to store whether the implication is infeasible */
9388 )
9389{
9390 SCIP_Real impllb;
9391 SCIP_Real implub;
9392
9393 assert(redundant != NULL);
9394 assert(infeasible != NULL);
9395
9396 impllb = SCIPvarGetLbGlobal(implvar);
9397 implub = SCIPvarGetUbGlobal(implvar);
9398 if( impltype == SCIP_BOUNDTYPE_LOWER )
9399 {
9400 *infeasible = SCIPsetIsFeasGT(set, implbound, implub);
9401 *redundant = SCIPsetIsFeasLE(set, implbound, impllb);
9402 }
9403 else
9404 {
9405 *infeasible = SCIPsetIsFeasLT(set, implbound, impllb);
9406 *redundant = SCIPsetIsFeasGE(set, implbound, implub);
9407 }
9408}
9409
9410/** applies the given implication, if it is not redundant */
9411static
9413 BMS_BLKMEM* blkmem, /**< block memory */
9414 SCIP_SET* set, /**< global SCIP settings */
9415 SCIP_STAT* stat, /**< problem statistics */
9416 SCIP_PROB* transprob, /**< transformed problem */
9417 SCIP_PROB* origprob, /**< original problem */
9418 SCIP_TREE* tree, /**< branch and bound tree if in solving stage */
9419 SCIP_REOPT* reopt, /**< reoptimization data structure */
9420 SCIP_LP* lp, /**< current LP data */
9421 SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
9422 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
9423 SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
9424 SCIP_VAR* implvar, /**< variable y in implication y <= b or y >= b */
9425 SCIP_BOUNDTYPE impltype, /**< type of implication y <= b (SCIP_BOUNDTYPE_UPPER) or y >= b (SCIP_BOUNDTYPE_LOWER) */
9426 SCIP_Real implbound, /**< bound b in implication y <= b or y >= b */
9427 SCIP_Bool* infeasible, /**< pointer to store whether an infeasibility was detected */
9428 int* nbdchgs /**< pointer to count the number of performed bound changes, or NULL */
9429 )
9430{
9431 SCIP_Real implub;
9432 SCIP_Real impllb;
9433
9434 assert(infeasible != NULL);
9435
9436 *infeasible = FALSE;
9437
9438 implub = SCIPvarGetUbGlobal(implvar);
9439 impllb = SCIPvarGetLbGlobal(implvar);
9440 if( impltype == SCIP_BOUNDTYPE_LOWER )
9441 {
9442 if( SCIPsetIsFeasGT(set, implbound, implub) )
9443 {
9444 /* the implication produces a conflict: the problem is infeasible */
9445 *infeasible = TRUE;
9446 }
9447 else if( SCIPsetIsFeasGT(set, implbound, impllb) )
9448 {
9449 /* during solving stage it can happen that the global bound change cannot be applied directly because it conflicts
9450 * with the local bound, in this case we need to store the bound change as pending bound change
9451 */
9453 {
9454 assert(tree != NULL);
9455 assert(transprob != NULL);
9456 assert(SCIPprobIsTransformed(transprob));
9457
9458 SCIP_CALL( SCIPnodeAddBoundchg(SCIPtreeGetRootNode(tree), blkmem, set, stat, transprob, origprob,
9459 tree, reopt, lp, branchcand, eventqueue, cliquetable, implvar, implbound, SCIP_BOUNDTYPE_LOWER, FALSE) );
9460 }
9461 else
9462 {
9463 SCIP_CALL( SCIPvarChgLbGlobal(implvar, blkmem, set, stat, lp, branchcand, eventqueue, cliquetable, implbound) );
9464 }
9465
9466 if( nbdchgs != NULL )
9467 (*nbdchgs)++;
9468 }
9469 }
9470 else
9471 {
9472 if( SCIPsetIsFeasLT(set, implbound, impllb) )
9473 {
9474 /* the implication produces a conflict: the problem is infeasible */
9475 *infeasible = TRUE;
9476 }
9477 else if( SCIPsetIsFeasLT(set, implbound, implub) )
9478 {
9479 /* during solving stage it can happen that the global bound change cannot be applied directly because it conflicts
9480 * with the local bound, in this case we need to store the bound change as pending bound change
9481 */
9483 {
9484 assert(tree != NULL);
9485 assert(transprob != NULL);
9486 assert(SCIPprobIsTransformed(transprob));
9487
9488 SCIP_CALL( SCIPnodeAddBoundchg(SCIPtreeGetRootNode(tree), blkmem, set, stat, transprob, origprob,
9489 tree, reopt, lp, branchcand, eventqueue, cliquetable, implvar, implbound, SCIP_BOUNDTYPE_UPPER, FALSE) );
9490 }
9491 else
9492 {
9493 SCIP_CALL( SCIPvarChgUbGlobal(implvar, blkmem, set, stat, lp, branchcand, eventqueue, cliquetable, implbound) );
9494 }
9495
9496 if( nbdchgs != NULL )
9497 (*nbdchgs)++;
9498 }
9499 }
9500
9501 return SCIP_OKAY;
9502}
9503
9504/** actually performs the addition of an implication to the variable's implication arrays,
9505 * and adds the corresponding implication or variable bound to the implied variable;
9506 * if the implication is conflicting, the variable is fixed to the opposite value;
9507 * if the variable is already fixed to the given value, the implication is performed immediately;
9508 * if the implication is redundant with respect to the variables' global bounds, it is ignored
9509 */
9510static
9512 SCIP_VAR* var, /**< problem variable */
9513 BMS_BLKMEM* blkmem, /**< block memory */
9514 SCIP_SET* set, /**< global SCIP settings */
9515 SCIP_STAT* stat, /**< problem statistics */
9516 SCIP_PROB* transprob, /**< transformed problem */
9517 SCIP_PROB* origprob, /**< original problem */
9518 SCIP_TREE* tree, /**< branch and bound tree if in solving stage */
9519 SCIP_REOPT* reopt, /**< reoptimization data structure */
9520 SCIP_LP* lp, /**< current LP data */
9521 SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
9522 SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
9523 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
9524 SCIP_Bool varfixing, /**< FALSE if y should be added in implications for x == 0, TRUE for x == 1 */
9525 SCIP_VAR* implvar, /**< variable y in implication y <= b or y >= b */
9526 SCIP_BOUNDTYPE impltype, /**< type of implication y <= b (SCIP_BOUNDTYPE_UPPER) or y >= b (SCIP_BOUNDTYPE_LOWER) */
9527 SCIP_Real implbound, /**< bound b in implication y <= b or y >= b */
9528 SCIP_Bool isshortcut, /**< is the implication a shortcut, i.e., added as part of the transitive closure of another implication? */
9529 SCIP_Bool* infeasible, /**< pointer to store whether an infeasibility was detected */
9530 int* nbdchgs, /**< pointer to count the number of performed bound changes, or NULL */
9531 SCIP_Bool* added /**< pointer to store whether an implication was added */
9532 )
9533{
9534 SCIP_Bool redundant;
9535 SCIP_Bool conflict;
9536
9537 assert(var != NULL);
9538 assert(SCIPvarIsActive(var));
9540 assert(SCIPvarGetType(var) == SCIP_VARTYPE_BINARY);
9541 assert(SCIPvarIsActive(implvar) || SCIPvarGetStatus(implvar) == SCIP_VARSTATUS_FIXED);
9542 assert(infeasible != NULL);
9543 assert(added != NULL);
9544
9545 /* check implication on debugging solution */
9546 SCIP_CALL( SCIPdebugCheckImplic(set, var, varfixing, implvar, impltype, implbound) ); /*lint !e506 !e774*/
9547
9548 *infeasible = FALSE;
9549 *added = FALSE;
9550
9551 /* check, if the implication is redundant or infeasible */
9552 checkImplic(set, implvar, impltype, implbound, &redundant, &conflict);
9553 assert(!redundant || !conflict);
9554 if( redundant )
9555 return SCIP_OKAY;
9556
9557 if( var == implvar )
9558 {
9559 /* special cases appear were a bound to a variable implies itself to be outside the bounds:
9560 * x == varfixing => x < 0 or x > 1
9561 */
9562 if( SCIPsetIsLT(set, implbound, 0.0) || SCIPsetIsGT(set, implbound, 1.0) )
9563 conflict = TRUE;
9564 else
9565 {
9566 /* variable implies itself: x == varfixing => x == (impltype == SCIP_BOUNDTYPE_LOWER) */
9567 assert(SCIPsetIsZero(set, implbound) || SCIPsetIsEQ(set, implbound, 1.0));
9568 assert(SCIPsetIsZero(set, implbound) == (impltype == SCIP_BOUNDTYPE_UPPER));
9569 assert(SCIPsetIsEQ(set, implbound, 1.0) == (impltype == SCIP_BOUNDTYPE_LOWER));
9570 conflict = conflict || ((varfixing == TRUE) == (impltype == SCIP_BOUNDTYPE_UPPER));
9571 if( !conflict )
9572 return SCIP_OKAY;
9573 }
9574 }
9575
9576 /* check, if the variable is already fixed */
9577 if( SCIPvarGetLbGlobal(var) > 0.5 || SCIPvarGetUbGlobal(var) < 0.5 )
9578 {
9579 /* if the variable is fixed to the given value, perform the implication; otherwise, ignore the implication */
9580 if( varfixing == (SCIPvarGetLbGlobal(var) > 0.5) )
9581 {
9582 SCIP_CALL( applyImplic(blkmem, set, stat, transprob, origprob, tree, reopt, lp, branchcand, eventqueue,
9583 cliquetable, implvar, impltype, implbound, infeasible, nbdchgs) );
9584 }
9585 return SCIP_OKAY;
9586 }
9587
9588 assert((impltype == SCIP_BOUNDTYPE_LOWER && SCIPsetIsGT(set, implbound, SCIPvarGetLbGlobal(implvar)))
9589 || (impltype == SCIP_BOUNDTYPE_UPPER && SCIPsetIsLT(set, implbound, SCIPvarGetUbGlobal(implvar))));
9590
9591 if( !conflict )
9592 {
9593 assert(SCIPvarIsActive(implvar)); /* a fixed implvar would either cause a redundancy or infeasibility */
9594
9595 if( SCIPvarIsBinary(implvar) )
9596 {
9597 SCIP_VAR* vars[2];
9598 SCIP_Bool vals[2];
9599
9600 assert(SCIPsetIsFeasEQ(set, implbound, 1.0) || SCIPsetIsFeasZero(set, implbound));
9601 assert((impltype == SCIP_BOUNDTYPE_UPPER) == SCIPsetIsFeasZero(set, implbound));
9602
9603 vars[0] = var;
9604 vars[1] = implvar;
9605 vals[0] = varfixing;
9606 vals[1] = (impltype == SCIP_BOUNDTYPE_UPPER);
9607
9608 /* add the clique to the clique table */
9609 SCIP_CALL( SCIPcliquetableAdd(cliquetable, blkmem, set, stat, transprob, origprob, tree, reopt, lp, branchcand,
9610 eventqueue, vars, vals, 2, FALSE, &conflict, nbdchgs) );
9611
9612 if( !conflict )
9613 return SCIP_OKAY;
9614 }
9615 else
9616 {
9617 /* add implication x == 0/1 -> y <= b / y >= b to the implications list of x */
9618 SCIPsetDebugMsg(set, "adding implication: <%s> == %u ==> <%s> %s %g\n",
9619 SCIPvarGetName(var), varfixing,
9620 SCIPvarGetName(implvar), impltype == SCIP_BOUNDTYPE_UPPER ? "<=" : ">=", implbound);
9621 SCIP_CALL( SCIPimplicsAdd(&var->implics, blkmem, set, stat, varfixing, implvar, impltype, implbound,
9622 isshortcut, &conflict, added) );
9623 }
9624 }
9625 assert(!conflict || !(*added));
9626
9627 /* on conflict, fix the variable to the opposite value */
9628 if( conflict )
9629 {
9630 SCIPsetDebugMsg(set, " -> implication yields a conflict: fix <%s> == %d\n", SCIPvarGetName(var), !varfixing);
9631
9632 /* during solving stage it can happen that the global bound change cannot be applied directly because it conflicts
9633 * with the local bound, in this case we need to store the bound change as pending bound change
9634 */
9636 {
9637 assert(tree != NULL);
9638 assert(transprob != NULL);
9639 assert(SCIPprobIsTransformed(transprob));
9640
9641 if( varfixing )
9642 {
9643 SCIP_CALL( SCIPnodeAddBoundchg(SCIPtreeGetRootNode(tree), blkmem, set, stat, transprob, origprob,
9644 tree, reopt, lp, branchcand, eventqueue, cliquetable, var, 0.0, SCIP_BOUNDTYPE_UPPER, FALSE) );
9645 }
9646 else
9647 {
9648 SCIP_CALL( SCIPnodeAddBoundchg(SCIPtreeGetRootNode(tree), blkmem, set, stat, transprob, origprob,
9649 tree, reopt, lp, branchcand, eventqueue, cliquetable, var, 1.0, SCIP_BOUNDTYPE_LOWER, FALSE) );
9650 }
9651 }
9652 else
9653 {
9654 if( varfixing )
9655 {
9656 SCIP_CALL( SCIPvarChgUbGlobal(var, blkmem, set, stat, lp, branchcand, eventqueue, cliquetable, 0.0) );
9657 }
9658 else
9659 {
9660 SCIP_CALL( SCIPvarChgLbGlobal(var, blkmem, set, stat, lp, branchcand, eventqueue, cliquetable, 1.0) );
9661 }
9662 }
9663 if( nbdchgs != NULL )
9664 (*nbdchgs)++;
9665
9666 return SCIP_OKAY;
9667 }
9668 else if( *added )
9669 {
9670 /* issue IMPLADDED event */
9671 SCIP_CALL( varEventImplAdded(var, blkmem, set, eventqueue) );
9672 }
9673 else
9674 {
9675 /* the implication was redundant: the inverse is also redundant */
9676 return SCIP_OKAY;
9677 }
9678
9679 assert(SCIPvarIsActive(implvar)); /* a fixed implvar would either cause a redundancy or infeasibility */
9680
9681 /* check, whether implied variable is binary */
9682 if( !SCIPvarIsBinary(implvar) )
9683 {
9684 SCIP_Real lb;
9685 SCIP_Real ub;
9686
9687 /* add inverse variable bound to the variable bounds of y with global bounds y \in [lb,ub]:
9688 * x == 0 -> y <= b <-> y <= (ub - b)*x + b
9689 * x == 1 -> y <= b <-> y <= (b - ub)*x + ub
9690 * x == 0 -> y >= b <-> y >= (lb - b)*x + b
9691 * x == 1 -> y >= b <-> y >= (b - lb)*x + lb
9692 * for numerical reasons, ignore variable bounds with large absolute coefficient
9693 */
9694 lb = SCIPvarGetLbGlobal(implvar);
9695 ub = SCIPvarGetUbGlobal(implvar);
9696 if( impltype == SCIP_BOUNDTYPE_UPPER )
9697 {
9698 if( REALABS(implbound - ub) <= MAXABSVBCOEF )
9699 {
9700 SCIP_CALL( varAddVbound(implvar, blkmem, set, eventqueue, SCIP_BOUNDTYPE_UPPER, var,
9701 varfixing ? implbound - ub : ub - implbound, varfixing ? ub : implbound) );
9702 }
9703 }
9704 else
9705 {
9706 if( REALABS(implbound - lb) <= MAXABSVBCOEF )
9707 {
9708 SCIP_CALL( varAddVbound(implvar, blkmem, set, eventqueue, SCIP_BOUNDTYPE_LOWER, var,
9709 varfixing ? implbound - lb : lb - implbound, varfixing ? lb : implbound) );
9710 }
9711 }
9712 }
9713
9714 return SCIP_OKAY;
9715}
9716
9717/** adds transitive closure for binary implication x = a -> y = b */
9718static
9720 SCIP_VAR* var, /**< problem variable */
9721 BMS_BLKMEM* blkmem, /**< block memory */
9722 SCIP_SET* set, /**< global SCIP settings */
9723 SCIP_STAT* stat, /**< problem statistics */
9724 SCIP_PROB* transprob, /**< transformed problem */
9725 SCIP_PROB* origprob, /**< original problem */
9726 SCIP_TREE* tree, /**< branch and bound tree if in solving stage */
9727 SCIP_REOPT* reopt, /**< reoptimization data structure */
9728 SCIP_LP* lp, /**< current LP data */
9729 SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
9730 SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
9731 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
9732 SCIP_Bool varfixing, /**< FALSE if y should be added in implications for x == 0, TRUE for x == 1 */
9733 SCIP_VAR* implvar, /**< variable y in implication y <= b or y >= b */
9734 SCIP_Bool implvarfixing, /**< fixing b in implication */
9735 SCIP_Bool* infeasible, /**< pointer to store whether an infeasibility was detected */
9736 int* nbdchgs /**< pointer to count the number of performed bound changes, or NULL */
9737 )
9738{
9739 SCIP_VAR** implvars;
9740 SCIP_BOUNDTYPE* impltypes;
9741 SCIP_Real* implbounds;
9742 int nimpls;
9743 int i;
9744
9745 *infeasible = FALSE;
9746
9747 /* binary variable: implications of implvar */
9748 nimpls = SCIPimplicsGetNImpls(implvar->implics, implvarfixing);
9749 implvars = SCIPimplicsGetVars(implvar->implics, implvarfixing);
9750 impltypes = SCIPimplicsGetTypes(implvar->implics, implvarfixing);
9751 implbounds = SCIPimplicsGetBounds(implvar->implics, implvarfixing);
9752
9753 /* if variable has too many implications, the implication graph may become too dense */
9754 i = MIN(nimpls, MAXIMPLSCLOSURE) - 1;
9755
9756 /* we have to iterate from back to front, because in varAddImplic() it may happen that a conflict is detected and
9757 * implvars[i] is fixed, s.t. the implication y == varfixing -> z <= b / z >= b is deleted; this affects the
9758 * array over which we currently iterate; the only thing that can happen, is that elements of the array are
9759 * deleted; in this case, the subsequent elements are moved to the front; if we iterate from back to front, the
9760 * only thing that can happen is that we add the same implication twice - this does no harm
9761 */
9762 while ( i >= 0 && !(*infeasible) )
9763 {
9764 SCIP_Bool added;
9765
9766 assert(implvars[i] != implvar);
9767
9768 /* we have x == varfixing -> y == implvarfixing -> z <= b / z >= b:
9769 * add implication x == varfixing -> z <= b / z >= b to the implications list of x
9770 */
9771 if( SCIPvarIsActive(implvars[i]) )
9772 {
9773 SCIP_CALL( varAddImplic(var, blkmem, set, stat, transprob, origprob, tree, reopt, lp, cliquetable, branchcand,
9774 eventqueue, varfixing, implvars[i], impltypes[i], implbounds[i], TRUE, infeasible, nbdchgs, &added) );
9775 assert(SCIPimplicsGetNImpls(implvar->implics, implvarfixing) <= nimpls);
9776 nimpls = SCIPimplicsGetNImpls(implvar->implics, implvarfixing);
9777 i = MIN(i, nimpls); /* some elements from the array could have been removed */
9778 }
9779 --i;
9780 }
9781
9782 return SCIP_OKAY;
9783}
9784
9785/** adds given implication to the variable's implication list, and adds all implications directly implied by this
9786 * implication to the variable's implication list;
9787 * if the implication is conflicting, the variable is fixed to the opposite value;
9788 * if the variable is already fixed to the given value, the implication is performed immediately;
9789 * if the implication is redundant with respect to the variables' global bounds, it is ignored
9790 */
9791static
9793 SCIP_VAR* var, /**< problem variable */
9794 BMS_BLKMEM* blkmem, /**< block memory */
9795 SCIP_SET* set, /**< global SCIP settings */
9796 SCIP_STAT* stat, /**< problem statistics */
9797 SCIP_PROB* transprob, /**< transformed problem */
9798 SCIP_PROB* origprob, /**< original problem */
9799 SCIP_TREE* tree, /**< branch and bound tree if in solving stage */
9800 SCIP_REOPT* reopt, /**< reoptimization data structure */
9801 SCIP_LP* lp, /**< current LP data */
9802 SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
9803 SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
9804 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
9805 SCIP_Bool varfixing, /**< FALSE if y should be added in implications for x == 0, TRUE for x == 1 */
9806 SCIP_VAR* implvar, /**< variable y in implication y <= b or y >= b */
9807 SCIP_BOUNDTYPE impltype, /**< type of implication y <= b (SCIP_BOUNDTYPE_UPPER) or y >= b (SCIP_BOUNDTYPE_LOWER) */
9808 SCIP_Real implbound, /**< bound b in implication y <= b or y >= b */
9809 SCIP_Bool transitive, /**< should transitive closure of implication also be added? */
9810 SCIP_Bool* infeasible, /**< pointer to store whether an infeasibility was detected */
9811 int* nbdchgs /**< pointer to count the number of performed bound changes, or NULL */
9812 )
9813{
9814 SCIP_Bool added;
9815
9816 assert(var != NULL);
9817 assert(SCIPvarGetType(var) == SCIP_VARTYPE_BINARY);
9818 assert(SCIPvarIsActive(var));
9819 assert(implvar != NULL);
9820 assert(SCIPvarIsActive(implvar) || SCIPvarGetStatus(implvar) == SCIP_VARSTATUS_FIXED);
9821 assert(infeasible != NULL);
9822
9823 /* add implication x == varfixing -> y <= b / y >= b to the implications list of x */
9824 SCIP_CALL( varAddImplic(var, blkmem, set, stat, transprob, origprob, tree, reopt, lp, cliquetable, branchcand,
9825 eventqueue, varfixing, implvar, impltype, implbound, FALSE, infeasible, nbdchgs, &added) );
9826
9827 if( *infeasible || var == implvar || !transitive || !added )
9828 return SCIP_OKAY;
9829
9830 assert(SCIPvarIsActive(implvar)); /* a fixed implvar would either cause a redundancy or infeasibility */
9831
9832 /* add transitive closure */
9833 if( SCIPvarGetType(implvar) == SCIP_VARTYPE_BINARY )
9834 {
9835 SCIP_Bool implvarfixing;
9836
9837 implvarfixing = (impltype == SCIP_BOUNDTYPE_LOWER);
9838
9839 /* binary variable: implications of implvar */
9840 SCIP_CALL( varAddTransitiveBinaryClosureImplic(var, blkmem, set, stat, transprob, origprob, tree, reopt, lp,
9841 cliquetable, branchcand, eventqueue, varfixing, implvar, implvarfixing, infeasible, nbdchgs) );
9842
9843 /* inverse implication */
9844 if( !(*infeasible) )
9845 {
9846 SCIP_CALL( varAddTransitiveBinaryClosureImplic(implvar, blkmem, set, stat, transprob, origprob, tree, reopt, lp,
9847 cliquetable, branchcand, eventqueue, !implvarfixing, var, !varfixing, infeasible, nbdchgs) );
9848 }
9849 }
9850 else
9851 {
9852 /* non-binary variable: variable lower bounds of implvar */
9853 if( impltype == SCIP_BOUNDTYPE_UPPER && implvar->vlbs != NULL )
9854 {
9855 SCIP_VAR** vlbvars;
9856 SCIP_Real* vlbcoefs;
9857 SCIP_Real* vlbconstants;
9858 int nvlbvars;
9859 int i;
9860
9861 nvlbvars = SCIPvboundsGetNVbds(implvar->vlbs);
9862 vlbvars = SCIPvboundsGetVars(implvar->vlbs);
9863 vlbcoefs = SCIPvboundsGetCoefs(implvar->vlbs);
9864 vlbconstants = SCIPvboundsGetConstants(implvar->vlbs);
9865
9866 /* we have to iterate from back to front, because in varAddImplic() it may happen that a conflict is detected and
9867 * vlbvars[i] is fixed, s.t. the variable bound is deleted; this affects the array over which we currently
9868 * iterate; the only thing that can happen, is that elements of the array are deleted; in this case, the
9869 * subsequent elements are moved to the front; if we iterate from back to front, the only thing that can happen
9870 * is that we add the same implication twice - this does no harm
9871 */
9872 i = nvlbvars-1;
9873 while ( i >= 0 && !(*infeasible) )
9874 {
9875 assert(vlbvars[i] != implvar);
9876 assert(!SCIPsetIsZero(set, vlbcoefs[i]));
9877
9878 /* we have x == varfixing -> y <= b and y >= c*z + d:
9879 * c > 0: add implication x == varfixing -> z <= (b-d)/c to the implications list of x
9880 * c < 0: add implication x == varfixing -> z >= (b-d)/c to the implications list of x
9881 *
9882 * @note during an aggregation the aggregated variable "aggrvar" (the one which will have the status
9883 * SCIP_VARSTATUS_AGGREGATED afterwards) copies its variable lower and uppers bounds to the
9884 * aggregation variable (the one which will stay active);
9885 *
9886 * W.l.o.g. we consider the variable upper bounds for now. Let "vubvar" be a variable upper bound of
9887 * the aggregated variable "aggvar"; During that copying of that variable upper bound variable
9888 * "vubvar" the variable lower and upper bounds of this variable "vubvar" are also considered; note
9889 * that the "aggvar" can be a variable lower bound variable of the variable "vubvar"; Due to that
9890 * situation it can happen that we reach that code place where "vlbvars[i] == aggvar". In particular
9891 * the "aggvar" has already the variable status SCIP_VARSTATUS_AGGREGATED or SCIP_VARSTATUS_NEGATED
9892 * but is still active since the aggregation is not finished yet (in SCIPvarAggregate()); therefore we
9893 * have to explicitly check that the active variable has not a variable status
9894 * SCIP_VARSTATUS_AGGREGATED or SCIP_VARSTATUS_NEGATED;
9895 */
9896 if( SCIPvarIsActive(vlbvars[i]) && SCIPvarGetStatus(vlbvars[i]) != SCIP_VARSTATUS_AGGREGATED && SCIPvarGetStatus(vlbvars[i]) != SCIP_VARSTATUS_NEGATED )
9897 {
9898 SCIP_Real vbimplbound;
9899
9900 vbimplbound = (implbound - vlbconstants[i])/vlbcoefs[i];
9901 if( vlbcoefs[i] >= 0.0 )
9902 {
9903 vbimplbound = adjustedUb(set, SCIPvarGetType(vlbvars[i]), vbimplbound);
9904 SCIP_CALL( varAddImplic(var, blkmem, set, stat, transprob, origprob, tree, reopt, lp, cliquetable,
9905 branchcand, eventqueue, varfixing, vlbvars[i], SCIP_BOUNDTYPE_UPPER, vbimplbound, TRUE,
9906 infeasible, nbdchgs, &added) );
9907 }
9908 else
9909 {
9910 vbimplbound = adjustedLb(set, SCIPvarGetType(vlbvars[i]), vbimplbound);
9911 SCIP_CALL( varAddImplic(var, blkmem, set, stat, transprob, origprob, tree, reopt, lp, cliquetable,
9912 branchcand, eventqueue, varfixing, vlbvars[i], SCIP_BOUNDTYPE_LOWER, vbimplbound, TRUE,
9913 infeasible, nbdchgs, &added) );
9914 }
9915 nvlbvars = SCIPvboundsGetNVbds(implvar->vlbs);
9916 i = MIN(i, nvlbvars); /* some elements from the array could have been removed */
9917 }
9918 --i;
9919 }
9920 }
9921
9922 /* non-binary variable: variable upper bounds of implvar */
9923 if( impltype == SCIP_BOUNDTYPE_LOWER && implvar->vubs != NULL )
9924 {
9925 SCIP_VAR** vubvars;
9926 SCIP_Real* vubcoefs;
9927 SCIP_Real* vubconstants;
9928 int nvubvars;
9929 int i;
9930
9931 nvubvars = SCIPvboundsGetNVbds(implvar->vubs);
9932 vubvars = SCIPvboundsGetVars(implvar->vubs);
9933 vubcoefs = SCIPvboundsGetCoefs(implvar->vubs);
9934 vubconstants = SCIPvboundsGetConstants(implvar->vubs);
9935
9936 /* we have to iterate from back to front, because in varAddImplic() it may happen that a conflict is detected and
9937 * vubvars[i] is fixed, s.t. the variable bound is deleted; this affects the array over which we currently
9938 * iterate; the only thing that can happen, is that elements of the array are deleted; in this case, the
9939 * subsequent elements are moved to the front; if we iterate from back to front, the only thing that can happen
9940 * is that we add the same implication twice - this does no harm
9941 */
9942 i = nvubvars-1;
9943 while ( i >= 0 && !(*infeasible) )
9944 {
9945 assert(vubvars[i] != implvar);
9946 assert(!SCIPsetIsZero(set, vubcoefs[i]));
9947
9948 /* we have x == varfixing -> y >= b and y <= c*z + d:
9949 * c > 0: add implication x == varfixing -> z >= (b-d)/c to the implications list of x
9950 * c < 0: add implication x == varfixing -> z <= (b-d)/c to the implications list of x
9951 *
9952 * @note during an aggregation the aggregated variable "aggrvar" (the one which will have the status
9953 * SCIP_VARSTATUS_AGGREGATED afterwards) copies its variable lower and uppers bounds to the
9954 * aggregation variable (the one which will stay active);
9955 *
9956 * W.l.o.g. we consider the variable lower bounds for now. Let "vlbvar" be a variable lower bound of
9957 * the aggregated variable "aggvar"; During that copying of that variable lower bound variable
9958 * "vlbvar" the variable lower and upper bounds of this variable "vlbvar" are also considered; note
9959 * that the "aggvar" can be a variable upper bound variable of the variable "vlbvar"; Due to that
9960 * situation it can happen that we reach that code place where "vubvars[i] == aggvar". In particular
9961 * the "aggvar" has already the variable status SCIP_VARSTATUS_AGGREGATED or SCIP_VARSTATUS_NEGATED
9962 * but is still active since the aggregation is not finished yet (in SCIPvarAggregate()); therefore we
9963 * have to explicitly check that the active variable has not a variable status
9964 * SCIP_VARSTATUS_AGGREGATED or SCIP_VARSTATUS_NEGATED;
9965 */
9966 if( SCIPvarIsActive(vubvars[i]) && SCIPvarGetStatus(vubvars[i]) != SCIP_VARSTATUS_AGGREGATED && SCIPvarGetStatus(vubvars[i]) != SCIP_VARSTATUS_NEGATED )
9967 {
9968 SCIP_Real vbimplbound;
9969
9970 vbimplbound = (implbound - vubconstants[i])/vubcoefs[i];
9971 if( vubcoefs[i] >= 0.0 )
9972 {
9973 vbimplbound = adjustedLb(set, SCIPvarGetType(vubvars[i]), vbimplbound);
9974 SCIP_CALL( varAddImplic(var, blkmem, set, stat, transprob, origprob, tree, reopt, lp, cliquetable,
9975 branchcand, eventqueue, varfixing, vubvars[i], SCIP_BOUNDTYPE_LOWER, vbimplbound, TRUE,
9976 infeasible, nbdchgs, &added) );
9977 }
9978 else
9979 {
9980 vbimplbound = adjustedUb(set, SCIPvarGetType(vubvars[i]), vbimplbound);
9981 SCIP_CALL( varAddImplic(var, blkmem, set, stat, transprob, origprob, tree, reopt, lp, cliquetable,
9982 branchcand, eventqueue, varfixing, vubvars[i], SCIP_BOUNDTYPE_UPPER, vbimplbound, TRUE,
9983 infeasible, nbdchgs, &added) );
9984 }
9985 nvubvars = SCIPvboundsGetNVbds(implvar->vubs);
9986 i = MIN(i, nvubvars); /* some elements from the array could have been removed */
9987 }
9988 --i;
9989 }
9990 }
9991 }
9992
9993 return SCIP_OKAY;
9994}
9995
9996/** informs variable x about a globally valid variable lower bound x >= b*z + d with integer variable z;
9997 * if z is binary, the corresponding valid implication for z is also added;
9998 * improves the global bounds of the variable and the vlb variable if possible
9999 */
10001 SCIP_VAR* var, /**< problem variable */
10002 BMS_BLKMEM* blkmem, /**< block memory */
10003 SCIP_SET* set, /**< global SCIP settings */
10004 SCIP_STAT* stat, /**< problem statistics */
10005 SCIP_PROB* transprob, /**< transformed problem */
10006 SCIP_PROB* origprob, /**< original problem */
10007 SCIP_TREE* tree, /**< branch and bound tree if in solving stage */
10008 SCIP_REOPT* reopt, /**< reoptimization data structure */
10009 SCIP_LP* lp, /**< current LP data */
10010 SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
10011 SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
10012 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
10013 SCIP_VAR* vlbvar, /**< variable z in x >= b*z + d */
10014 SCIP_Real vlbcoef, /**< coefficient b in x >= b*z + d */
10015 SCIP_Real vlbconstant, /**< constant d in x >= b*z + d */
10016 SCIP_Bool transitive, /**< should transitive closure of implication also be added? */
10017 SCIP_Bool* infeasible, /**< pointer to store whether an infeasibility was detected */
10018 int* nbdchgs /**< pointer to store the number of performed bound changes, or NULL */
10019 )
10020{
10021 assert(var != NULL);
10022 assert(set != NULL);
10023 assert(var->scip == set->scip);
10024 assert(SCIPvarGetType(vlbvar) != SCIP_VARTYPE_CONTINUOUS);
10025 assert(infeasible != NULL);
10026
10027 SCIPsetDebugMsg(set, "adding variable lower bound <%s> >= %g<%s> + %g\n", SCIPvarGetName(var), vlbcoef, SCIPvarGetName(vlbvar), vlbconstant);
10028
10029 *infeasible = FALSE;
10030 if( nbdchgs != NULL )
10031 *nbdchgs = 0;
10032
10033 switch( SCIPvarGetStatus(var) )
10034 {
10036 assert(var->data.original.transvar != NULL);
10037 SCIP_CALL( SCIPvarAddVlb(var->data.original.transvar, blkmem, set, stat, transprob, origprob, tree, reopt, lp,
10038 cliquetable, branchcand, eventqueue, vlbvar, vlbcoef, vlbconstant, transitive, infeasible, nbdchgs) );
10039 break;
10040
10044 /* transform b*z + d into the corresponding sum after transforming z to an active problem variable */
10045 SCIP_CALL( SCIPvarGetProbvarSum(&vlbvar, set, &vlbcoef, &vlbconstant) );
10046 SCIPsetDebugMsg(set, " -> transformed to variable lower bound <%s> >= %g<%s> + %g\n", SCIPvarGetName(var), vlbcoef, SCIPvarGetName(vlbvar), vlbconstant);
10047
10048 /* if the vlb coefficient is zero, just update the lower bound of the variable */
10049 if( SCIPsetIsZero(set, vlbcoef) )
10050 {
10051 if( SCIPsetIsFeasGT(set, vlbconstant, SCIPvarGetUbGlobal(var)) )
10052 *infeasible = TRUE;
10053 else if( SCIPsetIsFeasGT(set, vlbconstant, SCIPvarGetLbGlobal(var)) )
10054 {
10055 /* during solving stage it can happen that the global bound change cannot be applied directly because it conflicts
10056 * with the local bound, in this case we need to store the bound change as pending bound change
10057 */
10059 {
10060 assert(tree != NULL);
10061 assert(transprob != NULL);
10062 assert(SCIPprobIsTransformed(transprob));
10063
10064 SCIP_CALL( SCIPnodeAddBoundchg(SCIPtreeGetRootNode(tree), blkmem, set, stat, transprob, origprob,
10065 tree, reopt, lp, branchcand, eventqueue, cliquetable, var, vlbconstant, SCIP_BOUNDTYPE_LOWER, FALSE) );
10066 }
10067 else
10068 {
10069 SCIP_CALL( SCIPvarChgLbGlobal(var, blkmem, set, stat, lp, branchcand, eventqueue, cliquetable, vlbconstant) );
10070 }
10071
10072 if( nbdchgs != NULL )
10073 (*nbdchgs)++;
10074 }
10075 }
10076 else if( var == vlbvar )
10077 {
10078 /* the variables cancels out, the variable bound constraint is either redundant or proves global infeasibility */
10079 if( SCIPsetIsEQ(set, vlbcoef, 1.0) )
10080 {
10081 if( SCIPsetIsPositive(set, vlbconstant) )
10082 *infeasible = TRUE;
10083 return SCIP_OKAY;
10084 }
10085 else
10086 {
10087 SCIP_Real lb = SCIPvarGetLbGlobal(var);
10088 SCIP_Real ub = SCIPvarGetUbGlobal(var);
10089
10090 /* the variable bound constraint defines a new upper bound */
10091 if( SCIPsetIsGT(set, vlbcoef, 1.0) )
10092 {
10093 SCIP_Real newub = vlbconstant / (1.0 - vlbcoef);
10094
10095 if( SCIPsetIsFeasLT(set, newub, lb) )
10096 {
10097 *infeasible = TRUE;
10098 return SCIP_OKAY;
10099 }
10100 else if( SCIPsetIsFeasLT(set, newub, ub) )
10101 {
10102 /* bound might be adjusted due to integrality condition */
10103 newub = adjustedUb(set, SCIPvarGetType(var), newub);
10104
10105 /* during solving stage it can happen that the global bound change cannot be applied directly because it conflicts
10106 * with the local bound, in this case we need to store the bound change as pending bound change
10107 */
10109 {
10110 assert(tree != NULL);
10111 assert(transprob != NULL);
10112 assert(SCIPprobIsTransformed(transprob));
10113
10114 SCIP_CALL( SCIPnodeAddBoundchg(SCIPtreeGetRootNode(tree), blkmem, set, stat, transprob, origprob,
10115 tree, reopt, lp, branchcand, eventqueue, cliquetable, var, newub, SCIP_BOUNDTYPE_UPPER, FALSE) );
10116 }
10117 else
10118 {
10119 SCIP_CALL( SCIPvarChgUbGlobal(var, blkmem, set, stat, lp, branchcand, eventqueue, cliquetable, newub) );
10120 }
10121
10122 if( nbdchgs != NULL )
10123 (*nbdchgs)++;
10124 }
10125 }
10126 /* the variable bound constraint defines a new lower bound */
10127 else
10128 {
10129 SCIP_Real newlb;
10130
10131 assert(SCIPsetIsLT(set, vlbcoef, 1.0));
10132
10133 newlb = vlbconstant / (1.0 - vlbcoef);
10134
10135 if( SCIPsetIsFeasGT(set, newlb, ub) )
10136 {
10137 *infeasible = TRUE;
10138 return SCIP_OKAY;
10139 }
10140 else if( SCIPsetIsFeasGT(set, newlb, lb) )
10141 {
10142 /* bound might be adjusted due to integrality condition */
10143 newlb = adjustedLb(set, SCIPvarGetType(var), newlb);
10144
10145 /* during solving stage it can happen that the global bound change cannot be applied directly because it conflicts
10146 * with the local bound, in this case we need to store the bound change as pending bound change
10147 */
10149 {
10150 assert(tree != NULL);
10151 assert(transprob != NULL);
10152 assert(SCIPprobIsTransformed(transprob));
10153
10154 SCIP_CALL( SCIPnodeAddBoundchg(SCIPtreeGetRootNode(tree), blkmem, set, stat, transprob, origprob,
10155 tree, reopt, lp, branchcand, eventqueue, cliquetable, var, newlb, SCIP_BOUNDTYPE_LOWER, FALSE) );
10156 }
10157 else
10158 {
10159 SCIP_CALL( SCIPvarChgLbGlobal(var, blkmem, set, stat, lp, branchcand, eventqueue, cliquetable, newlb) );
10160 }
10161
10162 if( nbdchgs != NULL )
10163 (*nbdchgs)++;
10164 }
10165 }
10166 }
10167 }
10168 else if( SCIPvarIsActive(vlbvar) )
10169 {
10170 SCIP_Real xlb;
10171 SCIP_Real xub;
10172 SCIP_Real zlb;
10173 SCIP_Real zub;
10174 SCIP_Real minvlb;
10175 SCIP_Real maxvlb;
10176
10178 assert(vlbcoef != 0.0);
10179
10180 minvlb = -SCIPsetInfinity(set);
10181 maxvlb = SCIPsetInfinity(set);
10182
10183 xlb = SCIPvarGetLbGlobal(var);
10184 xub = SCIPvarGetUbGlobal(var);
10185 zlb = SCIPvarGetLbGlobal(vlbvar);
10186 zub = SCIPvarGetUbGlobal(vlbvar);
10187
10188 /* improve global bounds of vlb variable, and calculate minimal and maximal value of variable bound */
10189 if( vlbcoef >= 0.0 )
10190 {
10191 SCIP_Real newzub;
10192
10193 if( !SCIPsetIsInfinity(set, xub) )
10194 {
10195 /* x >= b*z + d -> z <= (x-d)/b */
10196 newzub = (xub - vlbconstant)/vlbcoef;
10197
10198 /* return if the new bound is less than -infinity */
10199 if( SCIPsetIsInfinity(set, REALABS(newzub)) )
10200 return SCIP_OKAY;
10201
10202 if( SCIPsetIsFeasLT(set, newzub, zlb) )
10203 {
10204 *infeasible = TRUE;
10205 return SCIP_OKAY;
10206 }
10207 if( SCIPsetIsFeasLT(set, newzub, zub) )
10208 {
10209 /* bound might be adjusted due to integrality condition */
10210 newzub = adjustedUb(set, SCIPvarGetType(vlbvar), newzub);
10211
10212 /* during solving stage it can happen that the global bound change cannot be applied directly because it conflicts
10213 * with the local bound, in this case we need to store the bound change as pending bound change
10214 */
10216 {
10217 assert(tree != NULL);
10218 assert(transprob != NULL);
10219 assert(SCIPprobIsTransformed(transprob));
10220
10221 SCIP_CALL( SCIPnodeAddBoundchg(SCIPtreeGetRootNode(tree), blkmem, set, stat, transprob, origprob,
10222 tree, reopt, lp, branchcand, eventqueue, cliquetable, vlbvar, newzub, SCIP_BOUNDTYPE_UPPER, FALSE) );
10223 }
10224 else
10225 {
10226 SCIP_CALL( SCIPvarChgUbGlobal(vlbvar, blkmem, set, stat, lp, branchcand, eventqueue, cliquetable, newzub) );
10227 }
10228 zub = newzub;
10229
10230 if( nbdchgs != NULL )
10231 (*nbdchgs)++;
10232 }
10233 maxvlb = vlbcoef * zub + vlbconstant;
10234 if( !SCIPsetIsInfinity(set, -zlb) )
10235 minvlb = vlbcoef * zlb + vlbconstant;
10236 }
10237 else
10238 {
10239 if( !SCIPsetIsInfinity(set, zub) )
10240 maxvlb = vlbcoef * zub + vlbconstant;
10241 if( !SCIPsetIsInfinity(set, -zlb) )
10242 minvlb = vlbcoef * zlb + vlbconstant;
10243 }
10244 }
10245 else
10246 {
10247 SCIP_Real newzlb;
10248
10249 if( !SCIPsetIsInfinity(set, xub) )
10250 {
10251 /* x >= b*z + d -> z >= (x-d)/b */
10252 newzlb = (xub - vlbconstant)/vlbcoef;
10253
10254 /* return if the new bound is larger than infinity */
10255 if( SCIPsetIsInfinity(set, REALABS(newzlb)) )
10256 return SCIP_OKAY;
10257
10258 if( SCIPsetIsFeasGT(set, newzlb, zub) )
10259 {
10260 *infeasible = TRUE;
10261 return SCIP_OKAY;
10262 }
10263 if( SCIPsetIsFeasGT(set, newzlb, zlb) )
10264 {
10265 /* bound might be adjusted due to integrality condition */
10266 newzlb = adjustedLb(set, SCIPvarGetType(vlbvar), newzlb);
10267
10268 /* during solving stage it can happen that the global bound change cannot be applied directly because it conflicts
10269 * with the local bound, in this case we need to store the bound change as pending bound change
10270 */
10272 {
10273 assert(tree != NULL);
10274 assert(transprob != NULL);
10275 assert(SCIPprobIsTransformed(transprob));
10276
10277 SCIP_CALL( SCIPnodeAddBoundchg(SCIPtreeGetRootNode(tree), blkmem, set, stat, transprob, origprob,
10278 tree, reopt, lp, branchcand, eventqueue, cliquetable, vlbvar, newzlb, SCIP_BOUNDTYPE_LOWER, FALSE) );
10279 }
10280 else
10281 {
10282 SCIP_CALL( SCIPvarChgLbGlobal(vlbvar, blkmem, set, stat, lp, branchcand, eventqueue, cliquetable, newzlb) );
10283 }
10284 zlb = newzlb;
10285
10286 if( nbdchgs != NULL )
10287 (*nbdchgs)++;
10288 }
10289 maxvlb = vlbcoef * zlb + vlbconstant;
10290 if( !SCIPsetIsInfinity(set, zub) )
10291 minvlb = vlbcoef * zub + vlbconstant;
10292 }
10293 else
10294 {
10295 if( !SCIPsetIsInfinity(set, -zlb) )
10296 maxvlb = vlbcoef * zlb + vlbconstant;
10297 if( !SCIPsetIsInfinity(set, zub) )
10298 minvlb = vlbcoef * zub + vlbconstant;
10299 }
10300 }
10301 if( maxvlb < minvlb )
10302 maxvlb = minvlb;
10303
10304 /* adjust bounds due to integrality of variable */
10305 minvlb = adjustedLb(set, SCIPvarGetType(var), minvlb);
10306 maxvlb = adjustedLb(set, SCIPvarGetType(var), maxvlb);
10307
10308 /* check bounds for feasibility */
10309 if( SCIPsetIsFeasGT(set, minvlb, xub) || (var == vlbvar && SCIPsetIsEQ(set, vlbcoef, 1.0) && SCIPsetIsFeasPositive(set, vlbconstant)) )
10310 {
10311 *infeasible = TRUE;
10312 return SCIP_OKAY;
10313 }
10314 /* improve global lower bound of variable */
10315 if( SCIPsetIsFeasGT(set, minvlb, xlb) )
10316 {
10317 /* bound might be adjusted due to integrality condition */
10318 minvlb = adjustedLb(set, SCIPvarGetType(var), minvlb);
10319
10320 /* during solving stage it can happen that the global bound change cannot be applied directly because it conflicts
10321 * with the local bound, in this case we need to store the bound change as pending bound change
10322 */
10324 {
10325 assert(tree != NULL);
10326 assert(transprob != NULL);
10327 assert(SCIPprobIsTransformed(transprob));
10328
10329 SCIP_CALL( SCIPnodeAddBoundchg(SCIPtreeGetRootNode(tree), blkmem, set, stat, transprob, origprob,
10330 tree, reopt, lp, branchcand, eventqueue, cliquetable, var, minvlb, SCIP_BOUNDTYPE_LOWER, FALSE) );
10331 }
10332 else
10333 {
10334 SCIP_CALL( SCIPvarChgLbGlobal(var, blkmem, set, stat, lp, branchcand, eventqueue, cliquetable, minvlb) );
10335 }
10336 xlb = minvlb;
10337
10338 if( nbdchgs != NULL )
10339 (*nbdchgs)++;
10340 }
10341 minvlb = xlb;
10342
10343 /* improve variable bound for binary z by moving the variable's global bound to the vlb constant */
10344 if( SCIPvarGetType(vlbvar) == SCIP_VARTYPE_BINARY )
10345 {
10346 /* b > 0: x >= (maxvlb - minvlb) * z + minvlb
10347 * b < 0: x >= (minvlb - maxvlb) * z + maxvlb
10348 */
10349
10350 assert(!SCIPsetIsInfinity(set, maxvlb) && !SCIPsetIsInfinity(set, -minvlb));
10351
10352 if( vlbcoef >= 0.0 )
10353 {
10354 vlbcoef = maxvlb - minvlb;
10355 vlbconstant = minvlb;
10356 }
10357 else
10358 {
10359 vlbcoef = minvlb - maxvlb;
10360 vlbconstant = maxvlb;
10361 }
10362 }
10363
10364 /* add variable bound to the variable bounds list */
10365 if( SCIPsetIsFeasGT(set, maxvlb, xlb) )
10366 {
10367 assert(SCIPvarGetStatus(var) != SCIP_VARSTATUS_FIXED);
10368 assert(!SCIPsetIsZero(set, vlbcoef));
10369
10370 /* if one of the variables is binary, add the corresponding implication to the variable's implication
10371 * list, thereby also adding the variable bound (or implication) to the other variable
10372 */
10373 if( SCIPvarGetType(vlbvar) == SCIP_VARTYPE_BINARY )
10374 {
10375 /* add corresponding implication:
10376 * b > 0, x >= b*z + d <-> z == 1 -> x >= b+d
10377 * b < 0, x >= b*z + d <-> z == 0 -> x >= d
10378 */
10379 SCIP_CALL( varAddTransitiveImplic(vlbvar, blkmem, set, stat, transprob, origprob, tree, reopt, lp,
10380 cliquetable, branchcand, eventqueue, (vlbcoef >= 0.0), var, SCIP_BOUNDTYPE_LOWER, maxvlb, transitive,
10381 infeasible, nbdchgs) );
10382 }
10383 else if( SCIPvarGetType(var) == SCIP_VARTYPE_BINARY )
10384 {
10385 /* add corresponding implication:
10386 * b > 0, x >= b*z + d <-> x == 0 -> z <= -d/b
10387 * b < 0, x >= b*z + d <-> x == 0 -> z >= -d/b
10388 */
10389 SCIP_Real implbound;
10390 implbound = -vlbconstant/vlbcoef;
10391
10392 /* tighten the implication bound if the variable is integer */
10393 if( SCIPvarIsIntegral(vlbvar) )
10394 {
10395 if( vlbcoef >= 0 )
10396 implbound = SCIPsetFloor(set, implbound);
10397 else
10398 implbound = SCIPsetCeil(set, implbound);
10399 }
10400 SCIP_CALL( varAddTransitiveImplic(var, blkmem, set, stat, transprob, origprob, tree, reopt, lp,
10401 cliquetable, branchcand, eventqueue, FALSE, vlbvar, (vlbcoef >= 0.0 ? SCIP_BOUNDTYPE_UPPER : SCIP_BOUNDTYPE_LOWER),
10402 implbound, transitive, infeasible, nbdchgs) );
10403 }
10404 else
10405 {
10406 SCIP_CALL( varAddVbound(var, blkmem, set, eventqueue, SCIP_BOUNDTYPE_LOWER, vlbvar, vlbcoef, vlbconstant) );
10407 }
10408 }
10409 }
10410 break;
10411
10413 /* x = a*y + c: x >= b*z + d <=> a*y + c >= b*z + d <=> y >= b/a * z + (d-c)/a, if a > 0
10414 * y <= b/a * z + (d-c)/a, if a < 0
10415 */
10416 assert(var->data.aggregate.var != NULL);
10418 {
10419 /* a > 0 -> add variable lower bound */
10420 SCIP_CALL( SCIPvarAddVlb(var->data.aggregate.var, blkmem, set, stat, transprob, origprob, tree, reopt, lp,
10421 cliquetable, branchcand, eventqueue, vlbvar, vlbcoef/var->data.aggregate.scalar,
10422 (vlbconstant - var->data.aggregate.constant)/var->data.aggregate.scalar, transitive, infeasible, nbdchgs) );
10423 }
10424 else if( SCIPsetIsNegative(set, var->data.aggregate.scalar) )
10425 {
10426 /* a < 0 -> add variable upper bound */
10427 SCIP_CALL( SCIPvarAddVub(var->data.aggregate.var, blkmem, set, stat, transprob, origprob, tree, reopt, lp,
10428 cliquetable, branchcand, eventqueue, vlbvar, vlbcoef/var->data.aggregate.scalar,
10429 (vlbconstant - var->data.aggregate.constant)/var->data.aggregate.scalar, transitive, infeasible, nbdchgs) );
10430 }
10431 else
10432 {
10433 SCIPerrorMessage("scalar is zero in aggregation\n");
10434 return SCIP_INVALIDDATA;
10435 }
10436 break;
10437
10439 /* nothing to do here */
10440 break;
10441
10443 /* x = offset - x': x >= b*z + d <=> offset - x' >= b*z + d <=> x' <= -b*z + (offset-d) */
10444 assert(var->negatedvar != NULL);
10446 assert(var->negatedvar->negatedvar == var);
10447 SCIP_CALL( SCIPvarAddVub(var->negatedvar, blkmem, set, stat, transprob, origprob, tree, reopt, lp, cliquetable,
10448 branchcand, eventqueue, vlbvar, -vlbcoef, var->data.negate.constant - vlbconstant, transitive, infeasible,
10449 nbdchgs) );
10450 break;
10451
10452 default:
10453 SCIPerrorMessage("unknown variable status\n");
10454 return SCIP_INVALIDDATA;
10455 }
10456
10457 return SCIP_OKAY;
10458}
10459
10460/** informs variable x about a globally valid variable upper bound x <= b*z + d with integer variable z;
10461 * if z is binary, the corresponding valid implication for z is also added;
10462 * updates the global bounds of the variable and the vub variable correspondingly
10463 */
10465 SCIP_VAR* var, /**< problem variable */
10466 BMS_BLKMEM* blkmem, /**< block memory */
10467 SCIP_SET* set, /**< global SCIP settings */
10468 SCIP_STAT* stat, /**< problem statistics */
10469 SCIP_PROB* transprob, /**< transformed problem */
10470 SCIP_PROB* origprob, /**< original problem */
10471 SCIP_TREE* tree, /**< branch and bound tree if in solving stage */
10472 SCIP_REOPT* reopt, /**< reoptimization data structure */
10473 SCIP_LP* lp, /**< current LP data */
10474 SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
10475 SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
10476 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
10477 SCIP_VAR* vubvar, /**< variable z in x <= b*z + d */
10478 SCIP_Real vubcoef, /**< coefficient b in x <= b*z + d */
10479 SCIP_Real vubconstant, /**< constant d in x <= b*z + d */
10480 SCIP_Bool transitive, /**< should transitive closure of implication also be added? */
10481 SCIP_Bool* infeasible, /**< pointer to store whether an infeasibility was detected */
10482 int* nbdchgs /**< pointer to store the number of performed bound changes, or NULL */
10483 )
10484{
10485 assert(var != NULL);
10486 assert(set != NULL);
10487 assert(var->scip == set->scip);
10488 assert(SCIPvarGetType(vubvar) != SCIP_VARTYPE_CONTINUOUS);
10489 assert(infeasible != NULL);
10490
10491 SCIPsetDebugMsg(set, "adding variable upper bound <%s> <= %g<%s> + %g\n", SCIPvarGetName(var), vubcoef, SCIPvarGetName(vubvar), vubconstant);
10492
10493 *infeasible = FALSE;
10494 if( nbdchgs != NULL )
10495 *nbdchgs = 0;
10496
10497 switch( SCIPvarGetStatus(var) )
10498 {
10500 assert(var->data.original.transvar != NULL);
10501 SCIP_CALL( SCIPvarAddVub(var->data.original.transvar, blkmem, set, stat, transprob, origprob, tree, reopt, lp,
10502 cliquetable, branchcand, eventqueue, vubvar, vubcoef, vubconstant, transitive, infeasible, nbdchgs) );
10503 break;
10504
10508 /* transform b*z + d into the corresponding sum after transforming z to an active problem variable */
10509 SCIP_CALL( SCIPvarGetProbvarSum(&vubvar, set, &vubcoef, &vubconstant) );
10510 SCIPsetDebugMsg(set, " -> transformed to variable upper bound <%s> <= %g<%s> + %g\n",
10511 SCIPvarGetName(var), vubcoef, SCIPvarGetName(vubvar), vubconstant);
10512
10513 /* if the vub coefficient is zero, just update the upper bound of the variable */
10514 if( SCIPsetIsZero(set, vubcoef) )
10515 {
10516 if( SCIPsetIsFeasLT(set, vubconstant, SCIPvarGetLbGlobal(var)) )
10517 *infeasible = TRUE;
10518 else if( SCIPsetIsFeasLT(set, vubconstant, SCIPvarGetUbGlobal(var)) )
10519 {
10520 /* during solving stage it can happen that the global bound change cannot be applied directly because it conflicts
10521 * with the local bound, in this case we need to store the bound change as pending bound change
10522 */
10524 {
10525 assert(tree != NULL);
10526 assert(transprob != NULL);
10527 assert(SCIPprobIsTransformed(transprob));
10528
10529 SCIP_CALL( SCIPnodeAddBoundchg(SCIPtreeGetRootNode(tree), blkmem, set, stat, transprob, origprob,
10530 tree, reopt, lp, branchcand, eventqueue, cliquetable, var, vubconstant, SCIP_BOUNDTYPE_UPPER, FALSE) );
10531 }
10532 else
10533 {
10534 SCIP_CALL( SCIPvarChgUbGlobal(var, blkmem, set, stat, lp, branchcand, eventqueue, cliquetable, vubconstant) );
10535 }
10536
10537 if( nbdchgs != NULL )
10538 (*nbdchgs)++;
10539 }
10540 }
10541 else if( var == vubvar )
10542 {
10543 /* the variables cancels out, the variable bound constraint is either redundant or proves global infeasibility */
10544 if( SCIPsetIsEQ(set, vubcoef, 1.0) )
10545 {
10546 if( SCIPsetIsNegative(set, vubconstant) )
10547 *infeasible = TRUE;
10548 return SCIP_OKAY;
10549 }
10550 else
10551 {
10552 SCIP_Real lb = SCIPvarGetLbGlobal(var);
10553 SCIP_Real ub = SCIPvarGetUbGlobal(var);
10554
10555 /* the variable bound constraint defines a new lower bound */
10556 if( SCIPsetIsGT(set, vubcoef, 1.0) )
10557 {
10558 SCIP_Real newlb = vubconstant / (1.0 - vubcoef);
10559
10560 if( SCIPsetIsFeasGT(set, newlb, ub) )
10561 {
10562 *infeasible = TRUE;
10563 return SCIP_OKAY;
10564 }
10565 else if( SCIPsetIsFeasGT(set, newlb, lb) )
10566 {
10567 /* bound might be adjusted due to integrality condition */
10568 newlb = adjustedLb(set, SCIPvarGetType(var), newlb);
10569
10570 /* during solving stage it can happen that the global bound change cannot be applied directly because it conflicts
10571 * with the local bound, in this case we need to store the bound change as pending bound change
10572 */
10574 {
10575 assert(tree != NULL);
10576 assert(transprob != NULL);
10577 assert(SCIPprobIsTransformed(transprob));
10578
10579 SCIP_CALL( SCIPnodeAddBoundchg(SCIPtreeGetRootNode(tree), blkmem, set, stat, transprob, origprob,
10580 tree, reopt, lp, branchcand, eventqueue, cliquetable, var, newlb, SCIP_BOUNDTYPE_LOWER, FALSE) );
10581 }
10582 else
10583 {
10584 SCIP_CALL( SCIPvarChgLbGlobal(var, blkmem, set, stat, lp, branchcand, eventqueue, cliquetable, newlb) );
10585 }
10586
10587 if( nbdchgs != NULL )
10588 (*nbdchgs)++;
10589 }
10590 }
10591 /* the variable bound constraint defines a new upper bound */
10592 else
10593 {
10594 SCIP_Real newub;
10595
10596 assert(SCIPsetIsLT(set, vubcoef, 1.0));
10597
10598 newub = vubconstant / (1.0 - vubcoef);
10599
10600 if( SCIPsetIsFeasLT(set, newub, lb) )
10601 {
10602 *infeasible = TRUE;
10603 return SCIP_OKAY;
10604 }
10605 else if( SCIPsetIsFeasLT(set, newub, ub) )
10606 {
10607 /* bound might be adjusted due to integrality condition */
10608 newub = adjustedUb(set, SCIPvarGetType(var), newub);
10609
10610 /* during solving stage it can happen that the global bound change cannot be applied directly because it conflicts
10611 * with the local bound, in this case we need to store the bound change as pending bound change
10612 */
10614 {
10615 assert(tree != NULL);
10616 assert(transprob != NULL);
10617 assert(SCIPprobIsTransformed(transprob));
10618
10619 SCIP_CALL( SCIPnodeAddBoundchg(SCIPtreeGetRootNode(tree), blkmem, set, stat, transprob, origprob,
10620 tree, reopt, lp, branchcand, eventqueue, cliquetable, var, newub, SCIP_BOUNDTYPE_UPPER, FALSE) );
10621 }
10622 else
10623 {
10624 SCIP_CALL( SCIPvarChgUbGlobal(var, blkmem, set, stat, lp, branchcand, eventqueue, cliquetable, newub) );
10625 }
10626
10627 if( nbdchgs != NULL )
10628 (*nbdchgs)++;
10629 }
10630 }
10631 }
10632 }
10633 else if( SCIPvarIsActive(vubvar) )
10634 {
10635 SCIP_Real xlb;
10636 SCIP_Real xub;
10637 SCIP_Real zlb;
10638 SCIP_Real zub;
10639 SCIP_Real minvub;
10640 SCIP_Real maxvub;
10641
10643 assert(vubcoef != 0.0);
10644
10645 minvub = -SCIPsetInfinity(set);
10646 maxvub = SCIPsetInfinity(set);
10647
10648 xlb = SCIPvarGetLbGlobal(var);
10649 xub = SCIPvarGetUbGlobal(var);
10650 zlb = SCIPvarGetLbGlobal(vubvar);
10651 zub = SCIPvarGetUbGlobal(vubvar);
10652
10653 /* improve global bounds of vub variable, and calculate minimal and maximal value of variable bound */
10654 if( vubcoef >= 0.0 )
10655 {
10656 SCIP_Real newzlb;
10657
10658 if( !SCIPsetIsInfinity(set, -xlb) )
10659 {
10660 /* x <= b*z + d -> z >= (x-d)/b */
10661 newzlb = (xlb - vubconstant)/vubcoef;
10662 if( SCIPsetIsFeasGT(set, newzlb, zub) )
10663 {
10664 *infeasible = TRUE;
10665 return SCIP_OKAY;
10666 }
10667 if( SCIPsetIsFeasGT(set, newzlb, zlb) )
10668 {
10669 /* bound might be adjusted due to integrality condition */
10670 newzlb = adjustedLb(set, SCIPvarGetType(vubvar), newzlb);
10671
10672 /* during solving stage it can happen that the global bound change cannot be applied directly because it conflicts
10673 * with the local bound, in this case we need to store the bound change as pending bound change
10674 */
10676 {
10677 assert(tree != NULL);
10678 assert(transprob != NULL);
10679 assert(SCIPprobIsTransformed(transprob));
10680
10681 SCIP_CALL( SCIPnodeAddBoundchg(SCIPtreeGetRootNode(tree), blkmem, set, stat, transprob, origprob,
10682 tree, reopt, lp, branchcand, eventqueue, cliquetable, vubvar, newzlb, SCIP_BOUNDTYPE_LOWER, FALSE) );
10683 }
10684 else
10685 {
10686 SCIP_CALL( SCIPvarChgLbGlobal(vubvar, blkmem, set, stat, lp, branchcand, eventqueue, cliquetable, newzlb) );
10687 }
10688 zlb = newzlb;
10689
10690 if( nbdchgs != NULL )
10691 (*nbdchgs)++;
10692 }
10693 minvub = vubcoef * zlb + vubconstant;
10694 if( !SCIPsetIsInfinity(set, zub) )
10695 maxvub = vubcoef * zub + vubconstant;
10696 }
10697 else
10698 {
10699 if( !SCIPsetIsInfinity(set, zub) )
10700 maxvub = vubcoef * zub + vubconstant;
10701 if( !SCIPsetIsInfinity(set, -zlb) )
10702 minvub = vubcoef * zlb + vubconstant;
10703 }
10704 }
10705 else
10706 {
10707 SCIP_Real newzub;
10708
10709 if( !SCIPsetIsInfinity(set, -xlb) )
10710 {
10711 /* x <= b*z + d -> z <= (x-d)/b */
10712 newzub = (xlb - vubconstant)/vubcoef;
10713 if( SCIPsetIsFeasLT(set, newzub, zlb) )
10714 {
10715 *infeasible = TRUE;
10716 return SCIP_OKAY;
10717 }
10718 if( SCIPsetIsFeasLT(set, newzub, zub) )
10719 {
10720 /* bound might be adjusted due to integrality condition */
10721 newzub = adjustedUb(set, SCIPvarGetType(vubvar), newzub);
10722
10723 /* during solving stage it can happen that the global bound change cannot be applied directly because it conflicts
10724 * with the local bound, in this case we need to store the bound change as pending bound change
10725 */
10727 {
10728 assert(tree != NULL);
10729 assert(transprob != NULL);
10730 assert(SCIPprobIsTransformed(transprob));
10731
10732 SCIP_CALL( SCIPnodeAddBoundchg(SCIPtreeGetRootNode(tree), blkmem, set, stat, transprob, origprob,
10733 tree, reopt, lp, branchcand, eventqueue, cliquetable, vubvar, newzub, SCIP_BOUNDTYPE_UPPER, FALSE) );
10734 }
10735 else
10736 {
10737 SCIP_CALL( SCIPvarChgUbGlobal(vubvar, blkmem, set, stat, lp, branchcand, eventqueue, cliquetable, newzub) );
10738 }
10739 zub = newzub;
10740
10741 if( nbdchgs != NULL )
10742 (*nbdchgs)++;
10743 }
10744 minvub = vubcoef * zub + vubconstant;
10745 if( !SCIPsetIsInfinity(set, -zlb) )
10746 maxvub = vubcoef * zlb + vubconstant;
10747 }
10748 else
10749 {
10750 if( !SCIPsetIsInfinity(set, zub) )
10751 minvub = vubcoef * zub + vubconstant;
10752 if( !SCIPsetIsInfinity(set, -zlb) )
10753 maxvub = vubcoef * zlb + vubconstant;
10754 }
10755 }
10756 if( minvub > maxvub )
10757 minvub = maxvub;
10758
10759 /* adjust bounds due to integrality of vub variable */
10760 minvub = adjustedUb(set, SCIPvarGetType(var), minvub);
10761 maxvub = adjustedUb(set, SCIPvarGetType(var), maxvub);
10762
10763 /* check bounds for feasibility */
10764 if( SCIPsetIsFeasLT(set, maxvub, xlb) || (var == vubvar && SCIPsetIsEQ(set, vubcoef, 1.0) && SCIPsetIsFeasNegative(set, vubconstant)) )
10765 {
10766 *infeasible = TRUE;
10767 return SCIP_OKAY;
10768 }
10769
10770 /* improve global upper bound of variable */
10771 if( SCIPsetIsFeasLT(set, maxvub, xub) )
10772 {
10773 /* bound might be adjusted due to integrality condition */
10774 maxvub = adjustedUb(set, SCIPvarGetType(var), maxvub);
10775
10776 /* during solving stage it can happen that the global bound change cannot be applied directly because it conflicts
10777 * with the local bound, in this case we need to store the bound change as pending bound change
10778 */
10780 {
10781 assert(tree != NULL);
10782 assert(transprob != NULL);
10783 assert(SCIPprobIsTransformed(transprob));
10784
10785 SCIP_CALL( SCIPnodeAddBoundchg(SCIPtreeGetRootNode(tree), blkmem, set, stat, transprob, origprob,
10786 tree, reopt, lp, branchcand, eventqueue, cliquetable, var, maxvub, SCIP_BOUNDTYPE_UPPER, FALSE) );
10787 }
10788 else
10789 {
10790 SCIP_CALL( SCIPvarChgUbGlobal(var, blkmem, set, stat, lp, branchcand, eventqueue, cliquetable, maxvub) );
10791 }
10792 xub = maxvub;
10793
10794 if( nbdchgs != NULL )
10795 (*nbdchgs)++;
10796 }
10797 maxvub = xub;
10798
10799 /* improve variable bound for binary z by moving the variable's global bound to the vub constant */
10800 if( SCIPvarIsBinary(vubvar) )
10801 {
10802 /* b > 0: x <= (maxvub - minvub) * z + minvub
10803 * b < 0: x <= (minvub - maxvub) * z + maxvub
10804 */
10805
10806 assert(!SCIPsetIsInfinity(set, maxvub) && !SCIPsetIsInfinity(set, -minvub));
10807
10808 if( vubcoef >= 0.0 )
10809 {
10810 vubcoef = maxvub - minvub;
10811 vubconstant = minvub;
10812 }
10813 else
10814 {
10815 vubcoef = minvub - maxvub;
10816 vubconstant = maxvub;
10817 }
10818 }
10819
10820 /* add variable bound to the variable bounds list */
10821 if( SCIPsetIsFeasLT(set, minvub, xub) )
10822 {
10823 assert(SCIPvarGetStatus(var) != SCIP_VARSTATUS_FIXED);
10824 assert(!SCIPsetIsZero(set, vubcoef));
10825
10826 /* if one of the variables is binary, add the corresponding implication to the variable's implication
10827 * list, thereby also adding the variable bound (or implication) to the other variable
10828 */
10829 if( SCIPvarGetType(vubvar) == SCIP_VARTYPE_BINARY )
10830 {
10831 /* add corresponding implication:
10832 * b > 0, x <= b*z + d <-> z == 0 -> x <= d
10833 * b < 0, x <= b*z + d <-> z == 1 -> x <= b+d
10834 */
10835 SCIP_CALL( varAddTransitiveImplic(vubvar, blkmem, set, stat, transprob, origprob, tree, reopt, lp,
10836 cliquetable, branchcand, eventqueue, (vubcoef < 0.0), var, SCIP_BOUNDTYPE_UPPER, minvub, transitive,
10837 infeasible, nbdchgs) );
10838 }
10839 else if( SCIPvarGetType(var) == SCIP_VARTYPE_BINARY )
10840 {
10841 /* add corresponding implication:
10842 * b > 0, x <= b*z + d <-> x == 1 -> z >= (1-d)/b
10843 * b < 0, x <= b*z + d <-> x == 1 -> z <= (1-d)/b
10844 */
10845 SCIP_CALL( varAddTransitiveImplic(var, blkmem, set, stat, transprob, origprob, tree, reopt, lp,
10846 cliquetable, branchcand, eventqueue, TRUE, vubvar, (vubcoef >= 0.0 ? SCIP_BOUNDTYPE_LOWER : SCIP_BOUNDTYPE_UPPER),
10847 (1.0-vubconstant)/vubcoef, transitive, infeasible, nbdchgs) );
10848 }
10849 else
10850 {
10851 SCIP_CALL( varAddVbound(var, blkmem, set, eventqueue, SCIP_BOUNDTYPE_UPPER, vubvar, vubcoef, vubconstant) );
10852 }
10853 }
10854 }
10855 break;
10856
10858 /* x = a*y + c: x <= b*z + d <=> a*y + c <= b*z + d <=> y <= b/a * z + (d-c)/a, if a > 0
10859 * y >= b/a * z + (d-c)/a, if a < 0
10860 */
10861 assert(var->data.aggregate.var != NULL);
10863 {
10864 /* a > 0 -> add variable upper bound */
10865 SCIP_CALL( SCIPvarAddVub(var->data.aggregate.var, blkmem, set, stat, transprob, origprob, tree, reopt, lp,
10866 cliquetable, branchcand, eventqueue, vubvar, vubcoef/var->data.aggregate.scalar,
10867 (vubconstant - var->data.aggregate.constant)/var->data.aggregate.scalar, transitive, infeasible, nbdchgs) );
10868 }
10869 else if( SCIPsetIsNegative(set, var->data.aggregate.scalar) )
10870 {
10871 /* a < 0 -> add variable lower bound */
10872 SCIP_CALL( SCIPvarAddVlb(var->data.aggregate.var, blkmem, set, stat, transprob, origprob, tree, reopt, lp,
10873 cliquetable, branchcand, eventqueue, vubvar, vubcoef/var->data.aggregate.scalar,
10874 (vubconstant - var->data.aggregate.constant)/var->data.aggregate.scalar, transitive, infeasible, nbdchgs) );
10875 }
10876 else
10877 {
10878 SCIPerrorMessage("scalar is zero in aggregation\n");
10879 return SCIP_INVALIDDATA;
10880 }
10881 break;
10882
10884 /* nothing to do here */
10885 break;
10886
10888 /* x = offset - x': x <= b*z + d <=> offset - x' <= b*z + d <=> x' >= -b*z + (offset-d) */
10889 assert(var->negatedvar != NULL);
10891 assert(var->negatedvar->negatedvar == var);
10892 SCIP_CALL( SCIPvarAddVlb(var->negatedvar, blkmem, set, stat, transprob, origprob, tree, reopt, lp, cliquetable,
10893 branchcand, eventqueue, vubvar, -vubcoef, var->data.negate.constant - vubconstant, transitive, infeasible,
10894 nbdchgs) );
10895 break;
10896
10897 default:
10898 SCIPerrorMessage("unknown variable status\n");
10899 return SCIP_INVALIDDATA;
10900 }
10901
10902 return SCIP_OKAY;
10903}
10904
10905/** informs binary variable x about a globally valid implication: x == 0 or x == 1 ==> y <= b or y >= b;
10906 * also adds the corresponding implication or variable bound to the implied variable;
10907 * if the implication is conflicting, the variable is fixed to the opposite value;
10908 * if the variable is already fixed to the given value, the implication is performed immediately;
10909 * if the implication is redundant with respect to the variables' global bounds, it is ignored
10910 */
10912 SCIP_VAR* var, /**< problem variable */
10913 BMS_BLKMEM* blkmem, /**< block memory */
10914 SCIP_SET* set, /**< global SCIP settings */
10915 SCIP_STAT* stat, /**< problem statistics */
10916 SCIP_PROB* transprob, /**< transformed problem */
10917 SCIP_PROB* origprob, /**< original problem */
10918 SCIP_TREE* tree, /**< branch and bound tree if in solving stage */
10919 SCIP_REOPT* reopt, /**< reoptimization data structure */
10920 SCIP_LP* lp, /**< current LP data */
10921 SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
10922 SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
10923 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
10924 SCIP_Bool varfixing, /**< FALSE if y should be added in implications for x == 0, TRUE for x == 1 */
10925 SCIP_VAR* implvar, /**< variable y in implication y <= b or y >= b */
10926 SCIP_BOUNDTYPE impltype, /**< type of implication y <= b (SCIP_BOUNDTYPE_UPPER) or y >= b (SCIP_BOUNDTYPE_LOWER) */
10927 SCIP_Real implbound, /**< bound b in implication y <= b or y >= b */
10928 SCIP_Bool transitive, /**< should transitive closure of implication also be added? */
10929 SCIP_Bool* infeasible, /**< pointer to store whether an infeasibility was detected */
10930 int* nbdchgs /**< pointer to store the number of performed bound changes, or NULL */
10931 )
10932{
10933 assert(var != NULL);
10934 assert(set != NULL);
10935 assert(var->scip == set->scip);
10936 assert(SCIPvarGetType(var) == SCIP_VARTYPE_BINARY);
10937 assert(infeasible != NULL);
10938
10939 *infeasible = FALSE;
10940 if( nbdchgs != NULL )
10941 *nbdchgs = 0;
10942
10943 switch( SCIPvarGetStatus(var) )
10944 {
10946 assert(var->data.original.transvar != NULL);
10947 SCIP_CALL( SCIPvarAddImplic(var->data.original.transvar, blkmem, set, stat, transprob, origprob, tree, reopt, lp,
10948 cliquetable, branchcand, eventqueue, varfixing, implvar, impltype, implbound, transitive, infeasible,
10949 nbdchgs) );
10950 break;
10951
10954 /* if the variable is fixed (although it has no FIXED status), and varfixing corresponds to the fixed value of
10955 * the variable, the implication can be applied directly;
10956 * otherwise, add implication to the implications list (and add inverse of implication to the implied variable)
10957 */
10958 if( SCIPvarGetLbGlobal(var) > 0.5 || SCIPvarGetUbGlobal(var) < 0.5 )
10959 {
10960 if( varfixing == (SCIPvarGetLbGlobal(var) > 0.5) )
10961 {
10962 SCIP_CALL( applyImplic(blkmem, set, stat, transprob, origprob, tree, reopt, lp, branchcand, eventqueue,
10963 cliquetable, implvar, impltype, implbound, infeasible, nbdchgs) );
10964 }
10965 }
10966 else
10967 {
10968 SCIP_CALL( SCIPvarGetProbvarBound(&implvar, &implbound, &impltype) );
10969 SCIPvarAdjustBd(implvar, set, impltype, &implbound);
10970 if( SCIPvarIsActive(implvar) || SCIPvarGetStatus(implvar) == SCIP_VARSTATUS_FIXED )
10971 {
10972 SCIP_CALL( varAddTransitiveImplic(var, blkmem, set, stat, transprob, origprob, tree, reopt, lp, cliquetable,
10973 branchcand, eventqueue, varfixing, implvar, impltype, implbound, transitive, infeasible, nbdchgs) );
10974 }
10975 }
10976 break;
10977
10979 /* if varfixing corresponds to the fixed value of the variable, the implication can be applied directly */
10980 if( varfixing == (SCIPvarGetLbGlobal(var) > 0.5) )
10981 {
10982 SCIP_CALL( applyImplic(blkmem, set, stat, transprob, origprob, tree, reopt, lp, branchcand, eventqueue,
10983 cliquetable, implvar, impltype, implbound, infeasible, nbdchgs) );
10984 }
10985 break;
10986
10988 /* implication added for x == 1:
10989 * x == 1 && x = 1*z + 0 ==> y <= b or y >= b <==> z >= 1 ==> y <= b or y >= b
10990 * x == 1 && x = -1*z + 1 ==> y <= b or y >= b <==> z <= 0 ==> y <= b or y >= b
10991 * implication added for x == 0:
10992 * x == 0 && x = 1*z + 0 ==> y <= b or y >= b <==> z <= 0 ==> y <= b or y >= b
10993 * x == 0 && x = -1*z + 1 ==> y <= b or y >= b <==> z >= 1 ==> y <= b or y >= b
10994 *
10995 * use only binary variables z
10996 */
10997 assert(var->data.aggregate.var != NULL);
10998 if( SCIPvarIsBinary(var->data.aggregate.var) )
10999 {
11000 assert( (SCIPsetIsEQ(set, var->data.aggregate.scalar, 1.0) && SCIPsetIsZero(set, var->data.aggregate.constant))
11001 || (SCIPsetIsEQ(set, var->data.aggregate.scalar, -1.0) && SCIPsetIsEQ(set, var->data.aggregate.constant, 1.0)) );
11002
11003 if( var->data.aggregate.scalar > 0 )
11004 {
11005 SCIP_CALL( SCIPvarAddImplic(var->data.aggregate.var, blkmem, set, stat, transprob, origprob, tree, reopt, lp,
11006 cliquetable, branchcand, eventqueue, varfixing, implvar, impltype, implbound, transitive, infeasible,
11007 nbdchgs) );
11008 }
11009 else
11010 {
11011 SCIP_CALL( SCIPvarAddImplic(var->data.aggregate.var, blkmem, set, stat, transprob, origprob, tree, reopt, lp,
11012 cliquetable, branchcand, eventqueue, !varfixing, implvar, impltype, implbound, transitive, infeasible,
11013 nbdchgs) );
11014 }
11015 }
11016 break;
11017
11019 /* nothing to do here */
11020 break;
11021
11023 /* implication added for x == 1:
11024 * x == 1 && x = -1*z + 1 ==> y <= b or y >= b <==> z <= 0 ==> y <= b or y >= b
11025 * implication added for x == 0:
11026 * x == 0 && x = -1*z + 1 ==> y <= b or y >= b <==> z >= 1 ==> y <= b or y >= b
11027 */
11028 assert(var->negatedvar != NULL);
11030 assert(var->negatedvar->negatedvar == var);
11031 assert(SCIPvarIsBinary(var->negatedvar));
11032
11034 {
11035 SCIP_CALL( SCIPvarAddImplic(var->negatedvar, blkmem, set, stat, transprob, origprob, tree, reopt, lp,
11036 cliquetable, branchcand, eventqueue, !varfixing, implvar, impltype, implbound, transitive, infeasible, nbdchgs) );
11037 }
11038 /* in case one both variables are not of binary type we have to add the implication as variable bounds */
11039 else
11040 {
11041 /* if the implied variable is of binary type exchange the variables */
11042 if( SCIPvarGetType(implvar) == SCIP_VARTYPE_BINARY )
11043 {
11044 SCIP_CALL( SCIPvarAddImplic(implvar, blkmem, set, stat, transprob, origprob, tree, reopt, lp, cliquetable,
11045 branchcand, eventqueue, (impltype == SCIP_BOUNDTYPE_UPPER) ? TRUE : FALSE, var->negatedvar,
11046 varfixing ? SCIP_BOUNDTYPE_LOWER : SCIP_BOUNDTYPE_UPPER, varfixing ? 1.0 : 0.0, transitive,
11047 infeasible, nbdchgs) );
11048 }
11049 else
11050 {
11051 /* both variables are not of binary type but are implicit binary; in that case we can only add this
11052 * implication as variable bounds
11053 */
11054
11055 /* add variable lower bound on the negation of var */
11056 if( varfixing )
11057 {
11058 /* (x = 1 => i) z = 0 ii) z = 1) <=> ( i) z = 1 ii) z = 0 => ~x = 1), this is done by adding ~x >= b*z + d
11059 * as variable lower bound
11060 */
11061 SCIP_CALL( SCIPvarAddVlb(var->negatedvar, blkmem, set, stat, transprob, origprob, tree, reopt, lp,
11062 cliquetable, branchcand, eventqueue, implvar, (impltype == SCIP_BOUNDTYPE_UPPER) ? 1.0 : -1.0,
11063 (impltype == SCIP_BOUNDTYPE_UPPER) ? 0.0 : 1.0, transitive, infeasible, nbdchgs) );
11064 }
11065 else
11066 {
11067 /* (x = 0 => i) z = 0 ii) z = 1) <=> ( i) z = 1 ii) z = 0 => ~x = 0), this is done by adding ~x <= b*z + d
11068 * as variable upper bound
11069 */
11070 SCIP_CALL( SCIPvarAddVub(var->negatedvar, blkmem, set, stat, transprob, origprob, tree, reopt, lp,
11071 cliquetable, branchcand, eventqueue, implvar, (impltype == SCIP_BOUNDTYPE_UPPER) ? -1.0 : 1.0,
11072 (impltype == SCIP_BOUNDTYPE_UPPER) ? 1.0 : 0.0, transitive, infeasible, nbdchgs) );
11073 }
11074
11075 /* add variable bound on implvar */
11076 if( impltype == SCIP_BOUNDTYPE_UPPER )
11077 {
11078 /* (z = 1 => i) x = 0 ii) x = 1) <=> ( i) ~x = 0 ii) ~x = 1 => z = 0), this is done by adding z <= b*~x + d
11079 * as variable upper bound
11080 */
11081 SCIP_CALL( SCIPvarAddVub(implvar, blkmem, set, stat, transprob, origprob, tree, reopt, lp, cliquetable,
11082 branchcand, eventqueue, var->negatedvar, (varfixing) ? 1.0 : -1.0,
11083 (varfixing) ? 0.0 : 1.0, transitive, infeasible, nbdchgs) );
11084 }
11085 else
11086 {
11087 /* (z = 0 => i) x = 0 ii) x = 1) <=> ( i) ~x = 0 ii) ~x = 1 => z = 1), this is done by adding z >= b*~x + d
11088 * as variable upper bound
11089 */
11090 SCIP_CALL( SCIPvarAddVlb(implvar, blkmem, set, stat, transprob, origprob, tree, reopt, lp, cliquetable,
11091 branchcand, eventqueue, var->negatedvar, (varfixing) ? -1.0 : 1.0, (varfixing) ? 1.0 : 0.0,
11092 transitive, infeasible, nbdchgs) );
11093 }
11094 }
11095 }
11096 break;
11097
11098 default:
11099 SCIPerrorMessage("unknown variable status\n");
11100 return SCIP_INVALIDDATA;
11101 }
11102
11103 return SCIP_OKAY;
11104}
11105
11106/** returns whether there is an implication x == varfixing -> y <= b or y >= b in the implication graph;
11107 * implications that are represented as cliques in the clique table are not regarded (use SCIPvarsHaveCommonClique());
11108 * both variables must be active, variable x must be binary
11109 */
11111 SCIP_VAR* var, /**< problem variable x */
11112 SCIP_Bool varfixing, /**< FALSE if y should be searched in implications for x == 0, TRUE for x == 1 */
11113 SCIP_VAR* implvar, /**< variable y to search for */
11114 SCIP_BOUNDTYPE impltype /**< type of implication y <=/>= b to search for */
11115 )
11116{
11117 assert(var != NULL);
11118 assert(implvar != NULL);
11119 assert(SCIPvarIsActive(var));
11120 assert(SCIPvarIsActive(implvar));
11121 assert(SCIPvarIsBinary(var));
11122
11123 return var->implics != NULL && SCIPimplicsContainsImpl(var->implics, varfixing, implvar, impltype);
11124}
11125
11126/** returns whether there is an implication x == varfixing -> y == implvarfixing in the implication graph;
11127 * implications that are represented as cliques in the clique table are not regarded (use SCIPvarsHaveCommonClique());
11128 * both variables must be active binary variables
11129 */
11131 SCIP_VAR* var, /**< problem variable x */
11132 SCIP_Bool varfixing, /**< FALSE if y should be searched in implications for x == 0, TRUE for x == 1 */
11133 SCIP_VAR* implvar, /**< variable y to search for */
11134 SCIP_Bool implvarfixing /**< value of the implied variable to search for */
11135 )
11136{
11137 assert(SCIPvarIsBinary(implvar));
11138
11139 return SCIPvarHasImplic(var, varfixing, implvar, implvarfixing ? SCIP_BOUNDTYPE_LOWER : SCIP_BOUNDTYPE_UPPER);
11140}
11141
11142/** gets the values of b in implications x == varfixing -> y <= b or y >= b in the implication graph;
11143 * the values are set to SCIP_INVALID if there is no implied bound
11144 */
11146 SCIP_VAR* var, /**< problem variable x */
11147 SCIP_Bool varfixing, /**< FALSE if y should be searched in implications for x == 0, TRUE for x == 1 */
11148 SCIP_VAR* implvar, /**< variable y to search for */
11149 SCIP_Real* lb, /**< buffer to store the value of the implied lower bound */
11150 SCIP_Real* ub /**< buffer to store the value of the implied upper bound */
11151 )
11152{
11153 int lowerpos;
11154 int upperpos;
11155 SCIP_Real* bounds;
11156
11157 assert(lb != NULL);
11158 assert(ub != NULL);
11159
11160 *lb = SCIP_INVALID;
11161 *ub = SCIP_INVALID;
11162
11163 if( var->implics == NULL )
11164 return;
11165
11166 SCIPimplicsGetVarImplicPoss(var->implics, varfixing, implvar, &lowerpos, &upperpos);
11167 bounds = SCIPvarGetImplBounds(var, varfixing);
11168
11169 if( bounds == NULL )
11170 return;
11171
11172 if( lowerpos >= 0 )
11173 *lb = bounds[lowerpos];
11174
11175 if( upperpos >= 0 )
11176 *ub = bounds[upperpos];
11177}
11178
11179
11180/** fixes the bounds of a binary variable to the given value, counting bound changes and detecting infeasibility */
11182 SCIP_VAR* var, /**< problem variable */
11183 BMS_BLKMEM* blkmem, /**< block memory */
11184 SCIP_SET* set, /**< global SCIP settings */
11185 SCIP_STAT* stat, /**< problem statistics */
11186 SCIP_PROB* transprob, /**< transformed problem */
11187 SCIP_PROB* origprob, /**< original problem */
11188 SCIP_TREE* tree, /**< branch and bound tree if in solving stage */
11189 SCIP_REOPT* reopt, /**< reoptimization data structure */
11190 SCIP_LP* lp, /**< current LP data */
11191 SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
11192 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
11193 SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
11194 SCIP_Bool value, /**< value to fix variable to */
11195 SCIP_Bool* infeasible, /**< pointer to store whether an infeasibility was detected */
11196 int* nbdchgs /**< pointer to count the number of performed bound changes, or NULL */
11197 )
11198{
11199 assert(var != NULL);
11200 assert(set != NULL);
11201 assert(var->scip == set->scip);
11202 assert(infeasible != NULL);
11203
11204 *infeasible = FALSE;
11205
11206 if( value == FALSE )
11207 {
11208 if( var->glbdom.lb > 0.5 )
11209 *infeasible = TRUE;
11210 else if( var->glbdom.ub > 0.5 )
11211 {
11212 /* during solving stage it can happen that the global bound change cannot be applied directly because it conflicts
11213 * with the local bound, in this case we need to store the bound change as pending bound change
11214 */
11216 {
11217 assert(tree != NULL);
11218 assert(transprob != NULL);
11219 assert(SCIPprobIsTransformed(transprob));
11220
11221 SCIP_CALL( SCIPnodeAddBoundchg(SCIPtreeGetRootNode(tree), blkmem, set, stat, transprob, origprob,
11222 tree, reopt, lp, branchcand, eventqueue, cliquetable, var, 0.0, SCIP_BOUNDTYPE_UPPER, FALSE) );
11223 }
11224 else
11225 {
11226 SCIP_CALL( SCIPvarChgUbGlobal(var, blkmem, set, stat, lp, branchcand, eventqueue, cliquetable, 0.0) );
11227 }
11228
11229 if( nbdchgs != NULL )
11230 (*nbdchgs)++;
11231 }
11232 }
11233 else
11234 {
11235 if( var->glbdom.ub < 0.5 )
11236 *infeasible = TRUE;
11237 else if( var->glbdom.lb < 0.5 )
11238 {
11239 /* during solving stage it can happen that the global bound change cannot be applied directly because it conflicts
11240 * with the local bound, in this case we need to store the bound change as pending bound change
11241 */
11243 {
11244 assert(tree != NULL);
11245 assert(transprob != NULL);
11246 assert(SCIPprobIsTransformed(transprob));
11247
11248 SCIP_CALL( SCIPnodeAddBoundchg(SCIPtreeGetRootNode(tree), blkmem, set, stat, transprob, origprob,
11249 tree, reopt, lp, branchcand, eventqueue, cliquetable, var, 1.0, SCIP_BOUNDTYPE_LOWER, FALSE) );
11250 }
11251 else
11252 {
11253 SCIP_CALL( SCIPvarChgLbGlobal(var, blkmem, set, stat, lp, branchcand, eventqueue, cliquetable, 1.0) );
11254 }
11255
11256 if( nbdchgs != NULL )
11257 (*nbdchgs)++;
11258 }
11259 }
11260
11261 return SCIP_OKAY;
11262}
11263
11264/** adds the variable to the given clique and updates the list of cliques the binary variable is member of;
11265 * if the variable now appears twice in the clique with the same value, it is fixed to the opposite value;
11266 * if the variable now appears twice in the clique with opposite values, all other variables are fixed to
11267 * the opposite of the value they take in the clique
11268 */
11270 SCIP_VAR* var, /**< problem variable */
11271 BMS_BLKMEM* blkmem, /**< block memory */
11272 SCIP_SET* set, /**< global SCIP settings */
11273 SCIP_STAT* stat, /**< problem statistics */
11274 SCIP_PROB* transprob, /**< transformed problem */
11275 SCIP_PROB* origprob, /**< original problem */
11276 SCIP_TREE* tree, /**< branch and bound tree if in solving stage */
11277 SCIP_REOPT* reopt, /**< reoptimization data structure */
11278 SCIP_LP* lp, /**< current LP data */
11279 SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
11280 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
11281 SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
11282 SCIP_Bool value, /**< value of the variable in the clique */
11283 SCIP_CLIQUE* clique, /**< clique the variable should be added to */
11284 SCIP_Bool* infeasible, /**< pointer to store whether an infeasibility was detected */
11285 int* nbdchgs /**< pointer to count the number of performed bound changes, or NULL */
11286 )
11287{
11288 assert(var != NULL);
11289 assert(set != NULL);
11290 assert(var->scip == set->scip);
11291 assert(SCIPvarIsBinary(var));
11292 assert(infeasible != NULL);
11293
11294 *infeasible = FALSE;
11295
11296 /* get corresponding active problem variable */
11297 SCIP_CALL( SCIPvarGetProbvarBinary(&var, &value) );
11302 assert(SCIPvarIsBinary(var));
11303
11304 /* only column and loose variables may be member of a clique */
11306 {
11307 SCIP_Bool doubleentry;
11308 SCIP_Bool oppositeentry;
11309
11310 /* add variable to clique */
11311 SCIP_CALL( SCIPcliqueAddVar(clique, blkmem, set, var, value, &doubleentry, &oppositeentry) );
11312
11313 /* add clique to variable's clique list */
11314 SCIP_CALL( SCIPcliquelistAdd(&var->cliquelist, blkmem, set, value, clique) );
11315
11316 /* check consistency of cliquelist */
11318
11319 /* if the variable now appears twice with the same value in the clique, it can be fixed to the opposite value */
11320 if( doubleentry )
11321 {
11322 SCIP_CALL( SCIPvarFixBinary(var, blkmem, set, stat, transprob, origprob, tree, reopt, lp, branchcand,
11323 eventqueue, cliquetable, !value, infeasible, nbdchgs) );
11324 }
11325
11326 /* if the variable appears with both values in the clique, all other variables of the clique can be fixed
11327 * to the opposite of the value they take in the clique
11328 */
11329 if( oppositeentry )
11330 {
11331 SCIP_VAR** vars;
11332 SCIP_Bool* values;
11333 int nvars;
11334 int i;
11335
11336 nvars = SCIPcliqueGetNVars(clique);
11337 vars = SCIPcliqueGetVars(clique);
11338 values = SCIPcliqueGetValues(clique);
11339 for( i = 0; i < nvars && !(*infeasible); ++i )
11340 {
11341 if( vars[i] == var )
11342 continue;
11343
11344 SCIP_CALL( SCIPvarFixBinary(vars[i], blkmem, set, stat, transprob, origprob, tree, reopt, lp, branchcand,
11345 eventqueue, cliquetable, !values[i], infeasible, nbdchgs) );
11346 }
11347 }
11348 }
11349
11350 return SCIP_OKAY;
11351}
11352
11353/** adds a filled clique to the cliquelists of all corresponding variables */
11355 SCIP_VAR** vars, /**< problem variables */
11356 SCIP_Bool* values, /**< values of the variables in the clique */
11357 int nvars, /**< number of problem variables */
11358 BMS_BLKMEM* blkmem, /**< block memory */
11359 SCIP_SET* set, /**< global SCIP settings */
11360 SCIP_CLIQUE* clique /**< clique that contains all given variables and values */
11361 )
11362{
11363 SCIP_VAR* var;
11364 int v;
11365
11366 assert(vars != NULL);
11367 assert(values != NULL);
11368 assert(nvars > 0);
11369 assert(set != NULL);
11370 assert(blkmem != NULL);
11371 assert(clique != NULL);
11372
11373 for( v = nvars - 1; v >= 0; --v )
11374 {
11375 var = vars[v];
11376 assert(SCIPvarIsBinary(var));
11378
11379 /* add clique to variable's clique list */
11380 SCIP_CALL( SCIPcliquelistAdd(&var->cliquelist, blkmem, set, values[v], clique) );
11381
11382 /* check consistency of cliquelist */
11384 }
11385
11386 return SCIP_OKAY;
11387}
11388
11389/** adds a clique to the list of cliques of the given binary variable, but does not change the clique
11390 * itself
11391 */
11393 SCIP_VAR* var, /**< problem variable */
11394 BMS_BLKMEM* blkmem, /**< block memory */
11395 SCIP_SET* set, /**< global SCIP settings */
11396 SCIP_Bool value, /**< value of the variable in the clique */
11397 SCIP_CLIQUE* clique /**< clique that should be removed from the variable's clique list */
11398 )
11399{
11400 assert(var != NULL);
11401 assert(SCIPvarIsBinary(var));
11403
11404 /* add clique to variable's clique list */
11405 SCIP_CALL( SCIPcliquelistAdd(&var->cliquelist, blkmem, set, value, clique) );
11406
11407 return SCIP_OKAY;
11408}
11409
11410
11411/** deletes a clique from the list of cliques the binary variable is member of, but does not change the clique
11412 * itself
11413 */
11415 SCIP_VAR* var, /**< problem variable */
11416 BMS_BLKMEM* blkmem, /**< block memory */
11417 SCIP_Bool value, /**< value of the variable in the clique */
11418 SCIP_CLIQUE* clique /**< clique that should be removed from the variable's clique list */
11419 )
11420{
11421 assert(var != NULL);
11422 assert(SCIPvarIsBinary(var));
11423
11424 /* delete clique from variable's clique list */
11425 SCIP_CALL( SCIPcliquelistDel(&var->cliquelist, blkmem, value, clique) );
11426
11427 return SCIP_OKAY;
11428}
11429
11430/** deletes the variable from the given clique and updates the list of cliques the binary variable is member of */
11432 SCIP_VAR* var, /**< problem variable */
11433 BMS_BLKMEM* blkmem, /**< block memory */
11434 SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
11435 SCIP_Bool value, /**< value of the variable in the clique */
11436 SCIP_CLIQUE* clique /**< clique the variable should be removed from */
11437 )
11438{
11439 assert(var != NULL);
11440 assert(SCIPvarIsBinary(var));
11441
11442 /* get corresponding active problem variable */
11443 SCIP_CALL( SCIPvarGetProbvarBinary(&var, &value) );
11448 assert(SCIPvarIsBinary(var));
11449
11450 /* only column and loose variables may be member of a clique */
11452 {
11453 /* delete clique from variable's clique list */
11454 SCIP_CALL( SCIPcliquelistDel(&var->cliquelist, blkmem, value, clique) );
11455
11456 /* delete variable from clique */
11457 SCIPcliqueDelVar(clique, cliquetable, var, value);
11458
11459 /* check consistency of cliquelist */
11461 }
11462
11463 return SCIP_OKAY;
11464}
11465
11466/** returns whether there is a clique that contains both given variable/value pairs;
11467 * the variables must be active binary variables;
11468 * if regardimplics is FALSE, only the cliques in the clique table are looked at;
11469 * if regardimplics is TRUE, both the cliques and the implications of the implication graph are regarded
11470 *
11471 * @note a variable with it's negated variable are NOT! in a clique
11472 * @note a variable with itself are in a clique
11473 */
11475 SCIP_VAR* var1, /**< first variable */
11476 SCIP_Bool value1, /**< value of first variable */
11477 SCIP_VAR* var2, /**< second variable */
11478 SCIP_Bool value2, /**< value of second variable */
11479 SCIP_Bool regardimplics /**< should the implication graph also be searched for a clique? */
11480 )
11481{
11482 assert(var1 != NULL);
11483 assert(var2 != NULL);
11484 assert(SCIPvarIsActive(var1));
11485 assert(SCIPvarIsActive(var2));
11486 assert(SCIPvarIsBinary(var1));
11487 assert(SCIPvarIsBinary(var2));
11488
11489 return (SCIPcliquelistsHaveCommonClique(var1->cliquelist, value1, var2->cliquelist, value2)
11490 || (regardimplics && SCIPvarHasImplic(var1, value1, var2, value2 ? SCIP_BOUNDTYPE_UPPER : SCIP_BOUNDTYPE_LOWER)));
11491}
11492
11493/** actually changes the branch factor of the variable and of all parent variables */
11494static
11496 SCIP_VAR* var, /**< problem variable */
11497 SCIP_SET* set, /**< global SCIP settings */
11498 SCIP_Real branchfactor /**< factor to weigh variable's branching score with */
11499 )
11500{
11501 SCIP_VAR* parentvar;
11502 SCIP_Real eps;
11503 int i;
11504
11505 assert(var != NULL);
11506 assert(set != NULL);
11507 assert(var->scip == set->scip);
11508
11509 /* only use positive values */
11511 branchfactor = MAX(branchfactor, eps);
11512
11513 SCIPsetDebugMsg(set, "process changing branch factor of <%s> from %f to %f\n", var->name, var->branchfactor, branchfactor);
11514
11515 if( SCIPsetIsEQ(set, branchfactor, var->branchfactor) )
11516 return SCIP_OKAY;
11517
11518 /* change the branch factor */
11519 var->branchfactor = branchfactor;
11520
11521 /* process parent variables */
11522 for( i = 0; i < var->nparentvars; ++i )
11523 {
11524 parentvar = var->parentvars[i];
11525 assert(parentvar != NULL);
11526
11527 switch( SCIPvarGetStatus(parentvar) )
11528 {
11530 /* do not change priorities across the border between transformed and original problem */
11531 break;
11532
11537 SCIPerrorMessage("column, loose, fixed or multi-aggregated variable cannot be the parent of a variable\n");
11538 SCIPABORT();
11539 return SCIP_INVALIDDATA; /*lint !e527*/
11540
11543 SCIP_CALL( varProcessChgBranchFactor(parentvar, set, branchfactor) );
11544 break;
11545
11546 default:
11547 SCIPerrorMessage("unknown variable status\n");
11548 SCIPABORT();
11549 return SCIP_ERROR; /*lint !e527*/
11550 }
11551 }
11552
11553 return SCIP_OKAY;
11554}
11555
11556/** sets the branch factor of the variable; this value can be used in the branching methods to scale the score
11557 * values of the variables; higher factor leads to a higher probability that this variable is chosen for branching
11558 */
11560 SCIP_VAR* var, /**< problem variable */
11561 SCIP_SET* set, /**< global SCIP settings */
11562 SCIP_Real branchfactor /**< factor to weigh variable's branching score with */
11563 )
11564{
11565 int v;
11566
11567 assert(var != NULL);
11568 assert(set != NULL);
11569 assert(var->scip == set->scip);
11570 assert(branchfactor >= 0.0);
11571
11572 SCIPdebugMessage("changing branch factor of <%s> from %g to %g\n", var->name, var->branchfactor, branchfactor);
11573
11574 if( SCIPsetIsEQ(set, var->branchfactor, branchfactor) )
11575 return SCIP_OKAY;
11576
11577 /* change priorities of attached variables */
11578 switch( SCIPvarGetStatus(var) )
11579 {
11581 if( var->data.original.transvar != NULL )
11582 {
11583 SCIP_CALL( SCIPvarChgBranchFactor(var->data.original.transvar, set, branchfactor) );
11584 }
11585 else
11586 {
11587 assert(set->stage == SCIP_STAGE_PROBLEM);
11588 var->branchfactor = branchfactor;
11589 }
11590 break;
11591
11595 SCIP_CALL( varProcessChgBranchFactor(var, set, branchfactor) );
11596 break;
11597
11599 assert(!var->donotaggr);
11600 assert(var->data.aggregate.var != NULL);
11601 SCIP_CALL( SCIPvarChgBranchFactor(var->data.aggregate.var, set, branchfactor) );
11602 break;
11603
11605 assert(!var->donotmultaggr);
11606 for( v = 0; v < var->data.multaggr.nvars; ++v )
11607 {
11608 SCIP_CALL( SCIPvarChgBranchFactor(var->data.multaggr.vars[v], set, branchfactor) );
11609 }
11610 break;
11611
11613 assert(var->negatedvar != NULL);
11615 assert(var->negatedvar->negatedvar == var);
11616 SCIP_CALL( SCIPvarChgBranchFactor(var->negatedvar, set, branchfactor) );
11617 break;
11618
11619 default:
11620 SCIPerrorMessage("unknown variable status\n");
11621 SCIPABORT();
11622 return SCIP_ERROR; /*lint !e527*/
11623 }
11624
11625 return SCIP_OKAY;
11626}
11627
11628/** actually changes the branch priority of the variable and of all parent variables */
11629static
11631 SCIP_VAR* var, /**< problem variable */
11632 int branchpriority /**< branching priority of the variable */
11633 )
11634{
11635 SCIP_VAR* parentvar;
11636 int i;
11637
11638 assert(var != NULL);
11639
11640 SCIPdebugMessage("process changing branch priority of <%s> from %d to %d\n",
11641 var->name, var->branchpriority, branchpriority);
11642
11643 if( branchpriority == var->branchpriority )
11644 return SCIP_OKAY;
11645
11646 /* change the branch priority */
11647 var->branchpriority = branchpriority;
11648
11649 /* process parent variables */
11650 for( i = 0; i < var->nparentvars; ++i )
11651 {
11652 parentvar = var->parentvars[i];
11653 assert(parentvar != NULL);
11654
11655 switch( SCIPvarGetStatus(parentvar) )
11656 {
11658 /* do not change priorities across the border between transformed and original problem */
11659 break;
11660
11665 SCIPerrorMessage("column, loose, fixed or multi-aggregated variable cannot be the parent of a variable\n");
11666 SCIPABORT();
11667 return SCIP_INVALIDDATA; /*lint !e527*/
11668
11671 SCIP_CALL( varProcessChgBranchPriority(parentvar, branchpriority) );
11672 break;
11673
11674 default:
11675 SCIPerrorMessage("unknown variable status\n");
11676 return SCIP_ERROR;
11677 }
11678 }
11679
11680 return SCIP_OKAY;
11681}
11682
11683/** sets the branch priority of the variable; variables with higher branch priority are always preferred to variables
11684 * with lower priority in selection of branching variable
11685 */
11687 SCIP_VAR* var, /**< problem variable */
11688 int branchpriority /**< branching priority of the variable */
11689 )
11690{
11691 int v;
11692
11693 assert(var != NULL);
11694
11695 SCIPdebugMessage("changing branch priority of <%s> from %d to %d\n", var->name, var->branchpriority, branchpriority);
11696
11697 if( var->branchpriority == branchpriority )
11698 return SCIP_OKAY;
11699
11700 /* change priorities of attached variables */
11701 switch( SCIPvarGetStatus(var) )
11702 {
11704 if( var->data.original.transvar != NULL )
11705 {
11706 SCIP_CALL( SCIPvarChgBranchPriority(var->data.original.transvar, branchpriority) );
11707 }
11708 else
11709 var->branchpriority = branchpriority;
11710 break;
11711
11715 SCIP_CALL( varProcessChgBranchPriority(var, branchpriority) );
11716 break;
11717
11719 assert(!var->donotaggr);
11720 assert(var->data.aggregate.var != NULL);
11721 SCIP_CALL( SCIPvarChgBranchPriority(var->data.aggregate.var, branchpriority) );
11722 break;
11723
11725 assert(!var->donotmultaggr);
11726 for( v = 0; v < var->data.multaggr.nvars; ++v )
11727 {
11728 SCIP_CALL( SCIPvarChgBranchPriority(var->data.multaggr.vars[v], branchpriority) );
11729 }
11730 break;
11731
11733 assert(var->negatedvar != NULL);
11735 assert(var->negatedvar->negatedvar == var);
11736 SCIP_CALL( SCIPvarChgBranchPriority(var->negatedvar, branchpriority) );
11737 break;
11738
11739 default:
11740 SCIPerrorMessage("unknown variable status\n");
11741 SCIPABORT();
11742 return SCIP_ERROR; /*lint !e527*/
11743 }
11744
11745 return SCIP_OKAY;
11746}
11747
11748/** actually changes the branch direction of the variable and of all parent variables */
11749static
11751 SCIP_VAR* var, /**< problem variable */
11752 SCIP_BRANCHDIR branchdirection /**< preferred branch direction of the variable (downwards, upwards, auto) */
11753 )
11754{
11755 SCIP_VAR* parentvar;
11756 int i;
11757
11758 assert(var != NULL);
11759
11760 SCIPdebugMessage("process changing branch direction of <%s> from %u to %d\n",
11761 var->name, var->branchdirection, branchdirection);
11762
11763 if( branchdirection == (SCIP_BRANCHDIR)var->branchdirection )
11764 return SCIP_OKAY;
11765
11766 /* change the branch direction */
11767 var->branchdirection = branchdirection; /*lint !e641*/
11768
11769 /* process parent variables */
11770 for( i = 0; i < var->nparentvars; ++i )
11771 {
11772 parentvar = var->parentvars[i];
11773 assert(parentvar != NULL);
11774
11775 switch( SCIPvarGetStatus(parentvar) )
11776 {
11778 /* do not change directions across the border between transformed and original problem */
11779 break;
11780
11785 SCIPerrorMessage("column, loose, fixed or multi-aggregated variable cannot be the parent of a variable\n");
11786 SCIPABORT();
11787 return SCIP_INVALIDDATA; /*lint !e527*/
11788
11790 if( parentvar->data.aggregate.scalar > 0.0 )
11791 {
11792 SCIP_CALL( varProcessChgBranchDirection(parentvar, branchdirection) );
11793 }
11794 else
11795 {
11796 SCIP_CALL( varProcessChgBranchDirection(parentvar, SCIPbranchdirOpposite(branchdirection)) );
11797 }
11798 break;
11799
11801 SCIP_CALL( varProcessChgBranchDirection(parentvar, SCIPbranchdirOpposite(branchdirection)) );
11802 break;
11803
11804 default:
11805 SCIPerrorMessage("unknown variable status\n");
11806 SCIPABORT();
11807 return SCIP_ERROR; /*lint !e527*/
11808 }
11809 }
11810
11811 return SCIP_OKAY;
11812}
11813
11814/** sets the branch direction of the variable; variables with higher branch direction are always preferred to variables
11815 * with lower direction in selection of branching variable
11816 */
11818 SCIP_VAR* var, /**< problem variable */
11819 SCIP_BRANCHDIR branchdirection /**< preferred branch direction of the variable (downwards, upwards, auto) */
11820 )
11821{
11822 int v;
11823
11824 assert(var != NULL);
11825
11826 SCIPdebugMessage("changing branch direction of <%s> from %u to %d\n", var->name, var->branchdirection, branchdirection);
11827
11828 if( (SCIP_BRANCHDIR)var->branchdirection == branchdirection )
11829 return SCIP_OKAY;
11830
11831 /* change directions of attached variables */
11832 switch( SCIPvarGetStatus(var) )
11833 {
11835 if( var->data.original.transvar != NULL )
11836 {
11837 SCIP_CALL( SCIPvarChgBranchDirection(var->data.original.transvar, branchdirection) );
11838 }
11839 else
11840 var->branchdirection = branchdirection; /*lint !e641*/
11841 break;
11842
11846 SCIP_CALL( varProcessChgBranchDirection(var, branchdirection) );
11847 break;
11848
11850 assert(!var->donotaggr);
11851 assert(var->data.aggregate.var != NULL);
11852 if( var->data.aggregate.scalar > 0.0 )
11853 {
11854 SCIP_CALL( SCIPvarChgBranchDirection(var->data.aggregate.var, branchdirection) );
11855 }
11856 else
11857 {
11859 }
11860 break;
11861
11863 assert(!var->donotmultaggr);
11864 for( v = 0; v < var->data.multaggr.nvars; ++v )
11865 {
11866 /* only update branching direction of aggregation variables, if they don't have a preferred direction yet */
11867 assert(var->data.multaggr.vars[v] != NULL);
11869 {
11870 if( var->data.multaggr.scalars[v] > 0.0 )
11871 {
11872 SCIP_CALL( SCIPvarChgBranchDirection(var->data.multaggr.vars[v], branchdirection) );
11873 }
11874 else
11875 {
11877 }
11878 }
11879 }
11880 break;
11881
11883 assert(var->negatedvar != NULL);
11885 assert(var->negatedvar->negatedvar == var);
11887 break;
11888
11889 default:
11890 SCIPerrorMessage("unknown variable status\n");
11891 SCIPABORT();
11892 return SCIP_ERROR; /*lint !e527*/
11893 }
11894
11895 return SCIP_OKAY;
11896}
11897
11898/** compares the index of two variables, only active, fixed or negated variables are allowed, if a variable
11899 * is negated then the index of the corresponding active variable is taken, returns -1 if first is
11900 * smaller than, and +1 if first is greater than second variable index; returns 0 if both indices
11901 * are equal, which means both variables are equal
11902 */
11904 SCIP_VAR* var1, /**< first problem variable */
11905 SCIP_VAR* var2 /**< second problem variable */
11906 )
11907{
11908 assert(var1 != NULL);
11909 assert(var2 != NULL);
11912
11914 var1 = SCIPvarGetNegatedVar(var1);
11916 var2 = SCIPvarGetNegatedVar(var2);
11917
11918 assert(var1 != NULL);
11919 assert(var2 != NULL);
11920
11921 if( SCIPvarGetIndex(var1) < SCIPvarGetIndex(var2) )
11922 return -1;
11923 else if( SCIPvarGetIndex(var1) > SCIPvarGetIndex(var2) )
11924 return +1;
11925
11926 assert(var1 == var2);
11927 return 0;
11928}
11929
11930/** comparison method for sorting active and negated variables by non-decreasing index, active and negated
11931 * variables are handled as the same variables
11932 */
11933SCIP_DECL_SORTPTRCOMP(SCIPvarCompActiveAndNegated)
11934{
11935 return SCIPvarCompareActiveAndNegated((SCIP_VAR*)elem1, (SCIP_VAR*)elem2);
11936}
11937
11938/** compares the index of two variables, returns -1 if first is smaller than, and +1 if first is greater than second
11939 * variable index; returns 0 if both indices are equal, which means both variables are equal
11940 */
11942 SCIP_VAR* var1, /**< first problem variable */
11943 SCIP_VAR* var2 /**< second problem variable */
11944 )
11945{
11946 assert(var1 != NULL);
11947 assert(var2 != NULL);
11948
11949 if( var1->index < var2->index )
11950 return -1;
11951 else if( var1->index > var2->index )
11952 return +1;
11953 else
11954 {
11955 assert(var1 == var2);
11956 return 0;
11957 }
11958}
11959
11960/** comparison method for sorting variables by non-decreasing index */
11962{
11963 return SCIPvarCompare((SCIP_VAR*)elem1, (SCIP_VAR*)elem2);
11964}
11965
11966/** comparison method for sorting variables by non-decreasing objective coefficient */
11968{
11969 SCIP_Real obj1;
11970 SCIP_Real obj2;
11971
11972 obj1 = SCIPvarGetObj((SCIP_VAR*)elem1);
11973 obj2 = SCIPvarGetObj((SCIP_VAR*)elem2);
11974
11975 if( obj1 < obj2 )
11976 return -1;
11977 else if( obj1 > obj2 )
11978 return +1;
11979 else
11980 return 0;
11981}
11982
11983/** hash key retrieval function for variables */
11984SCIP_DECL_HASHGETKEY(SCIPvarGetHashkey)
11985{ /*lint --e{715}*/
11986 return elem;
11987}
11988
11989/** returns TRUE iff the indices of both variables are equal */
11990SCIP_DECL_HASHKEYEQ(SCIPvarIsHashkeyEq)
11991{ /*lint --e{715}*/
11992 if( key1 == key2 )
11993 return TRUE;
11994 return FALSE;
11995}
11996
11997/** returns the hash value of the key */
11998SCIP_DECL_HASHKEYVAL(SCIPvarGetHashkeyVal)
11999{ /*lint --e{715}*/
12000 assert( SCIPvarGetIndex((SCIP_VAR*) key) >= 0 );
12001 return (unsigned int) SCIPvarGetIndex((SCIP_VAR*) key);
12002}
12003
12004/** return for given variables all their active counterparts; all active variables will be pairwise different */
12006 SCIP_SET* set, /**< global SCIP settings */
12007 SCIP_VAR** vars, /**< variable array with given variables and as output all active
12008 * variables, if enough slots exist
12009 */
12010 int* nvars, /**< number of given variables, and as output number of active variables,
12011 * if enough slots exist
12012 */
12013 int varssize, /**< available slots in vars array */
12014 int* requiredsize /**< pointer to store the required array size for the active variables */
12015 )
12016{
12017 SCIP_VAR** activevars;
12018 int nactivevars;
12019 int activevarssize;
12020
12021 SCIP_VAR* var;
12022 int v;
12023
12024 SCIP_VAR** tmpvars;
12025 SCIP_VAR** multvars;
12026 int tmpvarssize;
12027 int ntmpvars;
12028 int noldtmpvars;
12029 int nmultvars;
12030
12031 assert(set != NULL);
12032 assert(nvars != NULL);
12033 assert(vars != NULL || *nvars == 0);
12034 assert(varssize >= *nvars);
12035 assert(requiredsize != NULL);
12036
12037 *requiredsize = 0;
12038
12039 if( *nvars == 0 )
12040 return SCIP_OKAY;
12041
12042 nactivevars = 0;
12043 activevarssize = *nvars;
12044 ntmpvars = *nvars;
12045 tmpvarssize = *nvars;
12046
12047 /* temporary memory */
12048 SCIP_CALL( SCIPsetAllocBufferArray(set, &activevars, activevarssize) );
12049 /* coverity[copy_paste_error] */
12050 SCIP_CALL( SCIPsetDuplicateBufferArray(set, &tmpvars, vars, ntmpvars) );
12051
12052 noldtmpvars = ntmpvars;
12053
12054 /* sort all variables to combine equal variables easily */
12055 SCIPsortPtr((void**)tmpvars, SCIPvarComp, ntmpvars);
12056 for( v = ntmpvars - 1; v > 0; --v )
12057 {
12058 /* combine same variables */
12059 if( SCIPvarCompare(tmpvars[v], tmpvars[v - 1]) == 0 )
12060 {
12061 --ntmpvars;
12062 tmpvars[v] = tmpvars[ntmpvars];
12063 }
12064 }
12065 /* sort all variables again to combine equal variables later on */
12066 if( noldtmpvars > ntmpvars )
12067 SCIPsortPtr((void**)tmpvars, SCIPvarComp, ntmpvars);
12068
12069 /* collect for each variable the representation in active variables */
12070 while( ntmpvars >= 1 )
12071 {
12072 --ntmpvars;
12073 var = tmpvars[ntmpvars];
12074 assert( var != NULL );
12075
12076 switch( SCIPvarGetStatus(var) )
12077 {
12079 if( var->data.original.transvar == NULL )
12080 {
12081 SCIPerrorMessage("original variable has no transformed variable attached\n");
12082 SCIPABORT();
12083 return SCIP_INVALIDDATA; /*lint !e527*/
12084 }
12085 tmpvars[ntmpvars] = var->data.original.transvar;
12086 ++ntmpvars;
12087 break;
12088
12090 tmpvars[ntmpvars] = var->data.aggregate.var;
12091 ++ntmpvars;
12092 break;
12093
12095 tmpvars[ntmpvars] = var->negatedvar;
12096 ++ntmpvars;
12097 break;
12098
12101 /* check for space in temporary memory */
12102 if( nactivevars >= activevarssize )
12103 {
12104 activevarssize *= 2;
12105 SCIP_CALL( SCIPsetReallocBufferArray(set, &activevars, activevarssize) );
12106 assert(nactivevars < activevarssize);
12107 }
12108 activevars[nactivevars] = var;
12109 nactivevars++;
12110 break;
12111
12113 /* x = a_1*y_1 + ... + a_n*y_n + c */
12114 nmultvars = var->data.multaggr.nvars;
12115 multvars = var->data.multaggr.vars;
12116
12117 /* check for space in temporary memory */
12118 if( nmultvars + ntmpvars > tmpvarssize )
12119 {
12120 while( nmultvars + ntmpvars > tmpvarssize )
12121 tmpvarssize *= 2;
12122 SCIP_CALL( SCIPsetReallocBufferArray(set, &tmpvars, tmpvarssize) );
12123 assert(nmultvars + ntmpvars <= tmpvarssize);
12124 }
12125
12126 /* copy all multi-aggregation variables into our working array */
12127 BMScopyMemoryArray(&tmpvars[ntmpvars], multvars, nmultvars); /*lint !e866*/
12128
12129 /* get active, fixed or multi-aggregated corresponding variables for all new ones */
12130 SCIPvarsGetProbvar(&tmpvars[ntmpvars], nmultvars);
12131
12132 ntmpvars += nmultvars;
12133 noldtmpvars = ntmpvars;
12134
12135 /* sort all variables to combine equal variables easily */
12136 SCIPsortPtr((void**)tmpvars, SCIPvarComp, ntmpvars);
12137 for( v = ntmpvars - 1; v > 0; --v )
12138 {
12139 /* combine same variables */
12140 if( SCIPvarCompare(tmpvars[v], tmpvars[v - 1]) == 0 )
12141 {
12142 --ntmpvars;
12143 tmpvars[v] = tmpvars[ntmpvars];
12144 }
12145 }
12146 /* sort all variables again to combine equal variables later on */
12147 if( noldtmpvars > ntmpvars )
12148 SCIPsortPtr((void**)tmpvars, SCIPvarComp, ntmpvars);
12149
12150 break;
12151
12153 /* no need for memorizing fixed variables */
12154 break;
12155
12156 default:
12157 SCIPerrorMessage("unknown variable status\n");
12158 SCIPABORT();
12159 return SCIP_INVALIDDATA; /*lint !e527*/
12160 }
12161 }
12162
12163 /* sort variable array by variable index */
12164 SCIPsortPtr((void**)activevars, SCIPvarComp, nactivevars);
12165
12166 /* eliminate duplicates and count required size */
12167 v = nactivevars - 1;
12168 while( v > 0 )
12169 {
12170 /* combine both variable since they are the same */
12171 if( SCIPvarCompare(activevars[v - 1], activevars[v]) == 0 )
12172 {
12173 --nactivevars;
12174 activevars[v] = activevars[nactivevars];
12175 }
12176 --v;
12177 }
12178 *requiredsize = nactivevars;
12179
12180 if( varssize >= *requiredsize )
12181 {
12182 assert(vars != NULL);
12183
12184 *nvars = *requiredsize;
12185 BMScopyMemoryArray(vars, activevars, nactivevars);
12186 }
12187
12188 SCIPsetFreeBufferArray(set, &tmpvars);
12189 SCIPsetFreeBufferArray(set, &activevars);
12190
12191 return SCIP_OKAY;
12192}
12193
12194/** gets corresponding active, fixed, or multi-aggregated problem variables of given variables,
12195 * @note the content of the given array will/might change
12196 */
12198 SCIP_VAR** vars, /**< array of problem variables */
12199 int nvars /**< number of variables */
12200 )
12201{
12202 int v;
12203
12204 assert(vars != NULL || nvars == 0);
12205
12206 for( v = nvars - 1; v >= 0; --v )
12207 {
12208 assert(vars != NULL);
12209 assert(vars[v] != NULL);
12210
12211 vars[v] = SCIPvarGetProbvar(vars[v]);
12212 assert(vars[v] != NULL);
12213 }
12214}
12215
12216/** gets corresponding active, fixed, or multi-aggregated problem variable of a variable */
12218 SCIP_VAR* var /**< problem variable */
12219 )
12220{
12221 SCIP_VAR* retvar;
12222
12223 assert(var != NULL);
12224
12225 retvar = var;
12226
12227 SCIPdebugMessage("get problem variable of <%s>\n", var->name);
12228
12229 while( TRUE ) /*lint !e716 */
12230 {
12231 assert(retvar != NULL);
12232
12233 switch( SCIPvarGetStatus(retvar) )
12234 {
12236 if( retvar->data.original.transvar == NULL )
12237 {
12238 SCIPerrorMessage("original variable has no transformed variable attached\n");
12239 SCIPABORT();
12240 return NULL; /*lint !e527 */
12241 }
12242 retvar = retvar->data.original.transvar;
12243 break;
12244
12248 return retvar;
12249
12251 /* handle multi-aggregated variables depending on one variable only (possibly caused by SCIPvarFlattenAggregationGraph()) */
12252 if ( retvar->data.multaggr.nvars == 1 )
12253 retvar = retvar->data.multaggr.vars[0];
12254 else
12255 return retvar;
12256 break;
12257
12259 retvar = retvar->data.aggregate.var;
12260 break;
12261
12263 retvar = retvar->negatedvar;
12264 break;
12265
12266 default:
12267 SCIPerrorMessage("unknown variable status\n");
12268 SCIPABORT();
12269 return NULL; /*lint !e527*/
12270 }
12271 }
12272}
12273
12274/** gets corresponding active, fixed, or multi-aggregated problem variables of binary variables and updates the given
12275 * negation status of each variable
12276 */
12278 SCIP_VAR*** vars, /**< pointer to binary problem variables */
12279 SCIP_Bool** negatedarr, /**< pointer to corresponding array to update the negation status */
12280 int nvars /**< number of variables and values in vars and negated array */
12281 )
12282{
12283 SCIP_VAR** var;
12284 SCIP_Bool* negated;
12285 int v;
12286
12287 assert(vars != NULL);
12288 assert(*vars != NULL || nvars == 0);
12289 assert(negatedarr != NULL);
12290 assert(*negatedarr != NULL || nvars == 0);
12291
12292 for( v = nvars - 1; v >= 0; --v )
12293 {
12294 var = &((*vars)[v]);
12295 negated = &((*negatedarr)[v]);
12296
12297 /* get problem variable */
12298 SCIP_CALL( SCIPvarGetProbvarBinary(var, negated) );
12299 }
12300
12301 return SCIP_OKAY;
12302}
12303
12304
12305/** gets corresponding active, fixed, or multi-aggregated problem variable of a binary variable and updates the given
12306 * negation status (this means you have to assign a value to SCIP_Bool negated before calling this method, usually
12307 * FALSE is used)
12308 */
12310 SCIP_VAR** var, /**< pointer to binary problem variable */
12311 SCIP_Bool* negated /**< pointer to update the negation status */
12312 )
12313{
12315#ifndef NDEBUG
12316 SCIP_Real constant = 0.0;
12317 SCIP_Bool orignegated;
12318#endif
12319
12320 assert(var != NULL);
12321 assert(*var != NULL);
12322 assert(negated != NULL);
12323 assert(SCIPvarIsBinary(*var));
12324
12325#ifndef NDEBUG
12326 orignegated = *negated;
12327#endif
12328
12329 while( !active && *var != NULL )
12330 {
12331 switch( SCIPvarGetStatus(*var) )
12332 {
12334 if( (*var)->data.original.transvar == NULL )
12335 return SCIP_OKAY;
12336 *var = (*var)->data.original.transvar;
12337 break;
12338
12342 active = TRUE;
12343 break;
12344
12346 /* handle multi-aggregated variables depending on one variable only (possibly caused by SCIPvarFlattenAggregationGraph()) */
12347 if ( (*var)->data.multaggr.nvars == 1 )
12348 {
12349 assert( (*var)->data.multaggr.vars != NULL );
12350 assert( (*var)->data.multaggr.scalars != NULL );
12351 assert( SCIPvarIsBinary((*var)->data.multaggr.vars[0]) );
12352 assert(!EPSZ((*var)->data.multaggr.scalars[0], 1e-06));
12353
12354 /* if not all variables were fully propagated, it might happen that a variable is multi-aggregated to
12355 * another variable which needs to be fixed
12356 *
12357 * e.g. x = y - 1 => (x = 0 && y = 1)
12358 * e.g. x = y + 1 => (x = 1 && y = 0)
12359 *
12360 * is this special case we need to return the muti-aggregation
12361 */
12362 if( EPSEQ((*var)->data.multaggr.constant, -1.0, 1e-06) || (EPSEQ((*var)->data.multaggr.constant, 1.0, 1e-06) && EPSEQ((*var)->data.multaggr.scalars[0], 1.0, 1e-06)) )
12363 {
12364 assert(EPSEQ((*var)->data.multaggr.scalars[0], 1.0, 1e-06));
12365 }
12366 else
12367 {
12368 /* @note due to fixations, a multi-aggregation can have a constant of zero and a negative scalar or even
12369 * a scalar in absolute value unequal to one, in this case this aggregation variable needs to be
12370 * fixed to zero, but this should be done by another enforcement; so not depending on the scalar,
12371 * we will return the aggregated variable;
12372 */
12373 if( !EPSEQ(REALABS((*var)->data.multaggr.scalars[0]), 1.0, 1e-06) )
12374 {
12375 active = TRUE;
12376 break;
12377 }
12378
12379 /* @note it may also happen that the constant is larger than 1 or smaller than 0, in that case the
12380 * aggregation variable needs to be fixed to one, but this should be done by another enforcement;
12381 * so if this is the case, we will return the aggregated variable
12382 */
12383 assert(EPSZ((*var)->data.multaggr.constant, 1e-06) || EPSEQ((*var)->data.multaggr.constant, 1.0, 1e-06)
12384 || EPSZ((*var)->data.multaggr.constant + (*var)->data.multaggr.scalars[0], 1e-06)
12385 || EPSEQ((*var)->data.multaggr.constant + (*var)->data.multaggr.scalars[0], 1.0, 1e-06));
12386
12387 if( !EPSZ((*var)->data.multaggr.constant, 1e-06) && !EPSEQ((*var)->data.multaggr.constant, 1.0, 1e-06) )
12388 {
12389 active = TRUE;
12390 break;
12391 }
12392
12393 assert(EPSEQ((*var)->data.multaggr.scalars[0], 1.0, 1e-06) || EPSEQ((*var)->data.multaggr.scalars[0], -1.0, 1e-06));
12394
12395 if( EPSZ((*var)->data.multaggr.constant, 1e-06) )
12396 {
12397 /* if the scalar is negative, either the aggregation variable is already fixed to zero or has at
12398 * least one uplock (that hopefully will enforce this fixation to zero); can it happen that this
12399 * variable itself is multi-aggregated again?
12400 */
12401 assert(EPSEQ((*var)->data.multaggr.scalars[0], -1.0, 1e-06) ?
12402 ((SCIPvarGetUbGlobal((*var)->data.multaggr.vars[0]) < 0.5) ||
12403 SCIPvarGetNLocksUpType((*var)->data.multaggr.vars[0], SCIP_LOCKTYPE_MODEL) > 0) : TRUE);
12404 }
12405 else
12406 {
12407 assert(EPSEQ((*var)->data.multaggr.scalars[0], -1.0, 1e-06));
12408#ifndef NDEBUG
12409 constant += (*negated) != orignegated ? -1.0 : 1.0;
12410#endif
12411
12412 *negated = !(*negated);
12413 }
12414 *var = (*var)->data.multaggr.vars[0];
12415 break;
12416 }
12417 }
12418 active = TRUE; /*lint !e838*/
12419 break;
12420
12421 case SCIP_VARSTATUS_AGGREGATED: /* x = a'*x' + c' => a*x + c == (a*a')*x' + (a*c' + c) */
12422 assert((*var)->data.aggregate.var != NULL);
12423 assert(EPSEQ((*var)->data.aggregate.scalar, 1.0, 1e-06) || EPSEQ((*var)->data.aggregate.scalar, -1.0, 1e-06));
12424 assert(EPSLE((*var)->data.aggregate.var->glbdom.ub - (*var)->data.aggregate.var->glbdom.lb, 1.0, 1e-06));
12425#ifndef NDEBUG
12426 constant += (*negated) != orignegated ? -(*var)->data.aggregate.constant : (*var)->data.aggregate.constant;
12427#endif
12428
12429 *negated = ((*var)->data.aggregate.scalar > 0.0) ? *negated : !(*negated);
12430 *var = (*var)->data.aggregate.var;
12431 break;
12432
12433 case SCIP_VARSTATUS_NEGATED: /* x = - x' + c' => a*x + c == (-a)*x' + (a*c' + c) */
12434 assert((*var)->negatedvar != NULL);
12435#ifndef NDEBUG
12436 constant += (*negated) != orignegated ? -1.0 : 1.0;
12437#endif
12438
12439 *negated = !(*negated);
12440 *var = (*var)->negatedvar;
12441 break;
12442
12443 default:
12444 SCIPerrorMessage("unknown variable status\n");
12445 return SCIP_INVALIDDATA;
12446 }
12447 }
12448 assert(active == (*var != NULL));
12449
12450 if( active )
12451 {
12452 assert(SCIPvarIsBinary(*var));
12453 assert(EPSZ(constant, 1e-06) || EPSEQ(constant, 1.0, 1e-06));
12454 assert(EPSZ(constant, 1e-06) == ((*negated) == orignegated));
12455
12456 return SCIP_OKAY;
12457 }
12458 else
12459 {
12460 SCIPerrorMessage("active variable path leads to NULL pointer\n");
12461 return SCIP_INVALIDDATA;
12462 }
12463}
12464
12465/** transforms given variable, boundtype and bound to the corresponding active, fixed, or multi-aggregated variable
12466 * values
12467 */
12469 SCIP_VAR** var, /**< pointer to problem variable */
12470 SCIP_Real* bound, /**< pointer to bound value to transform */
12471 SCIP_BOUNDTYPE* boundtype /**< pointer to type of bound: lower or upper bound */
12472 )
12473{
12474 assert(var != NULL);
12475 assert(*var != NULL);
12476 assert(bound != NULL);
12477 assert(boundtype != NULL);
12478
12479 SCIPdebugMessage("get probvar bound %g of type %d of variable <%s>\n", *bound, *boundtype, (*var)->name);
12480
12481 switch( SCIPvarGetStatus(*var) )
12482 {
12484 if( (*var)->data.original.transvar == NULL )
12485 {
12486 SCIPerrorMessage("original variable has no transformed variable attached\n");
12487 return SCIP_INVALIDDATA;
12488 }
12489 *var = (*var)->data.original.transvar;
12490 SCIP_CALL( SCIPvarGetProbvarBound(var, bound, boundtype) );
12491 break;
12492
12496 break;
12497
12499 /* handle multi-aggregated variables depending on one variable only (possibly caused by SCIPvarFlattenAggregationGraph()) */
12500 if ( (*var)->data.multaggr.nvars == 1 )
12501 {
12502 assert( (*var)->data.multaggr.vars != NULL );
12503 assert( (*var)->data.multaggr.scalars != NULL );
12504 assert( (*var)->data.multaggr.scalars[0] != 0.0 );
12505
12506 (*bound) /= (*var)->data.multaggr.scalars[0];
12507 (*bound) -= (*var)->data.multaggr.constant/(*var)->data.multaggr.scalars[0];
12508 if ( (*var)->data.multaggr.scalars[0] < 0.0 )
12509 {
12510 if ( *boundtype == SCIP_BOUNDTYPE_LOWER )
12511 *boundtype = SCIP_BOUNDTYPE_UPPER;
12512 else
12513 *boundtype = SCIP_BOUNDTYPE_LOWER;
12514 }
12515 *var = (*var)->data.multaggr.vars[0];
12516 SCIP_CALL( SCIPvarGetProbvarBound(var, bound, boundtype) );
12517 }
12518 break;
12519
12520 case SCIP_VARSTATUS_AGGREGATED: /* x = a*y + c -> y = x/a - c/a */
12521 assert((*var)->data.aggregate.var != NULL);
12522 assert((*var)->data.aggregate.scalar != 0.0);
12523
12524 (*bound) /= (*var)->data.aggregate.scalar;
12525 (*bound) -= (*var)->data.aggregate.constant/(*var)->data.aggregate.scalar;
12526 if( (*var)->data.aggregate.scalar < 0.0 )
12527 {
12528 if( *boundtype == SCIP_BOUNDTYPE_LOWER )
12529 *boundtype = SCIP_BOUNDTYPE_UPPER;
12530 else
12531 *boundtype = SCIP_BOUNDTYPE_LOWER;
12532 }
12533 *var = (*var)->data.aggregate.var;
12534 SCIP_CALL( SCIPvarGetProbvarBound(var, bound, boundtype) );
12535 break;
12536
12537 case SCIP_VARSTATUS_NEGATED: /* x' = offset - x -> x = offset - x' */
12538 assert((*var)->negatedvar != NULL);
12539 assert(SCIPvarGetStatus((*var)->negatedvar) != SCIP_VARSTATUS_NEGATED);
12540 assert((*var)->negatedvar->negatedvar == *var);
12541 (*bound) = (*var)->data.negate.constant - *bound;
12542 if( *boundtype == SCIP_BOUNDTYPE_LOWER )
12543 *boundtype = SCIP_BOUNDTYPE_UPPER;
12544 else
12545 *boundtype = SCIP_BOUNDTYPE_LOWER;
12546 *var = (*var)->negatedvar;
12547 SCIP_CALL( SCIPvarGetProbvarBound(var, bound, boundtype) );
12548 break;
12549
12550 default:
12551 SCIPerrorMessage("unknown variable status\n");
12552 return SCIP_INVALIDDATA;
12553 }
12554
12555 return SCIP_OKAY;
12556}
12557
12558/** transforms given variable and domain hole to the corresponding active, fixed, or multi-aggregated variable
12559 * values
12560 */
12562 SCIP_VAR** var, /**< pointer to problem variable */
12563 SCIP_Real* left, /**< pointer to left bound of open interval in hole to transform */
12564 SCIP_Real* right /**< pointer to right bound of open interval in hole to transform */
12565 )
12566{
12567 assert(var != NULL);
12568 assert(*var != NULL);
12569 assert(left != NULL);
12570 assert(right != NULL);
12571
12572 SCIPdebugMessage("get probvar hole (%g,%g) of variable <%s>\n", *left, *right, (*var)->name);
12573
12574 switch( SCIPvarGetStatus(*var) )
12575 {
12577 if( (*var)->data.original.transvar == NULL )
12578 {
12579 SCIPerrorMessage("original variable has no transformed variable attached\n");
12580 return SCIP_INVALIDDATA;
12581 }
12582 *var = (*var)->data.original.transvar;
12583 SCIP_CALL( SCIPvarGetProbvarHole(var, left, right) );
12584 break;
12585
12590 break;
12591
12592 case SCIP_VARSTATUS_AGGREGATED: /* x = a*y + c -> y = x/a - c/a */
12593 assert((*var)->data.aggregate.var != NULL);
12594 assert((*var)->data.aggregate.scalar != 0.0);
12595
12596 /* scale back */
12597 (*left) /= (*var)->data.aggregate.scalar;
12598 (*right) /= (*var)->data.aggregate.scalar;
12599
12600 /* shift back */
12601 (*left) -= (*var)->data.aggregate.constant/(*var)->data.aggregate.scalar;
12602 (*right) -= (*var)->data.aggregate.constant/(*var)->data.aggregate.scalar;
12603
12604 *var = (*var)->data.aggregate.var;
12605
12606 /* check if the interval bounds have to swapped */
12607 if( (*var)->data.aggregate.scalar < 0.0 )
12608 {
12609 SCIP_CALL( SCIPvarGetProbvarHole(var, right, left) );
12610 }
12611 else
12612 {
12613 SCIP_CALL( SCIPvarGetProbvarHole(var, left, right) );
12614 }
12615 break;
12616
12617 case SCIP_VARSTATUS_NEGATED: /* x' = offset - x -> x = offset - x' */
12618 assert((*var)->negatedvar != NULL);
12619 assert(SCIPvarGetStatus((*var)->negatedvar) != SCIP_VARSTATUS_NEGATED);
12620 assert((*var)->negatedvar->negatedvar == *var);
12621
12622 /* shift and scale back */
12623 (*left) = (*var)->data.negate.constant - (*left);
12624 (*right) = (*var)->data.negate.constant - (*right);
12625
12626 *var = (*var)->negatedvar;
12627
12628 /* through the negated variable the left and right interval bound have to swapped */
12629 SCIP_CALL( SCIPvarGetProbvarHole(var, right, left) );
12630 break;
12631
12632 default:
12633 SCIPerrorMessage("unknown variable status\n");
12634 return SCIP_INVALIDDATA;
12635 }
12636
12637 return SCIP_OKAY;
12638}
12639
12640/** transforms given variable, scalar and constant to the corresponding active, fixed, or
12641 * multi-aggregated variable, scalar and constant; if the variable resolves to a fixed variable,
12642 * "scalar" will be 0.0 and the value of the sum will be stored in "constant"; a multi-aggregation
12643 * with only one active variable (this can happen due to fixings after the multi-aggregation),
12644 * is treated like an aggregation; if the multi-aggregation constant is infinite, "scalar" will be 0.0
12645 */
12647 SCIP_VAR** var, /**< pointer to problem variable x in sum a*x + c */
12648 SCIP_SET* set, /**< global SCIP settings */
12649 SCIP_Real* scalar, /**< pointer to scalar a in sum a*x + c */
12650 SCIP_Real* constant /**< pointer to constant c in sum a*x + c */
12651 )
12652{
12653 assert(var != NULL);
12654 assert(scalar != NULL);
12655 assert(constant != NULL);
12656
12657 while( *var != NULL )
12658 {
12659 switch( SCIPvarGetStatus(*var) )
12660 {
12662 if( (*var)->data.original.transvar == NULL )
12663 {
12664 SCIPerrorMessage("original variable has no transformed variable attached\n");
12665 return SCIP_INVALIDDATA;
12666 }
12667 *var = (*var)->data.original.transvar;
12668 break;
12669
12672 return SCIP_OKAY;
12673
12674 case SCIP_VARSTATUS_FIXED: /* x = c' => a*x + c == (a*c' + c) */
12675 if( !SCIPsetIsInfinity(set, (*constant)) && !SCIPsetIsInfinity(set, -(*constant)) )
12676 {
12677 if( SCIPsetIsInfinity(set, (*var)->glbdom.lb) || SCIPsetIsInfinity(set, -((*var)->glbdom.lb)) )
12678 {
12679 assert(*scalar != 0.0);
12680 if( (*scalar) * (*var)->glbdom.lb > 0.0 )
12681 (*constant) = SCIPsetInfinity(set);
12682 else
12683 (*constant) = -SCIPsetInfinity(set);
12684 }
12685 else
12686 (*constant) += *scalar * (*var)->glbdom.lb;
12687 }
12688#ifndef NDEBUG
12689 else
12690 {
12691 assert(!SCIPsetIsInfinity(set, (*constant)) || !((*scalar) * (*var)->glbdom.lb < 0.0 &&
12692 (SCIPsetIsInfinity(set, (*var)->glbdom.lb) || SCIPsetIsInfinity(set, -((*var)->glbdom.lb)))));
12693 assert(!SCIPsetIsInfinity(set, -(*constant)) || !((*scalar) * (*var)->glbdom.lb > 0.0 &&
12694 (SCIPsetIsInfinity(set, (*var)->glbdom.lb) || SCIPsetIsInfinity(set, -((*var)->glbdom.lb)))));
12695 }
12696#endif
12697 *scalar = 0.0;
12698 return SCIP_OKAY;
12699
12701 /* handle multi-aggregated variables depending on one variable only (possibly caused by SCIPvarFlattenAggregationGraph()) */
12702 if ( (*var)->data.multaggr.nvars == 1 )
12703 {
12704 assert((*var)->data.multaggr.vars != NULL);
12705 assert((*var)->data.multaggr.scalars != NULL);
12706 assert((*var)->data.multaggr.vars[0] != NULL);
12707 if( !SCIPsetIsInfinity(set, (*constant)) && !SCIPsetIsInfinity(set, -(*constant)) )
12708 {
12709 /* the multi-aggregation constant can be infinite, if one of the multi-aggregation variables
12710 * was fixed to +/-infinity; ensure that the constant is set to +/-infinity, too, and the scalar
12711 * is set to 0.0, because the multi-aggregated variable can be seen as fixed, too
12712 */
12713 if( SCIPsetIsInfinity(set, (*var)->data.multaggr.constant)
12714 || SCIPsetIsInfinity(set, -((*var)->data.multaggr.constant)) )
12715 {
12716 if( (*scalar) * (*var)->data.multaggr.constant > 0 )
12717 {
12718 assert(!SCIPsetIsInfinity(set, -(*constant)));
12719 (*constant) = SCIPsetInfinity(set);
12720 }
12721 else
12722 {
12723 assert(!SCIPsetIsInfinity(set, *constant));
12724 (*constant) = -SCIPsetInfinity(set);
12725 }
12726 (*scalar) = 0.0;
12727 }
12728 else
12729 (*constant) += *scalar * (*var)->data.multaggr.constant;
12730 }
12731 (*scalar) *= (*var)->data.multaggr.scalars[0];
12732 *var = (*var)->data.multaggr.vars[0];
12733 break;
12734 }
12735 return SCIP_OKAY;
12736
12737 case SCIP_VARSTATUS_AGGREGATED: /* x = a'*x' + c' => a*x + c == (a*a')*x' + (a*c' + c) */
12738 assert((*var)->data.aggregate.var != NULL);
12739 assert(!SCIPsetIsInfinity(set, (*var)->data.aggregate.constant)
12740 && !SCIPsetIsInfinity(set, (*var)->data.aggregate.constant));
12741 if( !SCIPsetIsInfinity(set, (*constant)) && !SCIPsetIsInfinity(set, -(*constant)) )
12742 (*constant) += *scalar * (*var)->data.aggregate.constant;
12743 (*scalar) *= (*var)->data.aggregate.scalar;
12744 *var = (*var)->data.aggregate.var;
12745 break;
12746
12747 case SCIP_VARSTATUS_NEGATED: /* x = - x' + c' => a*x + c == (-a)*x' + (a*c' + c) */
12748 assert((*var)->negatedvar != NULL);
12749 assert(SCIPvarGetStatus((*var)->negatedvar) != SCIP_VARSTATUS_NEGATED);
12750 assert((*var)->negatedvar->negatedvar == *var);
12751 assert(!SCIPsetIsInfinity(set, (*var)->data.negate.constant)
12752 && !SCIPsetIsInfinity(set, (*var)->data.negate.constant));
12753 if( !SCIPsetIsInfinity(set, (*constant)) && !SCIPsetIsInfinity(set, -(*constant)) )
12754 (*constant) += *scalar * (*var)->data.negate.constant;
12755 (*scalar) *= -1.0;
12756 *var = (*var)->negatedvar;
12757 break;
12758
12759 default:
12760 SCIPerrorMessage("unknown variable status\n");
12761 SCIPABORT();
12762 return SCIP_INVALIDDATA; /*lint !e527*/
12763 }
12764 }
12765 *scalar = 0.0;
12766
12767 return SCIP_OKAY;
12768}
12769
12770/** retransforms given variable, scalar and constant to the corresponding original variable, scalar
12771 * and constant, if possible; if the retransformation is impossible, NULL is returned as variable
12772 */
12774 SCIP_VAR** var, /**< pointer to problem variable x in sum a*x + c */
12775 SCIP_Real* scalar, /**< pointer to scalar a in sum a*x + c */
12776 SCIP_Real* constant /**< pointer to constant c in sum a*x + c */
12777 )
12778{
12779 SCIP_VAR* parentvar;
12780
12781 assert(var != NULL);
12782 assert(*var != NULL);
12783 assert(scalar != NULL);
12784 assert(constant != NULL);
12785
12786 while( !SCIPvarIsOriginal(*var) )
12787 {
12788 /* if the variable has no parent variables, it was generated during solving and has no corresponding original
12789 * var
12790 */
12791 if( (*var)->nparentvars == 0 )
12792 {
12793 /* negated variables do not need to have a parent variables, and negated variables can exist in original
12794 * space
12795 */
12797 ((*var)->negatedvar->nparentvars == 0 || (*var)->negatedvar->parentvars[0] != *var) )
12798 {
12799 *scalar *= -1.0;
12800 *constant -= (*var)->data.negate.constant * (*scalar);
12801 *var = (*var)->negatedvar;
12802
12803 continue;
12804 }
12805 /* if the variables does not have any parent the variables was created during solving and has no original
12806 * counterpart
12807 */
12808 else
12809 {
12810 *var = NULL;
12811
12812 return SCIP_OKAY;
12813 }
12814 }
12815
12816 /* follow the link to the first parent variable */
12817 parentvar = (*var)->parentvars[0];
12818 assert(parentvar != NULL);
12819
12820 switch( SCIPvarGetStatus(parentvar) )
12821 {
12823 break;
12824
12829 SCIPerrorMessage("column, loose, fixed or multi-aggregated variable cannot be the parent of a variable\n");
12830 return SCIP_INVALIDDATA;
12831
12832 case SCIP_VARSTATUS_AGGREGATED: /* x = a*y + b -> y = (x-b)/a, s*y + c = (s/a)*x + c-b*s/a */
12833 assert(parentvar->data.aggregate.var == *var);
12834 assert(parentvar->data.aggregate.scalar != 0.0);
12835 *scalar /= parentvar->data.aggregate.scalar;
12836 *constant -= parentvar->data.aggregate.constant * (*scalar);
12837 break;
12838
12839 case SCIP_VARSTATUS_NEGATED: /* x = b - y -> y = b - x, s*y + c = -s*x + c+b*s */
12840 assert(parentvar->negatedvar != NULL);
12841 assert(SCIPvarGetStatus(parentvar->negatedvar) != SCIP_VARSTATUS_NEGATED);
12842 assert(parentvar->negatedvar->negatedvar == parentvar);
12843 *scalar *= -1.0;
12844 *constant -= parentvar->data.negate.constant * (*scalar);
12845 break;
12846
12847 default:
12848 SCIPerrorMessage("unknown variable status\n");
12849 return SCIP_INVALIDDATA;
12850 }
12851
12852 assert( parentvar != NULL );
12853 *var = parentvar;
12854 }
12855
12856 return SCIP_OKAY;
12857}
12858
12859/** returns whether the given variable is the direct counterpart of an original problem variable */
12861 SCIP_VAR* var /**< problem variable */
12862 )
12863{
12864 SCIP_VAR* parentvar;
12865 assert(var != NULL);
12866
12867 if( !SCIPvarIsTransformed(var) || var->nparentvars < 1 )
12868 return FALSE;
12869
12870 assert(var->parentvars != NULL);
12871 parentvar = var->parentvars[0];
12872 assert(parentvar != NULL);
12873
12874 /* we follow the aggregation tree to the root unless an original variable has been found - the first entries in the parentlist are candidates */
12875 while( parentvar->nparentvars >= 1 && SCIPvarGetStatus(parentvar) != SCIP_VARSTATUS_ORIGINAL )
12876 parentvar = parentvar->parentvars[0];
12877 assert( parentvar != NULL );
12878
12879 return ( SCIPvarGetStatus(parentvar) == SCIP_VARSTATUS_ORIGINAL );
12880}
12881
12882/** gets objective value of variable in current SCIP_LP; the value can be different from the objective value stored in
12883 * the variable's own data due to diving, that operate only on the LP without updating the variables
12884 */
12886 SCIP_VAR* var /**< problem variable */
12887 )
12888{
12889 assert(var != NULL);
12890
12891 /* get bounds of attached variables */
12892 switch( SCIPvarGetStatus(var) )
12893 {
12895 assert(var->data.original.transvar != NULL);
12897
12899 assert(var->data.col != NULL);
12900 return SCIPcolGetObj(var->data.col);
12901
12904 return var->obj;
12905
12906 case SCIP_VARSTATUS_AGGREGATED: /* x = a*y + c -> y = (x-c)/a */
12907 assert(var->data.aggregate.var != NULL);
12909
12911 SCIPerrorMessage("cannot get the objective value of a multiple aggregated variable\n");
12912 SCIPABORT();
12913 return 0.0; /*lint !e527*/
12914
12915 case SCIP_VARSTATUS_NEGATED: /* x' = offset - x -> x = offset - x' */
12916 assert(var->negatedvar != NULL);
12918 assert(var->negatedvar->negatedvar == var);
12919 return -SCIPvarGetObjLP(var->negatedvar);
12920
12921 default:
12922 SCIPerrorMessage("unknown variable status\n");
12923 SCIPABORT();
12924 return 0.0; /*lint !e527*/
12925 }
12926}
12927
12928/** gets lower bound of variable in current SCIP_LP; the bound can be different from the bound stored in the variable's own
12929 * data due to diving or conflict analysis, that operate only on the LP without updating the variables
12930 */
12932 SCIP_VAR* var, /**< problem variable */
12933 SCIP_SET* set /**< global SCIP settings */
12934 )
12935{
12936 assert(var != NULL);
12937 assert(set != NULL);
12938 assert(var->scip == set->scip);
12939
12940 /* get bounds of attached variables */
12941 switch( SCIPvarGetStatus(var) )
12942 {
12944 assert(var->data.original.transvar != NULL);
12945 return SCIPvarGetLbLP(var->data.original.transvar, set);
12946
12948 assert(var->data.col != NULL);
12949 return SCIPcolGetLb(var->data.col);
12950
12953 return var->locdom.lb;
12954
12955 case SCIP_VARSTATUS_AGGREGATED: /* x = a*y + c -> y = (x-c)/a */
12956 assert(var->data.aggregate.var != NULL);
12959 {
12960 return -SCIPsetInfinity(set);
12961 }
12962 else if( var->data.aggregate.scalar > 0.0 )
12963 {
12964 /* a > 0 -> get lower bound of y */
12966 }
12967 else if( var->data.aggregate.scalar < 0.0 )
12968 {
12969 /* a < 0 -> get upper bound of y */
12971 }
12972 else
12973 {
12974 SCIPerrorMessage("scalar is zero in aggregation\n");
12975 SCIPABORT();
12976 return SCIP_INVALID; /*lint !e527*/
12977 }
12978
12980 /**@todo get the sides of the corresponding linear constraint */
12981 SCIPerrorMessage("getting the bounds of a multiple aggregated variable is not implemented yet\n");
12982 SCIPABORT();
12983 return SCIP_INVALID; /*lint !e527*/
12984
12985 case SCIP_VARSTATUS_NEGATED: /* x' = offset - x -> x = offset - x' */
12986 assert(var->negatedvar != NULL);
12988 assert(var->negatedvar->negatedvar == var);
12989 return var->data.negate.constant - SCIPvarGetUbLP(var->negatedvar, set);
12990
12991 default:
12992 SCIPerrorMessage("unknown variable status\n");
12993 SCIPABORT();
12994 return SCIP_INVALID; /*lint !e527*/
12995 }
12996}
12997
12998/** gets upper bound of variable in current SCIP_LP; the bound can be different from the bound stored in the variable's own
12999 * data due to diving or conflict analysis, that operate only on the LP without updating the variables
13000 */
13002 SCIP_VAR* var, /**< problem variable */
13003 SCIP_SET* set /**< global SCIP settings */
13004 )
13005{
13006 assert(var != NULL);
13007 assert(set != NULL);
13008 assert(var->scip == set->scip);
13009
13010 /* get bounds of attached variables */
13011 switch( SCIPvarGetStatus(var) )
13012 {
13014 assert(var->data.original.transvar != NULL);
13015 return SCIPvarGetUbLP(var->data.original.transvar, set);
13016
13018 assert(var->data.col != NULL);
13019 return SCIPcolGetUb(var->data.col);
13020
13023 return var->locdom.ub;
13024
13025 case SCIP_VARSTATUS_AGGREGATED: /* x = a*y + c -> y = (x-c)/a */
13026 assert(var->data.aggregate.var != NULL);
13029 {
13030 return SCIPsetInfinity(set);
13031 }
13032 if( var->data.aggregate.scalar > 0.0 )
13033 {
13034 /* a > 0 -> get upper bound of y */
13036 }
13037 else if( var->data.aggregate.scalar < 0.0 )
13038 {
13039 /* a < 0 -> get lower bound of y */
13041 }
13042 else
13043 {
13044 SCIPerrorMessage("scalar is zero in aggregation\n");
13045 SCIPABORT();
13046 return SCIP_INVALID; /*lint !e527*/
13047 }
13048
13050 SCIPerrorMessage("cannot get the bounds of a multi-aggregated variable.\n");
13051 SCIPABORT();
13052 return SCIP_INVALID; /*lint !e527*/
13053
13054 case SCIP_VARSTATUS_NEGATED: /* x' = offset - x -> x = offset - x' */
13055 assert(var->negatedvar != NULL);
13057 assert(var->negatedvar->negatedvar == var);
13058 return var->data.negate.constant - SCIPvarGetLbLP(var->negatedvar, set);
13059
13060 default:
13061 SCIPerrorMessage("unknown variable status\n");
13062 SCIPABORT();
13063 return SCIP_INVALID; /*lint !e527*/
13064 }
13065}
13066
13067/** gets primal LP solution value of variable */
13069 SCIP_VAR* var /**< problem variable */
13070 )
13071{
13072 assert(var != NULL);
13073
13074 switch( SCIPvarGetStatus(var) )
13075 {
13077 if( var->data.original.transvar == NULL )
13078 return SCIP_INVALID;
13080
13082 return SCIPvarGetBestBoundLocal(var);
13083
13085 assert(var->data.col != NULL);
13086 return SCIPcolGetPrimsol(var->data.col);
13087
13089 assert(var->locdom.lb == var->locdom.ub); /*lint !e777*/
13090 return var->locdom.lb;
13091
13093 {
13094 SCIP_Real lpsolval;
13095
13096 assert(!var->donotaggr);
13097 assert(var->data.aggregate.var != NULL);
13098 lpsolval = SCIPvarGetLPSol(var->data.aggregate.var);
13099
13100 /* a correct implementation would need to check the value of var->data.aggregate.var for infinity and return the
13101 * corresponding infinity value instead of performing an arithmetical transformation (compare method
13102 * SCIPvarGetLbLP()); however, we do not want to introduce a SCIP or SCIP_SET pointer to this method, since it is
13103 * (or is called by) a public interface method; instead, we only assert that values are finite
13104 * w.r.t. SCIP_DEFAULT_INFINITY, which seems to be true in our regression tests; note that this may yield false
13105 * positives and negatives if the parameter <numerics/infinity> is modified by the user
13106 */
13107 assert(lpsolval > -SCIP_DEFAULT_INFINITY);
13108 assert(lpsolval < +SCIP_DEFAULT_INFINITY);
13109 return var->data.aggregate.scalar * lpsolval + var->data.aggregate.constant;
13110 }
13112 {
13113 SCIP_Real primsol;
13114 int i;
13115
13116 assert(!var->donotmultaggr);
13117 assert(var->data.multaggr.vars != NULL);
13118 assert(var->data.multaggr.scalars != NULL);
13119 /* Due to method SCIPvarFlattenAggregationGraph(), this assert is no longer correct
13120 * assert(var->data.multaggr.nvars >= 2);
13121 */
13122 primsol = var->data.multaggr.constant;
13123 for( i = 0; i < var->data.multaggr.nvars; ++i )
13124 primsol += var->data.multaggr.scalars[i] * SCIPvarGetLPSol(var->data.multaggr.vars[i]);
13125 return primsol;
13126 }
13127 case SCIP_VARSTATUS_NEGATED: /* x' = offset - x -> x = offset - x' */
13128 assert(var->negatedvar != NULL);
13130 assert(var->negatedvar->negatedvar == var);
13131 return var->data.negate.constant - SCIPvarGetLPSol(var->negatedvar);
13132
13133 default:
13134 SCIPerrorMessage("unknown variable status\n");
13135 SCIPABORT();
13136 return SCIP_INVALID; /*lint !e527*/
13137 }
13138}
13139
13140/** gets primal NLP solution value of variable */
13142 SCIP_VAR* var /**< problem variable */
13143 )
13144{
13145 SCIP_Real solval;
13146 int i;
13147
13148 assert(var != NULL);
13149
13150 /* only values for non fixed variables (LOOSE or COLUMN) are stored; others have to be transformed */
13151 switch( SCIPvarGetStatus(var) )
13152 {
13155
13158 return var->nlpsol;
13159
13161 assert(SCIPvarGetLbGlobal(var) == SCIPvarGetUbGlobal(var)); /*lint !e777*/
13162 assert(SCIPvarGetLbLocal(var) == SCIPvarGetUbLocal(var)); /*lint !e777*/
13163 assert(SCIPvarGetLbGlobal(var) == SCIPvarGetLbLocal(var)); /*lint !e777*/
13164 return SCIPvarGetLbGlobal(var);
13165
13166 case SCIP_VARSTATUS_AGGREGATED: /* x = a*y + c => y = (x-c)/a */
13167 solval = SCIPvarGetNLPSol(var->data.aggregate.var);
13168 return var->data.aggregate.scalar * solval + var->data.aggregate.constant;
13169
13171 solval = var->data.multaggr.constant;
13172 for( i = 0; i < var->data.multaggr.nvars; ++i )
13173 solval += var->data.multaggr.scalars[i] * SCIPvarGetNLPSol(var->data.multaggr.vars[i]);
13174 return solval;
13175
13177 solval = SCIPvarGetNLPSol(var->negatedvar);
13178 return var->data.negate.constant - solval;
13179
13180 default:
13181 SCIPerrorMessage("unknown variable status\n");
13182 SCIPABORT();
13183 return SCIP_INVALID; /*lint !e527*/
13184 }
13185}
13186
13187/** gets pseudo solution value of variable at current node */
13188static
13190 SCIP_VAR* var /**< problem variable */
13191 )
13192{
13193 SCIP_Real pseudosol;
13194 int i;
13195
13196 assert(var != NULL);
13197
13198 switch( SCIPvarGetStatus(var) )
13199 {
13201 if( var->data.original.transvar == NULL )
13202 return SCIP_INVALID;
13204
13207 return SCIPvarGetBestBoundLocal(var);
13208
13210 assert(var->locdom.lb == var->locdom.ub); /*lint !e777*/
13211 return var->locdom.lb;
13212
13214 {
13215 SCIP_Real pseudosolval;
13216 assert(!var->donotaggr);
13217 assert(var->data.aggregate.var != NULL);
13218 /* a correct implementation would need to check the value of var->data.aggregate.var for infinity and return the
13219 * corresponding infinity value instead of performing an arithmetical transformation (compare method
13220 * SCIPvarGetLbLP()); however, we do not want to introduce a SCIP or SCIP_SET pointer to this method, since it is
13221 * (or is called by) a public interface method; instead, we only assert that values are finite
13222 * w.r.t. SCIP_DEFAULT_INFINITY, which seems to be true in our regression tests; note that this may yield false
13223 * positives and negatives if the parameter <numerics/infinity> is modified by the user
13224 */
13225 pseudosolval = SCIPvarGetPseudoSol(var->data.aggregate.var);
13226 assert(pseudosolval > -SCIP_DEFAULT_INFINITY);
13227 assert(pseudosolval < +SCIP_DEFAULT_INFINITY);
13228 return var->data.aggregate.scalar * pseudosolval + var->data.aggregate.constant;
13229 }
13231 assert(!var->donotmultaggr);
13232 assert(var->data.multaggr.vars != NULL);
13233 assert(var->data.multaggr.scalars != NULL);
13234 /* Due to method SCIPvarFlattenAggregationGraph(), this assert is no longer correct
13235 * assert(var->data.multaggr.nvars >= 2);
13236 */
13237 pseudosol = var->data.multaggr.constant;
13238 for( i = 0; i < var->data.multaggr.nvars; ++i )
13239 pseudosol += var->data.multaggr.scalars[i] * SCIPvarGetPseudoSol(var->data.multaggr.vars[i]);
13240 return pseudosol;
13241
13242 case SCIP_VARSTATUS_NEGATED: /* x' = offset - x -> x = offset - x' */
13243 assert(var->negatedvar != NULL);
13245 assert(var->negatedvar->negatedvar == var);
13247
13248 default:
13249 SCIPerrorMessage("unknown variable status\n");
13250 SCIPABORT();
13251 return SCIP_INVALID; /*lint !e527*/
13252 }
13253}
13254
13255/** gets current LP or pseudo solution value of variable */
13257 SCIP_VAR* var, /**< problem variable */
13258 SCIP_Bool getlpval /**< should the LP solution value be returned? */
13259 )
13260{
13261 if( getlpval )
13262 return SCIPvarGetLPSol(var);
13263 else
13264 return SCIPvarGetPseudoSol(var);
13265}
13266
13267/** remembers the current solution as root solution in the problem variables */
13269 SCIP_VAR* var, /**< problem variable */
13270 SCIP_Bool roothaslp /**< is the root solution from LP? */
13271 )
13272{
13273 assert(var != NULL);
13274
13275 var->rootsol = SCIPvarGetSol(var, roothaslp);
13276}
13277
13278/** updates the current solution as best root solution of the given variable if it is better */
13280 SCIP_VAR* var, /**< problem variable */
13281 SCIP_SET* set, /**< global SCIP settings */
13282 SCIP_Real rootsol, /**< root solution value */
13283 SCIP_Real rootredcost, /**< root reduced cost */
13284 SCIP_Real rootlpobjval /**< objective value of the root LP */
13285 )
13286{
13287 assert(var != NULL);
13288 assert(set != NULL);
13289 assert(var->scip == set->scip);
13290
13291 /* if reduced cost are zero nothing to update */
13292 if( SCIPsetIsDualfeasZero(set, rootredcost) )
13293 return;
13294
13295 /* check if we have already a best combination stored */
13297 {
13298 SCIP_Real currcutoffbound;
13299 SCIP_Real cutoffbound;
13301
13302 /* compute the cutoff bound which would improve the corresponding bound with the current stored root solution,
13303 * root reduced cost, and root LP objective value combination
13304 */
13305 if( var->bestrootredcost > 0.0 )
13307 else
13309
13310 currcutoffbound = (bound - var->bestrootsol) * var->bestrootredcost + var->bestrootlpobjval;
13311
13312 /* compute the cutoff bound which would improve the corresponding bound with new root solution, root reduced
13313 * cost, and root LP objective value combination
13314 */
13315 if( rootredcost > 0.0 )
13317 else
13319
13320 cutoffbound = (bound - rootsol) * rootredcost + rootlpobjval;
13321
13322 /* check if an improving root solution, root reduced cost, and root LP objective value is at hand */
13323 if( cutoffbound > currcutoffbound )
13324 {
13325 SCIPsetDebugMsg(set, "-> <%s> update potential cutoff bound <%g> -> <%g>\n",
13326 SCIPvarGetName(var), currcutoffbound, cutoffbound);
13327
13328 var->bestrootsol = rootsol;
13329 var->bestrootredcost = rootredcost;
13330 var->bestrootlpobjval = rootlpobjval;
13331 }
13332 }
13333 else
13334 {
13335 SCIPsetDebugMsg(set, "-> <%s> initialize best root reduced cost information\n", SCIPvarGetName(var));
13336 SCIPsetDebugMsg(set, " -> rootsol <%g>\n", rootsol);
13337 SCIPsetDebugMsg(set, " -> rootredcost <%g>\n", rootredcost);
13338 SCIPsetDebugMsg(set, " -> rootlpobjval <%g>\n", rootlpobjval);
13339
13340 var->bestrootsol = rootsol;
13341 var->bestrootredcost = rootredcost;
13342 var->bestrootlpobjval = rootlpobjval;
13343 }
13344}
13345
13346/** returns the solution of the variable in the last root node's relaxation, if the root relaxation is not yet
13347 * completely solved, zero is returned
13348 */
13350 SCIP_VAR* var /**< problem variable */
13351 )
13352{
13353 SCIP_Real rootsol;
13354 int i;
13355
13356 assert(var != NULL);
13357
13358 switch( SCIPvarGetStatus(var) )
13359 {
13361 if( var->data.original.transvar == NULL )
13362 return 0.0;
13364
13367 return var->rootsol;
13368
13370 assert(var->locdom.lb == var->locdom.ub); /*lint !e777*/
13371 return var->locdom.lb;
13372
13374 assert(!var->donotaggr);
13375 assert(var->data.aggregate.var != NULL);
13376 /* a correct implementation would need to check the value of var->data.aggregate.var for infinity and return the
13377 * corresponding infinity value instead of performing an arithmetical transformation (compare method
13378 * SCIPvarGetLbLP()); however, we do not want to introduce a SCIP or SCIP_SET pointer to this method, since it is
13379 * (or is called by) a public interface method; instead, we only assert that values are finite
13380 * w.r.t. SCIP_DEFAULT_INFINITY, which seems to be true in our regression tests; note that this may yield false
13381 * positives and negatives if the parameter <numerics/infinity> is modified by the user
13382 */
13386
13388 assert(!var->donotmultaggr);
13389 assert(var->data.multaggr.vars != NULL);
13390 assert(var->data.multaggr.scalars != NULL);
13391 /* Due to method SCIPvarFlattenAggregationGraph(), this assert is no longer correct
13392 * assert(var->data.multaggr.nvars >= 2);
13393 */
13394 rootsol = var->data.multaggr.constant;
13395 for( i = 0; i < var->data.multaggr.nvars; ++i )
13396 rootsol += var->data.multaggr.scalars[i] * SCIPvarGetRootSol(var->data.multaggr.vars[i]);
13397 return rootsol;
13398
13399 case SCIP_VARSTATUS_NEGATED: /* x' = offset - x -> x = offset - x' */
13400 assert(var->negatedvar != NULL);
13402 assert(var->negatedvar->negatedvar == var);
13403 return var->data.negate.constant - SCIPvarGetRootSol(var->negatedvar);
13404
13405 default:
13406 SCIPerrorMessage("unknown variable status\n");
13407 SCIPABORT();
13408 return SCIP_INVALID; /*lint !e527*/
13409 }
13410}
13411
13412/** returns for given variable the reduced cost */
13413static
13415 SCIP_VAR* var, /**< problem variable */
13416 SCIP_SET* set, /**< global SCIP settings */
13417 SCIP_Bool varfixing, /**< FALSE if for x == 0, TRUE for x == 1 */
13418 SCIP_STAT* stat, /**< problem statistics */
13419 SCIP_LP* lp /**< current LP data */
13420 )
13421{
13423 {
13424 SCIP_COL* col;
13425 SCIP_Real primsol;
13426 SCIP_BASESTAT basestat;
13427 SCIP_Bool lpissolbasic;
13428
13429 col = SCIPvarGetCol(var);
13430 assert(col != NULL);
13431
13432 basestat = SCIPcolGetBasisStatus(col);
13433 lpissolbasic = SCIPlpIsSolBasic(lp);
13434 primsol = SCIPcolGetPrimsol(col);
13435
13436 if( (lpissolbasic && (basestat == SCIP_BASESTAT_LOWER || basestat == SCIP_BASESTAT_UPPER)) ||
13437 (!lpissolbasic && (SCIPsetIsFeasEQ(set, SCIPvarGetLbLocal(var), primsol) || SCIPsetIsFeasEQ(set, SCIPvarGetUbLocal(var), primsol))) )
13438 {
13439 SCIP_Real redcost = SCIPcolGetRedcost(col, stat, lp);
13440
13441 assert(((!lpissolbasic && SCIPsetIsFeasEQ(set, SCIPvarGetLbLocal(var), primsol)) ||
13442 (lpissolbasic && basestat == SCIP_BASESTAT_LOWER)) ? (!SCIPsetIsDualfeasNegative(set, redcost) ||
13444 assert(((!lpissolbasic && SCIPsetIsFeasEQ(set, SCIPvarGetUbLocal(var), primsol)) ||
13445 (lpissolbasic && basestat == SCIP_BASESTAT_UPPER)) ? (!SCIPsetIsDualfeasPositive(set, redcost) ||
13447
13448 if( (varfixing && ((lpissolbasic && basestat == SCIP_BASESTAT_LOWER) ||
13449 (!lpissolbasic && SCIPsetIsFeasEQ(set, SCIPvarGetLbLocal(var), primsol)))) ||
13450 (!varfixing && ((lpissolbasic && basestat == SCIP_BASESTAT_UPPER) ||
13451 (!lpissolbasic && SCIPsetIsFeasEQ(set, SCIPvarGetUbLocal(var), primsol)))) )
13452 return redcost;
13453 else
13454 return 0.0;
13455 }
13456
13457 return 0.0;
13458 }
13459
13460 return 0.0;
13461}
13462
13463#define MAX_CLIQUELENGTH 50
13464/** returns for the given binary variable the reduced cost which are given by the variable itself and its implication if
13465 * the binary variable is fixed to the given value
13466 */
13468 SCIP_VAR* var, /**< problem variable */
13469 SCIP_SET* set, /**< global SCIP settings */
13470 SCIP_Bool varfixing, /**< FALSE if for x == 0, TRUE for x == 1 */
13471 SCIP_STAT* stat, /**< problem statistics */
13472 SCIP_PROB* prob, /**< transformed problem, or NULL */
13473 SCIP_LP* lp /**< current LP data */
13474 )
13475{
13476 SCIP_Real implredcost;
13477 int ncliques;
13478 int nvars;
13479
13480 assert(SCIPvarIsBinary(var));
13482
13483 /* get reduced cost of given variable */
13484 implredcost = getImplVarRedcost(var, set, varfixing, stat, lp);
13485
13486#ifdef SCIP_MORE_DEBUG
13487 SCIPsetDebugMsg(set, "variable <%s> itself has reduced cost of %g\n", SCIPvarGetName(var), implredcost);
13488#endif
13489
13490 /* the following algorithm is expensive */
13491 ncliques = SCIPvarGetNCliques(var, varfixing);
13492
13493 if( ncliques > 0 )
13494 {
13495 SCIP_CLIQUE** cliques;
13496 SCIP_CLIQUE* clique;
13497 SCIP_VAR** clqvars;
13498 SCIP_VAR** probvars;
13499 SCIP_VAR* clqvar;
13500 SCIP_Bool* clqvalues;
13501 int* entries;
13502 int* ids;
13503 SCIP_Real redcost;
13504 SCIP_Bool cleanedup;
13505 int nclqvars;
13506 int nentries;
13507 int nids;
13508 int id;
13509 int c;
13510 int v;
13511
13512 assert(prob != NULL);
13513 assert(SCIPprobIsTransformed(prob));
13514
13515 nentries = SCIPprobGetNVars(prob) - SCIPprobGetNContVars(prob) + 1;
13516
13517 SCIP_CALL_ABORT( SCIPsetAllocBufferArray(set, &ids, nentries) );
13518 nids = 0;
13519 SCIP_CALL_ABORT( SCIPsetAllocCleanBufferArray(set, &entries, nentries) );
13520
13521 cliques = SCIPvarGetCliques(var, varfixing);
13522 assert(cliques != NULL);
13523
13524 for( c = ncliques - 1; c >= 0; --c )
13525 {
13526 clique = cliques[c];
13527 assert(clique != NULL);
13528 nclqvars = SCIPcliqueGetNVars(clique);
13529 assert(nclqvars > 0);
13530
13531 if( nclqvars > MAX_CLIQUELENGTH )
13532 continue;
13533
13534 clqvars = SCIPcliqueGetVars(clique);
13535 clqvalues = SCIPcliqueGetValues(clique);
13536 assert(clqvars != NULL);
13537 assert(clqvalues != NULL);
13538
13539 cleanedup = SCIPcliqueIsCleanedUp(clique);
13540
13541 for( v = nclqvars - 1; v >= 0; --v )
13542 {
13543 clqvar = clqvars[v];
13544 assert(clqvar != NULL);
13545
13546 /* ignore binary variable which are fixed */
13547 if( clqvar != var && (cleanedup || SCIPvarIsActive(clqvar)) &&
13548 (SCIPvarGetLbLocal(clqvar) < 0.5 && SCIPvarGetUbLocal(clqvar) > 0.5) )
13549 {
13550 int probindex = SCIPvarGetProbindex(clqvar) + 1;
13551 assert(0 < probindex && probindex < nentries);
13552
13553#ifdef SCIP_DISABLED_CODE
13554 /* check that the variable was not yet visited or does not appear with two contradicting implications, ->
13555 * can appear since there is no guarantee that all these infeasible bounds were found
13556 */
13557 assert(!entries[probindex] || entries[probindex] == (clqvalues[v] ? probindex : -probindex));
13558#endif
13559 if( entries[probindex] == 0 )
13560 {
13561 ids[nids] = probindex;
13562 ++nids;
13563
13564 /* mark variable as visited */
13565 entries[probindex] = (clqvalues[v] ? probindex : -probindex);
13566 }
13567 }
13568 }
13569 }
13570
13571 probvars = SCIPprobGetVars(prob);
13572 assert(probvars != NULL);
13573
13574 /* add all implied reduced cost */
13575 for( v = nids - 1; v >= 0; --v )
13576 {
13577 id = ids[v];
13578 assert(0 < id && id < nentries);
13579 assert(entries[id] != 0);
13580 assert(probvars[id - 1] != NULL);
13581 assert(SCIPvarIsActive(probvars[id - 1]));
13582 assert(SCIPvarIsBinary(probvars[id - 1]));
13583 assert(SCIPvarGetLbLocal(probvars[id - 1]) < 0.5 && SCIPvarGetUbLocal(probvars[id - 1]) > 0.5);
13584
13585 if( (entries[id] > 0) != varfixing )
13586 redcost = getImplVarRedcost(probvars[id - 1], set, (entries[id] < 0), stat, lp);
13587 else
13588 redcost = -getImplVarRedcost(probvars[id - 1], set, (entries[id] < 0), stat, lp);
13589
13590 if( (varfixing && SCIPsetIsDualfeasPositive(set, redcost)) || (!varfixing && SCIPsetIsDualfeasNegative(set, redcost)) )
13591 implredcost += redcost;
13592
13593 /* reset entries clear buffer array */
13594 entries[id] = 0;
13595 }
13596
13599 }
13600
13601#ifdef SCIP_MORE_DEBUG
13602 SCIPsetDebugMsg(set, "variable <%s> incl. cliques (%d) has implied reduced cost of %g\n", SCIPvarGetName(var), ncliques,
13603 implredcost);
13604#endif
13605
13606 /* collect non-binary implication information */
13607 nvars = SCIPimplicsGetNImpls(var->implics, varfixing);
13608
13609 if( nvars > 0 )
13610 {
13611 SCIP_VAR** vars;
13612 SCIP_VAR* implvar;
13613 SCIP_COL* col;
13614 SCIP_Real* bounds;
13615 SCIP_BOUNDTYPE* boundtypes;
13616 SCIP_Real redcost;
13617 SCIP_Real lb;
13618 SCIP_Real ub;
13619 SCIP_Bool lpissolbasic;
13620 int v;
13621
13622 vars = SCIPimplicsGetVars(var->implics, varfixing);
13623 boundtypes = SCIPimplicsGetTypes(var->implics, varfixing);
13624 bounds = SCIPimplicsGetBounds(var->implics, varfixing);
13625 lpissolbasic = SCIPlpIsSolBasic(lp);
13626
13627 for( v = nvars - 1; v >= 0; --v )
13628 {
13629 implvar = vars[v];
13630 assert(implvar != NULL);
13631
13632 lb = SCIPvarGetLbLocal(implvar);
13633 ub = SCIPvarGetUbLocal(implvar);
13634
13635 /* ignore binary variable which are fixed or not of column status */
13636 if( SCIPvarGetStatus(implvar) != SCIP_VARSTATUS_COLUMN || SCIPsetIsFeasEQ(set, lb, ub) )
13637 continue;
13638
13639 col = SCIPvarGetCol(implvar);
13640 assert(col != NULL);
13641 redcost = 0.0;
13642
13643 /* solved lp with basis information or not? */
13644 if( lpissolbasic )
13645 {
13646 SCIP_BASESTAT basestat = SCIPcolGetBasisStatus(col);
13647
13648 /* check if the implication is not not yet applied */
13649 if( basestat == SCIP_BASESTAT_LOWER && boundtypes[v] == SCIP_BOUNDTYPE_LOWER && SCIPsetIsFeasGT(set, bounds[v], lb) )
13650 {
13651 redcost = SCIPcolGetRedcost(col, stat, lp);
13652 assert(!SCIPsetIsDualfeasNegative(set, redcost));
13653
13654 if( !varfixing )
13655 redcost *= (lb - bounds[v]);
13656 else
13657 redcost *= (bounds[v] - lb);
13658 }
13659 else if( basestat == SCIP_BASESTAT_UPPER && boundtypes[v] == SCIP_BOUNDTYPE_UPPER && SCIPsetIsFeasLT(set, bounds[v], ub) )
13660 {
13661 redcost = SCIPcolGetRedcost(col, stat, lp);
13662 assert(!SCIPsetIsDualfeasPositive(set, redcost));
13663
13664 if( varfixing )
13665 redcost *= (bounds[v] - ub);
13666 else
13667 redcost *= (ub - bounds[v]);
13668 }
13669 }
13670 else
13671 {
13672 SCIP_Real primsol = SCIPcolGetPrimsol(col);
13673
13674 /* check if the implication is not not yet applied */
13675 if( boundtypes[v] == SCIP_BOUNDTYPE_LOWER && SCIPsetIsFeasEQ(set, lb, primsol) && SCIPsetIsFeasGT(set, bounds[v], lb) )
13676 {
13677 redcost = SCIPcolGetRedcost(col, stat, lp);
13678 assert(!SCIPsetIsDualfeasNegative(set, redcost));
13679
13680 if( varfixing )
13681 redcost *= (lb - bounds[v]);
13682 else
13683 redcost *= (bounds[v] - lb);
13684 }
13685 else if( boundtypes[v] == SCIP_BOUNDTYPE_UPPER && SCIPsetIsFeasEQ(set, ub, primsol) && SCIPsetIsFeasLT(set, bounds[v], ub) )
13686 {
13687 redcost = SCIPcolGetRedcost(col, stat, lp);
13688 assert(!SCIPsetIsDualfeasPositive(set, redcost));
13689
13690 if( varfixing )
13691 redcost *= (bounds[v] - ub);
13692 else
13693 redcost *= (ub - bounds[v]);
13694 }
13695 }
13696
13697 /* improve implied reduced cost */
13698 if( (varfixing && SCIPsetIsDualfeasPositive(set, redcost)) || (!varfixing && SCIPsetIsDualfeasNegative(set, redcost)) )
13699 implredcost += redcost;
13700 }
13701 }
13702
13703#ifdef SCIP_MORE_DEBUG
13704 SCIPsetDebugMsg(set, "variable <%s> incl. cliques (%d) and implications (%d) has implied reduced cost of %g\n",
13705 SCIPvarGetName(var), ncliques, nvars, implredcost);
13706#endif
13707
13708 return implredcost;
13709}
13710
13711/** returns the best solution (w.r.t. root reduced cost propagation) of the variable in the root node's relaxation, if
13712 * the root relaxation is not yet completely solved, zero is returned
13713 */
13715 SCIP_VAR* var /**< problem variable */
13716 )
13717{
13718 SCIP_Real rootsol;
13719 int i;
13720
13721 assert(var != NULL);
13722
13723 switch( SCIPvarGetStatus(var) )
13724 {
13726 if( var->data.original.transvar == NULL )
13727 return 0.0;
13729
13732 return var->bestrootsol;
13733
13735 assert(var->locdom.lb == var->locdom.ub); /*lint !e777*/
13736 return var->locdom.lb;
13737
13739 assert(!var->donotaggr);
13740 assert(var->data.aggregate.var != NULL);
13741 /* a correct implementation would need to check the value of var->data.aggregate.var for infinity and return the
13742 * corresponding infinity value instead of performing an arithmetical transformation (compare method
13743 * SCIPvarGetLbLP()); however, we do not want to introduce a SCIP or SCIP_SET pointer to this method, since it is
13744 * (or is called by) a public interface method; instead, we only assert that values are finite
13745 * w.r.t. SCIP_DEFAULT_INFINITY, which seems to be true in our regression tests; note that this may yield false
13746 * positives and negatives if the parameter <numerics/infinity> is modified by the user
13747 */
13751
13753 assert(!var->donotmultaggr);
13754 assert(var->data.multaggr.vars != NULL);
13755 assert(var->data.multaggr.scalars != NULL);
13756 /* Due to method SCIPvarFlattenAggregationGraph(), this assert is no longer correct
13757 * assert(var->data.multaggr.nvars >= 2);
13758 */
13759 rootsol = var->data.multaggr.constant;
13760 for( i = 0; i < var->data.multaggr.nvars; ++i )
13761 rootsol += var->data.multaggr.scalars[i] * SCIPvarGetBestRootSol(var->data.multaggr.vars[i]);
13762 return rootsol;
13763
13764 case SCIP_VARSTATUS_NEGATED: /* x' = offset - x -> x = offset - x' */
13765 assert(var->negatedvar != NULL);
13767 assert(var->negatedvar->negatedvar == var);
13769
13770 default:
13771 SCIPerrorMessage("unknown variable status\n");
13772 SCIPABORT();
13773 return 0.0; /*lint !e527*/
13774 }
13775}
13776
13777/** returns the best reduced costs (w.r.t. root reduced cost propagation) of the variable in the root node's relaxation,
13778 * if the root relaxation is not yet completely solved, or the variable was no column of the root LP, SCIP_INVALID is
13779 * returned
13780 */
13782 SCIP_VAR* var /**< problem variable */
13783 )
13784{
13785 assert(var != NULL);
13786
13787 switch( SCIPvarGetStatus(var) )
13788 {
13790 if( var->data.original.transvar == NULL )
13791 return SCIP_INVALID;
13793
13796 return var->bestrootredcost;
13797
13802 return 0.0;
13803
13804 default:
13805 SCIPerrorMessage("unknown variable status\n");
13806 SCIPABORT();
13807 return 0.0; /*lint !e527*/
13808 }
13809}
13810
13811/** returns the best objective value (w.r.t. root reduced cost propagation) of the root LP which belongs the root
13812 * reduced cost which is accessible via SCIPvarGetRootRedcost() or the variable was no column of the root LP,
13813 * SCIP_INVALID is returned
13814 */
13816 SCIP_VAR* var /**< problem variable */
13817 )
13818{
13819 assert(var != NULL);
13820
13821 switch( SCIPvarGetStatus(var) )
13822 {
13824 if( var->data.original.transvar == NULL )
13825 return SCIP_INVALID;
13827
13830 return var->bestrootlpobjval;
13831
13836 return SCIP_INVALID;
13837
13838 default:
13839 SCIPerrorMessage("unknown variable status\n");
13840 SCIPABORT();
13841 return SCIP_INVALID; /*lint !e527*/
13842 }
13843}
13844
13845/** set the given solution as the best root solution w.r.t. root reduced cost propagation in the variables */
13847 SCIP_VAR* var, /**< problem variable */
13848 SCIP_Real rootsol, /**< root solution value */
13849 SCIP_Real rootredcost, /**< root reduced cost */
13850 SCIP_Real rootlpobjval /**< objective value of the root LP */
13851 )
13852{
13853 assert(var != NULL);
13854
13855 var->bestrootsol = rootsol;
13856 var->bestrootredcost = rootredcost;
13857 var->bestrootlpobjval = rootlpobjval;
13858}
13859
13860/** stores the solution value as relaxation solution in the problem variable */
13862 SCIP_VAR* var, /**< problem variable */
13863 SCIP_SET* set, /**< global SCIP settings */
13864 SCIP_RELAXATION* relaxation, /**< global relaxation data */
13865 SCIP_Real solval, /**< solution value in the current relaxation solution */
13866 SCIP_Bool updateobj /**< should the objective value be updated? */
13867 )
13868{
13869 assert(var != NULL);
13870 assert(relaxation != NULL);
13871 assert(set != NULL);
13872 assert(var->scip == set->scip);
13873
13874 /* we want to store only values for non fixed variables (LOOSE or COLUMN); others have to be transformed */
13875 switch( SCIPvarGetStatus(var) )
13876 {
13878 SCIP_CALL( SCIPvarSetRelaxSol(var->data.original.transvar, set, relaxation, solval, updateobj) );
13879 break;
13880
13883 if( updateobj )
13884 SCIPrelaxationSolObjAdd(relaxation, var->obj * (solval - var->relaxsol));
13885 var->relaxsol = solval;
13886 break;
13887
13889 if( !SCIPsetIsEQ(set, solval, var->glbdom.lb) )
13890 {
13891 SCIPerrorMessage("cannot set relaxation solution value for variable <%s> fixed to %.15g to different value %.15g\n",
13892 SCIPvarGetName(var), var->glbdom.lb, solval);
13893 return SCIP_INVALIDDATA;
13894 }
13895 break;
13896
13897 case SCIP_VARSTATUS_AGGREGATED: /* x = a*y + c => y = (x-c)/a */
13898 assert(!SCIPsetIsZero(set, var->data.aggregate.scalar));
13899 SCIP_CALL( SCIPvarSetRelaxSol(var->data.aggregate.var, set, relaxation,
13900 (solval - var->data.aggregate.constant)/var->data.aggregate.scalar, updateobj) );
13901 break;
13903 SCIPerrorMessage("cannot set solution value for multiple aggregated variable\n");
13904 return SCIP_INVALIDDATA;
13905
13907 SCIP_CALL( SCIPvarSetRelaxSol(var->negatedvar, set, relaxation, var->data.negate.constant - solval, updateobj) );
13908 break;
13909
13910 default:
13911 SCIPerrorMessage("unknown variable status\n");
13912 return SCIP_INVALIDDATA;
13913 }
13914
13915 return SCIP_OKAY;
13916}
13917
13918/** returns the solution value of the problem variable in the relaxation solution
13919 *
13920 * @todo Inline this function - similar to SCIPvarGetLPSol_rec.
13921 */
13923 SCIP_VAR* var, /**< problem variable */
13924 SCIP_SET* set /**< global SCIP settings */
13925 )
13926{
13927 SCIP_Real solvalsum;
13928 SCIP_Real solval;
13929 int i;
13930
13931 assert(var != NULL);
13932 assert(set != NULL);
13933 assert(var->scip == set->scip);
13934
13935 /* only values for non fixed variables (LOOSE or COLUMN) are stored; others have to be transformed */
13936 switch( SCIPvarGetStatus(var) )
13937 {
13940
13943 return var->relaxsol;
13944
13946 assert(SCIPvarGetLbGlobal(var) == SCIPvarGetUbGlobal(var)); /*lint !e777*/
13947 assert(SCIPvarGetLbLocal(var) == SCIPvarGetUbLocal(var)); /*lint !e777*/
13948 assert(SCIPvarGetLbGlobal(var) == SCIPvarGetLbLocal(var)); /*lint !e777*/
13949 return SCIPvarGetLbGlobal(var);
13950
13951 case SCIP_VARSTATUS_AGGREGATED: /* x = a*y + c => y = (x-c)/a */
13952 solval = SCIPvarGetRelaxSol(var->data.aggregate.var, set);
13953 if( SCIPsetIsInfinity(set, solval) || SCIPsetIsInfinity(set, -solval) )
13954 {
13955 if( var->data.aggregate.scalar * solval > 0.0 )
13956 return SCIPsetInfinity(set);
13957 if( var->data.aggregate.scalar * solval < 0.0 )
13958 return -SCIPsetInfinity(set);
13959 }
13960 return var->data.aggregate.scalar * solval + var->data.aggregate.constant;
13961
13963 solvalsum = var->data.multaggr.constant;
13964 for( i = 0; i < var->data.multaggr.nvars; ++i )
13965 {
13966 solval = SCIPvarGetRelaxSol(var->data.multaggr.vars[i], set);
13967 if( SCIPsetIsInfinity(set, solval) || SCIPsetIsInfinity(set, -solval) )
13968 {
13969 if( var->data.multaggr.scalars[i] * solval > 0.0 )
13970 return SCIPsetInfinity(set);
13971 if( var->data.multaggr.scalars[i] * solval < 0.0 )
13972 return -SCIPsetInfinity(set);
13973 }
13974 solvalsum += var->data.multaggr.scalars[i] * solval;
13975 }
13976 return solvalsum;
13977
13979 solval = SCIPvarGetRelaxSol(var->negatedvar, set);
13980 if( SCIPsetIsInfinity(set, solval) )
13981 return -SCIPsetInfinity(set);
13982 if( SCIPsetIsInfinity(set, -solval) )
13983 return SCIPsetInfinity(set);
13984 return var->data.negate.constant - solval;
13985
13986 default:
13987 SCIPerrorMessage("unknown variable status\n");
13988 SCIPABORT();
13989 return SCIP_INVALID; /*lint !e527*/
13990 }
13991}
13992
13993/** returns the solution value of the transformed problem variable in the relaxation solution */
13995 SCIP_VAR* var /**< problem variable */
13996 )
13997{
13998 assert(var != NULL);
14000
14001 return var->relaxsol;
14002}
14003
14004/** stores the solution value as NLP solution in the problem variable */
14006 SCIP_VAR* var, /**< problem variable */
14007 SCIP_SET* set, /**< global SCIP settings */
14008 SCIP_Real solval /**< solution value in the current NLP solution */
14009 )
14010{
14011 assert(var != NULL);
14012 assert(set != NULL);
14013 assert(var->scip == set->scip);
14014
14015 /* we want to store only values for non fixed variables (LOOSE or COLUMN); others have to be transformed */
14016 switch( SCIPvarGetStatus(var) )
14017 {
14020 break;
14021
14024 var->nlpsol = solval;
14025 break;
14026
14028 if( !SCIPsetIsEQ(set, solval, var->glbdom.lb) )
14029 {
14030 SCIPerrorMessage("cannot set NLP solution value for variable <%s> fixed to %.15g to different value %.15g\n",
14031 SCIPvarGetName(var), var->glbdom.lb, solval);
14032 SCIPABORT();
14033 return SCIP_INVALIDCALL; /*lint !e527*/
14034 }
14035 break;
14036
14037 case SCIP_VARSTATUS_AGGREGATED: /* x = a*y + c => y = (x-c)/a */
14038 assert(!SCIPsetIsZero(set, var->data.aggregate.scalar));
14040 break;
14041
14043 SCIPerrorMessage("cannot set solution value for multiple aggregated variable\n");
14044 SCIPABORT();
14045 return SCIP_INVALIDCALL; /*lint !e527*/
14046
14048 SCIP_CALL( SCIPvarSetNLPSol(var->negatedvar, set, var->data.negate.constant - solval) );
14049 break;
14050
14051 default:
14052 SCIPerrorMessage("unknown variable status\n");
14053 SCIPABORT();
14054 return SCIP_ERROR; /*lint !e527*/
14055 }
14056
14057 return SCIP_OKAY;
14058}
14059
14060/** returns a weighted average solution value of the variable in all feasible primal solutions found so far */
14062 SCIP_VAR* var /**< problem variable */
14063 )
14064{
14065 SCIP_Real avgsol;
14066 int i;
14067
14068 assert(var != NULL);
14069
14070 switch( SCIPvarGetStatus(var) )
14071 {
14073 if( var->data.original.transvar == NULL )
14074 return 0.0;
14076
14079 avgsol = var->primsolavg;
14080 avgsol = MAX(avgsol, var->glbdom.lb);
14081 avgsol = MIN(avgsol, var->glbdom.ub);
14082 return avgsol;
14083
14085 assert(var->locdom.lb == var->locdom.ub); /*lint !e777*/
14086 return var->locdom.lb;
14087
14089 assert(!var->donotaggr);
14090 assert(var->data.aggregate.var != NULL);
14092 + var->data.aggregate.constant;
14093
14095 assert(!var->donotmultaggr);
14096 assert(var->data.multaggr.vars != NULL);
14097 assert(var->data.multaggr.scalars != NULL);
14098 /* Due to method SCIPvarFlattenAggregationGraph(), this assert is no longer correct
14099 * assert(var->data.multaggr.nvars >= 2);
14100 */
14101 avgsol = var->data.multaggr.constant;
14102 for( i = 0; i < var->data.multaggr.nvars; ++i )
14103 avgsol += var->data.multaggr.scalars[i] * SCIPvarGetAvgSol(var->data.multaggr.vars[i]);
14104 return avgsol;
14105
14106 case SCIP_VARSTATUS_NEGATED: /* x' = offset - x -> x = offset - x' */
14107 assert(var->negatedvar != NULL);
14109 assert(var->negatedvar->negatedvar == var);
14110 return var->data.negate.constant - SCIPvarGetAvgSol(var->negatedvar);
14111
14112 default:
14113 SCIPerrorMessage("unknown variable status\n");
14114 SCIPABORT();
14115 return 0.0; /*lint !e527*/
14116 }
14117}
14118
14119/** returns solution value and index of variable lower bound that is closest to the variable's value in the given primal solution
14120 * or current LP solution if no primal solution is given; returns an index of -1 if no variable lower bound is available
14121 */
14123 SCIP_VAR* var, /**< active problem variable */
14124 SCIP_SOL* sol, /**< primal solution, or NULL for LP solution */
14125 SCIP_SET* set, /**< global SCIP settings */
14126 SCIP_STAT* stat, /**< problem statistics */
14127 SCIP_Real* closestvlb, /**< pointer to store the value of the closest variable lower bound */
14128 int* closestvlbidx /**< pointer to store the index of the closest variable lower bound */
14129 )
14130{
14131 int nvlbs;
14132
14133 assert(var != NULL);
14134 assert(stat != NULL);
14135 assert(set != NULL);
14136 assert(var->scip == set->scip);
14137 assert(closestvlb != NULL);
14138 assert(closestvlbidx != NULL);
14139
14140 *closestvlbidx = -1;
14141 *closestvlb = SCIP_REAL_MIN;
14142
14143 nvlbs = SCIPvarGetNVlbs(var);
14144 if( nvlbs > 0 )
14145 {
14146 SCIP_VAR** vlbvars;
14147 SCIP_Real* vlbcoefs;
14148 SCIP_Real* vlbconsts;
14149 int i;
14150
14151 vlbvars = SCIPvarGetVlbVars(var);
14152 vlbcoefs = SCIPvarGetVlbCoefs(var);
14153 vlbconsts = SCIPvarGetVlbConstants(var);
14154
14155 /* check for cached values */
14156 if( var->closestvblpcount == stat->lpcount && var->closestvlbidx != -1 && sol == NULL)
14157 {
14158 i = var->closestvlbidx;
14159 assert(0 <= i && i < nvlbs);
14160 assert(SCIPvarIsActive(vlbvars[i]));
14161 *closestvlbidx = i;
14162 *closestvlb = vlbcoefs[i] * SCIPvarGetLPSol(vlbvars[i]) + vlbconsts[i];
14163 }
14164 else
14165 {
14166 /* search best VUB */
14167 for( i = 0; i < nvlbs; i++ )
14168 {
14169 if( SCIPvarIsActive(vlbvars[i]) )
14170 {
14171 SCIP_Real vlbsol;
14172
14173 vlbsol = vlbcoefs[i] * (sol == NULL ? SCIPvarGetLPSol(vlbvars[i]) : SCIPsolGetVal(sol, set, stat, vlbvars[i])) + vlbconsts[i];
14174 if( vlbsol > *closestvlb )
14175 {
14176 *closestvlb = vlbsol;
14177 *closestvlbidx = i;
14178 }
14179 }
14180 }
14181
14182 if( sol == NULL )
14183 {
14184 /* update cached value */
14185 if( var->closestvblpcount != stat->lpcount )
14186 var->closestvubidx = -1;
14187 var->closestvlbidx = *closestvlbidx;
14188 var->closestvblpcount = stat->lpcount;
14189 }
14190 }
14191 }
14192}
14193
14194/** returns solution value and index of variable upper bound that is closest to the variable's value in the given primal solution;
14195 * or current LP solution if no primal solution is given; returns an index of -1 if no variable upper bound is available
14196 */
14198 SCIP_VAR* var, /**< active problem variable */
14199 SCIP_SOL* sol, /**< primal solution, or NULL for LP solution */
14200 SCIP_SET* set, /**< global SCIP settings */
14201 SCIP_STAT* stat, /**< problem statistics */
14202 SCIP_Real* closestvub, /**< pointer to store the value of the closest variable upper bound */
14203 int* closestvubidx /**< pointer to store the index of the closest variable upper bound */
14204 )
14205{
14206 int nvubs;
14207
14208 assert(var != NULL);
14209 assert(set != NULL);
14210 assert(var->scip == set->scip);
14211 assert(closestvub != NULL);
14212 assert(closestvubidx != NULL);
14213
14214 *closestvubidx = -1;
14215 *closestvub = SCIP_REAL_MAX;
14216
14217 nvubs = SCIPvarGetNVubs(var);
14218 if( nvubs > 0 )
14219 {
14220 SCIP_VAR** vubvars;
14221 SCIP_Real* vubcoefs;
14222 SCIP_Real* vubconsts;
14223 int i;
14224
14225 vubvars = SCIPvarGetVubVars(var);
14226 vubcoefs = SCIPvarGetVubCoefs(var);
14227 vubconsts = SCIPvarGetVubConstants(var);
14228
14229 /* check for cached values */
14230 if( var->closestvblpcount == stat->lpcount && var->closestvubidx != -1 && sol == NULL)
14231 {
14232 i = var->closestvubidx;
14233 assert(0 <= i && i < nvubs);
14234 assert(SCIPvarIsActive(vubvars[i]));
14235 *closestvubidx = i;
14236 *closestvub = vubcoefs[i] * SCIPvarGetLPSol(vubvars[i]) + vubconsts[i];
14237 }
14238 else
14239 {
14240 /* search best VUB */
14241 for( i = 0; i < nvubs; i++ )
14242 {
14243 if( SCIPvarIsActive(vubvars[i]) )
14244 {
14245 SCIP_Real vubsol;
14246
14247 vubsol = vubcoefs[i] * (sol == NULL ? SCIPvarGetLPSol(vubvars[i]) : SCIPsolGetVal(sol, set, stat, vubvars[i])) + vubconsts[i];
14248 if( vubsol < *closestvub )
14249 {
14250 *closestvub = vubsol;
14251 *closestvubidx = i;
14252 }
14253 }
14254 }
14255
14256 if( sol == NULL )
14257 {
14258 /* update cached value */
14259 if( var->closestvblpcount != stat->lpcount )
14260 var->closestvlbidx = -1;
14261 var->closestvubidx = *closestvubidx;
14262 var->closestvblpcount = stat->lpcount;
14263 }
14264 }
14265 }
14266}
14267
14268/** resolves variable to columns and adds them with the coefficient to the row */
14270 SCIP_VAR* var, /**< problem variable */
14271 BMS_BLKMEM* blkmem, /**< block memory */
14272 SCIP_SET* set, /**< global SCIP settings */
14273 SCIP_STAT* stat, /**< problem statistics */
14274 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
14275 SCIP_PROB* prob, /**< problem data */
14276 SCIP_LP* lp, /**< current LP data */
14277 SCIP_ROW* row, /**< LP row */
14278 SCIP_Real val /**< value of coefficient */
14279 )
14280{
14281 int i;
14282
14283 assert(var != NULL);
14284 assert(set != NULL);
14285 assert(var->scip == set->scip);
14286 assert(row != NULL);
14287 assert(!SCIPsetIsInfinity(set, REALABS(val)));
14288
14289 SCIPsetDebugMsg(set, "adding coefficient %g<%s> to row <%s>\n", val, var->name, row->name);
14290
14291 if ( SCIPsetIsZero(set, val) )
14292 return SCIP_OKAY;
14293
14294 switch( SCIPvarGetStatus(var) )
14295 {
14297 if( var->data.original.transvar == NULL )
14298 {
14299 SCIPerrorMessage("cannot add untransformed original variable <%s> to LP row <%s>\n", var->name, row->name);
14300 return SCIP_INVALIDDATA;
14301 }
14302 SCIP_CALL( SCIPvarAddToRow(var->data.original.transvar, blkmem, set, stat, eventqueue, prob, lp, row, val) );
14303 return SCIP_OKAY;
14304
14306 /* add globally fixed variables as constant */
14307 if( SCIPsetIsEQ(set, var->glbdom.lb, var->glbdom.ub) )
14308 {
14309 SCIP_CALL( SCIProwAddConstant(row, blkmem, set, stat, eventqueue, lp, val * var->glbdom.lb) );
14310 return SCIP_OKAY;
14311 }
14312 /* convert loose variable into column */
14313 SCIP_CALL( SCIPvarColumn(var, blkmem, set, stat, prob, lp) );
14315 /*lint -fallthrough*/
14316
14318 assert(var->data.col != NULL);
14319 assert(var->data.col->var == var);
14320 SCIP_CALL( SCIProwIncCoef(row, blkmem, set, eventqueue, lp, var->data.col, val) );
14321 return SCIP_OKAY;
14322
14324 assert(var->glbdom.lb == var->glbdom.ub); /*lint !e777*/
14325 assert(var->locdom.lb == var->locdom.ub); /*lint !e777*/
14326 assert(var->locdom.lb == var->glbdom.lb); /*lint !e777*/
14327 assert(!SCIPsetIsInfinity(set, REALABS(var->locdom.lb)));
14328 SCIP_CALL( SCIProwAddConstant(row, blkmem, set, stat, eventqueue, lp, val * var->locdom.lb) );
14329 return SCIP_OKAY;
14330
14332 assert(!var->donotaggr);
14333 assert(var->data.aggregate.var != NULL);
14334 SCIP_CALL( SCIPvarAddToRow(var->data.aggregate.var, blkmem, set, stat, eventqueue, prob, lp,
14335 row, var->data.aggregate.scalar * val) );
14336 SCIP_CALL( SCIProwAddConstant(row, blkmem, set, stat, eventqueue, lp, var->data.aggregate.constant * val) );
14337 return SCIP_OKAY;
14338
14340 assert(!var->donotmultaggr);
14341 assert(var->data.multaggr.vars != NULL);
14342 assert(var->data.multaggr.scalars != NULL);
14343 /* Due to method SCIPvarFlattenAggregationGraph(), this assert is no longer correct
14344 * assert(var->data.multaggr.nvars >= 2);
14345 */
14346 for( i = 0; i < var->data.multaggr.nvars; ++i )
14347 {
14348 SCIP_CALL( SCIPvarAddToRow(var->data.multaggr.vars[i], blkmem, set, stat, eventqueue, prob, lp,
14349 row, var->data.multaggr.scalars[i] * val) );
14350 }
14351 SCIP_CALL( SCIProwAddConstant(row, blkmem, set, stat, eventqueue, lp, var->data.multaggr.constant * val) );
14352 return SCIP_OKAY;
14353
14354 case SCIP_VARSTATUS_NEGATED: /* x' = offset - x -> x = offset - x' */
14355 assert(var->negatedvar != NULL);
14357 assert(var->negatedvar->negatedvar == var);
14358 SCIP_CALL( SCIPvarAddToRow(var->negatedvar, blkmem, set, stat, eventqueue, prob, lp, row, -val) );
14359 SCIP_CALL( SCIProwAddConstant(row, blkmem, set, stat, eventqueue, lp, var->data.negate.constant * val) );
14360 return SCIP_OKAY;
14361
14362 default:
14363 SCIPerrorMessage("unknown variable status\n");
14364 return SCIP_INVALIDDATA;
14365 }
14366}
14367
14368/* optionally, define this compiler flag to write complete variable histories to a file */
14369#ifdef SCIP_HISTORYTOFILE
14370SCIP_Longint counter = 0l;
14371const char* historypath="."; /* allows for user-defined path; use '.' for calling directory of SCIP */
14372#include "scip/scip.h"
14373#endif
14374
14375/** updates the pseudo costs of the given variable and the global pseudo costs after a change of
14376 * "solvaldelta" in the variable's solution value and resulting change of "objdelta" in the in the LP's objective value
14377 */
14379 SCIP_VAR* var, /**< problem variable */
14380 SCIP_SET* set, /**< global SCIP settings */
14381 SCIP_STAT* stat, /**< problem statistics */
14382 SCIP_Real solvaldelta, /**< difference of variable's new LP value - old LP value */
14383 SCIP_Real objdelta, /**< difference of new LP's objective value - old LP's objective value */
14384 SCIP_Real weight /**< weight in (0,1] of this update in pseudo cost sum */
14385 )
14386{
14387 SCIP_Real oldrootpseudocosts;
14388 assert(var != NULL);
14389 assert(set != NULL);
14390 assert(var->scip == set->scip);
14391 assert(stat != NULL);
14392
14393 /* check if history statistics should be collected for a variable */
14394 if( !stat->collectvarhistory )
14395 return SCIP_OKAY;
14396
14397 switch( SCIPvarGetStatus(var) )
14398 {
14400 if( var->data.original.transvar == NULL )
14401 {
14402 SCIPerrorMessage("cannot update pseudo costs of original untransformed variable\n");
14403 return SCIP_INVALIDDATA;
14404 }
14405 SCIP_CALL( SCIPvarUpdatePseudocost(var->data.original.transvar, set, stat, solvaldelta, objdelta, weight) );
14406 return SCIP_OKAY;
14407
14410 /* store old pseudo-costs for root LP best-estimate update */
14411 oldrootpseudocosts = SCIPvarGetMinPseudocostScore(var, stat, set, SCIPvarGetRootSol(var));
14412
14413 /* update history */
14414 SCIPhistoryUpdatePseudocost(var->history, set, solvaldelta, objdelta, weight);
14415 SCIPhistoryUpdatePseudocost(var->historycrun, set, solvaldelta, objdelta, weight);
14416 SCIPhistoryUpdatePseudocost(stat->glbhistory, set, solvaldelta, objdelta, weight);
14417 SCIPhistoryUpdatePseudocost(stat->glbhistorycrun, set, solvaldelta, objdelta, weight);
14418
14419 /* update root LP best-estimate */
14420 SCIP_CALL( SCIPstatUpdateVarRootLPBestEstimate(stat, set, var, oldrootpseudocosts) );
14421
14422 /* append history to file */
14423#ifdef SCIP_HISTORYTOFILE
14424 {
14425 FILE* f;
14426 char filename[256];
14427 SCIP_NODE* currentnode;
14428 SCIP_NODE* parentnode;
14429 currentnode = SCIPgetFocusNode(set->scip);
14430 parentnode = SCIPnodeGetParent(currentnode);
14431
14432 sprintf(filename, "%s/%s.pse", historypath, SCIPgetProbName(set->scip));
14433 f = fopen(filename, "a");
14434 if( NULL != f )
14435 {
14436 fprintf(f, "%lld %s \t %lld \t %lld \t %lld \t %d \t %15.9f \t %.3f\n",
14437 ++counter,
14438 SCIPvarGetName(var),
14439 SCIPnodeGetNumber(currentnode),
14440 parentnode != NULL ? SCIPnodeGetNumber(parentnode) : -1,
14442 SCIPgetDepth(set->scip),
14443 objdelta,
14444 solvaldelta);
14445 fclose(f);
14446 }
14447 }
14448#endif
14449 return SCIP_OKAY;
14450
14452 SCIPerrorMessage("cannot update pseudo cost values of a fixed variable\n");
14453 return SCIP_INVALIDDATA;
14454
14456 assert(!SCIPsetIsZero(set, var->data.aggregate.scalar));
14458 solvaldelta/var->data.aggregate.scalar, objdelta, weight) );
14459 return SCIP_OKAY;
14460
14462 SCIPerrorMessage("cannot update pseudo cost values of a multi-aggregated variable\n");
14463 return SCIP_INVALIDDATA;
14464
14466 SCIP_CALL( SCIPvarUpdatePseudocost(var->negatedvar, set, stat, -solvaldelta, objdelta, weight) );
14467 return SCIP_OKAY;
14468
14469 default:
14470 SCIPerrorMessage("unknown variable status\n");
14471 return SCIP_INVALIDDATA;
14472 }
14473}
14474
14475/** gets the variable's pseudo cost value for the given step size "solvaldelta" in the variable's LP solution value */
14477 SCIP_VAR* var, /**< problem variable */
14478 SCIP_STAT* stat, /**< problem statistics */
14479 SCIP_Real solvaldelta /**< difference of variable's new LP value - old LP value */
14480 )
14481{
14482 SCIP_BRANCHDIR dir;
14483
14484 assert(var != NULL);
14485 assert(stat != NULL);
14486
14487 switch( SCIPvarGetStatus(var) )
14488 {
14490 if( var->data.original.transvar == NULL )
14491 return SCIPhistoryGetPseudocost(stat->glbhistory, solvaldelta);
14492 else
14493 return SCIPvarGetPseudocost(var->data.original.transvar, stat, solvaldelta);
14494
14497 dir = (solvaldelta >= 0.0 ? SCIP_BRANCHDIR_UPWARDS : SCIP_BRANCHDIR_DOWNWARDS);
14498
14499 return SCIPhistoryGetPseudocostCount(var->history, dir) > 0.0
14500 ? SCIPhistoryGetPseudocost(var->history, solvaldelta)
14501 : SCIPhistoryGetPseudocost(stat->glbhistory, solvaldelta);
14502
14504 return 0.0;
14505
14507 return SCIPvarGetPseudocost(var->data.aggregate.var, stat, var->data.aggregate.scalar * solvaldelta);
14508
14510 return 0.0;
14511
14513 return SCIPvarGetPseudocost(var->negatedvar, stat, -solvaldelta);
14514
14515 default:
14516 SCIPerrorMessage("unknown variable status\n");
14517 SCIPABORT();
14518 return 0.0; /*lint !e527*/
14519 }
14520}
14521
14522/** gets the variable's pseudo cost value for the given step size "solvaldelta" in the variable's LP solution value,
14523 * only using the pseudo cost information of the current run
14524 */
14526 SCIP_VAR* var, /**< problem variable */
14527 SCIP_STAT* stat, /**< problem statistics */
14528 SCIP_Real solvaldelta /**< difference of variable's new LP value - old LP value */
14529 )
14530{
14531 SCIP_BRANCHDIR dir;
14532
14533 assert(var != NULL);
14534 assert(stat != NULL);
14535
14536 switch( SCIPvarGetStatus(var) )
14537 {
14539 if( var->data.original.transvar == NULL )
14540 return SCIPhistoryGetPseudocost(stat->glbhistorycrun, solvaldelta);
14541 else
14542 return SCIPvarGetPseudocostCurrentRun(var->data.original.transvar, stat, solvaldelta);
14543
14546 dir = (solvaldelta >= 0.0 ? SCIP_BRANCHDIR_UPWARDS : SCIP_BRANCHDIR_DOWNWARDS);
14547
14548 return SCIPhistoryGetPseudocostCount(var->historycrun, dir) > 0.0
14549 ? SCIPhistoryGetPseudocost(var->historycrun, solvaldelta)
14550 : SCIPhistoryGetPseudocost(stat->glbhistorycrun, solvaldelta);
14551
14553 return 0.0;
14554
14556 return SCIPvarGetPseudocostCurrentRun(var->data.aggregate.var, stat, var->data.aggregate.scalar * solvaldelta);
14557
14559 return 0.0;
14560
14562 return SCIPvarGetPseudocostCurrentRun(var->negatedvar, stat, -solvaldelta);
14563
14564 default:
14565 SCIPerrorMessage("unknown variable status\n");
14566 SCIPABORT();
14567 return 0.0; /*lint !e527*/
14568 }
14569}
14570
14571/** gets the variable's (possible fractional) number of pseudo cost updates for the given direction */
14573 SCIP_VAR* var, /**< problem variable */
14574 SCIP_BRANCHDIR dir /**< branching direction (downwards, or upwards) */
14575 )
14576{
14577 assert(var != NULL);
14578 assert(dir == SCIP_BRANCHDIR_DOWNWARDS || dir == SCIP_BRANCHDIR_UPWARDS);
14579
14580 switch( SCIPvarGetStatus(var) )
14581 {
14583 if( var->data.original.transvar == NULL )
14584 return 0.0;
14585 else
14587
14590 return SCIPhistoryGetPseudocostCount(var->history, dir);
14591
14593 return 0.0;
14594
14596 if( var->data.aggregate.scalar > 0.0 )
14597 return SCIPvarGetPseudocostCount(var->data.aggregate.var, dir);
14598 else
14600
14602 return 0.0;
14603
14606
14607 default:
14608 SCIPerrorMessage("unknown variable status\n");
14609 SCIPABORT();
14610 return 0.0; /*lint !e527*/
14611 }
14612}
14613
14614/** gets the variable's (possible fractional) number of pseudo cost updates for the given direction,
14615 * only using the pseudo cost information of the current run
14616 */
14618 SCIP_VAR* var, /**< problem variable */
14619 SCIP_BRANCHDIR dir /**< branching direction (downwards, or upwards) */
14620 )
14621{
14622 assert(var != NULL);
14623 assert(dir == SCIP_BRANCHDIR_DOWNWARDS || dir == SCIP_BRANCHDIR_UPWARDS);
14624
14625 switch( SCIPvarGetStatus(var) )
14626 {
14628 if( var->data.original.transvar == NULL )
14629 return 0.0;
14630 else
14632
14636
14638 return 0.0;
14639
14641 if( var->data.aggregate.scalar > 0.0 )
14643 else
14645
14647 return 0.0;
14648
14651
14652 default:
14653 SCIPerrorMessage("unknown variable status\n");
14654 SCIPABORT();
14655 return 0.0; /*lint !e527*/
14656 }
14657}
14658
14659/** compares both possible directions for rounding the given solution value and returns the minimum pseudo-costs of the variable */
14661 SCIP_VAR* var, /**< problem variable */
14662 SCIP_STAT* stat, /**< problem statistics */
14663 SCIP_SET* set, /**< global SCIP settings */
14664 SCIP_Real solval /**< solution value, e.g., LP solution value */
14665 )
14666{
14667 SCIP_Real upscore;
14668 SCIP_Real downscore;
14669 SCIP_Real solvaldeltaup;
14670 SCIP_Real solvaldeltadown;
14671
14672 /* LP root estimate only works for variables with fractional LP root solution */
14673 if( SCIPsetIsFeasIntegral(set, solval) )
14674 return 0.0;
14675
14676 /* no min pseudo-cost score is calculated as long as the variable was not initialized in a direction */
14678 return 0.0;
14679
14680 /* compute delta's to ceil and floor of root LP solution value */
14681 solvaldeltaup = SCIPsetCeil(set, solval) - solval;
14682 solvaldeltadown = SCIPsetFloor(set, solval) - solval;
14683
14684 upscore = SCIPvarGetPseudocost(var, stat, solvaldeltaup);
14685 downscore = SCIPvarGetPseudocost(var, stat, solvaldeltadown);
14686
14687 return MIN(upscore, downscore);
14688}
14689
14690/** gets the an estimate of the variable's pseudo cost variance in direction \p dir */
14692 SCIP_VAR* var, /**< problem variable */
14693 SCIP_BRANCHDIR dir, /**< branching direction (downwards, or upwards) */
14694 SCIP_Bool onlycurrentrun /**< return pseudo cost variance only for current branch and bound run */
14695 )
14696{
14697 assert(var != NULL);
14698 assert(dir == SCIP_BRANCHDIR_DOWNWARDS || dir == SCIP_BRANCHDIR_UPWARDS);
14699
14700 switch( SCIPvarGetStatus(var) )
14701 {
14703 if( var->data.original.transvar == NULL )
14704 return 0.0;
14705 else
14706 return SCIPvarGetPseudocostVariance(var->data.original.transvar, dir, onlycurrentrun);
14707
14710 if( onlycurrentrun )
14712 else
14713 return SCIPhistoryGetPseudocostVariance(var->history, dir);
14714
14716 return 0.0;
14717
14719 if( var->data.aggregate.scalar > 0.0 )
14720 return SCIPvarGetPseudocostVariance(var->data.aggregate.var, dir, onlycurrentrun);
14721 else
14722 return SCIPvarGetPseudocostVariance(var->data.aggregate.var, SCIPbranchdirOpposite(dir), onlycurrentrun);
14723
14725 return 0.0;
14726
14728 return SCIPvarGetPseudocostVariance(var->negatedvar, SCIPbranchdirOpposite(dir), onlycurrentrun);
14729
14730 default:
14731 SCIPerrorMessage("unknown variable status\n");
14732 SCIPABORT();
14733 return 0.0; /*lint !e527*/
14734 }
14735}
14736
14737/** calculates a confidence bound for this variable under the assumption of normally distributed pseudo costs
14738 *
14739 * The confidence bound \f$ \theta \geq 0\f$ denotes the interval borders \f$ [X - \theta, \ X + \theta]\f$, which contains
14740 * the true pseudo costs of the variable, i.e., the expected value of the normal distribution, with a probability
14741 * of 2 * clevel - 1.
14742 *
14743 * @return value of confidence bound for this variable
14744 */
14746 SCIP_VAR* var, /**< variable in question */
14747 SCIP_SET* set, /**< global SCIP settings */
14748 SCIP_BRANCHDIR dir, /**< the branching direction for the confidence bound */
14749 SCIP_Bool onlycurrentrun, /**< should only the current run be taken into account */
14750 SCIP_CONFIDENCELEVEL clevel /**< confidence level for the interval */
14751 )
14752{
14753 SCIP_Real confidencebound;
14754
14755 confidencebound = SCIPvarGetPseudocostVariance(var, dir, onlycurrentrun);
14756 if( SCIPsetIsFeasPositive(set, confidencebound) )
14757 {
14758 SCIP_Real count;
14759
14760 if( onlycurrentrun )
14761 count = SCIPvarGetPseudocostCountCurrentRun(var, dir);
14762 else
14763 count = SCIPvarGetPseudocostCount(var, dir);
14764 /* assertion is valid because variance is positive */
14765 assert(count >= 1.9);
14766
14767 confidencebound /= count; /*lint !e414 division by zero can obviously not occur */
14768 confidencebound = sqrt(confidencebound);
14769
14770 /* the actual, underlying distribution of the mean is a student-t-distribution with degrees of freedom equal to
14771 * the number of pseudo cost evaluations of this variable in the respective direction. */
14772 confidencebound *= SCIPstudentTGetCriticalValue(clevel, (int)SCIPsetFloor(set, count) - 1);
14773 }
14774 else
14775 confidencebound = 0.0;
14776
14777 return confidencebound;
14778}
14779
14780/** check if the current pseudo cost relative error in a direction violates the given threshold. The Relative
14781 * Error is calculated at a specific confidence level
14782 */
14784 SCIP_VAR* var, /**< variable in question */
14785 SCIP_SET* set, /**< global SCIP settings */
14786 SCIP_STAT* stat, /**< problem statistics */
14787 SCIP_Real threshold, /**< threshold for relative errors to be considered reliable (enough) */
14788 SCIP_CONFIDENCELEVEL clevel /**< a given confidence level */
14789 )
14790{
14791 SCIP_Real downsize;
14792 SCIP_Real upsize;
14793 SCIP_Real size;
14794 SCIP_Real relerrorup;
14795 SCIP_Real relerrordown;
14796 SCIP_Real relerror;
14797
14798 /* check, if the pseudo cost score of the variable is reliable */
14801 size = MIN(downsize, upsize);
14802
14803 /* Pseudo costs relative error can only be reliable if both directions have been tried at least twice */
14804 if( size <= 1.9 )
14805 return FALSE;
14806
14807 /* use the relative error between the current mean pseudo cost value of the candidate and its upper
14808 * confidence interval bound at confidence level of 95% for individual variable reliability.
14809 * this is only possible if we have at least 2 measurements and therefore a valid variance estimate.
14810 */
14811 if( downsize >= 1.9 )
14812 {
14813 SCIP_Real normval;
14814
14816 normval = SCIPvarGetPseudocostCurrentRun(var, stat, -1.0);
14817 normval = MAX(1.0, normval);
14818
14819 relerrordown /= normval;
14820 }
14821 else
14822 relerrordown = 0.0;
14823
14824 if( upsize >= 1.9 )
14825 {
14826 SCIP_Real normval;
14827
14829 normval = SCIPvarGetPseudocostCurrentRun(var, stat, +1.0);
14830 normval = MAX(1.0, normval);
14831 relerrorup /= normval;
14832 }
14833 else
14834 relerrorup = 0.0;
14835
14836 /* consider the relative error threshold violated, if it is violated in at least one branching direction */
14837 relerror = MAX(relerrorup, relerrordown);
14838
14839 return (relerror <= threshold);
14840}
14841
14842/** check if variable pseudo-costs have a significant difference in location. The significance depends on
14843 * the choice of \p clevel and on the kind of tested hypothesis. The one-sided hypothesis, which
14844 * should be rejected, is that fracy * mu_y >= fracx * mu_x, where mu_y and mu_x denote the
14845 * unknown location means of the underlying pseudo-cost distributions of x and y.
14846 *
14847 * This method is applied best if variable x has a better pseudo-cost score than y. The method hypothesizes that y were actually
14848 * better than x (despite the current information), meaning that y can be expected to yield branching
14849 * decisions as least as good as x in the long run. If the method returns TRUE, the current history information is
14850 * sufficient to safely rely on the alternative hypothesis that x yields indeed a better branching score (on average)
14851 * than y.
14852 *
14853 * @note The order of x and y matters for the one-sided hypothesis
14854 *
14855 * @note set \p onesided to FALSE if you are not sure which variable is better. The hypothesis tested then reads
14856 * fracy * mu_y == fracx * mu_x vs the alternative hypothesis fracy * mu_y != fracx * mu_x.
14857 *
14858 * @return TRUE if the hypothesis can be safely rejected at the given confidence level
14859 */
14861 SCIP_SET* set, /**< global SCIP settings */
14862 SCIP_STAT* stat, /**< problem statistics */
14863 SCIP_VAR* varx, /**< variable x */
14864 SCIP_Real fracx, /**< the fractionality of variable x */
14865 SCIP_VAR* vary, /**< variable y */
14866 SCIP_Real fracy, /**< the fractionality of variable y */
14867 SCIP_BRANCHDIR dir, /**< branching direction */
14868 SCIP_CONFIDENCELEVEL clevel, /**< confidence level for rejecting hypothesis */
14869 SCIP_Bool onesided /**< should a one-sided hypothesis y >= x be tested? */
14870 )
14871{
14872 SCIP_Real meanx;
14873 SCIP_Real meany;
14874 SCIP_Real variancex;
14875 SCIP_Real variancey;
14876 SCIP_Real countx;
14877 SCIP_Real county;
14878 SCIP_Real tresult;
14879 SCIP_Real realdirection;
14880
14881 if( varx == vary )
14882 return FALSE;
14883
14884 countx = SCIPvarGetPseudocostCount(varx, dir);
14885 county = SCIPvarGetPseudocostCount(vary, dir);
14886
14887 /* if not at least 2 measurements were taken, return FALSE */
14888 if( countx <= 1.9 || county <= 1.9 )
14889 return FALSE;
14890
14891 realdirection = (dir == SCIP_BRANCHDIR_DOWNWARDS ? -1.0 : 1.0);
14892
14893 meanx = fracx * SCIPvarGetPseudocost(varx, stat, realdirection);
14894 meany = fracy * SCIPvarGetPseudocost(vary, stat, realdirection);
14895
14896 variancex = SQR(fracx) * SCIPvarGetPseudocostVariance(varx, dir, FALSE);
14897 variancey = SQR(fracy) * SCIPvarGetPseudocostVariance(vary, dir, FALSE);
14898
14899 /* if there is no variance, the means are taken from a constant distribution */
14900 if( SCIPsetIsFeasEQ(set, variancex + variancey, 0.0) )
14901 return (onesided ? SCIPsetIsFeasGT(set, meanx, meany) : !SCIPsetIsFeasEQ(set, meanx, meany));
14902
14903 tresult = SCIPcomputeTwoSampleTTestValue(meanx, meany, variancex, variancey, countx, county);
14904
14905 /* for the two-sided hypothesis, just take the absolute of t */
14906 if( !onesided )
14907 tresult = REALABS(tresult);
14908
14909 return (tresult >= SCIPstudentTGetCriticalValue(clevel, (int)(countx + county - 2)));
14910}
14911
14912/** tests at a given confidence level whether the variable pseudo-costs only have a small probability to
14913 * exceed a \p threshold. This is useful to determine if past observations provide enough evidence
14914 * to skip an expensive strong-branching step if there is already a candidate that has been proven to yield an improvement
14915 * of at least \p threshold.
14916 *
14917 * @note use \p clevel to adjust the level of confidence. For SCIP_CONFIDENCELEVEL_MIN, the method returns TRUE if
14918 * the estimated probability to exceed \p threshold is less than 25 %.
14919 *
14920 * @see SCIP_Confidencelevel for a list of available levels. The used probability limits refer to the one-sided levels
14921 * of confidence.
14922 *
14923 * @return TRUE if the variable pseudo-cost probabilistic model is likely to be smaller than \p threshold
14924 * at the given confidence level \p clevel.
14925 */
14927 SCIP_SET* set, /**< global SCIP settings */
14928 SCIP_STAT* stat, /**< problem statistics */
14929 SCIP_VAR* var, /**< variable x */
14930 SCIP_Real frac, /**< the fractionality of variable x */
14931 SCIP_Real threshold, /**< the threshold to test against */
14932 SCIP_BRANCHDIR dir, /**< branching direction */
14933 SCIP_CONFIDENCELEVEL clevel /**< confidence level for rejecting hypothesis */
14934 )
14935{
14936 SCIP_Real mean;
14937 SCIP_Real variance;
14938 SCIP_Real count;
14939 SCIP_Real realdirection;
14940 SCIP_Real probability;
14941 SCIP_Real problimit;
14942
14943 count = SCIPvarGetPseudocostCount(var, dir);
14944
14945 /* if not at least 2 measurements were taken, return FALSE */
14946 if( count <= 1.9 )
14947 return FALSE;
14948
14949 realdirection = (dir == SCIP_BRANCHDIR_DOWNWARDS ? -1.0 : 1.0);
14950
14951 mean = frac * SCIPvarGetPseudocost(var, stat, realdirection);
14952 variance = SQR(frac) * SCIPvarGetPseudocostVariance(var, dir, FALSE);
14953
14954 /* if mean is at least threshold, it has at least a 50% probability to exceed threshold, we therefore return FALSE */
14955 if( SCIPsetIsFeasGE(set, mean, threshold) )
14956 return FALSE;
14957
14958 /* if there is no variance, the means are taken from a constant distribution */
14959 if( SCIPsetIsFeasEQ(set, variance, 0.0) )
14960 return SCIPsetIsFeasLT(set, mean, threshold);
14961
14962 /* obtain probability of a normally distributed random variable at given mean and variance to yield at most threshold */
14963 probability = SCIPnormalCDF(mean, variance, threshold);
14964
14965 /* determine a probability limit corresponding to the given confidence level */
14966 switch( clevel )
14967 {
14969 problimit = 0.75;
14970 break;
14972 problimit = 0.875;
14973 break;
14975 problimit = 0.9;
14976 break;
14978 problimit = 0.95;
14979 break;
14981 problimit = 0.975;
14982 break;
14983 default:
14984 problimit = -1;
14985 SCIPerrorMessage("Confidence level set to unknown value <%d>", (int)clevel);
14986 SCIPABORT();
14987 break;
14988 }
14989
14990 return (probability >= problimit);
14991}
14992
14993/** find the corresponding history entry if already existing, otherwise create new entry */
14994static
14996 SCIP_VAR* var, /**< problem variable */
14997 SCIP_Real value, /**< domain value, or SCIP_UNKNOWN */
14998 BMS_BLKMEM* blkmem, /**< block memory, or NULL if the domain value is SCIP_UNKNOWN */
14999 SCIP_SET* set, /**< global SCIP settings, or NULL if the domain value is SCIP_UNKNOWN */
15000 SCIP_HISTORY** history /**< pointer to store the value based history, or NULL */
15001 )
15002{
15003 assert(var != NULL);
15004 assert(blkmem != NULL);
15005 assert(set != NULL);
15006 assert(history != NULL);
15007
15008 (*history) = NULL;
15009
15010 if( var->valuehistory == NULL )
15011 {
15013 }
15014
15015 SCIP_CALL( SCIPvaluehistoryFind(var->valuehistory, blkmem, set, value, history) );
15016
15017 return SCIP_OKAY;
15018}
15019
15020/** check if value based history should be used */
15021static
15023 SCIP_VAR* var, /**< problem variable */
15024 SCIP_Real value, /**< domain value, or SCIP_UNKNOWN */
15025 SCIP_SET* set /**< global SCIP settings, or NULL if the domain value is SCIP_UNKNOWN */
15026 )
15027{
15028 /* check if the domain value is unknown (not specific) */
15029 if( value == SCIP_UNKNOWN ) /*lint !e777*/
15030 return FALSE;
15031
15032 assert(set != NULL);
15033
15034 /* check if value based history should be collected */
15035 if( !set->history_valuebased )
15036 return FALSE;
15037
15038 /* value based history is not collected for binary variable since the standard history already contains all information */
15040 return FALSE;
15041
15042 /* value based history is not collected for continuous variables */
15044 return FALSE;
15045
15046 return TRUE;
15047}
15048
15049/** increases VSIDS of the variable by the given weight */
15051 SCIP_VAR* var, /**< problem variable */
15052 BMS_BLKMEM* blkmem, /**< block memory, or NULL if the domain value is SCIP_UNKNOWN */
15053 SCIP_SET* set, /**< global SCIP settings, or NULL if the domain value is SCIP_UNKNOWN */
15054 SCIP_STAT* stat, /**< problem statistics */
15055 SCIP_BRANCHDIR dir, /**< branching direction */
15056 SCIP_Real value, /**< domain value, or SCIP_UNKNOWN */
15057 SCIP_Real weight /**< weight of this update in VSIDS */
15058 )
15059{
15060 assert(var != NULL);
15061 assert(dir == SCIP_BRANCHDIR_DOWNWARDS || dir == SCIP_BRANCHDIR_UPWARDS);
15062
15063 /* check if history statistics should be collected for a variable */
15064 if( !stat->collectvarhistory )
15065 return SCIP_OKAY;
15066
15067 if( SCIPsetIsZero(set, weight) )
15068 return SCIP_OKAY;
15069
15070 switch( SCIPvarGetStatus(var) )
15071 {
15073 if( var->data.original.transvar == NULL )
15074 {
15075 SCIPerrorMessage("cannot update VSIDS of original untransformed variable\n");
15076 return SCIP_INVALIDDATA;
15077 }
15078 SCIP_CALL( SCIPvarIncVSIDS(var->data.original.transvar, blkmem, set, stat, dir, value, weight) );
15079 return SCIP_OKAY;
15080
15083 {
15084 SCIPhistoryIncVSIDS(var->history, dir, weight);
15085 SCIPhistoryIncVSIDS(var->historycrun, dir, weight);
15086
15087 if( useValuehistory(var, value, set) )
15088 {
15089 SCIP_HISTORY* history;
15090
15091 SCIP_CALL( findValuehistoryEntry(var, value, blkmem, set, &history) );
15092 assert(history != NULL);
15093
15094 SCIPhistoryIncVSIDS(history, dir, weight);
15095 SCIPsetDebugMsg(set, "variable (<%s> %s %g) + <%g> = <%g>\n", SCIPvarGetName(var), dir == SCIP_BRANCHDIR_UPWARDS ? ">=" : "<=",
15096 value, weight, SCIPhistoryGetVSIDS(history, dir));
15097 }
15098
15099 return SCIP_OKAY;
15100 }
15102 SCIPerrorMessage("cannot update VSIDS of a fixed variable\n");
15103 return SCIP_INVALIDDATA;
15104
15106 value = (value - var->data.aggregate.constant)/var->data.aggregate.scalar;
15107
15108 if( var->data.aggregate.scalar > 0.0 )
15109 {
15110 SCIP_CALL( SCIPvarIncVSIDS(var->data.aggregate.var, blkmem, set, stat, dir, value, weight) );
15111 }
15112 else
15113 {
15114 assert(var->data.aggregate.scalar < 0.0);
15115 SCIP_CALL( SCIPvarIncVSIDS(var->data.aggregate.var, blkmem, set, stat, SCIPbranchdirOpposite(dir), value, weight) );
15116 }
15117 return SCIP_OKAY;
15118
15120 SCIPerrorMessage("cannot update VSIDS of a multi-aggregated variable\n");
15121 return SCIP_INVALIDDATA;
15122
15124 value = 1.0 - value;
15125
15126 SCIP_CALL( SCIPvarIncVSIDS(var->negatedvar, blkmem, set, stat, SCIPbranchdirOpposite(dir), value, weight) );
15127 return SCIP_OKAY;
15128
15129 default:
15130 SCIPerrorMessage("unknown variable status\n");
15131 return SCIP_INVALIDDATA;
15132 }
15133}
15134
15135/** scales the VSIDS of the variable by the given scalar */
15137 SCIP_VAR* var, /**< problem variable */
15138 SCIP_Real scalar /**< scalar to multiply the VSIDSs with */
15139 )
15140{
15141 assert(var != NULL);
15142
15143 switch( SCIPvarGetStatus(var) )
15144 {
15146 if( var->data.original.transvar == NULL )
15147 {
15148 SCIPerrorMessage("cannot update VSIDS of original untransformed variable\n");
15149 return SCIP_INVALIDDATA;
15150 }
15152 return SCIP_OKAY;
15153
15156 {
15157 SCIPhistoryScaleVSIDS(var->history, scalar);
15158 SCIPhistoryScaleVSIDS(var->historycrun, scalar);
15160
15161 return SCIP_OKAY;
15162 }
15164 SCIPerrorMessage("cannot update VSIDS of a fixed variable\n");
15165 return SCIP_INVALIDDATA;
15166
15168 SCIP_CALL( SCIPvarScaleVSIDS(var->data.aggregate.var, scalar) );
15169 return SCIP_OKAY;
15170
15172 SCIPerrorMessage("cannot update VSIDS of a multi-aggregated variable\n");
15173 return SCIP_INVALIDDATA;
15174
15176 SCIP_CALL( SCIPvarScaleVSIDS(var->negatedvar, scalar) );
15177 return SCIP_OKAY;
15178
15179 default:
15180 SCIPerrorMessage("unknown variable status\n");
15181 return SCIP_INVALIDDATA;
15182 }
15183}
15184
15185/** increases the number of active conflicts by one and the overall length of the variable by the given length */
15187 SCIP_VAR* var, /**< problem variable */
15188 BMS_BLKMEM* blkmem, /**< block memory, or NULL if the domain value is SCIP_UNKNOWN */
15189 SCIP_SET* set, /**< global SCIP settings, or NULL if the domain value is SCIP_UNKNOWN */
15190 SCIP_STAT* stat, /**< problem statistics */
15191 SCIP_BRANCHDIR dir, /**< branching direction */
15192 SCIP_Real value, /**< domain value, or SCIP_UNKNOWN */
15193 SCIP_Real length /**< length of the conflict */
15194 )
15195{
15196 assert(var != NULL);
15197 assert(dir == SCIP_BRANCHDIR_DOWNWARDS || dir == SCIP_BRANCHDIR_UPWARDS);
15198
15199 /* check if history statistics should be collected for a variable */
15200 if( !stat->collectvarhistory )
15201 return SCIP_OKAY;
15202
15203 switch( SCIPvarGetStatus(var) )
15204 {
15206 if( var->data.original.transvar == NULL )
15207 {
15208 SCIPerrorMessage("cannot update conflict score of original untransformed variable\n");
15209 return SCIP_INVALIDDATA;
15210 }
15211 SCIP_CALL( SCIPvarIncNActiveConflicts(var->data.original.transvar, blkmem, set, stat, dir, value, length) );
15212 return SCIP_OKAY;
15213
15216 {
15217 SCIPhistoryIncNActiveConflicts(var->history, dir, length);
15219
15220 if( useValuehistory(var, value, set) )
15221 {
15222 SCIP_HISTORY* history;
15223
15224 SCIP_CALL( findValuehistoryEntry(var, value, blkmem, set, &history) );
15225 assert(history != NULL);
15226
15227 SCIPhistoryIncNActiveConflicts(history, dir, length);
15228 }
15229
15230 return SCIP_OKAY;
15231 }
15233 SCIPerrorMessage("cannot update conflict score of a fixed variable\n");
15234 return SCIP_INVALIDDATA;
15235
15237 value = (value - var->data.aggregate.constant)/var->data.aggregate.scalar;
15238
15239 if( var->data.aggregate.scalar > 0.0 )
15240 {
15241 SCIP_CALL( SCIPvarIncNActiveConflicts(var->data.aggregate.var, blkmem, set, stat, dir, value, length) );
15242 }
15243 else
15244 {
15245 assert(var->data.aggregate.scalar < 0.0);
15246 SCIP_CALL( SCIPvarIncNActiveConflicts(var->data.aggregate.var, blkmem, set, stat, SCIPbranchdirOpposite(dir), value, length) );
15247 }
15248 return SCIP_OKAY;
15249
15251 SCIPerrorMessage("cannot update conflict score of a multi-aggregated variable\n");
15252 return SCIP_INVALIDDATA;
15253
15255 value = 1.0 - value;
15256
15257 SCIP_CALL( SCIPvarIncNActiveConflicts(var->negatedvar, blkmem, set, stat, SCIPbranchdirOpposite(dir), value, length) );
15258 return SCIP_OKAY;
15259
15260 default:
15261 SCIPerrorMessage("unknown variable status\n");
15262 return SCIP_INVALIDDATA;
15263 }
15264}
15265
15266/** gets the number of active conflicts containing this variable in given direction */
15268 SCIP_VAR* var, /**< problem variable */
15269 SCIP_STAT* stat, /**< problem statistics */
15270 SCIP_BRANCHDIR dir /**< branching direction (downwards, or upwards) */
15271 )
15272{
15273 assert(var != NULL);
15274 assert(stat != NULL);
15275 assert(dir == SCIP_BRANCHDIR_DOWNWARDS || dir == SCIP_BRANCHDIR_UPWARDS);
15276
15277 switch( SCIPvarGetStatus(var) )
15278 {
15280 if( var->data.original.transvar == NULL )
15281 return 0;
15282 else
15283 return SCIPvarGetNActiveConflicts(var->data.original.transvar, stat, dir);
15284
15287 return SCIPhistoryGetNActiveConflicts(var->history, dir);
15288
15290 return 0;
15291
15293 if( var->data.aggregate.scalar > 0.0 )
15294 return SCIPvarGetNActiveConflicts(var->data.aggregate.var, stat, dir);
15295 else
15297
15299 return 0;
15300
15303
15304 default:
15305 SCIPerrorMessage("unknown variable status\n");
15306 SCIPABORT();
15307 return 0; /*lint !e527*/
15308 }
15309}
15310
15311/** gets the number of active conflicts containing this variable in given direction
15312 * in the current run
15313 */
15315 SCIP_VAR* var, /**< problem variable */
15316 SCIP_STAT* stat, /**< problem statistics */
15317 SCIP_BRANCHDIR dir /**< branching direction (downwards, or upwards) */
15318 )
15319{
15320 assert(var != NULL);
15321 assert(stat != NULL);
15322 assert(dir == SCIP_BRANCHDIR_DOWNWARDS || dir == SCIP_BRANCHDIR_UPWARDS);
15323
15324 switch( SCIPvarGetStatus(var) )
15325 {
15327 if( var->data.original.transvar == NULL )
15328 return 0;
15329 else
15331
15335
15337 return 0;
15338
15340 if( var->data.aggregate.scalar > 0.0 )
15342 else
15344
15346 return 0;
15347
15350
15351 default:
15352 SCIPerrorMessage("unknown variable status\n");
15353 SCIPABORT();
15354 return 0; /*lint !e527*/
15355 }
15356}
15357
15358/** gets the average conflict length in given direction due to branching on the variable */
15360 SCIP_VAR* var, /**< problem variable */
15361 SCIP_BRANCHDIR dir /**< branching direction (downwards, or upwards) */
15362 )
15363{
15364 assert(var != NULL);
15365 assert(dir == SCIP_BRANCHDIR_DOWNWARDS || dir == SCIP_BRANCHDIR_UPWARDS);
15366
15367 switch( SCIPvarGetStatus(var) )
15368 {
15370 if( var->data.original.transvar == NULL )
15371 return 0.0;
15372 else
15374
15377 return SCIPhistoryGetAvgConflictlength(var->history, dir);
15379 return 0.0;
15380
15382 if( var->data.aggregate.scalar > 0.0 )
15384 else
15386
15388 return 0.0;
15389
15392
15393 default:
15394 SCIPerrorMessage("unknown variable status\n");
15395 SCIPABORT();
15396 return 0.0; /*lint !e527*/
15397 }
15398}
15399
15400/** gets the average conflict length in given direction due to branching on the variable
15401 * in the current run
15402 */
15404 SCIP_VAR* var, /**< problem variable */
15405 SCIP_BRANCHDIR dir /**< branching direction (downwards, or upwards) */
15406 )
15407{
15408 assert(var != NULL);
15409 assert(dir == SCIP_BRANCHDIR_DOWNWARDS || dir == SCIP_BRANCHDIR_UPWARDS);
15410
15411 switch( SCIPvarGetStatus(var) )
15412 {
15414 if( var->data.original.transvar == NULL )
15415 return 0.0;
15416 else
15418
15422
15424 return 0.0;
15425
15427 if( var->data.aggregate.scalar > 0.0 )
15429 else
15431
15433 return 0.0;
15434
15437
15438 default:
15439 SCIPerrorMessage("unknown variable status\n");
15440 SCIPABORT();
15441 return 0.0; /*lint !e527*/
15442 }
15443}
15444
15445/** increases the number of branchings counter of the variable */
15447 SCIP_VAR* var, /**< problem variable */
15448 BMS_BLKMEM* blkmem, /**< block memory, or NULL if the domain value is SCIP_UNKNOWN */
15449 SCIP_SET* set, /**< global SCIP settings, or NULL if the domain value is SCIP_UNKNOWN */
15450 SCIP_STAT* stat, /**< problem statistics */
15451 SCIP_BRANCHDIR dir, /**< branching direction (downwards, or upwards) */
15452 SCIP_Real value, /**< domain value, or SCIP_UNKNOWN */
15453 int depth /**< depth at which the bound change took place */
15454 )
15455{
15456 assert(var != NULL);
15457 assert(stat != NULL);
15458 assert(dir == SCIP_BRANCHDIR_DOWNWARDS || dir == SCIP_BRANCHDIR_UPWARDS);
15459
15460 /* check if history statistics should be collected for a variable */
15461 if( !stat->collectvarhistory )
15462 return SCIP_OKAY;
15463
15464 switch( SCIPvarGetStatus(var) )
15465 {
15467 if( var->data.original.transvar == NULL )
15468 {
15469 SCIPerrorMessage("cannot update branching counter of original untransformed variable\n");
15470 return SCIP_INVALIDDATA;
15471 }
15472 SCIP_CALL( SCIPvarIncNBranchings(var->data.original.transvar, blkmem, set, stat, dir, value, depth) );
15473 return SCIP_OKAY;
15474
15477 {
15478 SCIPhistoryIncNBranchings(var->history, dir, depth);
15479 SCIPhistoryIncNBranchings(var->historycrun, dir, depth);
15480 SCIPhistoryIncNBranchings(stat->glbhistory, dir, depth);
15481 SCIPhistoryIncNBranchings(stat->glbhistorycrun, dir, depth);
15482
15483 if( useValuehistory(var, value, set) )
15484 {
15485 SCIP_HISTORY* history;
15486
15487 SCIP_CALL( findValuehistoryEntry(var, value, blkmem, set, &history) );
15488 assert(history != NULL);
15489
15490 SCIPhistoryIncNBranchings(history, dir, depth);
15491 }
15492
15493 return SCIP_OKAY;
15494 }
15496 SCIPerrorMessage("cannot update branching counter of a fixed variable\n");
15497 return SCIP_INVALIDDATA;
15498
15500 value = (value - var->data.aggregate.constant)/var->data.aggregate.scalar;
15501
15502 if( var->data.aggregate.scalar > 0.0 )
15503 {
15504 SCIP_CALL( SCIPvarIncNBranchings(var->data.aggregate.var, blkmem, set, stat, dir, value, depth) );
15505 }
15506 else
15507 {
15508 assert(var->data.aggregate.scalar < 0.0);
15509 SCIP_CALL( SCIPvarIncNBranchings(var->data.aggregate.var, blkmem, set, stat, SCIPbranchdirOpposite(dir), value, depth) );
15510 }
15511 return SCIP_OKAY;
15512
15514 SCIPerrorMessage("cannot update branching counter of a multi-aggregated variable\n");
15515 return SCIP_INVALIDDATA;
15516
15518 value = 1.0 - value;
15519
15520 SCIP_CALL( SCIPvarIncNBranchings(var->negatedvar, blkmem, set, stat, SCIPbranchdirOpposite(dir), value, depth) );
15521 return SCIP_OKAY;
15522
15523 default:
15524 SCIPerrorMessage("unknown variable status\n");
15525 return SCIP_INVALIDDATA;
15526 }
15527}
15528
15529/** increases the inference sum of the variable by the given weight */
15531 SCIP_VAR* var, /**< problem variable */
15532 BMS_BLKMEM* blkmem, /**< block memory, or NULL if the domain value is SCIP_UNKNOWN */
15533 SCIP_SET* set, /**< global SCIP settings, or NULL if the domain value is SCIP_UNKNOWN */
15534 SCIP_STAT* stat, /**< problem statistics */
15535 SCIP_BRANCHDIR dir, /**< branching direction (downwards, or upwards) */
15536 SCIP_Real value, /**< domain value, or SCIP_UNKNOWN */
15537 SCIP_Real weight /**< weight of this update in inference score */
15538 )
15539{
15540 assert(var != NULL);
15541 assert(stat != NULL);
15542 assert(dir == SCIP_BRANCHDIR_DOWNWARDS || dir == SCIP_BRANCHDIR_UPWARDS);
15543
15544 /* check if history statistics should be collected for a variable */
15545 if( !stat->collectvarhistory )
15546 return SCIP_OKAY;
15547
15548 switch( SCIPvarGetStatus(var) )
15549 {
15551 if( var->data.original.transvar == NULL )
15552 {
15553 SCIPerrorMessage("cannot update inference counter of original untransformed variable\n");
15554 return SCIP_INVALIDDATA;
15555 }
15556 SCIP_CALL( SCIPvarIncInferenceSum(var->data.original.transvar, blkmem, set, stat, dir, value, weight) );
15557 return SCIP_OKAY;
15558
15561 {
15562 SCIPhistoryIncInferenceSum(var->history, dir, weight);
15563 SCIPhistoryIncInferenceSum(var->historycrun, dir, weight);
15564 SCIPhistoryIncInferenceSum(stat->glbhistory, dir, weight);
15565 SCIPhistoryIncInferenceSum(stat->glbhistorycrun, dir, weight);
15566
15567 if( useValuehistory(var, value, set) )
15568 {
15569 SCIP_HISTORY* history;
15570
15571 SCIP_CALL( findValuehistoryEntry(var, value, blkmem, set, &history) );
15572 assert(history != NULL);
15573
15574 SCIPhistoryIncInferenceSum(history, dir, weight);
15575 }
15576
15577 return SCIP_OKAY;
15578 }
15580 SCIPerrorMessage("cannot update inference counter of a fixed variable\n");
15581 return SCIP_INVALIDDATA;
15582
15584 value = (value - var->data.aggregate.constant)/var->data.aggregate.scalar;
15585
15586 if( var->data.aggregate.scalar > 0.0 )
15587 {
15588 SCIP_CALL( SCIPvarIncInferenceSum(var->data.aggregate.var, blkmem, set, stat, dir, value, weight) );
15589 }
15590 else
15591 {
15592 assert(var->data.aggregate.scalar < 0.0);
15593 SCIP_CALL( SCIPvarIncInferenceSum(var->data.aggregate.var, blkmem, set, stat, SCIPbranchdirOpposite(dir), value, weight) );
15594 }
15595 return SCIP_OKAY;
15596
15598 SCIPerrorMessage("cannot update inference counter of a multi-aggregated variable\n");
15599 return SCIP_INVALIDDATA;
15600
15602 value = 1.0 - value;
15603
15604 SCIP_CALL( SCIPvarIncInferenceSum(var->negatedvar, blkmem, set, stat, SCIPbranchdirOpposite(dir), value, weight) );
15605 return SCIP_OKAY;
15606
15607 default:
15608 SCIPerrorMessage("unknown variable status\n");
15609 return SCIP_INVALIDDATA;
15610 }
15611}
15612
15613/** increases the cutoff sum of the variable by the given weight */
15615 SCIP_VAR* var, /**< problem variable */
15616 BMS_BLKMEM* blkmem, /**< block memory, or NULL if the domain value is SCIP_UNKNOWN */
15617 SCIP_SET* set, /**< global SCIP settings, or NULL if the domain value is SCIP_UNKNOWN */
15618 SCIP_STAT* stat, /**< problem statistics */
15619 SCIP_BRANCHDIR dir, /**< branching direction (downwards, or upwards) */
15620 SCIP_Real value, /**< domain value, or SCIP_UNKNOWN */
15621 SCIP_Real weight /**< weight of this update in cutoff score */
15622 )
15623{
15624 assert(var != NULL);
15625 assert(stat != NULL);
15626 assert(dir == SCIP_BRANCHDIR_DOWNWARDS || dir == SCIP_BRANCHDIR_UPWARDS);
15627
15628 /* check if history statistics should be collected for a variable */
15629 if( !stat->collectvarhistory )
15630 return SCIP_OKAY;
15631
15632 switch( SCIPvarGetStatus(var) )
15633 {
15635 if( var->data.original.transvar == NULL )
15636 {
15637 SCIPerrorMessage("cannot update cutoff sum of original untransformed variable\n");
15638 return SCIP_INVALIDDATA;
15639 }
15640 SCIP_CALL( SCIPvarIncCutoffSum(var->data.original.transvar, blkmem, set, stat, dir, value, weight) );
15641 return SCIP_OKAY;
15642
15645 {
15646 SCIPhistoryIncCutoffSum(var->history, dir, weight);
15647 SCIPhistoryIncCutoffSum(var->historycrun, dir, weight);
15648 SCIPhistoryIncCutoffSum(stat->glbhistory, dir, weight);
15649 SCIPhistoryIncCutoffSum(stat->glbhistorycrun, dir, weight);
15650
15651 if( useValuehistory(var, value, set) )
15652 {
15653 SCIP_HISTORY* history;
15654
15655 SCIP_CALL( findValuehistoryEntry(var, value, blkmem, set, &history) );
15656 assert(history != NULL);
15657
15658 SCIPhistoryIncCutoffSum(history, dir, weight);
15659 }
15660
15661 return SCIP_OKAY;
15662 }
15664 SCIPerrorMessage("cannot update cutoff sum of a fixed variable\n");
15665 return SCIP_INVALIDDATA;
15666
15668 value = (value - var->data.aggregate.constant)/var->data.aggregate.scalar;
15669
15670 if( var->data.aggregate.scalar > 0.0 )
15671 {
15672 SCIP_CALL( SCIPvarIncCutoffSum(var->data.aggregate.var, blkmem, set, stat, dir, value, weight) );
15673 }
15674 else
15675 {
15676 assert(var->data.aggregate.scalar < 0.0);
15677 SCIP_CALL( SCIPvarIncCutoffSum(var->data.aggregate.var, blkmem, set, stat, SCIPbranchdirOpposite(dir), value, weight) );
15678 }
15679 return SCIP_OKAY;
15680
15682 SCIPerrorMessage("cannot update cutoff sum of a multi-aggregated variable\n");
15683 return SCIP_INVALIDDATA;
15684
15686 value = 1.0 - value;
15687
15688 SCIP_CALL( SCIPvarIncCutoffSum(var->negatedvar, blkmem, set, stat, SCIPbranchdirOpposite(dir), value, weight) );
15689 return SCIP_OKAY;
15690
15691 default:
15692 SCIPerrorMessage("unknown variable status\n");
15693 return SCIP_INVALIDDATA;
15694 }
15695}
15696
15697/** returns the number of times, a bound of the variable was changed in given direction due to branching */
15699 SCIP_VAR* var, /**< problem variable */
15700 SCIP_BRANCHDIR dir /**< branching direction (downwards, or upwards) */
15701 )
15702{
15703 assert(var != NULL);
15704 assert(dir == SCIP_BRANCHDIR_DOWNWARDS || dir == SCIP_BRANCHDIR_UPWARDS);
15705
15706 switch( SCIPvarGetStatus(var) )
15707 {
15709 if( var->data.original.transvar == NULL )
15710 return 0;
15711 else
15712 return SCIPvarGetNBranchings(var->data.original.transvar, dir);
15713
15716 return SCIPhistoryGetNBranchings(var->history, dir);
15717
15719 return 0;
15720
15722 if( var->data.aggregate.scalar > 0.0 )
15723 return SCIPvarGetNBranchings(var->data.aggregate.var, dir);
15724 else
15726
15728 return 0;
15729
15732
15733 default:
15734 SCIPerrorMessage("unknown variable status\n");
15735 SCIPABORT();
15736 return 0; /*lint !e527*/
15737 }
15738}
15739
15740/** returns the number of times, a bound of the variable was changed in given direction due to branching
15741 * in the current run
15742 */
15744 SCIP_VAR* var, /**< problem variable */
15745 SCIP_BRANCHDIR dir /**< branching direction (downwards, or upwards) */
15746 )
15747{
15748 assert(var != NULL);
15749 assert(dir == SCIP_BRANCHDIR_DOWNWARDS || dir == SCIP_BRANCHDIR_UPWARDS);
15750
15751 switch( SCIPvarGetStatus(var) )
15752 {
15754 if( var->data.original.transvar == NULL )
15755 return 0;
15756 else
15758
15761 return SCIPhistoryGetNBranchings(var->historycrun, dir);
15762
15764 return 0;
15765
15767 if( var->data.aggregate.scalar > 0.0 )
15769 else
15771
15773 return 0;
15774
15777
15778 default:
15779 SCIPerrorMessage("unknown variable status\n");
15780 SCIPABORT();
15781 return 0; /*lint !e527*/
15782 }
15783}
15784
15785/** returns the average depth of bound changes in given direction due to branching on the variable */
15787 SCIP_VAR* var, /**< problem variable */
15788 SCIP_BRANCHDIR dir /**< branching direction (downwards, or upwards) */
15789 )
15790{
15791 assert(var != NULL);
15792 assert(dir == SCIP_BRANCHDIR_DOWNWARDS || dir == SCIP_BRANCHDIR_UPWARDS);
15793
15794 switch( SCIPvarGetStatus(var) )
15795 {
15797 if( var->data.original.transvar == NULL )
15798 return 0.0;
15799 else
15801
15804 return SCIPhistoryGetAvgBranchdepth(var->history, dir);
15805
15807 return 0.0;
15808
15810 if( var->data.aggregate.scalar > 0.0 )
15811 return SCIPvarGetAvgBranchdepth(var->data.aggregate.var, dir);
15812 else
15814
15816 return 0.0;
15817
15820
15821 default:
15822 SCIPerrorMessage("unknown variable status\n");
15823 SCIPABORT();
15824 return 0.0; /*lint !e527*/
15825 }
15826}
15827
15828/** returns the average depth of bound changes in given direction due to branching on the variable
15829 * in the current run
15830 */
15832 SCIP_VAR* var, /**< problem variable */
15833 SCIP_BRANCHDIR dir /**< branching direction (downwards, or upwards) */
15834 )
15835{
15836 assert(var != NULL);
15837 assert(dir == SCIP_BRANCHDIR_DOWNWARDS || dir == SCIP_BRANCHDIR_UPWARDS);
15838
15839 switch( SCIPvarGetStatus(var) )
15840 {
15842 if( var->data.original.transvar == NULL )
15843 return 0.0;
15844 else
15846
15849 return SCIPhistoryGetAvgBranchdepth(var->historycrun, dir);
15850
15852 return 0.0;
15853
15855 if( var->data.aggregate.scalar > 0.0 )
15857 else
15860
15862 return 0.0;
15863
15867
15868 default:
15869 SCIPerrorMessage("unknown variable status\n");
15870 SCIPABORT();
15871 return 0.0; /*lint !e527*/
15872 }
15873}
15874
15875/** returns the variable's VSIDS score */
15877 SCIP_VAR* var, /**< problem variable */
15878 SCIP_STAT* stat, /**< problem statistics */
15879 SCIP_BRANCHDIR dir /**< branching direction (downwards, or upwards) */
15880 )
15881{
15882 assert(var != NULL);
15883 assert(stat != NULL);
15884 assert(dir == SCIP_BRANCHDIR_DOWNWARDS || dir == SCIP_BRANCHDIR_UPWARDS);
15885
15887 return SCIPvarGetVSIDS(var->data.original.transvar, stat, dir);
15888
15889 switch( SCIPvarGetStatus(var) )
15890 {
15892 if( var->data.original.transvar == NULL )
15893 return 0.0;
15894 else
15895 return SCIPvarGetVSIDS(var->data.original.transvar, stat, dir);
15896
15899 assert(SCIPvarGetStatus(var) == SCIP_VARSTATUS_LOOSE); /* column case already handled in if condition above */
15900 return SCIPhistoryGetVSIDS(var->history, dir)/stat->vsidsweight;
15901
15903 return 0.0;
15904
15906 if( var->data.aggregate.scalar > 0.0 )
15907 return SCIPvarGetVSIDS(var->data.aggregate.var, stat, dir);
15908 else
15909 /* coverity[overrun-local] */
15910 return SCIPvarGetVSIDS(var->data.aggregate.var, stat, SCIPbranchdirOpposite(dir));
15911
15913 return 0.0;
15914
15916 /* coverity[overrun-local] */
15917 return SCIPvarGetVSIDS(var->negatedvar, stat, SCIPbranchdirOpposite(dir));
15918
15919 default:
15920 SCIPerrorMessage("unknown variable status\n");
15921 SCIPABORT();
15922 return 0.0; /*lint !e527*/
15923 }
15924}
15925
15926/** returns the variable's VSIDS score only using conflicts of the current run */
15928 SCIP_VAR* var, /**< problem variable */
15929 SCIP_STAT* stat, /**< problem statistics */
15930 SCIP_BRANCHDIR dir /**< branching direction (downwards, or upwards) */
15931 )
15932{
15933 assert(var != NULL);
15934 assert(stat != NULL);
15935 assert(dir == SCIP_BRANCHDIR_DOWNWARDS || dir == SCIP_BRANCHDIR_UPWARDS);
15936
15938 {
15939 SCIPerrorMessage("invalid branching direction %d when asking for VSIDS value\n", dir);
15940 return SCIP_INVALID;
15941 }
15942
15943 switch( SCIPvarGetStatus(var) )
15944 {
15946 if( var->data.original.transvar == NULL )
15947 return 0.0;
15948 else
15949 return SCIPvarGetVSIDSCurrentRun(var->data.original.transvar, stat, dir);
15950
15953 return SCIPhistoryGetVSIDS(var->historycrun, dir)/stat->vsidsweight;
15954
15956 return 0.0;
15957
15959 if( var->data.aggregate.scalar > 0.0 )
15960 return SCIPvarGetVSIDSCurrentRun(var->data.aggregate.var, stat, dir);
15961 else
15963
15965 return 0.0;
15966
15969
15970 default:
15971 SCIPerrorMessage("unknown variable status\n");
15972 SCIPABORT();
15973 return 0.0; /*lint !e527*/
15974 }
15975}
15976
15977/** returns the number of inferences branching on this variable in given direction triggered */
15979 SCIP_VAR* var, /**< problem variable */
15980 SCIP_BRANCHDIR dir /**< branching direction (downwards, or upwards) */
15981 )
15982{
15983 assert(var != NULL);
15984 assert(dir == SCIP_BRANCHDIR_DOWNWARDS || dir == SCIP_BRANCHDIR_UPWARDS);
15985
15986 switch( SCIPvarGetStatus(var) )
15987 {
15989 if( var->data.original.transvar == NULL )
15990 return 0.0;
15991 else
15992 return SCIPvarGetInferenceSum(var->data.original.transvar, dir);
15993
15996 return SCIPhistoryGetInferenceSum(var->history, dir);
15997
15999 return 0.0;
16000
16002 if( var->data.aggregate.scalar > 0.0 )
16003 return SCIPvarGetInferenceSum(var->data.aggregate.var, dir);
16004 else
16006
16008 return 0.0;
16009
16012
16013 default:
16014 SCIPerrorMessage("unknown variable status\n");
16015 SCIPABORT();
16016 return 0.0; /*lint !e527*/
16017 }
16018}
16019
16020/** returns the number of inferences branching on this variable in given direction triggered
16021 * in the current run
16022 */
16024 SCIP_VAR* var, /**< problem variable */
16025 SCIP_BRANCHDIR dir /**< branching direction (downwards, or upwards) */
16026 )
16027{
16028 assert(var != NULL);
16029 assert(dir == SCIP_BRANCHDIR_DOWNWARDS || dir == SCIP_BRANCHDIR_UPWARDS);
16030
16031 switch( SCIPvarGetStatus(var) )
16032 {
16034 if( var->data.original.transvar == NULL )
16035 return 0.0;
16036 else
16038
16041 return SCIPhistoryGetInferenceSum(var->historycrun, dir);
16042
16044 return 0.0;
16045
16047 if( var->data.aggregate.scalar > 0.0 )
16049 else
16051
16053 return 0.0;
16054
16057
16058 default:
16059 SCIPerrorMessage("unknown variable status\n");
16060 SCIPABORT();
16061 return 0.0; /*lint !e527*/
16062 }
16063}
16064
16065/** returns the average number of inferences found after branching on the variable in given direction */
16067 SCIP_VAR* var, /**< problem variable */
16068 SCIP_STAT* stat, /**< problem statistics */
16069 SCIP_BRANCHDIR dir /**< branching direction (downwards, or upwards) */
16070 )
16071{
16072 assert(var != NULL);
16073 assert(stat != NULL);
16074 assert(dir == SCIP_BRANCHDIR_DOWNWARDS || dir == SCIP_BRANCHDIR_UPWARDS);
16075
16076 switch( SCIPvarGetStatus(var) )
16077 {
16079 if( var->data.original.transvar == NULL )
16080 return SCIPhistoryGetAvgInferences(stat->glbhistory, dir);
16081 else
16082 return SCIPvarGetAvgInferences(var->data.original.transvar, stat, dir);
16083
16086 if( SCIPhistoryGetNBranchings(var->history, dir) > 0 )
16087 return SCIPhistoryGetAvgInferences(var->history, dir);
16088 else
16089 {
16090 int nimpls;
16091 int ncliques;
16092
16093 nimpls = SCIPvarGetNImpls(var, dir == SCIP_BRANCHDIR_UPWARDS);
16094 ncliques = SCIPvarGetNCliques(var, dir == SCIP_BRANCHDIR_UPWARDS);
16095 return nimpls + ncliques > 0 ? (SCIP_Real)(nimpls + 2*ncliques) : SCIPhistoryGetAvgInferences(stat->glbhistory, dir); /*lint !e790*/
16096 }
16097
16099 return 0.0;
16100
16102 if( var->data.aggregate.scalar > 0.0 )
16103 return SCIPvarGetAvgInferences(var->data.aggregate.var, stat, dir);
16104 else
16106
16108 return 0.0;
16109
16112
16113 default:
16114 SCIPerrorMessage("unknown variable status\n");
16115 SCIPABORT();
16116 return 0.0; /*lint !e527*/
16117 }
16118}
16119
16120/** returns the average number of inferences found after branching on the variable in given direction
16121 * in the current run
16122 */
16124 SCIP_VAR* var, /**< problem variable */
16125 SCIP_STAT* stat, /**< problem statistics */
16126 SCIP_BRANCHDIR dir /**< branching direction (downwards, or upwards) */
16127 )
16128{
16129 assert(var != NULL);
16130 assert(stat != NULL);
16131 assert(dir == SCIP_BRANCHDIR_DOWNWARDS || dir == SCIP_BRANCHDIR_UPWARDS);
16132
16133 switch( SCIPvarGetStatus(var) )
16134 {
16136 if( var->data.original.transvar == NULL )
16138 else
16140
16143 if( SCIPhistoryGetNBranchings(var->historycrun, dir) > 0 )
16144 return SCIPhistoryGetAvgInferences(var->historycrun, dir);
16145 else
16146 {
16147 int nimpls;
16148 int ncliques;
16149
16150 nimpls = SCIPvarGetNImpls(var, dir == SCIP_BRANCHDIR_UPWARDS);
16151 ncliques = SCIPvarGetNCliques(var, dir == SCIP_BRANCHDIR_UPWARDS);
16152 return nimpls + ncliques > 0 ? (SCIP_Real)(nimpls + 2*ncliques) : SCIPhistoryGetAvgInferences(stat->glbhistorycrun, dir); /*lint !e790*/
16153 }
16154
16156 return 0.0;
16157
16159 if( var->data.aggregate.scalar > 0.0 )
16160 return SCIPvarGetAvgInferencesCurrentRun(var->data.aggregate.var, stat, dir);
16161 else
16163
16165 return 0.0;
16166
16169
16170 default:
16171 SCIPerrorMessage("unknown variable status\n");
16172 SCIPABORT();
16173 return 0.0; /*lint !e527*/
16174 }
16175}
16176
16177/** returns the number of cutoffs branching on this variable in given direction produced */
16179 SCIP_VAR* var, /**< problem variable */
16180 SCIP_BRANCHDIR dir /**< branching direction (downwards, or upwards) */
16181 )
16182{
16183 assert(var != NULL);
16184 assert(dir == SCIP_BRANCHDIR_DOWNWARDS || dir == SCIP_BRANCHDIR_UPWARDS);
16185
16186 switch( SCIPvarGetStatus(var) )
16187 {
16189 if( var->data.original.transvar == NULL )
16190 return 0;
16191 else
16192 return SCIPvarGetCutoffSum(var->data.original.transvar, dir);
16193
16196 return SCIPhistoryGetCutoffSum(var->history, dir);
16197
16199 return 0;
16200
16202 if( var->data.aggregate.scalar > 0.0 )
16203 return SCIPvarGetCutoffSum(var->data.aggregate.var, dir);
16204 else
16206
16208 return 0;
16209
16212
16213 default:
16214 SCIPerrorMessage("unknown variable status\n");
16215 SCIPABORT();
16216 return 0; /*lint !e527*/
16217 }
16218}
16219
16220/** returns the number of cutoffs branching on this variable in given direction produced in the current run */
16222 SCIP_VAR* var, /**< problem variable */
16223 SCIP_BRANCHDIR dir /**< branching direction (downwards, or upwards) */
16224 )
16225{
16226 assert(var != NULL);
16227 assert(dir == SCIP_BRANCHDIR_DOWNWARDS || dir == SCIP_BRANCHDIR_UPWARDS);
16228
16229 switch( SCIPvarGetStatus(var) )
16230 {
16232 if( var->data.original.transvar == NULL )
16233 return 0;
16234 else
16236
16239 return SCIPhistoryGetCutoffSum(var->historycrun, dir);
16240
16242 return 0;
16243
16245 if( var->data.aggregate.scalar > 0.0 )
16247 else
16249
16251 return 0;
16252
16255
16256 default:
16257 SCIPerrorMessage("unknown variable status\n");
16258 SCIPABORT();
16259 return 0; /*lint !e527*/
16260 }
16261}
16262
16263/** returns the average number of cutoffs found after branching on the variable in given direction */
16265 SCIP_VAR* var, /**< problem variable */
16266 SCIP_STAT* stat, /**< problem statistics */
16267 SCIP_BRANCHDIR dir /**< branching direction (downwards, or upwards) */
16268 )
16269{
16270 assert(var != NULL);
16271 assert(stat != NULL);
16272 assert(dir == SCIP_BRANCHDIR_DOWNWARDS || dir == SCIP_BRANCHDIR_UPWARDS);
16273
16274 switch( SCIPvarGetStatus(var) )
16275 {
16277 if( var->data.original.transvar == NULL )
16278 return SCIPhistoryGetAvgCutoffs(stat->glbhistory, dir);
16279 else
16280 return SCIPvarGetAvgCutoffs(var->data.original.transvar, stat, dir);
16281
16284 return SCIPhistoryGetNBranchings(var->history, dir) > 0
16287
16289 return 0.0;
16290
16292 if( var->data.aggregate.scalar > 0.0 )
16293 return SCIPvarGetAvgCutoffs(var->data.aggregate.var, stat, dir);
16294 else
16296
16298 return 0.0;
16299
16301 return SCIPvarGetAvgCutoffs(var->negatedvar, stat, SCIPbranchdirOpposite(dir));
16302
16303 default:
16304 SCIPerrorMessage("unknown variable status\n");
16305 SCIPABORT();
16306 return 0.0; /*lint !e527*/
16307 }
16308}
16309
16310/** returns the average number of cutoffs found after branching on the variable in given direction in the current run */
16312 SCIP_VAR* var, /**< problem variable */
16313 SCIP_STAT* stat, /**< problem statistics */
16314 SCIP_BRANCHDIR dir /**< branching direction (downwards, or upwards) */
16315 )
16316{
16317 assert(var != NULL);
16318 assert(stat != NULL);
16319 assert(dir == SCIP_BRANCHDIR_DOWNWARDS || dir == SCIP_BRANCHDIR_UPWARDS);
16320
16321 switch( SCIPvarGetStatus(var) )
16322 {
16324 if( var->data.original.transvar == NULL )
16325 return SCIPhistoryGetAvgCutoffs(stat->glbhistorycrun, dir);
16326 else
16327 return SCIPvarGetAvgCutoffsCurrentRun(var->data.original.transvar, stat, dir);
16328
16331 return SCIPhistoryGetNBranchings(var->historycrun, dir) > 0
16334
16336 return 0.0;
16337
16339 if( var->data.aggregate.scalar > 0.0 )
16340 return SCIPvarGetAvgCutoffsCurrentRun(var->data.aggregate.var, stat, dir);
16341 else
16343
16345 return 0.0;
16346
16349
16350 default:
16351 SCIPerrorMessage("unknown variable status\n");
16352 SCIPABORT();
16353 return 0.0; /*lint !e527*/
16354 }
16355}
16356
16357/** returns the variable's average GMI efficacy score value generated from simplex tableau rows of this variable */
16359 SCIP_VAR* var, /**< problem variable */
16360 SCIP_STAT* stat /**< problem statistics */
16361 )
16362{
16363 assert(var != NULL);
16364 assert(stat != NULL);
16365
16366 switch( SCIPvarGetStatus(var) )
16367 {
16369 if( var->data.original.transvar == NULL )
16370 return 0.0;
16371 else
16372 return SCIPvarGetAvgGMIScore(var->data.original.transvar, stat);
16373
16376 return SCIPhistoryGetAvgGMIeff(var->history);
16377
16379 return 0.0;
16380
16382 return SCIPvarGetAvgGMIScore(var->data.aggregate.var, stat);
16383
16385 return 0.0;
16386
16388 return SCIPvarGetAvgGMIScore(var->negatedvar, stat);
16389
16390 default:
16391 SCIPerrorMessage("unknown variable status\n");
16392 SCIPABORT();
16393 return 0.0; /*lint !e527*/
16394 }
16395}
16396
16397/** increase the variable's GMI efficacy scores generated from simplex tableau rows of this variable */
16399 SCIP_VAR* var, /**< problem variable */
16400 SCIP_STAT* stat, /**< problem statistics */
16401 SCIP_Real gmieff /**< efficacy of last GMI cut produced when variable was frac and basic */
16402 )
16403{
16404 assert(var != NULL);
16405 assert(stat != NULL);
16406 assert(gmieff >= 0);
16407
16408 switch( SCIPvarGetStatus(var) )
16409 {
16411 if( var->data.original.transvar != NULL )
16412 SCIP_CALL( SCIPvarIncGMIeffSum(var->data.original.transvar, stat, gmieff) );
16413 return SCIP_OKAY;
16414
16417 SCIPhistoryIncGMIeffSum(var->history, gmieff);
16418 return SCIP_OKAY;
16419
16421 return SCIP_INVALIDDATA;
16422
16424 SCIP_CALL( SCIPvarIncGMIeffSum(var->data.aggregate.var, stat, gmieff) );
16425 return SCIP_OKAY;
16426
16428 SCIP_CALL( SCIPvarIncGMIeffSum(var->negatedvar, stat, gmieff) );
16429 return SCIP_OKAY;
16430
16432 return SCIP_INVALIDDATA;
16433
16434 default:
16435 SCIPerrorMessage("unknown variable status\n");
16436 SCIPABORT();
16437 return SCIP_INVALIDDATA; /*lint !e527*/
16438 }
16439}
16440
16441/** returns the variable's last GMI efficacy score value generated from a simplex tableau row of this variable */
16443 SCIP_VAR* var, /**< problem variable */
16444 SCIP_STAT* stat /**< problem statistics */
16445 )
16446{
16447 assert(var != NULL);
16448 assert(stat != NULL);
16449
16450 switch( SCIPvarGetStatus(var) )
16451 {
16453 if( var->data.original.transvar != NULL )
16454 return SCIPvarGetLastGMIScore(var->data.original.transvar, stat);
16455 return 0.0;
16456
16459 return SCIPhistoryGetLastGMIeff(var->history);
16460
16462 return 0.0;
16463
16465 return SCIPvarGetLastGMIScore(var->data.aggregate.var, stat);
16466
16468 return 0.0;
16469
16471 return SCIPvarGetLastGMIScore(var->negatedvar, stat);
16472
16473 default:
16474 SCIPerrorMessage("unknown variable status\n");
16475 SCIPABORT();
16476 return 0.0; /*lint !e527*/
16477 }
16478}
16479
16480
16481/** sets the variable's last GMI efficacy score value generated from a simplex tableau row of this variable */
16483 SCIP_VAR* var, /**< problem variable */
16484 SCIP_STAT* stat, /**< problem statistics */
16485 SCIP_Real gmieff /**< efficacy of last GMI cut produced when variable was frac and basic */
16486 )
16487{
16488 assert(var != NULL);
16489 assert(stat != NULL);
16490 assert(gmieff >= 0);
16491
16492 switch( SCIPvarGetStatus(var) )
16493 {
16495 if( var->data.original.transvar != NULL )
16496 SCIP_CALL( SCIPvarSetLastGMIScore(var->data.original.transvar, stat, gmieff) );
16497 return SCIP_OKAY;
16498
16501 SCIPhistorySetLastGMIeff(var->history, gmieff);
16502 return SCIP_OKAY;
16503
16505 return SCIP_INVALIDDATA;
16506
16508 SCIP_CALL( SCIPvarSetLastGMIScore(var->data.aggregate.var, stat, gmieff) );
16509 return SCIP_OKAY;
16510
16512 SCIP_CALL( SCIPvarSetLastGMIScore(var->negatedvar, stat, gmieff) );
16513 return SCIP_OKAY;
16514
16516 return SCIP_INVALIDDATA;
16517
16518 default:
16519 SCIPerrorMessage("unknown variable status\n");
16520 SCIPABORT();
16521 return SCIP_INVALIDDATA; /*lint !e527*/
16522 }
16523}
16524
16525
16526
16527/*
16528 * information methods for bound changes
16529 */
16530
16531/** creates an artificial bound change information object with depth = INT_MAX and pos = -1 */
16533 SCIP_BDCHGINFO** bdchginfo, /**< pointer to store bound change information */
16534 BMS_BLKMEM* blkmem, /**< block memory */
16535 SCIP_VAR* var, /**< active variable that changed the bounds */
16536 SCIP_BOUNDTYPE boundtype, /**< type of bound for var: lower or upper bound */
16537 SCIP_Real oldbound, /**< old value for bound */
16538 SCIP_Real newbound /**< new value for bound */
16539 )
16540{
16541 assert(bdchginfo != NULL);
16542
16543 SCIP_ALLOC( BMSallocBlockMemory(blkmem, bdchginfo) );
16544 (*bdchginfo)->oldbound = oldbound;
16545 (*bdchginfo)->newbound = newbound;
16546 (*bdchginfo)->var = var;
16547 (*bdchginfo)->inferencedata.var = var;
16548 (*bdchginfo)->inferencedata.reason.prop = NULL;
16549 (*bdchginfo)->inferencedata.info = 0;
16550 (*bdchginfo)->bdchgidx.depth = INT_MAX;
16551 (*bdchginfo)->bdchgidx.pos = -1;
16552 (*bdchginfo)->pos = 0;
16553 (*bdchginfo)->boundchgtype = SCIP_BOUNDCHGTYPE_BRANCHING; /*lint !e641*/
16554 (*bdchginfo)->boundtype = boundtype; /*lint !e641*/
16555 (*bdchginfo)->inferboundtype = boundtype; /*lint !e641*/
16556 (*bdchginfo)->redundant = FALSE;
16557
16558 return SCIP_OKAY;
16559}
16560
16561/** frees a bound change information object */
16563 SCIP_BDCHGINFO** bdchginfo, /**< pointer to store bound change information */
16564 BMS_BLKMEM* blkmem /**< block memory */
16565 )
16566{
16567 assert(bdchginfo != NULL);
16568
16569 BMSfreeBlockMemory(blkmem, bdchginfo);
16570}
16571
16572/** returns the bound change information for the last lower bound change on given active problem variable before or
16573 * after the bound change with the given index was applied;
16574 * returns NULL, if no change to the lower bound was applied up to this point of time
16575 */
16577 SCIP_VAR* var, /**< active problem variable */
16578 SCIP_BDCHGIDX* bdchgidx, /**< bound change index representing time on path to current node */
16579 SCIP_Bool after /**< should the bound change with given index be included? */
16580 )
16581{
16582 int i;
16583
16584 assert(var != NULL);
16585 assert(SCIPvarIsActive(var));
16586
16587 /* search the correct bound change information for the given bound change index */
16588 if( after )
16589 {
16590 for( i = var->nlbchginfos-1; i >= 0; --i )
16591 {
16592 assert(var->lbchginfos[i].var == var);
16594 assert(var->lbchginfos[i].pos == i);
16595
16596 /* if we reached the (due to global bounds) redundant bound changes, return NULL */
16597 if( var->lbchginfos[i].redundant )
16598 return NULL;
16599 assert(var->lbchginfos[i].oldbound < var->lbchginfos[i].newbound);
16600
16601 /* if we reached the bound change index, return the current bound change info */
16602 if( !SCIPbdchgidxIsEarlier(bdchgidx, &var->lbchginfos[i].bdchgidx) )
16603 return &var->lbchginfos[i];
16604 }
16605 }
16606 else
16607 {
16608 for( i = var->nlbchginfos-1; i >= 0; --i )
16609 {
16610 assert(var->lbchginfos[i].var == var);
16612 assert(var->lbchginfos[i].pos == i);
16613
16614 /* if we reached the (due to global bounds) redundant bound changes, return NULL */
16615 if( var->lbchginfos[i].redundant )
16616 return NULL;
16617 assert(var->lbchginfos[i].oldbound < var->lbchginfos[i].newbound);
16618
16619 /* if we reached the bound change index, return the current bound change info */
16620 if( SCIPbdchgidxIsEarlier(&var->lbchginfos[i].bdchgidx, bdchgidx) )
16621 return &var->lbchginfos[i];
16622 }
16623 }
16624
16625 return NULL;
16626}
16627
16628/** returns the bound change information for the last upper bound change on given active problem variable before or
16629 * after the bound change with the given index was applied;
16630 * returns NULL, if no change to the upper bound was applied up to this point of time
16631 */
16633 SCIP_VAR* var, /**< active problem variable */
16634 SCIP_BDCHGIDX* bdchgidx, /**< bound change index representing time on path to current node */
16635 SCIP_Bool after /**< should the bound change with given index be included? */
16636 )
16637{
16638 int i;
16639
16640 assert(var != NULL);
16641 assert(SCIPvarIsActive(var));
16642
16643 /* search the correct bound change information for the given bound change index */
16644 if( after )
16645 {
16646 for( i = var->nubchginfos-1; i >= 0; --i )
16647 {
16648 assert(var->ubchginfos[i].var == var);
16650 assert(var->ubchginfos[i].pos == i);
16651
16652 /* if we reached the (due to global bounds) redundant bound changes, return NULL */
16653 if( var->ubchginfos[i].redundant )
16654 return NULL;
16655 assert(var->ubchginfos[i].oldbound > var->ubchginfos[i].newbound);
16656
16657 /* if we reached the bound change index, return the current bound change info */
16658 if( !SCIPbdchgidxIsEarlier(bdchgidx, &var->ubchginfos[i].bdchgidx) )
16659 return &var->ubchginfos[i];
16660 }
16661 }
16662 else
16663 {
16664 for( i = var->nubchginfos-1; i >= 0; --i )
16665 {
16666 assert(var->ubchginfos[i].var == var);
16668 assert(var->ubchginfos[i].pos == i);
16669
16670 /* if we reached the (due to global bounds) redundant bound changes, return NULL */
16671 if( var->ubchginfos[i].redundant )
16672 return NULL;
16673 assert(var->ubchginfos[i].oldbound > var->ubchginfos[i].newbound);
16674
16675 /* if we reached the bound change index, return the current bound change info */
16676 if( SCIPbdchgidxIsEarlier(&var->ubchginfos[i].bdchgidx, bdchgidx) )
16677 return &var->ubchginfos[i];
16678 }
16679 }
16680
16681 return NULL;
16682}
16683
16684/** returns the bound change information for the last lower or upper bound change on given active problem variable
16685 * before or after the bound change with the given index was applied;
16686 * returns NULL, if no change to the lower/upper bound was applied up to this point of time
16687 */
16689 SCIP_VAR* var, /**< active problem variable */
16690 SCIP_BOUNDTYPE boundtype, /**< type of bound: lower or upper bound */
16691 SCIP_BDCHGIDX* bdchgidx, /**< bound change index representing time on path to current node */
16692 SCIP_Bool after /**< should the bound change with given index be included? */
16693 )
16694{
16695 if( boundtype == SCIP_BOUNDTYPE_LOWER )
16696 return SCIPvarGetLbchgInfo(var, bdchgidx, after);
16697 else
16698 {
16699 assert(boundtype == SCIP_BOUNDTYPE_UPPER);
16700 return SCIPvarGetUbchgInfo(var, bdchgidx, after);
16701 }
16702}
16703
16704/** returns lower bound of variable directly before or after the bound change given by the bound change index
16705 * was applied
16706 *
16707 * @deprecated Please use SCIPgetVarLbAtIndex()
16708 */
16710 SCIP_VAR* var, /**< problem variable */
16711 SCIP_BDCHGIDX* bdchgidx, /**< bound change index representing time on path to current node */
16712 SCIP_Bool after /**< should the bound change with given index be included? */
16713 )
16714{
16715 SCIP_VARSTATUS varstatus;
16716 assert(var != NULL);
16717
16718 varstatus = SCIPvarGetStatus(var);
16719
16720 /* get bounds of attached variables */
16721 switch( varstatus )
16722 {
16724 assert(var->data.original.transvar != NULL);
16725 return SCIPvarGetLbAtIndex(var->data.original.transvar, bdchgidx, after);
16726
16729 if( bdchgidx == NULL )
16730 return SCIPvarGetLbLocal(var);
16731 else
16732 {
16733 SCIP_BDCHGINFO* bdchginfo;
16734
16735 bdchginfo = SCIPvarGetLbchgInfo(var, bdchgidx, after);
16736 if( bdchginfo != NULL )
16737 return SCIPbdchginfoGetNewbound(bdchginfo);
16738 else
16739 return var->glbdom.lb;
16740 }
16742 return var->glbdom.lb;
16743
16744 case SCIP_VARSTATUS_AGGREGATED: /* x = a*y + c -> y = (x-c)/a */
16745 assert(var->data.aggregate.var != NULL);
16746 /* a correct implementation would need to check the value of var->data.aggregate.var for infinity and return the
16747 * corresponding infinity value instead of performing an arithmetical transformation (compare method
16748 * SCIPvarGetLbLP()); however, we do not want to introduce a SCIP or SCIP_SET pointer to this method, since it is
16749 * (or is called by) a public interface method; instead, we only assert that values are finite
16750 * w.r.t. SCIP_DEFAULT_INFINITY, which seems to be true in our regression tests; note that this may yield false
16751 * positives and negatives if the parameter <numerics/infinity> is modified by the user
16752 */
16753 if( var->data.aggregate.scalar > 0.0 )
16754 {
16755 /* a > 0 -> get lower bound of y */
16756 assert(SCIPvarGetLbAtIndex(var->data.aggregate.var, bdchgidx, after) > -SCIP_DEFAULT_INFINITY);
16757 assert(SCIPvarGetLbAtIndex(var->data.aggregate.var, bdchgidx, after) < +SCIP_DEFAULT_INFINITY);
16758 return var->data.aggregate.scalar * SCIPvarGetLbAtIndex(var->data.aggregate.var, bdchgidx, after)
16759 + var->data.aggregate.constant;
16760 }
16761 else if( var->data.aggregate.scalar < 0.0 )
16762 {
16763 /* a < 0 -> get upper bound of y */
16764 assert(SCIPvarGetUbAtIndex(var->data.aggregate.var, bdchgidx, after) > -SCIP_DEFAULT_INFINITY);
16765 assert(SCIPvarGetUbAtIndex(var->data.aggregate.var, bdchgidx, after) < +SCIP_DEFAULT_INFINITY);
16766 return var->data.aggregate.scalar * SCIPvarGetUbAtIndex(var->data.aggregate.var, bdchgidx, after)
16767 + var->data.aggregate.constant;
16768 }
16769 else
16770 {
16771 SCIPerrorMessage("scalar is zero in aggregation\n");
16772 SCIPABORT();
16773 return SCIP_INVALID; /*lint !e527*/
16774 }
16775
16777 /* handle multi-aggregated variables depending on one variable only (possibly caused by SCIPvarFlattenAggregationGraph()) */
16778 if ( var->data.multaggr.nvars == 1 )
16779 {
16780 assert(var->data.multaggr.vars != NULL);
16781 assert(var->data.multaggr.scalars != NULL);
16782 assert(var->data.multaggr.vars[0] != NULL);
16783
16784 if( var->data.multaggr.scalars[0] > 0.0 )
16785 {
16786 /* a > 0 -> get lower bound of y */
16787 assert(SCIPvarGetLbAtIndex(var->data.multaggr.vars[0], bdchgidx, after) > -SCIP_DEFAULT_INFINITY);
16788 assert(SCIPvarGetLbAtIndex(var->data.multaggr.vars[0], bdchgidx, after) < +SCIP_DEFAULT_INFINITY);
16789 return var->data.multaggr.scalars[0] * SCIPvarGetLbAtIndex(var->data.multaggr.vars[0], bdchgidx, after)
16790 + var->data.multaggr.constant;
16791 }
16792 else if( var->data.multaggr.scalars[0] < 0.0 )
16793 {
16794 /* a < 0 -> get upper bound of y */
16795 assert(SCIPvarGetUbAtIndex(var->data.multaggr.vars[0], bdchgidx, after) > -SCIP_DEFAULT_INFINITY);
16796 assert(SCIPvarGetUbAtIndex(var->data.multaggr.vars[0], bdchgidx, after) < +SCIP_DEFAULT_INFINITY);
16797 return var->data.multaggr.scalars[0] * SCIPvarGetUbAtIndex(var->data.multaggr.vars[0], bdchgidx, after)
16798 + var->data.multaggr.constant;
16799 }
16800 else
16801 {
16802 SCIPerrorMessage("scalar is zero in multi-aggregation\n");
16803 SCIPABORT();
16804 return SCIP_INVALID; /*lint !e527*/
16805 }
16806 }
16807 SCIPerrorMessage("cannot get the bounds of a multi-aggregated variable.\n");
16808 SCIPABORT();
16809 return SCIP_INVALID; /*lint !e527*/
16810
16811 case SCIP_VARSTATUS_NEGATED: /* x' = offset - x -> x = offset - x' */
16812 assert(var->negatedvar != NULL);
16814 assert(var->negatedvar->negatedvar == var);
16815 return var->data.negate.constant - SCIPvarGetUbAtIndex(var->negatedvar, bdchgidx, after);
16816 default:
16817 SCIPerrorMessage("unknown variable status\n");
16818 SCIPABORT();
16819 return SCIP_INVALID; /*lint !e527*/
16820 }
16821}
16822
16823/** returns upper bound of variable directly before or after the bound change given by the bound change index
16824 * was applied
16825 *
16826 * @deprecated Please use SCIPgetVarUbAtIndex()
16827 */
16829 SCIP_VAR* var, /**< problem variable */
16830 SCIP_BDCHGIDX* bdchgidx, /**< bound change index representing time on path to current node */
16831 SCIP_Bool after /**< should the bound change with given index be included? */
16832 )
16833{
16834 SCIP_VARSTATUS varstatus;
16835 assert(var != NULL);
16836
16837 varstatus = SCIPvarGetStatus(var);
16838
16839 /* get bounds of attached variables */
16840 switch( varstatus )
16841 {
16843 assert(var->data.original.transvar != NULL);
16844 return SCIPvarGetUbAtIndex(var->data.original.transvar, bdchgidx, after);
16845
16848 if( bdchgidx == NULL )
16849 return SCIPvarGetUbLocal(var);
16850 else
16851 {
16852 SCIP_BDCHGINFO* bdchginfo;
16853
16854 bdchginfo = SCIPvarGetUbchgInfo(var, bdchgidx, after);
16855 if( bdchginfo != NULL )
16856 return SCIPbdchginfoGetNewbound(bdchginfo);
16857 else
16858 return var->glbdom.ub;
16859 }
16860
16862 return var->glbdom.ub;
16863
16864 case SCIP_VARSTATUS_AGGREGATED: /* x = a*y + c -> y = (x-c)/a */
16865 assert(var->data.aggregate.var != NULL);
16866 /* a correct implementation would need to check the value of var->data.aggregate.var for infinity and return the
16867 * corresponding infinity value instead of performing an arithmetical transformation (compare method
16868 * SCIPvarGetLbLP()); however, we do not want to introduce a SCIP or SCIP_SET pointer to this method, since it is
16869 * (or is called by) a public interface method; instead, we only assert that values are finite
16870 * w.r.t. SCIP_DEFAULT_INFINITY, which seems to be true in our regression tests; note that this may yield false
16871 * positives and negatives if the parameter <numerics/infinity> is modified by the user
16872 */
16873 if( var->data.aggregate.scalar > 0.0 )
16874 {
16875 /* a > 0 -> get lower bound of y */
16876 assert(SCIPvarGetUbAtIndex(var->data.aggregate.var, bdchgidx, after) > -SCIP_DEFAULT_INFINITY);
16877 assert(SCIPvarGetUbAtIndex(var->data.aggregate.var, bdchgidx, after) < +SCIP_DEFAULT_INFINITY);
16878 return var->data.aggregate.scalar * SCIPvarGetUbAtIndex(var->data.aggregate.var, bdchgidx, after)
16879 + var->data.aggregate.constant;
16880 }
16881 else if( var->data.aggregate.scalar < 0.0 )
16882 {
16883 /* a < 0 -> get upper bound of y */
16884 assert(SCIPvarGetLbAtIndex(var->data.aggregate.var, bdchgidx, after) > -SCIP_DEFAULT_INFINITY);
16885 assert(SCIPvarGetLbAtIndex(var->data.aggregate.var, bdchgidx, after) < +SCIP_DEFAULT_INFINITY);
16886 return var->data.aggregate.scalar * SCIPvarGetLbAtIndex(var->data.aggregate.var, bdchgidx, after)
16887 + var->data.aggregate.constant;
16888 }
16889 else
16890 {
16891 SCIPerrorMessage("scalar is zero in aggregation\n");
16892 SCIPABORT();
16893 return SCIP_INVALID; /*lint !e527*/
16894 }
16895
16897 /* handle multi-aggregated variables depending on one variable only (possibly caused by SCIPvarFlattenAggregationGraph()) */
16898 if ( var->data.multaggr.nvars == 1 )
16899 {
16900 assert(var->data.multaggr.vars != NULL);
16901 assert(var->data.multaggr.scalars != NULL);
16902 assert(var->data.multaggr.vars[0] != NULL);
16903
16904 if( var->data.multaggr.scalars[0] > 0.0 )
16905 {
16906 /* a > 0 -> get lower bound of y */
16907 assert(SCIPvarGetUbAtIndex(var->data.multaggr.vars[0], bdchgidx, after) > -SCIP_DEFAULT_INFINITY);
16908 assert(SCIPvarGetUbAtIndex(var->data.multaggr.vars[0], bdchgidx, after) < +SCIP_DEFAULT_INFINITY);
16909 return var->data.multaggr.scalars[0] * SCIPvarGetUbAtIndex(var->data.multaggr.vars[0], bdchgidx, after)
16910 + var->data.multaggr.constant;
16911 }
16912 else if( var->data.multaggr.scalars[0] < 0.0 )
16913 {
16914 /* a < 0 -> get upper bound of y */
16915 assert(SCIPvarGetLbAtIndex(var->data.multaggr.vars[0], bdchgidx, after) > -SCIP_DEFAULT_INFINITY);
16916 assert(SCIPvarGetLbAtIndex(var->data.multaggr.vars[0], bdchgidx, after) < +SCIP_DEFAULT_INFINITY);
16917 return var->data.multaggr.scalars[0] * SCIPvarGetLbAtIndex(var->data.multaggr.vars[0], bdchgidx, after)
16918 + var->data.multaggr.constant;
16919 }
16920 else
16921 {
16922 SCIPerrorMessage("scalar is zero in multi-aggregation\n");
16923 SCIPABORT();
16924 return SCIP_INVALID; /*lint !e527*/
16925 }
16926 }
16927 SCIPerrorMessage("cannot get the bounds of a multiple aggregated variable.\n");
16928 SCIPABORT();
16929 return SCIP_INVALID; /*lint !e527*/
16930
16931 case SCIP_VARSTATUS_NEGATED: /* x' = offset - x -> x = offset - x' */
16932 assert(var->negatedvar != NULL);
16934 assert(var->negatedvar->negatedvar == var);
16935 return var->data.negate.constant - SCIPvarGetLbAtIndex(var->negatedvar, bdchgidx, after);
16936
16937 default:
16938 SCIPerrorMessage("unknown variable status\n");
16939 SCIPABORT();
16940 return SCIP_INVALID; /*lint !e527*/
16941 }
16942}
16943
16944/** returns lower or upper bound of variable directly before or after the bound change given by the bound change index
16945 * was applied
16946 *
16947 * @deprecated Please use SCIPgetVarBdAtIndex()
16948 */
16950 SCIP_VAR* var, /**< problem variable */
16951 SCIP_BOUNDTYPE boundtype, /**< type of bound: lower or upper bound */
16952 SCIP_BDCHGIDX* bdchgidx, /**< bound change index representing time on path to current node */
16953 SCIP_Bool after /**< should the bound change with given index be included? */
16954 )
16955{
16956 if( boundtype == SCIP_BOUNDTYPE_LOWER )
16957 return SCIPvarGetLbAtIndex(var, bdchgidx, after);
16958 else
16959 {
16960 assert(boundtype == SCIP_BOUNDTYPE_UPPER);
16961 return SCIPvarGetUbAtIndex(var, bdchgidx, after);
16962 }
16963}
16964
16965/** returns whether the binary variable was fixed at the time given by the bound change index
16966 *
16967 * @deprecated Please use SCIPgetVarWasFixedAtIndex()
16968 */
16970 SCIP_VAR* var, /**< problem variable */
16971 SCIP_BDCHGIDX* bdchgidx, /**< bound change index representing time on path to current node */
16972 SCIP_Bool after /**< should the bound change with given index be included? */
16973 )
16974{
16975 assert(var != NULL);
16976 assert(SCIPvarIsBinary(var));
16977
16978 /* check the current bounds first in order to decide at which bound change information we have to look
16979 * (which is expensive because we have to follow the aggregation tree to the active variable)
16980 */
16981 return ((SCIPvarGetLbLocal(var) > 0.5 && SCIPvarGetLbAtIndex(var, bdchgidx, after) > 0.5)
16982 || (SCIPvarGetUbLocal(var) < 0.5 && SCIPvarGetUbAtIndex(var, bdchgidx, after) < 0.5));
16983}
16984
16985/** bound change index representing the initial time before any bound changes took place */
16987
16988/** bound change index representing the presolving stage */
16990
16991/** returns the last bound change index, at which the bounds of the given variable were tightened */
16993 SCIP_VAR* var /**< problem variable */
16994 )
16995{
16996 SCIP_BDCHGIDX* lbchgidx;
16997 SCIP_BDCHGIDX* ubchgidx;
16998
16999 assert(var != NULL);
17000
17001 var = SCIPvarGetProbvar(var);
17002
17003 /* check, if variable is original without transformed variable */
17004 if( var == NULL )
17005 return &initbdchgidx;
17006
17007 /* check, if variable was fixed in presolving */
17008 if( !SCIPvarIsActive(var) )
17009 return &presolvebdchgidx;
17010
17012
17013 /* get depths of last bound change information for the lower and upper bound */
17014 lbchgidx = (var->nlbchginfos > 0 && !var->lbchginfos[var->nlbchginfos-1].redundant
17015 ? &var->lbchginfos[var->nlbchginfos-1].bdchgidx : &initbdchgidx);
17016 ubchgidx = (var->nubchginfos > 0 && !var->ubchginfos[var->nubchginfos-1].redundant
17017 ? &var->ubchginfos[var->nubchginfos-1].bdchgidx : &initbdchgidx);
17018
17019 if( SCIPbdchgidxIsEarlierNonNull(lbchgidx, ubchgidx) )
17020 return ubchgidx;
17021 else
17022 return lbchgidx;
17023}
17024
17025/** returns the last depth level, at which the bounds of the given variable were tightened;
17026 * returns -2, if the variable's bounds are still the global bounds
17027 * returns -1, if the variable was fixed in presolving
17028 */
17030 SCIP_VAR* var /**< problem variable */
17031 )
17032{
17033 SCIP_BDCHGIDX* bdchgidx;
17034
17035 bdchgidx = SCIPvarGetLastBdchgIndex(var);
17036 assert(bdchgidx != NULL);
17037
17038 return bdchgidx->depth;
17039}
17040
17041/** returns at which depth in the tree a bound change was applied to the variable that conflicts with the
17042 * given bound; returns -1 if the bound does not conflict with the current local bounds of the variable
17043 */
17045 SCIP_VAR* var, /**< problem variable */
17046 SCIP_SET* set, /**< global SCIP settings */
17047 SCIP_BOUNDTYPE boundtype, /**< bound type of the conflicting bound */
17048 SCIP_Real bound /**< conflicting bound */
17049 )
17050{
17051 int i;
17052
17053 assert(var != NULL);
17054 assert(set != NULL);
17055 assert(var->scip == set->scip);
17056
17057 if( boundtype == SCIP_BOUNDTYPE_LOWER )
17058 {
17059 /* check if the bound is in conflict with the current local bounds */
17060 if( SCIPsetIsLE(set, bound, var->locdom.ub) )
17061 return -1;
17062
17063 /* check if the bound is in conflict with the global bound */
17064 if( SCIPsetIsGT(set, bound, var->glbdom.ub) )
17065 return 0;
17066
17067 /* local bounds are in conflict with the given bound -> there must be at least one conflicting change! */
17068 assert(var->nubchginfos > 0);
17069 assert(SCIPsetIsGT(set, bound, var->ubchginfos[var->nubchginfos-1].newbound));
17070
17071 /* search for the first conflicting bound change */
17072 for( i = var->nubchginfos-1; i > 0 && SCIPsetIsGT(set, bound, var->ubchginfos[i-1].newbound); --i )
17073 {
17074 assert(var->ubchginfos[i].var == var); /* perform sanity check on the search for the first conflicting bound */
17076 }
17077 assert(SCIPsetIsGT(set, bound, var->ubchginfos[i].newbound)); /* bound change i is conflicting */
17078 assert(i == 0 || SCIPsetIsLE(set, bound, var->ubchginfos[i-1].newbound)); /* bound change i-1 is not conflicting */
17079
17080 /* return the depth at which the first conflicting bound change took place */
17081 return var->ubchginfos[i].bdchgidx.depth;
17082 }
17083 else
17084 {
17085 assert(boundtype == SCIP_BOUNDTYPE_UPPER);
17086
17087 /* check if the bound is in conflict with the current local bounds */
17088 if( SCIPsetIsGE(set, bound, var->locdom.lb) )
17089 return -1;
17090
17091 /* check if the bound is in conflict with the global bound */
17092 if( SCIPsetIsLT(set, bound, var->glbdom.lb) )
17093 return 0;
17094
17095 /* local bounds are in conflict with the given bound -> there must be at least one conflicting change! */
17096 assert(var->nlbchginfos > 0);
17097 assert(SCIPsetIsLT(set, bound, var->lbchginfos[var->nlbchginfos-1].newbound));
17098
17099 /* search for the first conflicting bound change */
17100 for( i = var->nlbchginfos-1; i > 0 && SCIPsetIsLT(set, bound, var->lbchginfos[i-1].newbound); --i )
17101 {
17102 assert(var->lbchginfos[i].var == var); /* perform sanity check on the search for the first conflicting bound */
17104 }
17105 assert(SCIPsetIsLT(set, bound, var->lbchginfos[i].newbound)); /* bound change i is conflicting */
17106 assert(i == 0 || SCIPsetIsGE(set, bound, var->lbchginfos[i-1].newbound)); /* bound change i-1 is not conflicting */
17107
17108 /* return the depth at which the first conflicting bound change took place */
17109 return var->lbchginfos[i].bdchgidx.depth;
17110 }
17111}
17112
17113/** returns whether the first binary variable was fixed earlier than the second one;
17114 * returns FALSE, if the first variable is not fixed, and returns TRUE, if the first variable is fixed, but the
17115 * second one is not fixed
17116 */
17118 SCIP_VAR* var1, /**< first binary variable */
17119 SCIP_VAR* var2 /**< second binary variable */
17120 )
17121{
17122 SCIP_BDCHGIDX* bdchgidx1;
17123 SCIP_BDCHGIDX* bdchgidx2;
17124
17125 assert(var1 != NULL);
17126 assert(var2 != NULL);
17127 assert(SCIPvarIsBinary(var1));
17128 assert(SCIPvarIsBinary(var2));
17129
17130 var1 = SCIPvarGetProbvar(var1);
17131 var2 = SCIPvarGetProbvar(var2);
17132 assert(var1 != NULL);
17133 assert(var2 != NULL);
17134
17135 /* check, if variables are globally fixed */
17136 if( !SCIPvarIsActive(var2) || var2->glbdom.lb > 0.5 || var2->glbdom.ub < 0.5 )
17137 return FALSE;
17138 if( !SCIPvarIsActive(var1) || var1->glbdom.lb > 0.5 || var1->glbdom.ub < 0.5 )
17139 return TRUE;
17140
17143 assert(SCIPvarIsBinary(var1));
17144 assert(SCIPvarIsBinary(var2));
17145 assert(var1->nlbchginfos + var1->nubchginfos <= 1);
17146 assert(var2->nlbchginfos + var2->nubchginfos <= 1);
17147 assert(var1->nlbchginfos == 0 || !var1->lbchginfos[0].redundant); /* otherwise, var would be globally fixed */
17148 assert(var1->nubchginfos == 0 || !var1->ubchginfos[0].redundant); /* otherwise, var would be globally fixed */
17149 assert(var2->nlbchginfos == 0 || !var2->lbchginfos[0].redundant); /* otherwise, var would be globally fixed */
17150 assert(var2->nubchginfos == 0 || !var2->ubchginfos[0].redundant); /* otherwise, var would be globally fixed */
17151
17152 if( var1->nlbchginfos == 1 )
17153 bdchgidx1 = &var1->lbchginfos[0].bdchgidx;
17154 else if( var1->nubchginfos == 1 )
17155 bdchgidx1 = &var1->ubchginfos[0].bdchgidx;
17156 else
17157 bdchgidx1 = NULL;
17158
17159 if( var2->nlbchginfos == 1 )
17160 bdchgidx2 = &var2->lbchginfos[0].bdchgidx;
17161 else if( var2->nubchginfos == 1 )
17162 bdchgidx2 = &var2->ubchginfos[0].bdchgidx;
17163 else
17164 bdchgidx2 = NULL;
17165
17166 return SCIPbdchgidxIsEarlier(bdchgidx1, bdchgidx2);
17167}
17168
17169
17170
17171/*
17172 * Hash functions
17173 */
17174
17175/** gets the key (i.e. the name) of the given variable */
17176SCIP_DECL_HASHGETKEY(SCIPhashGetKeyVar)
17177{ /*lint --e{715}*/
17178 SCIP_VAR* var = (SCIP_VAR*)elem;
17179
17180 assert(var != NULL);
17181 return var->name;
17182}
17183
17184
17185
17186
17187/*
17188 * simple functions implemented as defines
17189 */
17190
17191/* In debug mode, the following methods are implemented as function calls to ensure
17192 * type validity.
17193 * In optimized mode, the methods are implemented as defines to improve performance.
17194 * However, we want to have them in the library anyways, so we have to undef the defines.
17195 */
17196
17197#undef SCIPboundchgGetNewbound
17198#undef SCIPboundchgGetVar
17199#undef SCIPboundchgGetBoundchgtype
17200#undef SCIPboundchgGetBoundtype
17201#undef SCIPboundchgIsRedundant
17202#undef SCIPdomchgGetNBoundchgs
17203#undef SCIPdomchgGetBoundchg
17204#undef SCIPholelistGetLeft
17205#undef SCIPholelistGetRight
17206#undef SCIPholelistGetNext
17207#undef SCIPvarGetName
17208#undef SCIPvarGetNUses
17209#undef SCIPvarGetData
17210#undef SCIPvarSetData
17211#undef SCIPvarSetDelorigData
17212#undef SCIPvarSetTransData
17213#undef SCIPvarSetDeltransData
17214#undef SCIPvarGetStatus
17215#undef SCIPvarIsOriginal
17216#undef SCIPvarIsTransformed
17217#undef SCIPvarIsNegated
17218#undef SCIPvarGetType
17219#undef SCIPvarIsBinary
17220#undef SCIPvarIsIntegral
17221#undef SCIPvarIsInitial
17222#undef SCIPvarIsRemovable
17223#undef SCIPvarIsDeleted
17224#undef SCIPvarIsDeletable
17225#undef SCIPvarMarkDeletable
17226#undef SCIPvarMarkNotDeletable
17227#undef SCIPvarIsActive
17228#undef SCIPvarGetIndex
17229#undef SCIPvarGetProbindex
17230#undef SCIPvarGetTransVar
17231#undef SCIPvarGetCol
17232#undef SCIPvarIsInLP
17233#undef SCIPvarGetAggrVar
17234#undef SCIPvarGetAggrScalar
17235#undef SCIPvarGetAggrConstant
17236#undef SCIPvarGetMultaggrNVars
17237#undef SCIPvarGetMultaggrVars
17238#undef SCIPvarGetMultaggrScalars
17239#undef SCIPvarGetMultaggrConstant
17240#undef SCIPvarGetNegatedVar
17241#undef SCIPvarGetNegationVar
17242#undef SCIPvarGetNegationConstant
17243#undef SCIPvarGetObj
17244#undef SCIPvarGetLbOriginal
17245#undef SCIPvarGetUbOriginal
17246#undef SCIPvarGetHolelistOriginal
17247#undef SCIPvarGetLbGlobal
17248#undef SCIPvarGetUbGlobal
17249#undef SCIPvarGetHolelistGlobal
17250#undef SCIPvarGetBestBoundGlobal
17251#undef SCIPvarGetWorstBoundGlobal
17252#undef SCIPvarGetLbLocal
17253#undef SCIPvarGetUbLocal
17254#undef SCIPvarGetHolelistLocal
17255#undef SCIPvarGetBestBoundLocal
17256#undef SCIPvarGetWorstBoundLocal
17257#undef SCIPvarGetBestBoundType
17258#undef SCIPvarGetWorstBoundType
17259#undef SCIPvarGetLbLazy
17260#undef SCIPvarGetUbLazy
17261#undef SCIPvarGetBranchFactor
17262#undef SCIPvarGetBranchPriority
17263#undef SCIPvarGetBranchDirection
17264#undef SCIPvarGetNVlbs
17265#undef SCIPvarGetVlbVars
17266#undef SCIPvarGetVlbCoefs
17267#undef SCIPvarGetVlbConstants
17268#undef SCIPvarGetNVubs
17269#undef SCIPvarGetVubVars
17270#undef SCIPvarGetVubCoefs
17271#undef SCIPvarGetVubConstants
17272#undef SCIPvarGetNImpls
17273#undef SCIPvarGetImplVars
17274#undef SCIPvarGetImplTypes
17275#undef SCIPvarGetImplBounds
17276#undef SCIPvarGetImplIds
17277#undef SCIPvarGetNCliques
17278#undef SCIPvarGetCliques
17279#undef SCIPvarGetLPSol
17280#undef SCIPvarGetNLPSol
17281#undef SCIPvarGetBdchgInfoLb
17282#undef SCIPvarGetNBdchgInfosLb
17283#undef SCIPvarGetBdchgInfoUb
17284#undef SCIPvarGetNBdchgInfosUb
17285#undef SCIPvarGetValuehistory
17286#undef SCIPvarGetPseudoSol
17287#undef SCIPvarCatchEvent
17288#undef SCIPvarDropEvent
17289#undef SCIPvarGetVSIDS
17290#undef SCIPvarGetCliqueComponentIdx
17291#undef SCIPvarIsRelaxationOnly
17292#undef SCIPvarMarkRelaxationOnly
17293#undef SCIPbdchgidxGetPos
17294#undef SCIPbdchgidxIsEarlierNonNull
17295#undef SCIPbdchgidxIsEarlier
17296#undef SCIPbdchginfoGetOldbound
17297#undef SCIPbdchginfoGetNewbound
17298#undef SCIPbdchginfoGetVar
17299#undef SCIPbdchginfoGetChgtype
17300#undef SCIPbdchginfoGetBoundtype
17301#undef SCIPbdchginfoGetDepth
17302#undef SCIPbdchginfoGetPos
17303#undef SCIPbdchginfoGetIdx
17304#undef SCIPbdchginfoGetInferVar
17305#undef SCIPbdchginfoGetInferCons
17306#undef SCIPbdchginfoGetInferProp
17307#undef SCIPbdchginfoGetInferInfo
17308#undef SCIPbdchginfoGetInferBoundtype
17309#undef SCIPbdchginfoIsRedundant
17310#undef SCIPbdchginfoHasInferenceReason
17311#undef SCIPbdchginfoIsTighter
17312
17313
17314/** returns the new value of the bound in the bound change data */
17316 SCIP_BOUNDCHG* boundchg /**< bound change data */
17317 )
17318{
17319 assert(boundchg != NULL);
17320
17321 return boundchg->newbound;
17322}
17323
17324/** returns the variable of the bound change in the bound change data */
17326 SCIP_BOUNDCHG* boundchg /**< bound change data */
17327 )
17328{
17329 assert(boundchg != NULL);
17330
17331 return boundchg->var;
17332}
17333
17334/** returns the bound change type of the bound change in the bound change data */
17336 SCIP_BOUNDCHG* boundchg /**< bound change data */
17337 )
17338{
17339 assert(boundchg != NULL);
17340
17341 return (SCIP_BOUNDCHGTYPE)(boundchg->boundchgtype);
17342}
17343
17344/** returns the bound type of the bound change in the bound change data */
17346 SCIP_BOUNDCHG* boundchg /**< bound change data */
17347 )
17348{
17349 assert(boundchg != NULL);
17350
17351 return (SCIP_BOUNDTYPE)(boundchg->boundtype);
17352}
17353
17354/** returns whether the bound change is redundant due to a more global bound that is at least as strong */
17356 SCIP_BOUNDCHG* boundchg /**< bound change data */
17357 )
17358{
17359 assert(boundchg != NULL);
17360
17361 return boundchg->redundant;
17362}
17363
17364/** returns the number of bound changes in the domain change data */
17366 SCIP_DOMCHG* domchg /**< domain change data */
17367 )
17368{
17369 return domchg != NULL ? domchg->domchgbound.nboundchgs : 0;
17370}
17371
17372/** returns a particular bound change in the domain change data */
17374 SCIP_DOMCHG* domchg, /**< domain change data */
17375 int pos /**< position of the bound change in the domain change data */
17376 )
17377{
17378 assert(domchg != NULL);
17379 assert(0 <= pos && pos < (int)domchg->domchgbound.nboundchgs);
17380
17381 return &domchg->domchgbound.boundchgs[pos];
17382}
17383
17384/** returns left bound of open interval in hole */
17386 SCIP_HOLELIST* holelist /**< hole list pointer to hole of interest */
17387 )
17388{
17389 assert(holelist != NULL);
17390
17391 return holelist->hole.left;
17392}
17393
17394/** returns right bound of open interval in hole */
17396 SCIP_HOLELIST* holelist /**< hole list pointer to hole of interest */
17397 )
17398{
17399 assert(holelist != NULL);
17400
17401 return holelist->hole.right;
17402}
17403
17404/** returns next hole in list */
17406 SCIP_HOLELIST* holelist /**< hole list pointer to hole of interest */
17407 )
17408{
17409 assert(holelist != NULL);
17410
17411 return holelist->next;
17412}
17413
17414/** returns the name of the variable
17415 *
17416 * @note to change the name of a variable, use SCIPchgVarName() from scip.h
17417 */
17418const char* SCIPvarGetName(
17419 SCIP_VAR* var /**< problem variable */
17420 )
17421{
17422 assert(var != NULL);
17423
17424 return var->name;
17425}
17426
17427/** gets number of times, the variable is currently captured */
17429 SCIP_VAR* var /**< problem variable */
17430 )
17431{
17432 assert(var != NULL);
17433
17434 return var->nuses;
17435}
17436
17437/** returns the user data of the variable */
17439 SCIP_VAR* var /**< problem variable */
17440 )
17441{
17442 assert(var != NULL);
17443
17444 return var->vardata;
17445}
17446
17447/** sets the user data for the variable */
17449 SCIP_VAR* var, /**< problem variable */
17450 SCIP_VARDATA* vardata /**< user variable data */
17451 )
17452{
17453 assert(var != NULL);
17454
17455 var->vardata = vardata;
17456}
17457
17458/** sets method to free user data for the original variable */
17460 SCIP_VAR* var, /**< problem variable */
17461 SCIP_DECL_VARDELORIG ((*vardelorig)) /**< frees user data of original variable */
17462 )
17463{
17464 assert(var != NULL);
17466
17467 var->vardelorig = vardelorig;
17468}
17469
17470/** sets method to transform user data of the variable */
17472 SCIP_VAR* var, /**< problem variable */
17473 SCIP_DECL_VARTRANS ((*vartrans)) /**< creates transformed user data by transforming original user data */
17474 )
17475{
17476 assert(var != NULL);
17478
17479 var->vartrans = vartrans;
17480}
17481
17482/** sets method to free transformed user data for the variable */
17484 SCIP_VAR* var, /**< problem variable */
17485 SCIP_DECL_VARDELTRANS ((*vardeltrans)) /**< frees user data of transformed variable */
17486 )
17487{
17488 assert(var != NULL);
17489
17490 var->vardeltrans = vardeltrans;
17491}
17492
17493/** sets method to copy this variable into sub-SCIPs */
17495 SCIP_VAR* var, /**< problem variable */
17496 SCIP_DECL_VARCOPY ((*varcopy)) /**< copy method of the variable */
17497 )
17498{
17499 assert(var != NULL);
17500
17501 var->varcopy = varcopy;
17502}
17503
17504/** sets the initial flag of a variable; only possible for original or loose variables */
17506 SCIP_VAR* var, /**< problem variable */
17507 SCIP_Bool initial /**< initial flag */
17508 )
17509{
17510 assert(var != NULL);
17511
17513 return SCIP_INVALIDCALL;
17514
17515 var->initial = initial;
17516
17517 return SCIP_OKAY;
17518}
17519
17520/** sets the removable flag of a variable; only possible for original or loose variables */
17522 SCIP_VAR* var, /**< problem variable */
17523 SCIP_Bool removable /**< removable flag */
17524 )
17525{
17526 assert(var != NULL);
17527
17529 return SCIP_INVALIDCALL;
17530
17531 var->removable = removable;
17532
17533 return SCIP_OKAY;
17534}
17535
17536/** gets status of variable */
17538 SCIP_VAR* var /**< problem variable */
17539 )
17540{
17541 assert(var != NULL);
17542
17543 return (SCIP_VARSTATUS)(var->varstatus);
17544}
17545
17546/** returns whether the variable belongs to the original problem */
17548 SCIP_VAR* var /**< problem variable */
17549 )
17550{
17551 assert(var != NULL);
17552 assert(SCIPvarGetStatus(var) != SCIP_VARSTATUS_NEGATED || var->negatedvar != NULL);
17553
17557}
17558
17559/** returns whether the variable belongs to the transformed problem */
17561 SCIP_VAR* var /**< problem variable */
17562 )
17563{
17564 assert(var != NULL);
17565 assert(SCIPvarGetStatus(var) != SCIP_VARSTATUS_NEGATED || var->negatedvar != NULL);
17566
17570}
17571
17572/** returns whether the variable was created by negation of a different variable */
17574 SCIP_VAR* var /**< problem variable */
17575 )
17576{
17577 assert(var != NULL);
17578
17580}
17581
17582/** gets type of variable */
17584 SCIP_VAR* var /**< problem variable */
17585 )
17586{
17587 assert(var != NULL);
17588
17589 return (SCIP_VARTYPE)(var->vartype);
17590}
17591
17592/** returns TRUE if the variable is of binary type; this is the case if:
17593 * (1) variable type is binary
17594 * (2) variable type is integer or implicit integer and
17595 * (i) the global lower bound is greater than or equal to zero
17596 * (ii) the global upper bound is less than or equal to one
17597 */
17599 SCIP_VAR* var /**< problem variable */
17600 )
17601{
17602 assert(var != NULL);
17603
17604 return (SCIPvarGetType(var) == SCIP_VARTYPE_BINARY ||
17605 (SCIPvarGetType(var) != SCIP_VARTYPE_CONTINUOUS && var->glbdom.lb >= 0.0 && var->glbdom.ub <= 1.0));
17606}
17607
17608/** returns whether variable is of integral type (binary, integer, or implicit integer) */
17610 SCIP_VAR* var /**< problem variable */
17611 )
17612{
17613 assert(var != NULL);
17614
17615 return (SCIPvarGetType(var) != SCIP_VARTYPE_CONTINUOUS);
17616}
17617
17618/** returns whether variable's column should be present in the initial root LP */
17620 SCIP_VAR* var /**< problem variable */
17621 )
17622{
17623 assert(var != NULL);
17624
17625 return var->initial;
17626}
17627
17628/** returns whether variable's column is removable from the LP (due to aging or cleanup) */
17630 SCIP_VAR* var /**< problem variable */
17631 )
17632{
17633 assert(var != NULL);
17634
17635 return var->removable;
17636}
17637
17638/** returns whether the variable was deleted from the problem */
17640 SCIP_VAR* var /**< problem variable */
17641 )
17642{
17643 assert(var != NULL);
17644
17645 return var->deleted;
17646}
17647
17648/** marks the variable to be deletable, i.e., it may be deleted completely from the problem;
17649 * method can only be called before the variable is added to the problem by SCIPaddVar() or SCIPaddPricedVar()
17650 */
17652 SCIP_VAR* var /**< problem variable */
17653 )
17654{
17655 assert(var != NULL);
17656 assert(var->probindex == -1);
17657
17658 var->deletable = TRUE;
17659}
17660
17661/** marks the variable to be not deletable from the problem */
17663 SCIP_VAR* var
17664 )
17665{
17666 assert(var != NULL);
17667
17668 var->deletable = FALSE;
17669}
17670
17671/** marks variable to be deleted from global structures (cliques etc.) when cleaning up
17672 *
17673 * @note: this is not equivalent to marking the variable itself for deletion, this is done by using SCIPvarMarkDeletable()
17674 */
17676 SCIP_VAR* var /**< problem variable */
17677 )
17678{
17679 assert(var != NULL);
17680
17681 var->delglobalstructs = TRUE;
17682}
17683
17684/** returns whether the variable was flagged for deletion from global structures (cliques etc.) */
17686 SCIP_VAR* var /**< problem variable */
17687 )
17688{
17689 assert(var != NULL);
17690
17691 return var->delglobalstructs;
17692}
17693
17694/** returns whether a variable has been introduced to define a relaxation
17695 *
17696 * These variables are only valid for the current SCIP solve round,
17697 * they are not contained in any (checked) constraints, but may be used
17698 * in cutting planes, for example.
17699 * Relaxation-only variables are not copied by SCIPcopyVars and cuts
17700 * that contain these variables are not added as linear constraints when
17701 * restarting or transferring information from a copied SCIP to a SCIP.
17702 * Also conflicts with relaxation-only variables are not generated at
17703 * the moment.
17704 */
17706 SCIP_VAR* var /**< problem variable */
17707 )
17708{
17709 assert(var != NULL);
17710
17711 return var->relaxationonly;
17712}
17713
17714/** marks that this variable has only been introduced to define a relaxation
17715 *
17716 * The variable must not have a coefficient in the objective and must be deletable.
17717 * If it is not marked deletable, it will be marked as deletable, which is only possible
17718 * before the variable is added to a problem.
17719 *
17720 * @see SCIPvarIsRelaxationOnly
17721 * @see SCIPvarMarkDeletable
17722 */
17724 SCIP_VAR* var /**< problem variable */
17725 )
17726{
17727 assert(var != NULL);
17728 assert(SCIPvarGetObj(var) == 0.0);
17729
17730 if( !SCIPvarIsDeletable(var) )
17732
17733 var->relaxationonly = TRUE;
17734}
17735
17736/** returns whether variable is allowed to be deleted completely from the problem */
17738 SCIP_VAR* var
17739 )
17740{
17741 assert(var != NULL);
17742
17743 return var->deletable;
17744}
17745
17746/** returns whether variable is an active (neither fixed nor aggregated) variable */
17748 SCIP_VAR* var /**< problem variable */
17749 )
17750{
17751 assert(var != NULL);
17752
17753 return (var->probindex >= 0);
17754}
17755
17756/** gets unique index of variable */
17758 SCIP_VAR* var /**< problem variable */
17759 )
17760{
17761 assert(var != NULL);
17762
17763 return var->index;
17764}
17765
17766/** gets position of variable in problem, or -1 if variable is not active */
17768 SCIP_VAR* var /**< problem variable */
17769 )
17770{
17771 assert(var != NULL);
17772
17773 return var->probindex;
17774}
17775
17776/** gets transformed variable of ORIGINAL variable */
17778 SCIP_VAR* var /**< problem variable */
17779 )
17780{
17781 assert(var != NULL);
17783
17784 return var->data.original.transvar;
17785}
17786
17787/** gets column of COLUMN variable */
17789 SCIP_VAR* var /**< problem variable */
17790 )
17791{
17792 assert(var != NULL);
17794
17795 return var->data.col;
17796}
17797
17798/** returns whether the variable is a COLUMN variable that is member of the current LP */
17800 SCIP_VAR* var /**< problem variable */
17801 )
17802{
17803 assert(var != NULL);
17804
17806}
17807
17808/** gets aggregation variable y of an aggregated variable x = a*y + c */
17810 SCIP_VAR* var /**< problem variable */
17811 )
17812{
17813 assert(var != NULL);
17815 assert(!var->donotaggr);
17816
17817 return var->data.aggregate.var;
17818}
17819
17820/** gets aggregation scalar a of an aggregated variable x = a*y + c */
17822 SCIP_VAR* var /**< problem variable */
17823 )
17824{
17825 assert(var != NULL);
17827 assert(!var->donotaggr);
17828
17829 return var->data.aggregate.scalar;
17830}
17831
17832/** gets aggregation constant c of an aggregated variable x = a*y + c */
17834 SCIP_VAR* var /**< problem variable */
17835 )
17836{
17837 assert(var != NULL);
17839 assert(!var->donotaggr);
17840
17841 return var->data.aggregate.constant;
17842}
17843
17844/** gets number n of aggregation variables of a multi aggregated variable x = a0*y0 + ... + a(n-1)*y(n-1) + c */
17846 SCIP_VAR* var /**< problem variable */
17847 )
17848{
17849 assert(var != NULL);
17851 assert(!var->donotmultaggr);
17852
17853 return var->data.multaggr.nvars;
17854}
17855
17856/** gets vector of aggregation variables y of a multi aggregated variable x = a0*y0 + ... + a(n-1)*y(n-1) + c */
17858 SCIP_VAR* var /**< problem variable */
17859 )
17860{
17861 assert(var != NULL);
17863 assert(!var->donotmultaggr);
17864
17865 return var->data.multaggr.vars;
17866}
17867
17868/** gets vector of aggregation scalars a of a multi aggregated variable x = a0*y0 + ... + a(n-1)*y(n-1) + c */
17870 SCIP_VAR* var /**< problem variable */
17871 )
17872{
17873 assert(var != NULL);
17875 assert(!var->donotmultaggr);
17876
17877 return var->data.multaggr.scalars;
17878}
17879
17880/** gets aggregation constant c of a multi aggregated variable x = a0*y0 + ... + a(n-1)*y(n-1) + c */
17882 SCIP_VAR* var /**< problem variable */
17883 )
17884{
17885 assert(var != NULL);
17887 assert(!var->donotmultaggr);
17888
17889 return var->data.multaggr.constant;
17890}
17891
17892/** gets the negation of the given variable; may return NULL, if no negation is existing yet */
17894 SCIP_VAR* var /**< negated problem variable */
17895 )
17896{
17897 assert(var != NULL);
17898
17899 return var->negatedvar;
17900}
17901
17902/** gets the negation variable x of a negated variable x' = offset - x */
17904 SCIP_VAR* var /**< negated problem variable */
17905 )
17906{
17907 assert(var != NULL);
17909
17910 return var->negatedvar;
17911}
17912
17913/** gets the negation offset of a negated variable x' = offset - x */
17915 SCIP_VAR* var /**< negated problem variable */
17916 )
17917{
17918 assert(var != NULL);
17920
17921 return var->data.negate.constant;
17922}
17923
17924/** gets objective function value of variable */
17926 SCIP_VAR* var /**< problem variable */
17927 )
17928{
17929 assert(var != NULL);
17930
17931 return var->obj;
17932}
17933
17934/** gets the unchanged objective function value of a variable (ignoring temproray changes performed in probing mode) */
17936 SCIP_VAR* var /**< problem variable */
17937 )
17938{
17939 assert(var != NULL);
17940
17941 return var->unchangedobj;
17942}
17943
17944/** gets corresponding objective value of active, fixed, or multi-aggregated problem variable of given variable
17945 * e.g. obj(x) = 1 this method returns for ~x the value -1
17946 */
17948 SCIP_VAR* var, /**< problem variable */
17949 SCIP_Real* aggrobj /**< pointer to store the aggregated objective value */
17950 )
17951{
17952 SCIP_VAR* probvar = var;
17953 SCIP_Real mult = 1.0;
17954
17955 assert(probvar != NULL);
17956 assert(aggrobj != NULL);
17957
17958 while( probvar != NULL )
17959 {
17960 switch( SCIPvarGetStatus(probvar) )
17961 {
17965 (*aggrobj) = mult * SCIPvarGetObj(probvar);
17966 return SCIP_OKAY;
17967
17969 assert(SCIPvarGetObj(probvar) == 0.0);
17970 (*aggrobj) = 0.0;
17971 return SCIP_OKAY;
17972
17974 /* handle multi-aggregated variables depending on one variable only (possibly caused by SCIPvarFlattenAggregationGraph()) */
17975 if ( probvar->data.multaggr.nvars == 1 )
17976 {
17977 assert( probvar->data.multaggr.vars != NULL );
17978 assert( probvar->data.multaggr.scalars != NULL );
17979 assert( probvar->data.multaggr.vars[0] != NULL );
17980 mult *= probvar->data.multaggr.scalars[0];
17981 probvar = probvar->data.multaggr.vars[0];
17982 break;
17983 }
17984 else
17985 {
17986 SCIP_Real tmpobj;
17987 int v;
17988
17989 (*aggrobj) = 0.0;
17990
17991 for( v = probvar->data.multaggr.nvars - 1; v >= 0; --v )
17992 {
17993 SCIP_CALL( SCIPvarGetAggregatedObj(probvar->data.multaggr.vars[v], &tmpobj) );
17994 (*aggrobj) += probvar->data.multaggr.scalars[v] * tmpobj;
17995 }
17996 return SCIP_OKAY;
17997 }
17998
17999 case SCIP_VARSTATUS_AGGREGATED: /* x = a'*x' + c' => a*x + c == (a*a')*x' + (a*c' + c) */
18000 assert(probvar->data.aggregate.var != NULL);
18001 mult *= probvar->data.aggregate.scalar;
18002 probvar = probvar->data.aggregate.var;
18003 break;
18004
18005 case SCIP_VARSTATUS_NEGATED: /* x = - x' + c' => a*x + c == (-a)*x' + (a*c' + c) */
18006 assert(probvar->negatedvar != NULL);
18008 assert(probvar->negatedvar->negatedvar == probvar);
18009 mult *= -1.0;
18010 probvar = probvar->negatedvar;
18011 break;
18012
18013 default:
18014 SCIPABORT();
18015 return SCIP_INVALIDDATA; /*lint !e527*/
18016 }
18017 }
18018
18019 return SCIP_INVALIDDATA;
18020}
18021
18022/** gets original lower bound of original problem variable (i.e. the bound set in problem creation) */
18024 SCIP_VAR* var /**< original problem variable */
18025 )
18026{
18027 assert(var != NULL);
18028 assert(SCIPvarIsOriginal(var));
18029
18031 return var->data.original.origdom.lb;
18032 else
18033 {
18035 assert(var->negatedvar != NULL);
18037
18038 return var->data.negate.constant - var->negatedvar->data.original.origdom.ub;
18039 }
18040}
18041
18042/** gets original upper bound of original problem variable (i.e. the bound set in problem creation) */
18044 SCIP_VAR* var /**< original problem variable */
18045 )
18046{
18047 assert(var != NULL);
18048 assert(SCIPvarIsOriginal(var));
18049
18051 return var->data.original.origdom.ub;
18052 else
18053 {
18055 assert(var->negatedvar != NULL);
18057
18058 return var->data.negate.constant - var->negatedvar->data.original.origdom.lb;
18059 }
18060}
18061
18062/** gets the original hole list of an original variable */
18064 SCIP_VAR* var /**< problem variable */
18065 )
18066{
18067 assert(var != NULL);
18068 assert(SCIPvarIsOriginal(var));
18069
18071 return var->data.original.origdom.holelist;
18072
18073 return NULL;
18074}
18075
18076/** gets global lower bound of variable */
18078 SCIP_VAR* var /**< problem variable */
18079 )
18080{
18081 assert(var != NULL);
18082
18083 return var->glbdom.lb;
18084}
18085
18086/** gets global upper bound of variable */
18088 SCIP_VAR* var /**< problem variable */
18089 )
18090{
18091 assert(var != NULL);
18092
18093 return var->glbdom.ub;
18094}
18095
18096/** gets the global hole list of an active variable */
18098 SCIP_VAR* var /**< problem variable */
18099 )
18100{
18101 assert(var != NULL);
18102
18103 return var->glbdom.holelist;
18104}
18105
18106/** gets best global bound of variable with respect to the objective function */
18108 SCIP_VAR* var /**< problem variable */
18109 )
18110{
18111 assert(var != NULL);
18112
18113 if( var->obj >= 0.0 )
18114 return var->glbdom.lb;
18115 else
18116 return var->glbdom.ub;
18117}
18118
18119/** gets worst global bound of variable with respect to the objective function */
18121 SCIP_VAR* var /**< problem variable */
18122 )
18123{
18124 assert(var != NULL);
18125
18126 if( var->obj >= 0.0 )
18127 return var->glbdom.ub;
18128 else
18129 return var->glbdom.lb;
18130}
18131
18132/** gets current lower bound of variable */
18134 SCIP_VAR* var /**< problem variable */
18135 )
18136{
18137 assert(var != NULL);
18138
18139 return var->locdom.lb;
18140}
18141
18142/** gets current upper bound of variable */
18144 SCIP_VAR* var /**< problem variable */
18145 )
18146{
18147 assert(var != NULL);
18148
18149 return var->locdom.ub;
18150}
18151
18152/** gets the current hole list of an active variable */
18154 SCIP_VAR* var /**< problem variable */
18155 )
18156{
18157 assert(var != NULL);
18158
18159 return var->locdom.holelist;
18160}
18161
18162/** gets best local bound of variable with respect to the objective function */
18164 SCIP_VAR* var /**< problem variable */
18165 )
18166{
18167 assert(var != NULL);
18168
18169 if( var->obj >= 0.0 )
18170 return var->locdom.lb;
18171 else
18172 return var->locdom.ub;
18173}
18174
18175/** gets worst local bound of variable with respect to the objective function */
18177 SCIP_VAR* var /**< problem variable */
18178 )
18179{
18180 assert(var != NULL);
18181
18182 if( var->obj >= 0.0 )
18183 return var->locdom.ub;
18184 else
18185 return var->locdom.lb;
18186}
18187
18188/** gets type (lower or upper) of best bound of variable with respect to the objective function */
18190 SCIP_VAR* var /**< problem variable */
18191 )
18192{
18193 assert(var != NULL);
18194
18195 if( var->obj >= 0.0 )
18196 return SCIP_BOUNDTYPE_LOWER;
18197 else
18198 return SCIP_BOUNDTYPE_UPPER;
18199}
18200
18201/** gets type (lower or upper) of worst bound of variable with respect to the objective function */
18203 SCIP_VAR* var /**< problem variable */
18204 )
18205{
18206 assert(var != NULL);
18207
18208 if( var->obj >= 0.0 )
18209 return SCIP_BOUNDTYPE_UPPER;
18210 else
18211 return SCIP_BOUNDTYPE_LOWER;
18212}
18213
18214/** gets lazy lower bound of variable, returns -infinity if the variable has no lazy lower bound */
18216 SCIP_VAR* var /**< problem variable */
18217 )
18218{
18219 assert(var != NULL);
18220
18221 return var->lazylb;
18222}
18223
18224/** gets lazy upper bound of variable, returns infinity if the variable has no lazy upper bound */
18226 SCIP_VAR* var /**< problem variable */
18227 )
18228{
18229 assert(var != NULL);
18230
18231 return var->lazyub;
18232}
18233
18234/** gets the branch factor of the variable; this value can be used in the branching methods to scale the score
18235 * values of the variables; higher factor leads to a higher probability that this variable is chosen for branching
18236 */
18238 SCIP_VAR* var /**< problem variable */
18239 )
18240{
18241 assert(var != NULL);
18242
18243 return var->branchfactor;
18244}
18245
18246/** gets the branch priority of the variable; variables with higher priority should always be preferred to variables
18247 * with lower priority
18248 */
18250 SCIP_VAR* var /**< problem variable */
18251 )
18252{
18253 assert(var != NULL);
18254
18255 return var->branchpriority;
18256}
18257
18258/** gets the preferred branch direction of the variable (downwards, upwards, or auto) */
18260 SCIP_VAR* var /**< problem variable */
18261 )
18262{
18263 assert(var != NULL);
18264
18265 return (SCIP_BRANCHDIR)var->branchdirection;
18266}
18267
18268/** gets number of variable lower bounds x >= b_i*z_i + d_i of given variable x */
18270 SCIP_VAR* var /**< problem variable */
18271 )
18272{
18273 assert(var != NULL);
18274
18275 return SCIPvboundsGetNVbds(var->vlbs);
18276}
18277
18278/** gets array with bounding variables z_i in variable lower bounds x >= b_i*z_i + d_i of given variable x;
18279 * the variable bounds are sorted by increasing variable index of the bounding variable z_i (see SCIPvarGetIndex())
18280 */
18282 SCIP_VAR* var /**< problem variable */
18283 )
18284{
18285 assert(var != NULL);
18286
18287 return SCIPvboundsGetVars(var->vlbs);
18288}
18289
18290/** gets array with bounding coefficients b_i in variable lower bounds x >= b_i*z_i + d_i of given variable x */
18292 SCIP_VAR* var /**< problem variable */
18293 )
18294{
18295 assert(var != NULL);
18296
18297 return SCIPvboundsGetCoefs(var->vlbs);
18298}
18299
18300/** gets array with bounding constants d_i in variable lower bounds x >= b_i*z_i + d_i of given variable x */
18302 SCIP_VAR* var /**< problem variable */
18303 )
18304{
18305 assert(var != NULL);
18306
18307 return SCIPvboundsGetConstants(var->vlbs);
18308}
18309
18310/** gets number of variable upper bounds x <= b_i*z_i + d_i of given variable x */
18312 SCIP_VAR* var /**< problem variable */
18313 )
18314{
18315 assert(var != NULL);
18316
18317 return SCIPvboundsGetNVbds(var->vubs);
18318}
18319
18320/** gets array with bounding variables z_i in variable upper bounds x <= b_i*z_i + d_i of given variable x;
18321 * the variable bounds are sorted by increasing variable index of the bounding variable z_i (see SCIPvarGetIndex())
18322 */
18324 SCIP_VAR* var /**< problem variable */
18325 )
18326{
18327 assert(var != NULL);
18328
18329 return SCIPvboundsGetVars(var->vubs);
18330}
18331
18332/** gets array with bounding coefficients b_i in variable upper bounds x <= b_i*z_i + d_i of given variable x */
18334 SCIP_VAR* var /**< problem variable */
18335 )
18336{
18337 assert(var != NULL);
18338
18339 return SCIPvboundsGetCoefs(var->vubs);
18340}
18341
18342/** gets array with bounding constants d_i in variable upper bounds x <= b_i*z_i + d_i of given variable x */
18344 SCIP_VAR* var /**< problem variable */
18345 )
18346{
18347 assert(var != NULL);
18348
18349 return SCIPvboundsGetConstants(var->vubs);
18350}
18351
18352/** gets number of implications y <= b or y >= b for x == 0 or x == 1 of given active problem variable x,
18353 * there are no implications for nonbinary variable x
18354 */
18356 SCIP_VAR* var, /**< active problem variable */
18357 SCIP_Bool varfixing /**< FALSE for implications for x == 0, TRUE for x == 1 */
18358 )
18359{
18360 assert(var != NULL);
18361 assert(SCIPvarIsActive(var));
18362
18363 return SCIPimplicsGetNImpls(var->implics, varfixing);
18364}
18365
18366/** gets array with implication variables y of implications y <= b or y >= b for x == 0 or x == 1 of given active
18367 * problem variable x, there are no implications for nonbinary variable x;
18368 * the implications are sorted such that implications with binary implied variables precede the ones with non-binary
18369 * implied variables, and as a second criteria, the implied variables are sorted by increasing variable index
18370 * (see SCIPvarGetIndex())
18371 */
18373 SCIP_VAR* var, /**< active problem variable */
18374 SCIP_Bool varfixing /**< FALSE for implications for x == 0, TRUE for x == 1 */
18375 )
18376{
18377 assert(var != NULL);
18378 assert(SCIPvarIsActive(var));
18379
18380 return SCIPimplicsGetVars(var->implics, varfixing);
18381}
18382
18383/** gets array with implication types of implications y <= b or y >= b for x == 0 or x == 1 of given active problem
18384 * variable x (SCIP_BOUNDTYPE_UPPER if y <= b, SCIP_BOUNDTYPE_LOWER if y >= b),
18385 * there are no implications for nonbinary variable x
18386 */
18388 SCIP_VAR* var, /**< active problem variable */
18389 SCIP_Bool varfixing /**< FALSE for implications for x == 0, TRUE for x == 1 */
18390 )
18391{
18392 assert(var != NULL);
18393 assert(SCIPvarIsActive(var));
18394
18395 return SCIPimplicsGetTypes(var->implics, varfixing);
18396}
18397
18398/** gets array with implication bounds b of implications y <= b or y >= b for x == 0 or x == 1 of given active problem
18399 * variable x, there are no implications for nonbinary variable x
18400 */
18402 SCIP_VAR* var, /**< active problem variable */
18403 SCIP_Bool varfixing /**< FALSE for implications for x == 0, TRUE for x == 1 */
18404 )
18405{
18406 assert(var != NULL);
18407 assert(SCIPvarIsActive(var));
18408
18409 return SCIPimplicsGetBounds(var->implics, varfixing);
18410}
18411
18412/** Gets array with unique ids of implications y <= b or y >= b for x == 0 or x == 1 of given active problem variable x,
18413 * there are no implications for nonbinary variable x.
18414 * If an implication is a shortcut, i.e., it was added as part of the transitive closure of another implication,
18415 * its id is negative, otherwise it is nonnegative.
18416 */
18418 SCIP_VAR* var, /**< active problem variable */
18419 SCIP_Bool varfixing /**< FALSE for implications for x == 0, TRUE for x == 1 */
18420 )
18421{
18422 assert(var != NULL);
18423 assert(SCIPvarIsActive(var));
18424
18425 return SCIPimplicsGetIds(var->implics, varfixing);
18426}
18427
18428/** gets number of cliques, the active variable is contained in */
18430 SCIP_VAR* var, /**< active problem variable */
18431 SCIP_Bool varfixing /**< FALSE for cliques containing x == 0, TRUE for x == 1 */
18432 )
18433{
18434 assert(var != NULL);
18435
18436 return SCIPcliquelistGetNCliques(var->cliquelist, varfixing);
18437}
18438
18439/** gets array of cliques, the active variable is contained in */
18441 SCIP_VAR* var, /**< active problem variable */
18442 SCIP_Bool varfixing /**< FALSE for cliques containing x == 0, TRUE for x == 1 */
18443 )
18444{
18445 assert(var != NULL);
18446
18447 return SCIPcliquelistGetCliques(var->cliquelist, varfixing);
18448}
18449
18450/** gets primal LP solution value of variable */
18452 SCIP_VAR* var /**< problem variable */
18453 )
18454{
18455 assert(var != NULL);
18456
18458 return SCIPcolGetPrimsol(var->data.col);
18459 else
18460 return SCIPvarGetLPSol_rec(var);
18461}
18462
18463/** gets primal NLP solution value of variable */
18465 SCIP_VAR* var /**< problem variable */
18466 )
18467{
18468 assert(var != NULL);
18469
18471 return var->nlpsol;
18472 else
18473 return SCIPvarGetNLPSol_rec(var);
18474}
18475
18476/** return lower bound change info at requested position */
18478 SCIP_VAR* var, /**< problem variable */
18479 int pos /**< requested position */
18480 )
18481{
18482 assert(pos >= 0);
18483 assert(pos < var->nlbchginfos);
18484
18485 return &var->lbchginfos[pos];
18486}
18487
18488/** gets the number of lower bound change info array */
18490 SCIP_VAR* var /**< problem variable */
18491 )
18492{
18493 return var->nlbchginfos;
18494}
18495
18496/** return upper bound change info at requested position */
18498 SCIP_VAR* var, /**< problem variable */
18499 int pos /**< requested position */
18500 )
18501{
18502 assert(pos >= 0);
18503 assert(pos < var->nubchginfos);
18504
18505 return &var->ubchginfos[pos];
18506}
18507
18508/** gets the number upper bound change info array */
18510 SCIP_VAR* var /**< problem variable */
18511 )
18512{
18513 assert(var != NULL);
18514
18515 return var->nubchginfos;
18516}
18517
18518/** returns the value based history for the variable */
18520 SCIP_VAR* var /**< problem variable */
18521 )
18522{
18523 assert(var != NULL);
18524
18525 return var->valuehistory;
18526}
18527
18528/** gets pseudo solution value of variable */
18530 SCIP_VAR* var /**< problem variable */
18531 )
18532{
18533 assert(var != NULL);
18534
18536 return SCIPvarGetBestBoundLocal(var);
18537 else
18538 return SCIPvarGetPseudoSol_rec(var);
18539}
18540
18541/** returns the variable's VSIDS score */
18543 SCIP_VAR* var, /**< problem variable */
18544 SCIP_STAT* stat, /**< problem statistics */
18545 SCIP_BRANCHDIR dir /**< branching direction (downwards, or upwards) */
18546 )
18547{
18548 assert(var != NULL);
18549
18551 return SCIPhistoryGetVSIDS(var->history, dir)/stat->vsidsweight;
18552 else
18553 return SCIPvarGetVSIDS_rec(var, stat, dir);
18554}
18555
18556/** includes event handler with given data in variable's event filter */
18558 SCIP_VAR* var, /**< problem variable */
18559 BMS_BLKMEM* blkmem, /**< block memory */
18560 SCIP_SET* set, /**< global SCIP settings */
18561 SCIP_EVENTTYPE eventtype, /**< event type to catch */
18562 SCIP_EVENTHDLR* eventhdlr, /**< event handler to call for the event processing */
18563 SCIP_EVENTDATA* eventdata, /**< event data to pass to the event handler for the event processing */
18564 int* filterpos /**< pointer to store position of event filter entry, or NULL */
18565 )
18566{
18567 assert(var != NULL);
18568 assert(set != NULL);
18569 assert(var->scip == set->scip);
18570 assert(var->eventfilter != NULL);
18571 assert((eventtype & ~SCIP_EVENTTYPE_VARCHANGED) == 0);
18572 assert((eventtype & SCIP_EVENTTYPE_VARCHANGED) != 0);
18573 assert(SCIPvarIsTransformed(var));
18574
18575 SCIPsetDebugMsg(set, "catch event of type 0x%" SCIP_EVENTTYPE_FORMAT " of variable <%s> with handler %p and data %p\n",
18576 eventtype, var->name, (void*)eventhdlr, (void*)eventdata);
18577
18578 SCIP_CALL( SCIPeventfilterAdd(var->eventfilter, blkmem, set, eventtype, eventhdlr, eventdata, filterpos) );
18579
18580 return SCIP_OKAY;
18581}
18582
18583/** deletes event handler with given data from variable's event filter */
18585 SCIP_VAR* var, /**< problem variable */
18586 BMS_BLKMEM* blkmem, /**< block memory */
18587 SCIP_SET* set, /**< global SCIP settings */
18588 SCIP_EVENTTYPE eventtype, /**< event type mask of dropped event */
18589 SCIP_EVENTHDLR* eventhdlr, /**< event handler to call for the event processing */
18590 SCIP_EVENTDATA* eventdata, /**< event data to pass to the event handler for the event processing */
18591 int filterpos /**< position of event filter entry returned by SCIPvarCatchEvent(), or -1 */
18592 )
18593{
18594 assert(var != NULL);
18595 assert(set != NULL);
18596 assert(var->scip == set->scip);
18597 assert(var->eventfilter != NULL);
18598 assert(SCIPvarIsTransformed(var));
18599
18600 SCIPsetDebugMsg(set, "drop event of variable <%s> with handler %p and data %p\n", var->name, (void*)eventhdlr,
18601 (void*)eventdata);
18602
18603 SCIP_CALL( SCIPeventfilterDel(var->eventfilter, blkmem, set, eventtype, eventhdlr, eventdata, filterpos) );
18604
18605 return SCIP_OKAY;
18606}
18607
18608/** returns the position of the bound change index */
18610 SCIP_BDCHGIDX* bdchgidx /**< bound change index */
18611 )
18612{
18613 assert(bdchgidx != NULL);
18614
18615 return bdchgidx->pos;
18616}
18617
18618/** returns whether first bound change index belongs to an earlier applied bound change than second one */
18620 SCIP_BDCHGIDX* bdchgidx1, /**< first bound change index */
18621 SCIP_BDCHGIDX* bdchgidx2 /**< second bound change index */
18622 )
18623{
18624 assert(bdchgidx1 != NULL);
18625 assert(bdchgidx1->depth >= -2);
18626 assert(bdchgidx1->pos >= 0);
18627 assert(bdchgidx2 != NULL);
18628 assert(bdchgidx2->depth >= -2);
18629 assert(bdchgidx2->pos >= 0);
18630
18631 return (bdchgidx1->depth < bdchgidx2->depth)
18632 || (bdchgidx1->depth == bdchgidx2->depth && (bdchgidx1->pos < bdchgidx2->pos));
18633}
18634
18635/** returns whether first bound change index belongs to an earlier applied bound change than second one;
18636 * if a bound change index is NULL, the bound change index represents the current time, i.e. the time after the
18637 * last bound change was applied to the current node
18638 */
18640 SCIP_BDCHGIDX* bdchgidx1, /**< first bound change index, or NULL */
18641 SCIP_BDCHGIDX* bdchgidx2 /**< second bound change index, or NULL */
18642 )
18643{
18644 assert(bdchgidx1 == NULL || bdchgidx1->depth >= -2);
18645 assert(bdchgidx1 == NULL || bdchgidx1->pos >= 0);
18646 assert(bdchgidx2 == NULL || bdchgidx2->depth >= -2);
18647 assert(bdchgidx2 == NULL || bdchgidx2->pos >= 0);
18648
18649 if( bdchgidx1 == NULL )
18650 return FALSE;
18651 else if( bdchgidx2 == NULL )
18652 return TRUE;
18653 else
18654 return (bdchgidx1->depth < bdchgidx2->depth)
18655 || (bdchgidx1->depth == bdchgidx2->depth && (bdchgidx1->pos < bdchgidx2->pos));
18656}
18657
18658/** returns old bound that was overwritten for given bound change information */
18660 SCIP_BDCHGINFO* bdchginfo /**< bound change information */
18661 )
18662{
18663 assert(bdchginfo != NULL);
18664
18665 return bdchginfo->oldbound;
18666}
18667
18668/** returns new bound installed for given bound change information */
18670 SCIP_BDCHGINFO* bdchginfo /**< bound change information */
18671 )
18672{
18673 assert(bdchginfo != NULL);
18674
18675 return bdchginfo->newbound;
18676}
18677
18678/** returns variable that belongs to the given bound change information */
18680 SCIP_BDCHGINFO* bdchginfo /**< bound change information */
18681 )
18682{
18683 assert(bdchginfo != NULL);
18684
18685 return bdchginfo->var;
18686}
18687
18688/** returns whether the bound change information belongs to a branching decision or a deduction */
18690 SCIP_BDCHGINFO* bdchginfo /**< bound change information */
18691 )
18692{
18693 assert(bdchginfo != NULL);
18694
18695 return (SCIP_BOUNDCHGTYPE)(bdchginfo->boundchgtype);
18696}
18697
18698/** returns whether the bound change information belongs to a lower or upper bound change */
18700 SCIP_BDCHGINFO* bdchginfo /**< bound change information */
18701 )
18702{
18703 assert(bdchginfo != NULL);
18704
18705 return (SCIP_BOUNDTYPE)(bdchginfo->boundtype);
18706}
18707
18708/** returns depth level of given bound change information */
18710 SCIP_BDCHGINFO* bdchginfo /**< bound change information */
18711 )
18712{
18713 assert(bdchginfo != NULL);
18714
18715 return bdchginfo->bdchgidx.depth;
18716}
18717
18718/** returns bound change position in its depth level of given bound change information */
18720 SCIP_BDCHGINFO* bdchginfo /**< bound change information */
18721 )
18722{
18723 assert(bdchginfo != NULL);
18724
18725 return bdchginfo->bdchgidx.pos;
18726}
18727
18728/** returns bound change index of given bound change information */
18730 SCIP_BDCHGINFO* bdchginfo /**< bound change information */
18731 )
18732{
18733 assert(bdchginfo != NULL);
18734
18735 return &bdchginfo->bdchgidx;
18736}
18737
18738/** returns inference variable of given bound change information */
18740 SCIP_BDCHGINFO* bdchginfo /**< bound change information */
18741 )
18742{
18743 assert(bdchginfo != NULL);
18746
18747 return bdchginfo->inferencedata.var;
18748}
18749
18750/** returns inference constraint of given bound change information */
18752 SCIP_BDCHGINFO* bdchginfo /**< bound change information */
18753 )
18754{
18755 assert(bdchginfo != NULL);
18757 assert(bdchginfo->inferencedata.reason.cons != NULL);
18758
18759 return bdchginfo->inferencedata.reason.cons;
18760}
18761
18762/** returns inference propagator of given bound change information, or NULL if no propagator was responsible */
18764 SCIP_BDCHGINFO* bdchginfo /**< bound change information */
18765 )
18766{
18767 assert(bdchginfo != NULL);
18769
18770 return bdchginfo->inferencedata.reason.prop;
18771}
18772
18773/** returns inference user information of given bound change information */
18775 SCIP_BDCHGINFO* bdchginfo /**< bound change information */
18776 )
18777{
18778 assert(bdchginfo != NULL);
18781
18782 return bdchginfo->inferencedata.info;
18783}
18784
18785/** returns inference bound of inference variable of given bound change information */
18787 SCIP_BDCHGINFO* bdchginfo /**< bound change information */
18788 )
18789{
18790 assert(bdchginfo != NULL);
18793
18794 return (SCIP_BOUNDTYPE)(bdchginfo->inferboundtype);
18795}
18796
18797/** returns the relaxed bound change type */
18799 SCIP_BDCHGINFO* bdchginfo /**< bound change to add to the conflict set */
18800 )
18801{
18802 return ((SCIP_BOUNDTYPE)(bdchginfo->boundtype) == SCIP_BOUNDTYPE_LOWER ? bdchginfo->var->conflictrelaxedlb : bdchginfo->var->conflictrelaxedub);
18803}
18804
18805
18806/** returns whether the bound change information belongs to a redundant bound change */
18808 SCIP_BDCHGINFO* bdchginfo /**< bound change information */
18809 )
18810{
18811 assert(bdchginfo != NULL);
18812 assert(bdchginfo->redundant == (bdchginfo->oldbound == bdchginfo->newbound)); /*lint !e777*/
18813
18814 return bdchginfo->redundant;
18815}
18816
18817/** returns whether the bound change has an inference reason (constraint or propagator), that can be resolved */
18819 SCIP_BDCHGINFO* bdchginfo /**< bound change information */
18820 )
18821{
18822 assert(bdchginfo != NULL);
18823
18826 && bdchginfo->inferencedata.reason.prop != NULL);
18827}
18828
18829/** for two bound change informations belonging to the same variable and bound, returns whether the first bound change
18830 * has a tighter new bound as the second bound change
18831 */
18833 SCIP_BDCHGINFO* bdchginfo1, /**< first bound change information */
18834 SCIP_BDCHGINFO* bdchginfo2 /**< second bound change information */
18835 )
18836{
18837 assert(bdchginfo1 != NULL);
18838 assert(bdchginfo2 != NULL);
18839 assert(bdchginfo1->var == bdchginfo2->var);
18840 assert(bdchginfo1->boundtype == bdchginfo2->boundtype);
18841
18842 return (SCIPbdchginfoGetBoundtype(bdchginfo1) == SCIP_BOUNDTYPE_LOWER
18843 ? bdchginfo1->newbound > bdchginfo2->newbound
18844 : bdchginfo1->newbound < bdchginfo2->newbound);
18845}
static long bound
static GRAPHNODE ** active
SCIP_VAR * a
Definition: circlepacking.c:66
SCIP_VAR ** b
Definition: circlepacking.c:65
void SCIPconsCapture(SCIP_CONS *cons)
Definition: cons.c:6254
SCIP_RETCODE SCIPconsRelease(SCIP_CONS **cons, BMS_BLKMEM *blkmem, SCIP_SET *set)
Definition: cons.c:6266
internal methods for constraints and constraint handlers
#define SCIPdebugCheckLbGlobal(scip, var, lb)
Definition: debug.h:285
#define SCIPdebugCheckImplic(set, var, varfixing, implvar, impltype, implbound)
Definition: debug.h:292
#define SCIPdebugCheckUbGlobal(scip, var, ub)
Definition: debug.h:286
#define SCIPdebugCheckVbound(set, var, vbtype, vbvar, vbcoef, vbconstant)
Definition: debug.h:291
#define SCIPdebugCheckAggregation(set, var, aggrvars, scalars, constant, naggrvars)
Definition: debug.h:293
#define SCIP_DEFAULT_INFINITY
Definition: def.h:177
#define NULL
Definition: def.h:266
#define SCIP_MAXSTRLEN
Definition: def.h:287
#define SCIP_Longint
Definition: def.h:157
#define EPSISINT(x, eps)
Definition: def.h:209
#define SCIP_REAL_MAX
Definition: def.h:173
#define SCIP_INVALID
Definition: def.h:192
#define SCIP_Bool
Definition: def.h:91
#define EPSLE(x, y, eps)
Definition: def.h:199
#define MIN(x, y)
Definition: def.h:242
#define SCIP_ALLOC(x)
Definition: def.h:384
#define SCIP_Real
Definition: def.h:172
#define SCIP_UNKNOWN
Definition: def.h:193
#define ABS(x)
Definition: def.h:234
#define SQR(x)
Definition: def.h:213
#define EPSEQ(x, y, eps)
Definition: def.h:197
#define TRUE
Definition: def.h:93
#define FALSE
Definition: def.h:94
#define MAX(x, y)
Definition: def.h:238
#define SCIP_CALL_ABORT(x)
Definition: def.h:352
#define SCIPABORT()
Definition: def.h:345
#define SCIP_REAL_MIN
Definition: def.h:174
#define REALABS(x)
Definition: def.h:196
#define EPSZ(x, eps)
Definition: def.h:202
#define SCIP_CALL(x)
Definition: def.h:373
SCIP_RETCODE SCIPeventCreateLbChanged(SCIP_EVENT **event, BMS_BLKMEM *blkmem, SCIP_VAR *var, SCIP_Real oldbound, SCIP_Real newbound)
Definition: event.c:674
SCIP_RETCODE SCIPeventCreateVarFixed(SCIP_EVENT **event, BMS_BLKMEM *blkmem, SCIP_VAR *var)
Definition: event.c:562
SCIP_RETCODE SCIPeventCreateUbChanged(SCIP_EVENT **event, BMS_BLKMEM *blkmem, SCIP_VAR *var, SCIP_Real oldbound, SCIP_Real newbound)
Definition: event.c:700
SCIP_RETCODE SCIPeventCreateVarUnlocked(SCIP_EVENT **event, BMS_BLKMEM *blkmem, SCIP_VAR *var)
Definition: event.c:584
SCIP_RETCODE SCIPeventCreateObjChanged(SCIP_EVENT **event, BMS_BLKMEM *blkmem, SCIP_VAR *var, SCIP_Real oldobj, SCIP_Real newobj)
Definition: event.c:605
SCIP_RETCODE SCIPeventqueueAdd(SCIP_EVENTQUEUE *eventqueue, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_PRIMAL *primal, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTFILTER *eventfilter, SCIP_EVENT **event)
Definition: event.c:2240
SCIP_RETCODE SCIPeventfilterFree(SCIP_EVENTFILTER **eventfilter, BMS_BLKMEM *blkmem, SCIP_SET *set)
Definition: event.c:1846
SCIP_Bool SCIPeventqueueIsDelayed(SCIP_EVENTQUEUE *eventqueue)
Definition: event.c:2568
SCIP_RETCODE SCIPeventCreateGholeAdded(SCIP_EVENT **event, BMS_BLKMEM *blkmem, SCIP_VAR *var, SCIP_Real left, SCIP_Real right)
Definition: event.c:726
SCIP_RETCODE SCIPeventfilterDel(SCIP_EVENTFILTER *eventfilter, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_EVENTTYPE eventtype, SCIP_EVENTHDLR *eventhdlr, SCIP_EVENTDATA *eventdata, int filterpos)
Definition: event.c:1979
SCIP_RETCODE SCIPeventfilterCreate(SCIP_EVENTFILTER **eventfilter, BMS_BLKMEM *blkmem)
Definition: event.c:1821
SCIP_RETCODE SCIPeventProcess(SCIP_EVENT *event, SCIP_SET *set, SCIP_PRIMAL *primal, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTFILTER *eventfilter)
Definition: event.c:1574
SCIP_RETCODE SCIPeventCreateImplAdded(SCIP_EVENT **event, BMS_BLKMEM *blkmem, SCIP_VAR *var)
Definition: event.c:814
SCIP_RETCODE SCIPeventChgType(SCIP_EVENT *event, SCIP_EVENTTYPE eventtype)
Definition: event.c:1040
SCIP_RETCODE SCIPeventfilterAdd(SCIP_EVENTFILTER *eventfilter, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_EVENTTYPE eventtype, SCIP_EVENTHDLR *eventhdlr, SCIP_EVENTDATA *eventdata, int *filterpos)
Definition: event.c:1886
SCIP_RETCODE SCIPeventCreateGubChanged(SCIP_EVENT **event, BMS_BLKMEM *blkmem, SCIP_VAR *var, SCIP_Real oldbound, SCIP_Real newbound)
Definition: event.c:651
SCIP_RETCODE SCIPeventCreateGlbChanged(SCIP_EVENT **event, BMS_BLKMEM *blkmem, SCIP_VAR *var, SCIP_Real oldbound, SCIP_Real newbound)
Definition: event.c:628
SCIP_RETCODE SCIPeventCreateTypeChanged(SCIP_EVENT **event, BMS_BLKMEM *blkmem, SCIP_VAR *var, SCIP_VARTYPE oldtype, SCIP_VARTYPE newtype)
Definition: event.c:833
internal methods for managing events
const char * SCIPgetProbName(SCIP *scip)
Definition: scip_prob.c:1067
SCIP_RETCODE SCIPhashmapInsert(SCIP_HASHMAP *hashmap, void *origin, void *image)
Definition: misc.c:3159
SCIP_Bool SCIPhashmapExists(SCIP_HASHMAP *hashmap, void *origin)
Definition: misc.c:3426
SCIP_Longint SCIPcalcGreComDiv(SCIP_Longint val1, SCIP_Longint val2)
Definition: misc.c:9124
SCIP_Longint SCIPcalcSmaComMul(SCIP_Longint val1, SCIP_Longint val2)
Definition: misc.c:9376
SCIP_Bool SCIPrealToRational(SCIP_Real val, SCIP_Real mindelta, SCIP_Real maxdelta, SCIP_Longint maxdnom, SCIP_Longint *nominator, SCIP_Longint *denominator)
Definition: misc.c:9397
SCIP_Real SCIPcolGetObj(SCIP_COL *col)
Definition: lp.c:16953
SCIP_Real SCIPcolGetLb(SCIP_COL *col)
Definition: lp.c:16963
SCIP_Real SCIPcolGetPrimsol(SCIP_COL *col)
Definition: lp.c:16996
SCIP_Real SCIPcolGetUb(SCIP_COL *col)
Definition: lp.c:16973
SCIP_Bool SCIPcolIsInLP(SCIP_COL *col)
Definition: lp.c:17115
SCIP_BASESTAT SCIPcolGetBasisStatus(SCIP_COL *col)
Definition: lp.c:17031
const char * SCIPconsGetName(SCIP_CONS *cons)
Definition: cons.c:8214
SCIP_Longint SCIPnodeGetNumber(SCIP_NODE *node)
Definition: tree.c:7510
SCIP_NODE * SCIPnodeGetParent(SCIP_NODE *node)
Definition: tree.c:7805
const char * SCIPpropGetName(SCIP_PROP *prop)
Definition: prop.c:941
SCIP_Longint SCIPgetNLPIterations(SCIP *scip)
SCIP_NODE * SCIPgetFocusNode(SCIP *scip)
Definition: scip_tree.c:72
int SCIPgetDepth(SCIP *scip)
Definition: scip_tree.c:672
SCIP_Bool SCIPvarIsInitial(SCIP_VAR *var)
Definition: var.c:17619
SCIP_Real SCIPvarGetLPSol_rec(SCIP_VAR *var)
Definition: var.c:13068
int SCIPvarCompareActiveAndNegated(SCIP_VAR *var1, SCIP_VAR *var2)
Definition: var.c:11903
void SCIPvarSetDelorigData(SCIP_VAR *var, SCIP_DECL_VARDELORIG((*vardelorig)))
Definition: var.c:17459
SCIP_RETCODE SCIPvarGetOrigvarSum(SCIP_VAR **var, SCIP_Real *scalar, SCIP_Real *constant)
Definition: var.c:12773
SCIP_HOLELIST * SCIPvarGetHolelistLocal(SCIP_VAR *var)
Definition: var.c:18153
int SCIPvarGetNVlbs(SCIP_VAR *var)
Definition: var.c:18269
SCIP_RETCODE SCIPvarGetProbvarBound(SCIP_VAR **var, SCIP_Real *bound, SCIP_BOUNDTYPE *boundtype)
Definition: var.c:12468
SCIP_Bool SCIPvarIsDeleted(SCIP_VAR *var)
Definition: var.c:17639
SCIP_Real SCIPvarGetNegationConstant(SCIP_VAR *var)
Definition: var.c:17914
SCIP_COL * SCIPvarGetCol(SCIP_VAR *var)
Definition: var.c:17788
SCIP_Bool SCIPbdchginfoIsRedundant(SCIP_BDCHGINFO *bdchginfo)
Definition: var.c:18807
SCIP_Bool SCIPvarWasFixedAtIndex(SCIP_VAR *var, SCIP_BDCHGIDX *bdchgidx, SCIP_Bool after)
Definition: var.c:16969
SCIP_Real SCIPvarGetAvgBranchdepthCurrentRun(SCIP_VAR *var, SCIP_BRANCHDIR dir)
Definition: var.c:15831
SCIP_Bool SCIPvarMayRoundUp(SCIP_VAR *var)
Definition: var.c:3451
SCIP_Real SCIPvarGetMultaggrConstant(SCIP_VAR *var)
Definition: var.c:17881
SCIP_BOUNDTYPE SCIPvarGetBestBoundType(SCIP_VAR *var)
Definition: var.c:18189
void SCIPvarsGetProbvar(SCIP_VAR **vars, int nvars)
Definition: var.c:12197
SCIP_Real SCIPvarGetSol(SCIP_VAR *var, SCIP_Bool getlpval)
Definition: var.c:13256
SCIP_VAR * SCIPvarGetNegatedVar(SCIP_VAR *var)
Definition: var.c:17893
SCIP_Real * SCIPvarGetVlbCoefs(SCIP_VAR *var)
Definition: var.c:18291
SCIP_Bool SCIPvarIsActive(SCIP_VAR *var)
Definition: var.c:17747
SCIP_Bool SCIPvarIsBinary(SCIP_VAR *var)
Definition: var.c:17598
SCIP_BOUNDTYPE SCIPboundchgGetBoundtype(SCIP_BOUNDCHG *boundchg)
Definition: var.c:17345
SCIP_Real SCIPholelistGetRight(SCIP_HOLELIST *holelist)
Definition: var.c:17395
void SCIPvarSetTransData(SCIP_VAR *var, SCIP_DECL_VARTRANS((*vartrans)))
Definition: var.c:17471
SCIP_Real SCIPvarGetAvgBranchdepth(SCIP_VAR *var, SCIP_BRANCHDIR dir)
Definition: var.c:15786
SCIP_Real SCIPvarGetBestBoundGlobal(SCIP_VAR *var)
Definition: var.c:18107
SCIP_Bool SCIPbdchgidxIsEarlier(SCIP_BDCHGIDX *bdchgidx1, SCIP_BDCHGIDX *bdchgidx2)
Definition: var.c:18639
SCIP_Bool SCIPvarWasFixedEarlier(SCIP_VAR *var1, SCIP_VAR *var2)
Definition: var.c:17117
SCIP_BDCHGIDX * SCIPbdchginfoGetIdx(SCIP_BDCHGINFO *bdchginfo)
Definition: var.c:18729
SCIP_VAR * SCIPboundchgGetVar(SCIP_BOUNDCHG *boundchg)
Definition: var.c:17325
SCIP_Bool SCIPvarHasImplic(SCIP_VAR *var, SCIP_Bool varfixing, SCIP_VAR *implvar, SCIP_BOUNDTYPE impltype)
Definition: var.c:11110
SCIP_BOUNDCHG * SCIPdomchgGetBoundchg(SCIP_DOMCHG *domchg, int pos)
Definition: var.c:17373
int SCIPvarGetNImpls(SCIP_VAR *var, SCIP_Bool varfixing)
Definition: var.c:18355
SCIP_VARSTATUS SCIPvarGetStatus(SCIP_VAR *var)
Definition: var.c:17537
int SCIPvarGetNLocksUpType(SCIP_VAR *var, SCIP_LOCKTYPE locktype)
Definition: var.c:3353
SCIP_BOUNDCHGTYPE SCIPboundchgGetBoundchgtype(SCIP_BOUNDCHG *boundchg)
Definition: var.c:17335
SCIP_Real SCIPvarGetInferenceSum(SCIP_VAR *var, SCIP_BRANCHDIR dir)
Definition: var.c:15978
SCIP_Real SCIPvarGetAggrConstant(SCIP_VAR *var)
Definition: var.c:17833
SCIP_RETCODE SCIPvarGetAggregatedObj(SCIP_VAR *var, SCIP_Real *aggrobj)
Definition: var.c:17947
SCIP_Real SCIPvarGetUbLocal(SCIP_VAR *var)
Definition: var.c:18143
int SCIPvarGetNLocksDown(SCIP_VAR *var)
Definition: var.c:3416
SCIP_Real SCIPvarGetBestRootSol(SCIP_VAR *var)
Definition: var.c:13714
void SCIPvarSetDeltransData(SCIP_VAR *var, SCIP_DECL_VARDELTRANS((*vardeltrans)))
Definition: var.c:17483
SCIP_HOLELIST * SCIPholelistGetNext(SCIP_HOLELIST *holelist)
Definition: var.c:17405
SCIP_Real SCIPvarGetLbOriginal(SCIP_VAR *var)
Definition: var.c:18023
SCIP_BDCHGINFO * SCIPvarGetLbchgInfo(SCIP_VAR *var, SCIP_BDCHGIDX *bdchgidx, SCIP_Bool after)
Definition: var.c:16576
SCIP_DECL_HASHGETKEY(SCIPvarGetHashkey)
Definition: var.c:11984
SCIP_Bool SCIPvarIsTransformed(SCIP_VAR *var)
Definition: var.c:17560
void SCIPvarMarkDeletable(SCIP_VAR *var)
Definition: var.c:17651
void SCIPvarGetImplicVarBounds(SCIP_VAR *var, SCIP_Bool varfixing, SCIP_VAR *implvar, SCIP_Real *lb, SCIP_Real *ub)
Definition: var.c:11145
SCIP_PROP * SCIPbdchginfoGetInferProp(SCIP_BDCHGINFO *bdchginfo)
Definition: var.c:18763
SCIP_Real SCIPboundchgGetNewbound(SCIP_BOUNDCHG *boundchg)
Definition: var.c:17315
SCIP_Bool SCIPvarMayRoundDown(SCIP_VAR *var)
Definition: var.c:3440
SCIP_Real SCIPvarGetObj(SCIP_VAR *var)
Definition: var.c:17925
SCIP_Real SCIPvarGetAggrScalar(SCIP_VAR *var)
Definition: var.c:17821
SCIP_DECL_SORTPTRCOMP(SCIPvarCompActiveAndNegated)
Definition: var.c:11933
SCIP_VAR * SCIPvarGetProbvar(SCIP_VAR *var)
Definition: var.c:12217
void SCIPvarMarkRelaxationOnly(SCIP_VAR *var)
Definition: var.c:17723
SCIP_VARTYPE SCIPvarGetType(SCIP_VAR *var)
Definition: var.c:17583
SCIP_Real SCIPvarGetUbGlobal(SCIP_VAR *var)
Definition: var.c:18087
SCIP_RETCODE SCIPvarSetInitial(SCIP_VAR *var, SCIP_Bool initial)
Definition: var.c:17505
SCIP_VAR ** SCIPvarGetImplVars(SCIP_VAR *var, SCIP_Bool varfixing)
Definition: var.c:18372
void SCIPvarSetBestRootSol(SCIP_VAR *var, SCIP_Real rootsol, SCIP_Real rootredcost, SCIP_Real rootlpobjval)
Definition: var.c:13846
int SCIPbdchginfoGetDepth(SCIP_BDCHGINFO *bdchginfo)
Definition: var.c:18709
int SCIPbdchginfoGetInferInfo(SCIP_BDCHGINFO *bdchginfo)
Definition: var.c:18774
int SCIPvarGetIndex(SCIP_VAR *var)
Definition: var.c:17757
SCIP_CONS * SCIPbdchginfoGetInferCons(SCIP_BDCHGINFO *bdchginfo)
Definition: var.c:18751
SCIP_Real SCIPvarGetNLPSol_rec(SCIP_VAR *var)
Definition: var.c:13141
SCIP_BDCHGIDX * SCIPvarGetLastBdchgIndex(SCIP_VAR *var)
Definition: var.c:16992
int SCIPbdchginfoGetPos(SCIP_BDCHGINFO *bdchginfo)
Definition: var.c:18719
SCIP_Real SCIPvarGetWorstBoundLocal(SCIP_VAR *var)
Definition: var.c:18176
int SCIPvarGetNUses(SCIP_VAR *var)
Definition: var.c:17428
int SCIPdomchgGetNBoundchgs(SCIP_DOMCHG *domchg)
Definition: var.c:17365
int SCIPvarGetProbindex(SCIP_VAR *var)
Definition: var.c:17767
const char * SCIPvarGetName(SCIP_VAR *var)
Definition: var.c:17418
SCIP_Real SCIPvarGetUbOriginal(SCIP_VAR *var)
Definition: var.c:18043
SCIP_Real SCIPvarGetWorstBoundGlobal(SCIP_VAR *var)
Definition: var.c:18120
SCIP_VAR * SCIPbdchginfoGetVar(SCIP_BDCHGINFO *bdchginfo)
Definition: var.c:18679
SCIP_Bool SCIPvarHasBinaryImplic(SCIP_VAR *var, SCIP_Bool varfixing, SCIP_VAR *implvar, SCIP_Bool implvarfixing)
Definition: var.c:11130
void SCIPvarMarkDeleteGlobalStructures(SCIP_VAR *var)
Definition: var.c:17675
SCIP_Real * SCIPvarGetVlbConstants(SCIP_VAR *var)
Definition: var.c:18301
SCIP_Real SCIPvarGetRootSol(SCIP_VAR *var)
Definition: var.c:13349
int * SCIPvarGetImplIds(SCIP_VAR *var, SCIP_Bool varfixing)
Definition: var.c:18417
SCIP_Real SCIPvarGetBestBoundLocal(SCIP_VAR *var)
Definition: var.c:18163
int SCIPvarGetNVubs(SCIP_VAR *var)
Definition: var.c:18311
SCIP_Real SCIPvarGetBranchFactor(SCIP_VAR *var)
Definition: var.c:18237
SCIP_Real SCIPvarGetAvgSol(SCIP_VAR *var)
Definition: var.c:14061
SCIP_Bool SCIPvarIsDeletable(SCIP_VAR *var)
Definition: var.c:17737
SCIP_Real SCIPbdchginfoGetOldbound(SCIP_BDCHGINFO *bdchginfo)
Definition: var.c:18659
SCIP_Bool SCIPvarIsIntegral(SCIP_VAR *var)
Definition: var.c:17609
SCIP_Bool SCIPvarIsTransformedOrigvar(SCIP_VAR *var)
Definition: var.c:12860
SCIP_Real SCIPvarGetUbLazy(SCIP_VAR *var)
Definition: var.c:18225
SCIP_Real SCIPvarGetPseudoSol(SCIP_VAR *var)
Definition: var.c:18529
SCIP_BRANCHDIR SCIPvarGetBranchDirection(SCIP_VAR *var)
Definition: var.c:18259
SCIP_BOUNDTYPE SCIPbdchginfoGetInferBoundtype(SCIP_BDCHGINFO *bdchginfo)
Definition: var.c:18786
void SCIPvarSetData(SCIP_VAR *var, SCIP_VARDATA *vardata)
Definition: var.c:17448
SCIP_Real * SCIPvarGetImplBounds(SCIP_VAR *var, SCIP_Bool varfixing)
Definition: var.c:18401
SCIP_Real SCIPvarGetLPSol(SCIP_VAR *var)
Definition: var.c:18451
SCIP_BDCHGINFO * SCIPvarGetBdchgInfo(SCIP_VAR *var, SCIP_BOUNDTYPE boundtype, SCIP_BDCHGIDX *bdchgidx, SCIP_Bool after)
Definition: var.c:16688
SCIP_VARDATA * SCIPvarGetData(SCIP_VAR *var)
Definition: var.c:17438
SCIP_VAR ** SCIPvarGetMultaggrVars(SCIP_VAR *var)
Definition: var.c:17857
SCIP_Bool SCIPbdchginfoIsTighter(SCIP_BDCHGINFO *bdchginfo1, SCIP_BDCHGINFO *bdchginfo2)
Definition: var.c:18832
int SCIPvarGetMultaggrNVars(SCIP_VAR *var)
Definition: var.c:17845
SCIP_RETCODE SCIPvarSetRemovable(SCIP_VAR *var, SCIP_Bool removable)
Definition: var.c:17521
SCIP_HOLELIST * SCIPvarGetHolelistOriginal(SCIP_VAR *var)
Definition: var.c:18063
SCIP_Bool SCIPvarIsRemovable(SCIP_VAR *var)
Definition: var.c:17629
int SCIPvarGetNCliques(SCIP_VAR *var, SCIP_Bool varfixing)
Definition: var.c:18429
SCIP_BOUNDCHGTYPE SCIPbdchginfoGetChgtype(SCIP_BDCHGINFO *bdchginfo)
Definition: var.c:18689
SCIP_Real SCIPvarGetLbLocal(SCIP_VAR *var)
Definition: var.c:18133
SCIP_Bool SCIPvarIsNegated(SCIP_VAR *var)
Definition: var.c:17573
SCIP_DECL_HASHKEYEQ(SCIPvarIsHashkeyEq)
Definition: var.c:11990
SCIP_VAR * SCIPbdchginfoGetInferVar(SCIP_BDCHGINFO *bdchginfo)
Definition: var.c:18739
SCIP_Bool SCIPbdchginfoHasInferenceReason(SCIP_BDCHGINFO *bdchginfo)
Definition: var.c:18818
SCIP_Bool SCIPboundchgIsRedundant(SCIP_BOUNDCHG *boundchg)
Definition: var.c:17355
SCIP_Longint SCIPvarGetNBranchings(SCIP_VAR *var, SCIP_BRANCHDIR dir)
Definition: var.c:15698
SCIP_Bool SCIPvarIsRelaxationOnly(SCIP_VAR *var)
Definition: var.c:17705
SCIP_VAR * SCIPvarGetNegationVar(SCIP_VAR *var)
Definition: var.c:17903
SCIP_RETCODE SCIPvarGetProbvarHole(SCIP_VAR **var, SCIP_Real *left, SCIP_Real *right)
Definition: var.c:12561
SCIP_VAR ** SCIPvarGetVlbVars(SCIP_VAR *var)
Definition: var.c:18281
SCIP_BDCHGINFO * SCIPvarGetUbchgInfo(SCIP_VAR *var, SCIP_BDCHGIDX *bdchgidx, SCIP_Bool after)
Definition: var.c:16632
SCIP_Real SCIPholelistGetLeft(SCIP_HOLELIST *holelist)
Definition: var.c:17385
int SCIPvarGetBranchPriority(SCIP_VAR *var)
Definition: var.c:18249
SCIP_Bool SCIPvarIsOriginal(SCIP_VAR *var)
Definition: var.c:17547
SCIP_CLIQUE ** SCIPvarGetCliques(SCIP_VAR *var, SCIP_Bool varfixing)
Definition: var.c:18440
SCIP_Real SCIPvarGetLbGlobal(SCIP_VAR *var)
Definition: var.c:18077
void SCIPvarMarkNotDeletable(SCIP_VAR *var)
Definition: var.c:17662
SCIP_Real SCIPvarGetBestRootRedcost(SCIP_VAR *var)
Definition: var.c:13781
SCIP_BDCHGINFO * SCIPvarGetBdchgInfoLb(SCIP_VAR *var, int pos)
Definition: var.c:18477
SCIP_DECL_HASHKEYVAL(SCIPvarGetHashkeyVal)
Definition: var.c:11998
int SCIPvarCompare(SCIP_VAR *var1, SCIP_VAR *var2)
Definition: var.c:11941
SCIP_Real SCIPvarGetCutoffSumCurrentRun(SCIP_VAR *var, SCIP_BRANCHDIR dir)
Definition: var.c:16221
SCIP_Real SCIPvarGetBestRootLPObjval(SCIP_VAR *var)
Definition: var.c:13815
SCIP_Real SCIPvarGetLbAtIndex(SCIP_VAR *var, SCIP_BDCHGIDX *bdchgidx, SCIP_Bool after)
Definition: var.c:16709
SCIP_RETCODE SCIPvarGetProbvarBinary(SCIP_VAR **var, SCIP_Bool *negated)
Definition: var.c:12309
SCIP_Longint SCIPvarGetNBranchingsCurrentRun(SCIP_VAR *var, SCIP_BRANCHDIR dir)
Definition: var.c:15743
SCIP_Real * SCIPvarGetVubConstants(SCIP_VAR *var)
Definition: var.c:18343
int SCIPvarGetNLocksUp(SCIP_VAR *var)
Definition: var.c:3429
SCIP_VAR * SCIPvarGetTransVar(SCIP_VAR *var)
Definition: var.c:17777
SCIP_Real SCIPvarGetNLPSol(SCIP_VAR *var)
Definition: var.c:18464
SCIP_VAR ** SCIPvarGetVubVars(SCIP_VAR *var)
Definition: var.c:18323
int SCIPvarGetNBdchgInfosUb(SCIP_VAR *var)
Definition: var.c:18509
SCIP_BOUNDTYPE SCIPbdchginfoGetBoundtype(SCIP_BDCHGINFO *bdchginfo)
Definition: var.c:18699
SCIP_VALUEHISTORY * SCIPvarGetValuehistory(SCIP_VAR *var)
Definition: var.c:18519
SCIP_BOUNDTYPE SCIPvarGetWorstBoundType(SCIP_VAR *var)
Definition: var.c:18202
SCIP_Real SCIPvarGetInferenceSumCurrentRun(SCIP_VAR *var, SCIP_BRANCHDIR dir)
Definition: var.c:16023
SCIP_Bool SCIPvarsHaveCommonClique(SCIP_VAR *var1, SCIP_Bool value1, SCIP_VAR *var2, SCIP_Bool value2, SCIP_Bool regardimplics)
Definition: var.c:11474
SCIP_Bool SCIPbdchgidxIsEarlierNonNull(SCIP_BDCHGIDX *bdchgidx1, SCIP_BDCHGIDX *bdchgidx2)
Definition: var.c:18619
SCIP_Real * SCIPvarGetVubCoefs(SCIP_VAR *var)
Definition: var.c:18333
SCIP_HOLELIST * SCIPvarGetHolelistGlobal(SCIP_VAR *var)
Definition: var.c:18097
SCIP_Real SCIPvarGetBdAtIndex(SCIP_VAR *var, SCIP_BOUNDTYPE boundtype, SCIP_BDCHGIDX *bdchgidx, SCIP_Bool after)
Definition: var.c:16949
SCIP_Real SCIPbdchginfoGetNewbound(SCIP_BDCHGINFO *bdchginfo)
Definition: var.c:18669
int SCIPvarGetNLocksDownType(SCIP_VAR *var, SCIP_LOCKTYPE locktype)
Definition: var.c:3295
SCIP_Real SCIPvarGetUbAtIndex(SCIP_VAR *var, SCIP_BDCHGIDX *bdchgidx, SCIP_Bool after)
Definition: var.c:16828
SCIP_BDCHGINFO * SCIPvarGetBdchgInfoUb(SCIP_VAR *var, int pos)
Definition: var.c:18497
int SCIPvarGetNBdchgInfosLb(SCIP_VAR *var)
Definition: var.c:18489
SCIP_BOUNDTYPE * SCIPvarGetImplTypes(SCIP_VAR *var, SCIP_Bool varfixing)
Definition: var.c:18387
int SCIPvarGetLastBdchgDepth(SCIP_VAR *var)
Definition: var.c:17029
void SCIPvarSetCopyData(SCIP_VAR *var, SCIP_DECL_VARCOPY((*varcopy)))
Definition: var.c:17494
SCIP_RETCODE SCIPvarsGetProbvarBinary(SCIP_VAR ***vars, SCIP_Bool **negatedarr, int nvars)
Definition: var.c:12277
SCIP_Real SCIPvarGetUnchangedObj(SCIP_VAR *var)
Definition: var.c:17935
SCIP_Real * SCIPvarGetMultaggrScalars(SCIP_VAR *var)
Definition: var.c:17869
SCIP_Real SCIPvarGetCutoffSum(SCIP_VAR *var, SCIP_BRANCHDIR dir)
Definition: var.c:16178
SCIP_Real SCIPvarGetLbLazy(SCIP_VAR *var)
Definition: var.c:18215
SCIP_Bool SCIPvarIsInLP(SCIP_VAR *var)
Definition: var.c:17799
SCIP_VAR * SCIPvarGetAggrVar(SCIP_VAR *var)
Definition: var.c:17809
SCIP_Real SCIPnormalCDF(SCIP_Real mean, SCIP_Real variance, SCIP_Real value)
Definition: misc.c:199
SCIP_Real SCIPcomputeTwoSampleTTestValue(SCIP_Real meanx, SCIP_Real meany, SCIP_Real variancex, SCIP_Real variancey, SCIP_Real countx, SCIP_Real county)
Definition: misc.c:126
SCIP_Real SCIPstudentTGetCriticalValue(SCIP_CONFIDENCELEVEL clevel, int df)
Definition: misc.c:109
SCIP_Bool SCIPsortedvecFindPtr(void **ptrarray, SCIP_DECL_SORTPTRCOMP((*ptrcomp)), void *val, int len, int *pos)
void SCIPsortPtr(void **ptrarray, SCIP_DECL_SORTPTRCOMP((*ptrcomp)), int len)
void SCIPsortPtrReal(void **ptrarray, SCIP_Real *realarray, SCIP_DECL_SORTPTRCOMP((*ptrcomp)), int len)
int SCIPsnprintf(char *t, int len, const char *s,...)
Definition: misc.c:10880
SCIP_Bool SCIPstrToRealValue(const char *str, SCIP_Real *value, char **endptr)
Definition: misc.c:11008
void SCIPstrCopySection(const char *str, char startchar, char endchar, char *token, int size, char **endptr)
Definition: misc.c:11038
SCIP_RETCODE SCIPvaluehistoryCreate(SCIP_VALUEHISTORY **valuehistory, BMS_BLKMEM *blkmem)
Definition: history.c:243
SCIP_RETCODE SCIPvaluehistoryFind(SCIP_VALUEHISTORY *valuehistory, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_Real value, SCIP_HISTORY **history)
Definition: history.c:284
void SCIPvaluehistoryFree(SCIP_VALUEHISTORY **valuehistory, BMS_BLKMEM *blkmem)
Definition: history.c:262
void SCIPvaluehistoryScaleVSIDS(SCIP_VALUEHISTORY *valuehistory, SCIP_Real scalar)
Definition: history.c:329
void SCIPhistoryReset(SCIP_HISTORY *history)
Definition: history.c:78
SCIP_Real SCIPhistoryGetPseudocost(SCIP_HISTORY *history, SCIP_Real solvaldelta)
Definition: history.c:446
SCIP_Real SCIPhistoryGetAvgInferences(SCIP_HISTORY *history, SCIP_BRANCHDIR dir)
Definition: history.c:665
SCIP_Longint SCIPhistoryGetNActiveConflicts(SCIP_HISTORY *history, SCIP_BRANCHDIR dir)
Definition: history.c:565
SCIP_Longint SCIPhistoryGetNBranchings(SCIP_HISTORY *history, SCIP_BRANCHDIR dir)
Definition: history.c:639
SCIP_Real SCIPhistoryGetAvgConflictlength(SCIP_HISTORY *history, SCIP_BRANCHDIR dir)
Definition: history.c:578
SCIP_Real SCIPhistoryGetAvgCutoffs(SCIP_HISTORY *history, SCIP_BRANCHDIR dir)
Definition: history.c:691
SCIP_RETCODE SCIPhistoryCreate(SCIP_HISTORY **history, BMS_BLKMEM *blkmem)
Definition: history.c:51
void SCIPhistorySetLastGMIeff(SCIP_HISTORY *history, SCIP_Real gmieff)
Definition: history.c:782
void SCIPhistoryIncInferenceSum(SCIP_HISTORY *history, SCIP_BRANCHDIR dir, SCIP_Real weight)
Definition: history.c:607
SCIP_Real SCIPhistoryGetCutoffSum(SCIP_HISTORY *history, SCIP_BRANCHDIR dir)
Definition: history.c:678
SCIP_Real SCIPhistoryGetPseudocostCount(SCIP_HISTORY *history, SCIP_BRANCHDIR dir)
Definition: history.c:484
SCIP_Real SCIPhistoryGetPseudocostVariance(SCIP_HISTORY *history, SCIP_BRANCHDIR direction)
Definition: history.c:460
void SCIPhistoryIncNActiveConflicts(SCIP_HISTORY *history, SCIP_BRANCHDIR dir, SCIP_Real length)
Definition: history.c:549
void SCIPhistoryScaleVSIDS(SCIP_HISTORY *history, SCIP_Real scalar)
Definition: history.c:524
void SCIPhistoryIncCutoffSum(SCIP_HISTORY *history, SCIP_BRANCHDIR dir, SCIP_Real weight)
Definition: history.c:623
void SCIPhistoryIncNBranchings(SCIP_HISTORY *history, SCIP_BRANCHDIR dir, int depth)
Definition: history.c:591
void SCIPhistoryUpdatePseudocost(SCIP_HISTORY *history, SCIP_SET *set, SCIP_Real solvaldelta, SCIP_Real objdelta, SCIP_Real weight)
Definition: history.c:174
SCIP_Real SCIPhistoryGetVSIDS(SCIP_HISTORY *history, SCIP_BRANCHDIR dir)
Definition: history.c:536
SCIP_Real SCIPhistoryGetAvgBranchdepth(SCIP_HISTORY *history, SCIP_BRANCHDIR dir)
Definition: history.c:704
SCIP_Real SCIPhistoryGetLastGMIeff(SCIP_HISTORY *history)
Definition: history.c:772
SCIP_Real SCIPhistoryGetAvgGMIeff(SCIP_HISTORY *history)
Definition: history.c:749
SCIP_Real SCIPhistoryGetInferenceSum(SCIP_HISTORY *history, SCIP_BRANCHDIR dir)
Definition: history.c:652
void SCIPhistoryFree(SCIP_HISTORY **history, BMS_BLKMEM *blkmem)
Definition: history.c:66
void SCIPhistoryUnite(SCIP_HISTORY *history, SCIP_HISTORY *addhistory, SCIP_Bool switcheddirs)
Definition: history.c:113
void SCIPhistoryIncGMIeffSum(SCIP_HISTORY *history, SCIP_Real gmieff)
Definition: history.c:759
SCIP_BRANCHDIR SCIPbranchdirOpposite(SCIP_BRANCHDIR dir)
Definition: history.c:437
void SCIPhistoryIncVSIDS(SCIP_HISTORY *history, SCIP_BRANCHDIR dir, SCIP_Real weight)
Definition: history.c:510
internal methods for branching and inference history
SCIP_VAR ** SCIPimplicsGetVars(SCIP_IMPLICS *implics, SCIP_Bool varfixing)
Definition: implics.c:3331
void SCIPcliqueDelVar(SCIP_CLIQUE *clique, SCIP_CLIQUETABLE *cliquetable, SCIP_VAR *var, SCIP_Bool value)
Definition: implics.c:1285
void SCIPcliquelistRemoveFromCliques(SCIP_CLIQUELIST *cliquelist, SCIP_CLIQUETABLE *cliquetable, SCIP_VAR *var, SCIP_Bool irrelevantvar)
Definition: implics.c:1683
void SCIPvboundsFree(SCIP_VBOUNDS **vbounds, BMS_BLKMEM *blkmem)
Definition: implics.c:73
SCIP_Real * SCIPvboundsGetCoefs(SCIP_VBOUNDS *vbounds)
Definition: implics.c:3306
void SCIPvboundsShrink(SCIP_VBOUNDS **vbounds, BMS_BLKMEM *blkmem, int newnvbds)
Definition: implics.c:333
SCIP_VAR ** SCIPcliqueGetVars(SCIP_CLIQUE *clique)
Definition: implics.c:3380
SCIP_CLIQUE ** SCIPcliquelistGetCliques(SCIP_CLIQUELIST *cliquelist, SCIP_Bool value)
Definition: implics.c:3455
SCIP_Bool SCIPcliquelistsHaveCommonClique(SCIP_CLIQUELIST *cliquelist1, SCIP_Bool value1, SCIP_CLIQUELIST *cliquelist2, SCIP_Bool value2)
Definition: implics.c:1605
SCIP_Real * SCIPimplicsGetBounds(SCIP_IMPLICS *implics, SCIP_Bool varfixing)
Definition: implics.c:3349
void SCIPcliquelistCheck(SCIP_CLIQUELIST *cliquelist, SCIP_VAR *var)
Definition: implics.c:3464
SCIP_VAR ** SCIPvboundsGetVars(SCIP_VBOUNDS *vbounds)
Definition: implics.c:3298
int SCIPcliqueGetNVars(SCIP_CLIQUE *clique)
Definition: implics.c:3370
SCIP_Bool * SCIPcliqueGetValues(SCIP_CLIQUE *clique)
Definition: implics.c:3392
SCIP_RETCODE SCIPvboundsDel(SCIP_VBOUNDS **vbounds, BMS_BLKMEM *blkmem, SCIP_VAR *vbdvar, SCIP_Bool negativecoef)
Definition: implics.c:288
SCIP_RETCODE SCIPcliquetableAdd(SCIP_CLIQUETABLE *cliquetable, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, SCIP_VAR **vars, SCIP_Bool *values, int nvars, SCIP_Bool isequation, SCIP_Bool *infeasible, int *nbdchgs)
Definition: implics.c:2376
int * SCIPimplicsGetIds(SCIP_IMPLICS *implics, SCIP_Bool varfixing)
Definition: implics.c:3361
SCIP_RETCODE SCIPimplicsAdd(SCIP_IMPLICS **implics, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_Bool varfixing, SCIP_VAR *implvar, SCIP_BOUNDTYPE impltype, SCIP_Real implbound, SCIP_Bool isshortcut, SCIP_Bool *conflict, SCIP_Bool *added)
Definition: implics.c:633
SCIP_RETCODE SCIPvboundsAdd(SCIP_VBOUNDS **vbounds, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_BOUNDTYPE vboundtype, SCIP_VAR *var, SCIP_Real coef, SCIP_Real constant, SCIP_Bool *added)
Definition: implics.c:206
void SCIPcliquelistFree(SCIP_CLIQUELIST **cliquelist, BMS_BLKMEM *blkmem)
Definition: implics.c:1441
int SCIPimplicsGetNImpls(SCIP_IMPLICS *implics, SCIP_Bool varfixing)
Definition: implics.c:3322
SCIP_RETCODE SCIPcliqueAddVar(SCIP_CLIQUE *clique, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_VAR *var, SCIP_Bool value, SCIP_Bool *doubleentry, SCIP_Bool *oppositeentry)
Definition: implics.c:1151
SCIP_BOUNDTYPE * SCIPimplicsGetTypes(SCIP_IMPLICS *implics, SCIP_Bool varfixing)
Definition: implics.c:3340
int SCIPcliquelistGetNCliques(SCIP_CLIQUELIST *cliquelist, SCIP_Bool value)
Definition: implics.c:3446
SCIP_RETCODE SCIPcliquelistDel(SCIP_CLIQUELIST **cliquelist, BMS_BLKMEM *blkmem, SCIP_Bool value, SCIP_CLIQUE *clique)
Definition: implics.c:1527
SCIP_Bool SCIPcliqueIsCleanedUp(SCIP_CLIQUE *clique)
Definition: implics.c:3426
void SCIPimplicsGetVarImplicPoss(SCIP_IMPLICS *implics, SCIP_Bool varfixing, SCIP_VAR *implvar, int *lowerimplicpos, int *upperimplicpos)
Definition: implics.c:916
SCIP_RETCODE SCIPimplicsDel(SCIP_IMPLICS **implics, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_Bool varfixing, SCIP_VAR *implvar, SCIP_BOUNDTYPE impltype)
Definition: implics.c:836
SCIP_Real * SCIPvboundsGetConstants(SCIP_VBOUNDS *vbounds)
Definition: implics.c:3314
int SCIPvboundsGetNVbds(SCIP_VBOUNDS *vbounds)
Definition: implics.c:3290
SCIP_Bool SCIPimplicsContainsImpl(SCIP_IMPLICS *implics, SCIP_Bool varfixing, SCIP_VAR *implvar, SCIP_BOUNDTYPE impltype)
Definition: implics.c:933
void SCIPimplicsFree(SCIP_IMPLICS **implics, BMS_BLKMEM *blkmem)
Definition: implics.c:451
SCIP_RETCODE SCIPcliquelistAdd(SCIP_CLIQUELIST **cliquelist, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_Bool value, SCIP_CLIQUE *clique)
Definition: implics.c:1482
methods for implications, variable bounds, and cliques
SCIP_Bool SCIPlpIsSolBasic(SCIP_LP *lp)
Definition: lp.c:17837
SCIP_RETCODE SCIPcolChgUb(SCIP_COL *col, SCIP_SET *set, SCIP_LP *lp, SCIP_Real newub)
Definition: lp.c:3802
SCIP_RETCODE SCIPcolFree(SCIP_COL **col, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_EVENTQUEUE *eventqueue, SCIP_LP *lp)
Definition: lp.c:3377
SCIP_RETCODE SCIPcolChgLb(SCIP_COL *col, SCIP_SET *set, SCIP_LP *lp, SCIP_Real newlb)
Definition: lp.c:3757
void SCIPlpDecNLoosevars(SCIP_LP *lp)
Definition: lp.c:14330
SCIP_RETCODE SCIProwAddConstant(SCIP_ROW *row, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_EVENTQUEUE *eventqueue, SCIP_LP *lp, SCIP_Real addval)
Definition: lp.c:5640
SCIP_RETCODE SCIPcolChgObj(SCIP_COL *col, SCIP_SET *set, SCIP_LP *lp, SCIP_Real newobj)
Definition: lp.c:3698
SCIP_RETCODE SCIProwIncCoef(SCIP_ROW *row, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_EVENTQUEUE *eventqueue, SCIP_LP *lp, SCIP_COL *col, SCIP_Real incval)
Definition: lp.c:5528
SCIP_Bool SCIPlpDiving(SCIP_LP *lp)
Definition: lp.c:17847
SCIP_Real SCIPcolGetRedcost(SCIP_COL *col, SCIP_STAT *stat, SCIP_LP *lp)
Definition: lp.c:3952
SCIP_RETCODE SCIPcolCreate(SCIP_COL **col, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_VAR *var, int len, SCIP_ROW **rows, SCIP_Real *vals, SCIP_Bool removable)
Definition: lp.c:3279
SCIP_RETCODE SCIPlpUpdateVarLoose(SCIP_LP *lp, SCIP_SET *set, SCIP_VAR *var)
Definition: lp.c:14309
static const SCIP_Real scalars[]
Definition: lp.c:5743
SCIP_RETCODE SCIPlpUpdateVarColumn(SCIP_LP *lp, SCIP_SET *set, SCIP_VAR *var)
Definition: lp.c:14185
internal methods for LP management
#define BMSreallocBlockMemorySize(mem, ptr, oldsize, newsize)
Definition: memory.h:456
#define BMSduplicateBlockMemoryArray(mem, ptr, source, num)
Definition: memory.h:462
#define BMSfreeBlockMemory(mem, ptr)
Definition: memory.h:465
#define BMSallocBlockMemory(mem, ptr)
Definition: memory.h:451
#define BMSfreeBlockMemoryArrayNull(mem, ptr, num)
Definition: memory.h:468
#define BMSfreeBlockMemorySize(mem, ptr, size)
Definition: memory.h:469
#define BMScopyMemoryArray(ptr, source, num)
Definition: memory.h:134
#define BMSfreeBlockMemoryArray(mem, ptr, num)
Definition: memory.h:467
#define BMSreallocBlockMemoryArray(mem, ptr, oldnum, newnum)
Definition: memory.h:458
#define BMSallocBlockMemorySize(mem, ptr, size)
Definition: memory.h:453
struct BMS_BlkMem BMS_BLKMEM
Definition: memory.h:437
void SCIPmessageFPrintInfo(SCIP_MESSAGEHDLR *messagehdlr, FILE *file, const char *formatstr,...)
Definition: message.c:618
void SCIPmessagePrintWarning(SCIP_MESSAGEHDLR *messagehdlr, const char *formatstr,...)
Definition: message.c:427
real eps
SCIP_RETCODE SCIPprimalUpdateObjoffset(SCIP_PRIMAL *primal, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_EVENTFILTER *eventfilter, SCIP_EVENTQUEUE *eventqueue, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp)
Definition: primal.c:488
internal methods for collecting primal CIP solutions and primal informations
void SCIPprobUpdateNObjVars(SCIP_PROB *prob, SCIP_SET *set, SCIP_Real oldobj, SCIP_Real newobj)
Definition: prob.c:1592
int SCIPprobGetNContVars(SCIP_PROB *prob)
Definition: prob.c:2429
SCIP_RETCODE SCIPprobAddVar(SCIP_PROB *prob, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTFILTER *eventfilter, SCIP_EVENTQUEUE *eventqueue, SCIP_VAR *var)
Definition: prob.c:970
SCIP_RETCODE SCIPprobVarChangedStatus(SCIP_PROB *prob, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_BRANCHCAND *branchcand, SCIP_CLIQUETABLE *cliquetable, SCIP_VAR *var)
Definition: prob.c:1224
const char * SCIPprobGetName(SCIP_PROB *prob)
Definition: prob.c:2384
void SCIPprobAddObjoffset(SCIP_PROB *prob, SCIP_Real addval)
Definition: prob.c:1481
int SCIPprobGetNVars(SCIP_PROB *prob)
Definition: prob.c:2393
SCIP_VAR ** SCIPprobGetVars(SCIP_PROB *prob)
Definition: prob.c:2438
SCIP_Bool SCIPprobIsTransformed(SCIP_PROB *prob)
Definition: prob.c:2328
internal methods for storing and manipulating the main problem
public methods for managing constraints
public methods for branching and inference history structure
public methods for implications, variable bounds, and cliques
public methods for LP management
public methods for message output
#define SCIPerrorMessage
Definition: pub_message.h:64
#define SCIPdebugMessage
Definition: pub_message.h:96
public data structures and miscellaneous methods
methods for sorting joint arrays of various types
public methods for propagators
public methods for problem variables
void SCIPrelaxationSolObjAdd(SCIP_RELAXATION *relaxation, SCIP_Real val)
Definition: relax.c:849
internal methods for relaxators
SCIP callable library.
SCIP_Bool SCIPsetIsDualfeasZero(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6918
SCIP_Real SCIPsetFloor(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6386
SCIP_Bool SCIPsetIsFeasPositive(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6718
SCIP_Bool SCIPsetIsGE(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6293
SCIP_Real SCIPsetFeasCeil(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6775
SCIP_Bool SCIPsetIsFeasNegative(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6729
SCIP_Real SCIPsetFeastol(SCIP_SET *set)
Definition: set.c:6106
SCIP_Real SCIPsetCeil(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6397
SCIP_Bool SCIPsetIsFeasGT(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6663
SCIP_Bool SCIPsetIsFeasLE(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6641
SCIP_Bool SCIPsetIsFeasEQ(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6597
SCIP_Bool SCIPsetIsPositive(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6322
SCIP_Bool SCIPsetIsLE(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6257
SCIP_Real SCIPsetFeasFloor(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6764
SCIP_Bool SCIPsetIsDualfeasNegative(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6940
SCIP_Real SCIPsetEpsilon(SCIP_SET *set)
Definition: set.c:6086
SCIP_Bool SCIPsetIsEQ(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6221
SCIP_Bool SCIPsetIsFeasZero(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6707
SCIP_STAGE SCIPsetGetStage(SCIP_SET *set)
Definition: set.c:2952
SCIP_Bool SCIPsetIsFeasLT(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6619
SCIP_Real SCIPsetInfinity(SCIP_SET *set)
Definition: set.c:6064
SCIP_Bool SCIPsetIsLT(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6239
SCIP_Bool SCIPsetIsInfinity(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6199
SCIP_Bool SCIPsetIsDualfeasPositive(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6929
SCIP_Bool SCIPsetIsGT(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6275
SCIP_Bool SCIPsetIsIntegral(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6344
SCIP_Bool SCIPsetIsZero(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6311
SCIP_Bool SCIPsetIsFeasGE(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6685
SCIP_Real SCIPsetGetHugeValue(SCIP_SET *set)
Definition: set.c:6076
SCIP_Real SCIPsetRound(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6408
int SCIPsetCalcMemGrowSize(SCIP_SET *set, int num)
Definition: set.c:5764
SCIP_Bool SCIPsetIsFeasIntegral(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6740
SCIP_Bool SCIPsetIsNegative(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6333
internal methods for global SCIP settings
#define SCIPsetFreeBufferArray(set, ptr)
Definition: set.h:1755
#define SCIPsetFreeCleanBufferArray(set, ptr)
Definition: set.h:1762
#define SCIPsetAllocBufferArray(set, ptr, num)
Definition: set.h:1748
#define SCIPsetAllocCleanBufferArray(set, ptr, num)
Definition: set.h:1759
#define SCIPsetDuplicateBufferArray(set, ptr, source, num)
Definition: set.h:1750
#define SCIPsetDebugMsg
Definition: set.h:1784
#define SCIPsetReallocBufferArray(set, ptr, num)
Definition: set.h:1752
SCIP_Real SCIPsolGetVal(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_VAR *var)
Definition: sol.c:1372
internal methods for storing primal CIP solutions
SCIP_RETCODE SCIPstatUpdateVarRootLPBestEstimate(SCIP_STAT *stat, SCIP_SET *set, SCIP_VAR *var, SCIP_Real oldrootpscostscore)
Definition: stat.c:807
internal methods for problem statistics
#define SCIPstatIncrement(stat, set, field)
Definition: stat.h:260
SCIP_VAR * var
Definition: struct_var.h:187
SCIP_Real scalar
Definition: struct_var.h:185
SCIP_Real constant
Definition: struct_var.h:186
SCIP_BDCHGIDX bdchgidx
Definition: struct_var.h:121
SCIP_Real newbound
Definition: struct_var.h:118
SCIP_INFERENCEDATA inferencedata
Definition: struct_var.h:120
unsigned int boundchgtype
Definition: struct_var.h:123
unsigned int boundtype
Definition: struct_var.h:124
SCIP_VAR * var
Definition: struct_var.h:119
unsigned int redundant
Definition: struct_var.h:126
unsigned int inferboundtype
Definition: struct_var.h:125
SCIP_Real oldbound
Definition: struct_var.h:117
unsigned int pos
Definition: struct_var.h:122
union SCIP_BoundChg::@21 data
SCIP_Real newbound
Definition: struct_var.h:93
unsigned int applied
Definition: struct_var.h:103
unsigned int boundtype
Definition: struct_var.h:101
SCIP_INFERENCEDATA inferencedata
Definition: struct_var.h:97
unsigned int redundant
Definition: struct_var.h:104
SCIP_VAR * var
Definition: struct_var.h:99
SCIP_BRANCHINGDATA branchingdata
Definition: struct_var.h:96
unsigned int inferboundtype
Definition: struct_var.h:102
unsigned int boundchgtype
Definition: struct_var.h:100
int lppos
Definition: struct_lp.h:172
int lpipos
Definition: struct_lp.h:173
SCIP_VAR * var
Definition: struct_lp.h:160
int var_probindex
Definition: struct_lp.h:178
SCIP_HOLECHG * holechgs
Definition: struct_var.h:143
SCIP_BOUNDCHG * boundchgs
Definition: struct_var.h:134
unsigned int nboundchgs
Definition: struct_var.h:132
SCIP_BOUNDCHG * boundchgs
Definition: struct_var.h:152
SCIP_HOLECHG * holechgs
Definition: struct_var.h:153
unsigned int domchgtype
Definition: struct_var.h:151
SCIP_Real lb
Definition: struct_var.h:170
SCIP_Real ub
Definition: struct_var.h:171
SCIP_HOLELIST * holelist
Definition: struct_var.h:172
SCIP_EVENTTYPE eventmask
Definition: struct_event.h:198
SCIP_HOLELIST ** ptr
Definition: struct_var.h:67
SCIP_HOLELIST * oldlist
Definition: struct_var.h:69
SCIP_HOLELIST * newlist
Definition: struct_var.h:68
SCIP_Real right
Definition: struct_var.h:54
SCIP_Real left
Definition: struct_var.h:53
SCIP_HOLELIST * next
Definition: struct_var.h:61
SCIP_HOLE hole
Definition: struct_var.h:60
SCIP_Bool divingobjchg
Definition: struct_lp.h:381
SCIP_VAR ** vars
Definition: struct_var.h:195
SCIP_Real constant
Definition: struct_var.h:193
SCIP_Real * scalars
Definition: struct_var.h:194
SCIP_Real constant
Definition: struct_var.h:203
SCIP_DOM origdom
Definition: struct_var.h:178
SCIP_VAR * transvar
Definition: struct_var.h:179
SCIP_OBJSENSE objsense
Definition: struct_prob.h:87
SCIP_Real objscale
Definition: struct_prob.h:51
char * name
Definition: struct_lp.h:226
SCIP_VAR * lastbranchvar
Definition: struct_stat.h:183
SCIP_Longint lpcount
Definition: struct_stat.h:190
SCIP_HISTORY * glbhistory
Definition: struct_stat.h:181
int nrootboundchgs
Definition: struct_stat.h:222
int nrootintfixingsrun
Definition: struct_stat.h:225
int nrootintfixings
Definition: struct_stat.h:224
SCIP_Real vsidsweight
Definition: struct_stat.h:132
SCIP_BRANCHDIR lastbranchdir
Definition: struct_stat.h:187
int nrootboundchgsrun
Definition: struct_stat.h:223
SCIP_Bool collectvarhistory
Definition: struct_stat.h:281
SCIP_HISTORY * glbhistorycrun
Definition: struct_stat.h:182
SCIP_Real lastbranchvalue
Definition: struct_stat.h:143
SCIP_Real lazylb
Definition: struct_var.h:223
SCIP_VARDATA * vardata
Definition: struct_var.h:240
SCIP_EVENTFILTER * eventfilter
Definition: struct_var.h:247
int nubchginfos
Definition: struct_var.h:269
SCIP_Real lazyub
Definition: struct_var.h:224
SCIP_ORIGINAL original
Definition: struct_var.h:229
SCIP_VBOUNDS * vlbs
Definition: struct_var.h:243
SCIP_AGGREGATE aggregate
Definition: struct_var.h:231
SCIP_IMPLICS * implics
Definition: struct_var.h:245
SCIP_VAR ** parentvars
Definition: struct_var.h:241
SCIP_BDCHGINFO * lbchginfos
Definition: struct_var.h:248
SCIP_Real rootsol
Definition: struct_var.h:212
SCIP_VAR * negatedvar
Definition: struct_var.h:242
SCIP * scip
Definition: struct_var.h:288
unsigned int varstatus
Definition: struct_var.h:281
union SCIP_Var::@22 data
int nlocksdown[NLOCKTYPES]
Definition: struct_var.h:263
SCIP_Real bestrootsol
Definition: struct_var.h:213
SCIP_HISTORY * historycrun
Definition: struct_var.h:251
unsigned int relaxationonly
Definition: struct_var.h:286
unsigned int donotmultaggr
Definition: struct_var.h:279
int closestvubidx
Definition: struct_var.h:273
SCIP_DOM glbdom
Definition: struct_var.h:225
unsigned int vartype
Definition: struct_var.h:280
SCIP_Real branchfactor
Definition: struct_var.h:211
int conflictubcount
Definition: struct_var.h:271
SCIP_Real unchangedobj
Definition: struct_var.h:210
SCIP_Real conflictrelaxedub
Definition: struct_var.h:222
SCIP_BDCHGINFO * ubchginfos
Definition: struct_var.h:249
SCIP_Real bestrootredcost
Definition: struct_var.h:214
char * name
Definition: struct_var.h:235
SCIP_Real conflictrelaxedlb
Definition: struct_var.h:221
unsigned int deletable
Definition: struct_var.h:276
unsigned int initial
Definition: struct_var.h:274
SCIP_DOM locdom
Definition: struct_var.h:226
unsigned int removable
Definition: struct_var.h:275
SCIP_CLIQUELIST * cliquelist
Definition: struct_var.h:246
SCIP_COL * col
Definition: struct_var.h:230
unsigned int deleted
Definition: struct_var.h:277
SCIP_MULTAGGR multaggr
Definition: struct_var.h:232
SCIP_Real obj
Definition: struct_var.h:209
int probindex
Definition: struct_var.h:255
SCIP_Real nlpsol
Definition: struct_var.h:217
int nlocksup[NLOCKTYPES]
Definition: struct_var.h:264
int nlbchginfos
Definition: struct_var.h:267
unsigned int branchdirection
Definition: struct_var.h:283
unsigned int delglobalstructs
Definition: struct_var.h:285
int lbchginfossize
Definition: struct_var.h:266
SCIP_HISTORY * history
Definition: struct_var.h:250
int index
Definition: struct_var.h:254
SCIP_VBOUNDS * vubs
Definition: struct_var.h:244
int nparentvars
Definition: struct_var.h:261
unsigned int donotaggr
Definition: struct_var.h:278
int parentvarssize
Definition: struct_var.h:260
int nuses
Definition: struct_var.h:262
int closestvlbidx
Definition: struct_var.h:272
SCIP_NEGATE negate
Definition: struct_var.h:233
SCIP_Real primsolavg
Definition: struct_var.h:218
SCIP_Real relaxsol
Definition: struct_var.h:216
SCIP_Longint closestvblpcount
Definition: struct_var.h:253
SCIP_Real bestrootlpobjval
Definition: struct_var.h:215
int ubchginfossize
Definition: struct_var.h:268
SCIP_VALUEHISTORY * valuehistory
Definition: struct_var.h:252
int branchpriority
Definition: struct_var.h:265
int conflictlbcount
Definition: struct_var.h:270
SCIP_PROB * origprob
Definition: struct_scip.h:81
SCIP_PROB * transprob
Definition: struct_scip.h:99
datastructures for managing events
data structures for LP management
datastructures for storing and manipulating the main problem
SCIP main data structure.
datastructures for global SCIP settings
datastructures for problem statistics
datastructures for problem variables
Definition: heur_padm.c:135
SCIP_NODE * SCIPtreeGetRootNode(SCIP_TREE *tree)
Definition: tree.c:8552
SCIP_RETCODE SCIPnodeAddBoundchg(SCIP_NODE *node, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, SCIP_CLIQUETABLE *cliquetable, SCIP_VAR *var, SCIP_Real newbound, SCIP_BOUNDTYPE boundtype, SCIP_Bool probingchange)
Definition: tree.c:2106
internal methods for branch and bound tree
#define SCIP_EVENTTYPE_GHOLEADDED
Definition: type_event.h:81
#define SCIP_EVENTTYPE_GUBCHANGED
Definition: type_event.h:76
struct SCIP_EventData SCIP_EVENTDATA
Definition: type_event.h:173
#define SCIP_EVENTTYPE_FORMAT
Definition: type_event.h:152
#define SCIP_EVENTTYPE_GLBCHANGED
Definition: type_event.h:75
#define SCIP_EVENTTYPE_VARCHANGED
Definition: type_event.h:130
#define SCIP_EVENTTYPE_LBCHANGED
Definition: type_event.h:121
#define SCIP_EVENTTYPE_UBCHANGED
Definition: type_event.h:122
#define SCIP_EVENTTYPE_LHOLEADDED
Definition: type_event.h:83
uint64_t SCIP_EVENTTYPE
Definition: type_event.h:151
@ SCIP_BRANCHDIR_DOWNWARDS
Definition: type_history.h:43
@ SCIP_BRANCHDIR_AUTO
Definition: type_history.h:46
@ SCIP_BRANCHDIR_UPWARDS
Definition: type_history.h:44
enum SCIP_BranchDir SCIP_BRANCHDIR
Definition: type_history.h:48
@ SCIP_BOUNDTYPE_UPPER
Definition: type_lp.h:57
@ SCIP_BOUNDTYPE_LOWER
Definition: type_lp.h:56
enum SCIP_BoundType SCIP_BOUNDTYPE
Definition: type_lp.h:59
@ SCIP_BASESTAT_UPPER
Definition: type_lpi.h:93
@ SCIP_BASESTAT_LOWER
Definition: type_lpi.h:91
enum SCIP_BaseStat SCIP_BASESTAT
Definition: type_lpi.h:96
@ SCIP_CONFIDENCELEVEL_MAX
Definition: type_misc.h:51
@ SCIP_CONFIDENCELEVEL_MEDIUM
Definition: type_misc.h:49
@ SCIP_CONFIDENCELEVEL_HIGH
Definition: type_misc.h:50
@ SCIP_CONFIDENCELEVEL_MIN
Definition: type_misc.h:47
@ SCIP_CONFIDENCELEVEL_LOW
Definition: type_misc.h:48
enum SCIP_Confidencelevel SCIP_CONFIDENCELEVEL
Definition: type_misc.h:53
enum SCIP_Objsense SCIP_OBJSENSE
Definition: type_prob.h:50
@ SCIP_DIDNOTRUN
Definition: type_result.h:42
@ SCIP_SUCCESS
Definition: type_result.h:58
enum SCIP_Result SCIP_RESULT
Definition: type_result.h:61
@ SCIP_INVALIDRESULT
Definition: type_retcode.h:53
@ SCIP_READERROR
Definition: type_retcode.h:45
@ SCIP_INVALIDDATA
Definition: type_retcode.h:52
@ SCIP_OKAY
Definition: type_retcode.h:42
@ SCIP_INVALIDCALL
Definition: type_retcode.h:51
@ SCIP_ERROR
Definition: type_retcode.h:43
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:63
@ SCIP_STAGE_PROBLEM
Definition: type_set.h:45
@ SCIP_STAGE_PRESOLVING
Definition: type_set.h:49
@ SCIP_STAGE_INITSOLVE
Definition: type_set.h:52
@ SCIP_STAGE_SOLVING
Definition: type_set.h:53
@ SCIP_STAGE_TRANSFORMING
Definition: type_set.h:46
@ SCIP_STAGE_PRESOLVED
Definition: type_set.h:51
struct SCIP_VarData SCIP_VARDATA
Definition: type_var.h:120
enum SCIP_BoundchgType SCIP_BOUNDCHGTYPE
Definition: type_var.h:91
#define NLOCKTYPES
Definition: type_var.h:94
#define SCIP_DECL_VARDELORIG(x)
Definition: type_var.h:131
@ SCIP_DOMCHGTYPE_DYNAMIC
Definition: type_var.h:78
@ SCIP_DOMCHGTYPE_BOUND
Definition: type_var.h:80
@ SCIP_DOMCHGTYPE_BOTH
Definition: type_var.h:79
#define SCIP_DECL_VARTRANS(x)
Definition: type_var.h:151
@ SCIP_VARTYPE_INTEGER
Definition: type_var.h:63
@ SCIP_VARTYPE_CONTINUOUS
Definition: type_var.h:71
@ SCIP_VARTYPE_IMPLINT
Definition: type_var.h:64
@ SCIP_VARTYPE_BINARY
Definition: type_var.h:62
@ SCIP_BOUNDCHGTYPE_PROPINFER
Definition: type_var.h:89
@ SCIP_BOUNDCHGTYPE_BRANCHING
Definition: type_var.h:87
@ SCIP_BOUNDCHGTYPE_CONSINFER
Definition: type_var.h:88
@ SCIP_VARSTATUS_ORIGINAL
Definition: type_var.h:49
@ SCIP_VARSTATUS_FIXED
Definition: type_var.h:52
@ SCIP_VARSTATUS_COLUMN
Definition: type_var.h:51
@ SCIP_VARSTATUS_MULTAGGR
Definition: type_var.h:54
@ SCIP_VARSTATUS_NEGATED
Definition: type_var.h:55
@ SCIP_VARSTATUS_AGGREGATED
Definition: type_var.h:53
@ SCIP_VARSTATUS_LOOSE
Definition: type_var.h:50
#define SCIP_DECL_VARCOPY(x)
Definition: type_var.h:194
#define SCIP_DECL_VARDELTRANS(x)
Definition: type_var.h:164
enum SCIP_LockType SCIP_LOCKTYPE
Definition: type_var.h:100
@ SCIP_LOCKTYPE_MODEL
Definition: type_var.h:97
enum SCIP_Vartype SCIP_VARTYPE
Definition: type_var.h:73
enum SCIP_Varstatus SCIP_VARSTATUS
Definition: type_var.h:57
SCIP_DOMCHGBOUND domchgbound
Definition: struct_var.h:162
SCIP_DOMCHGDYN domchgdyn
Definition: struct_var.h:164
SCIP_DOMCHGBOTH domchgboth
Definition: struct_var.h:163
SCIP_RETCODE SCIPvarRemove(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_CLIQUETABLE *cliquetable, SCIP_SET *set, SCIP_Bool final)
Definition: var.c:6059
static SCIP_RETCODE varParse(SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, const char *str, char *name, SCIP_Real *lb, SCIP_Real *ub, SCIP_Real *obj, SCIP_VARTYPE *vartype, SCIP_Real *lazylb, SCIP_Real *lazyub, SCIP_Bool local, char **endptr, SCIP_Bool *success)
Definition: var.c:2349
SCIP_RETCODE SCIPvarAddObj(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_PRIMAL *primal, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_EVENTFILTER *eventfilter, SCIP_EVENTQUEUE *eventqueue, SCIP_Real addobj)
Definition: var.c:6339
SCIP_Real SCIPvarGetObjLP(SCIP_VAR *var)
Definition: var.c:12885
SCIP_Real SCIPvarGetPseudocost(SCIP_VAR *var, SCIP_STAT *stat, SCIP_Real solvaldelta)
Definition: var.c:14476
SCIP_RETCODE SCIPvarsGetActiveVars(SCIP_SET *set, SCIP_VAR **vars, int *nvars, int varssize, int *requiredsize)
Definition: var.c:12005
static SCIP_RETCODE tryAggregateIntVars(SCIP_SET *set, BMS_BLKMEM *blkmem, SCIP_STAT *stat, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_PRIMAL *primal, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_CLIQUETABLE *cliquetable, SCIP_BRANCHCAND *branchcand, SCIP_EVENTFILTER *eventfilter, SCIP_EVENTQUEUE *eventqueue, SCIP_VAR *varx, SCIP_VAR *vary, SCIP_Real scalarx, SCIP_Real scalary, SCIP_Real rhs, SCIP_Bool *infeasible, SCIP_Bool *aggregated)
Definition: var.c:5054
SCIP_RETCODE SCIPvarIncNBranchings(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_BRANCHDIR dir, SCIP_Real value, int depth)
Definition: var.c:15446
static SCIP_RETCODE varEventGlbChanged(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, SCIP_Real oldbound, SCIP_Real newbound)
Definition: var.c:6686
static SCIP_RETCODE varEnsureUbchginfosSize(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, int num)
Definition: var.c:453
SCIP_RETCODE SCIPvarChgLbLazy(SCIP_VAR *var, SCIP_SET *set, SCIP_Real lazylb)
Definition: var.c:7469
static SCIP_RETCODE domchgEnsureBoundchgsSize(SCIP_DOMCHG *domchg, BMS_BLKMEM *blkmem, SCIP_SET *set, int num)
Definition: var.c:1250
SCIP_RETCODE SCIPvarCreateTransformed(SCIP_VAR **var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, const char *name, SCIP_Real lb, SCIP_Real ub, SCIP_Real obj, SCIP_VARTYPE vartype, SCIP_Bool initial, SCIP_Bool removable, SCIP_DECL_VARDELORIG((*vardelorig)), SCIP_DECL_VARTRANS((*vartrans)), SCIP_DECL_VARDELTRANS((*vardeltrans)), SCIP_DECL_VARCOPY((*varcopy)), SCIP_VARDATA *vardata)
Definition: var.c:2117
static SCIP_RETCODE varProcessChgUbLocal(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, SCIP_Real newbound)
Definition: var.c:7804
SCIP_Real SCIPvarGetPseudocostCount(SCIP_VAR *var, SCIP_BRANCHDIR dir)
Definition: var.c:14572
SCIP_RETCODE SCIPvarResetBounds(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat)
Definition: var.c:9230
void SCIPbdchginfoFree(SCIP_BDCHGINFO **bdchginfo, BMS_BLKMEM *blkmem)
Definition: var.c:16562
static SCIP_RETCODE domAddHole(SCIP_DOM *dom, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_Real left, SCIP_Real right, SCIP_Bool *added)
Definition: var.c:224
SCIP_RETCODE SCIPvarGetTransformed(SCIP_VAR *origvar, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_VAR **transvar)
Definition: var.c:3548
SCIP_RETCODE SCIPvarChgObj(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_PROB *prob, SCIP_PRIMAL *primal, SCIP_LP *lp, SCIP_EVENTQUEUE *eventqueue, SCIP_Real newobj)
Definition: var.c:6264
static SCIP_RETCODE varProcessChgBranchPriority(SCIP_VAR *var, int branchpriority)
Definition: var.c:11630
static SCIP_RETCODE parseValue(SCIP_SET *set, const char *str, SCIP_Real *value, char **endptr)
Definition: var.c:2272
#define MAXDNOM
SCIP_Real SCIPvarGetPseudocostVariance(SCIP_VAR *var, SCIP_BRANCHDIR dir, SCIP_Bool onlycurrentrun)
Definition: var.c:14691
static SCIP_RETCODE boundchgApplyGlobal(SCIP_BOUNDCHG *boundchg, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, SCIP_CLIQUETABLE *cliquetable, SCIP_Bool *cutoff)
Definition: var.c:910
SCIP_Real SCIPvarGetImplRedcost(SCIP_VAR *var, SCIP_SET *set, SCIP_Bool varfixing, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_LP *lp)
Definition: var.c:13467
static SCIP_RETCODE varCreate(SCIP_VAR **var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, const char *name, SCIP_Real lb, SCIP_Real ub, SCIP_Real obj, SCIP_VARTYPE vartype, SCIP_Bool initial, SCIP_Bool removable, SCIP_DECL_VARCOPY((*varcopy)), SCIP_DECL_VARDELORIG((*vardelorig)), SCIP_DECL_VARTRANS((*vartrans)), SCIP_DECL_VARDELTRANS((*vardeltrans)), SCIP_VARDATA *vardata)
Definition: var.c:1929
SCIP_RETCODE SCIPvarSetLastGMIScore(SCIP_VAR *var, SCIP_STAT *stat, SCIP_Real gmieff)
Definition: var.c:16482
SCIP_RETCODE SCIPvarFix(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_PRIMAL *primal, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTFILTER *eventfilter, SCIP_EVENTQUEUE *eventqueue, SCIP_CLIQUETABLE *cliquetable, SCIP_Real fixedval, SCIP_Bool *infeasible, SCIP_Bool *fixed)
Definition: var.c:3749
static SCIP_RETCODE varAddImplic(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_CLIQUETABLE *cliquetable, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, SCIP_Bool varfixing, SCIP_VAR *implvar, SCIP_BOUNDTYPE impltype, SCIP_Real implbound, SCIP_Bool isshortcut, SCIP_Bool *infeasible, int *nbdchgs, SCIP_Bool *added)
Definition: var.c:9511
void SCIPvarInitSolve(SCIP_VAR *var)
Definition: var.c:2931
SCIP_RETCODE SCIPvarIncInferenceSum(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_BRANCHDIR dir, SCIP_Real value, SCIP_Real weight)
Definition: var.c:15530
static void printBounds(SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, FILE *file, SCIP_Real lb, SCIP_Real ub, const char *name)
Definition: var.c:2944
SCIP_RETCODE SCIPvarIncVSIDS(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_BRANCHDIR dir, SCIP_Real value, SCIP_Real weight)
Definition: var.c:15050
static SCIP_RETCODE varProcessChgLbLocal(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, SCIP_Real newbound)
Definition: var.c:7637
static SCIP_RETCODE varAddLbchginfo(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_Real oldbound, SCIP_Real newbound, int depth, int pos, SCIP_VAR *infervar, SCIP_CONS *infercons, SCIP_PROP *inferprop, int inferinfo, SCIP_BOUNDTYPE inferboundtype, SCIP_BOUNDCHGTYPE boundchgtype)
Definition: var.c:479
SCIP_RETCODE SCIPdomchgUndo(SCIP_DOMCHG *domchg, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue)
Definition: var.c:1348
static SCIP_RETCODE varProcessAddHoleLocal(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_EVENTQUEUE *eventqueue, SCIP_Real left, SCIP_Real right, SCIP_Bool *added)
Definition: var.c:8993
SCIP_Real SCIPvarGetAvgCutoffs(SCIP_VAR *var, SCIP_STAT *stat, SCIP_BRANCHDIR dir)
Definition: var.c:16264
SCIP_RETCODE SCIPboundchgApply(SCIP_BOUNDCHG *boundchg, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, int depth, int pos, SCIP_Bool *cutoff)
Definition: var.c:628
SCIP_RETCODE SCIPdomchgMakeStatic(SCIP_DOMCHG **domchg, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_EVENTQUEUE *eventqueue, SCIP_LP *lp)
Definition: var.c:1161
static void checkImplic(SCIP_SET *set, SCIP_VAR *implvar, SCIP_BOUNDTYPE impltype, SCIP_Real implbound, SCIP_Bool *redundant, SCIP_Bool *infeasible)
Definition: var.c:9381
static SCIP_VAR * varGetActiveVar(SCIP_VAR *var)
Definition: var.c:5799
SCIP_RETCODE SCIPvarUpdatePseudocost(SCIP_VAR *var, SCIP_SET *set, SCIP_STAT *stat, SCIP_Real solvaldelta, SCIP_Real objdelta, SCIP_Real weight)
Definition: var.c:14378
SCIP_RETCODE SCIPvarTransform(SCIP_VAR *origvar, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_OBJSENSE objsense, SCIP_VAR **transvar)
Definition: var.c:3461
SCIP_RETCODE SCIPvarAddHoleOriginal(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_Real left, SCIP_Real right)
Definition: var.c:8693
SCIP_RETCODE SCIPvarAddCliqueToList(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_Bool value, SCIP_CLIQUE *clique)
Definition: var.c:11392
static SCIP_RETCODE varEventObjChanged(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_PRIMAL *primal, SCIP_LP *lp, SCIP_EVENTQUEUE *eventqueue, SCIP_Real oldobj, SCIP_Real newobj)
Definition: var.c:6229
static SCIP_RETCODE varFree(SCIP_VAR **var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_EVENTQUEUE *eventqueue, SCIP_LP *lp)
Definition: var.c:2744
SCIP_RETCODE SCIPvarAddHoleGlobal(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_EVENTQUEUE *eventqueue, SCIP_Real left, SCIP_Real right, SCIP_Bool *added)
Definition: var.c:8874
SCIP_Real SCIPvarGetAvgInferencesCurrentRun(SCIP_VAR *var, SCIP_STAT *stat, SCIP_BRANCHDIR dir)
Definition: var.c:16123
static SCIP_RETCODE varEventImplAdded(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_EVENTQUEUE *eventqueue)
Definition: var.c:9263
SCIP_RETCODE SCIPvarRelease(SCIP_VAR **var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_EVENTQUEUE *eventqueue, SCIP_LP *lp)
Definition: var.c:2872
void SCIPvarGetClosestVub(SCIP_VAR *var, SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_Real *closestvub, int *closestvubidx)
Definition: var.c:14197
SCIP_RETCODE SCIPvarIncNActiveConflicts(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_BRANCHDIR dir, SCIP_Real value, SCIP_Real length)
Definition: var.c:15186
void SCIPvarAdjustLb(SCIP_VAR *var, SCIP_SET *set, SCIP_Real *lb)
Definition: var.c:6517
SCIP_RETCODE SCIPvarDropEvent(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_EVENTTYPE eventtype, SCIP_EVENTHDLR *eventhdlr, SCIP_EVENTDATA *eventdata, int filterpos)
Definition: var.c:18584
SCIP_RETCODE SCIPvarChgLbGlobal(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, SCIP_CLIQUETABLE *cliquetable, SCIP_Real newbound)
Definition: var.c:7185
SCIP_RETCODE SCIPvarSetNLPSol(SCIP_VAR *var, SCIP_SET *set, SCIP_Real solval)
Definition: var.c:14005
SCIP_RETCODE SCIPvarCopy(SCIP_VAR **var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP *sourcescip, SCIP_VAR *sourcevar, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_Bool global)
Definition: var.c:2159
SCIP_Real SCIPvarCalcPscostConfidenceBound(SCIP_VAR *var, SCIP_SET *set, SCIP_BRANCHDIR dir, SCIP_Bool onlycurrentrun, SCIP_CONFIDENCELEVEL clevel)
Definition: var.c:14745
static SCIP_BDCHGIDX presolvebdchgidx
Definition: var.c:16989
static SCIP_RETCODE varEventLbChanged(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, SCIP_Real oldbound, SCIP_Real newbound)
Definition: var.c:7546
SCIP_Bool SCIPvarIsPscostRelerrorReliable(SCIP_VAR *var, SCIP_SET *set, SCIP_STAT *stat, SCIP_Real threshold, SCIP_CONFIDENCELEVEL clevel)
Definition: var.c:14783
SCIP_RETCODE SCIPvarChgLbOriginal(SCIP_VAR *var, SCIP_SET *set, SCIP_Real newbound)
Definition: var.c:6567
SCIP_RETCODE SCIPvarAddToRow(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_EVENTQUEUE *eventqueue, SCIP_PROB *prob, SCIP_LP *lp, SCIP_ROW *row, SCIP_Real val)
Definition: var.c:14269
SCIP_Real SCIPvarGetLbLP(SCIP_VAR *var, SCIP_SET *set)
Definition: var.c:12931
void SCIPvarAdjustBd(SCIP_VAR *var, SCIP_SET *set, SCIP_BOUNDTYPE boundtype, SCIP_Real *bd)
Definition: var.c:6551
static SCIP_RETCODE varEventUbChanged(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, SCIP_Real oldbound, SCIP_Real newbound)
Definition: var.c:7584
SCIP_RETCODE SCIPvarChgObjDive(SCIP_VAR *var, SCIP_SET *set, SCIP_LP *lp, SCIP_Real newobj)
Definition: var.c:6454
SCIP_RETCODE SCIPdomchgFree(SCIP_DOMCHG **domchg, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_EVENTQUEUE *eventqueue, SCIP_LP *lp)
Definition: var.c:1060
SCIP_Real SCIPvarGetRelaxSolTransVar(SCIP_VAR *var)
Definition: var.c:13994
SCIP_RETCODE SCIPvarPrint(SCIP_VAR *var, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, FILE *file)
Definition: var.c:3006
SCIP_Real SCIPvarGetAvgGMIScore(SCIP_VAR *var, SCIP_STAT *stat)
Definition: var.c:16358
SCIP_Real SCIPvarGetVSIDS(SCIP_VAR *var, SCIP_STAT *stat, SCIP_BRANCHDIR dir)
Definition: var.c:18542
static SCIP_RETCODE varEventVarFixed(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_EVENTQUEUE *eventqueue, int fixeventtype)
Definition: var.c:3654
SCIP_RETCODE SCIPvarIncCutoffSum(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_BRANCHDIR dir, SCIP_Real value, SCIP_Real weight)
Definition: var.c:15614
SCIP_Real SCIPvarGetMultaggrLbLocal(SCIP_VAR *var, SCIP_SET *set)
Definition: var.c:8434
static SCIP_RETCODE varUpdateAggregationBounds(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_PRIMAL *primal, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTFILTER *eventfilter, SCIP_EVENTQUEUE *eventqueue, SCIP_CLIQUETABLE *cliquetable, SCIP_VAR *aggvar, SCIP_Real scalar, SCIP_Real constant, SCIP_Bool *infeasible, SCIP_Bool *fixed)
Definition: var.c:4550
SCIP_Bool SCIPvarSignificantPscostDifference(SCIP_SET *set, SCIP_STAT *stat, SCIP_VAR *varx, SCIP_Real fracx, SCIP_VAR *vary, SCIP_Real fracy, SCIP_BRANCHDIR dir, SCIP_CONFIDENCELEVEL clevel, SCIP_Bool onesided)
Definition: var.c:14860
void SCIPvarCapture(SCIP_VAR *var)
Definition: var.c:2847
static SCIP_RETCODE varEventGubChanged(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, SCIP_Real oldbound, SCIP_Real newbound)
Definition: var.c:6724
SCIP_RETCODE SCIPvarChgBranchDirection(SCIP_VAR *var, SCIP_BRANCHDIR branchdirection)
Definition: var.c:11817
SCIP_Real SCIPvarGetPseudocostCurrentRun(SCIP_VAR *var, SCIP_STAT *stat, SCIP_Real solvaldelta)
Definition: var.c:14525
static SCIP_Real adjustedLb(SCIP_SET *set, SCIP_VARTYPE vartype, SCIP_Real lb)
Definition: var.c:1568
SCIP_RETCODE SCIPdomchgAddHolechg(SCIP_DOMCHG **domchg, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_HOLELIST **ptr, SCIP_HOLELIST *newlist, SCIP_HOLELIST *oldlist)
Definition: var.c:1519
void SCIPvarStoreRootSol(SCIP_VAR *var, SCIP_Bool roothaslp)
Definition: var.c:13268
static SCIP_RETCODE domchgEnsureHolechgsSize(SCIP_DOMCHG *domchg, BMS_BLKMEM *blkmem, SCIP_SET *set, int num)
Definition: var.c:1275
static SCIP_RETCODE varEnsureLbchginfosSize(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, int num)
Definition: var.c:427
SCIP_Bool SCIPvarDoNotAggr(SCIP_VAR *var)
Definition: var.c:5848
SCIP_RETCODE SCIPvarChgType(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_PRIMAL *primal, SCIP_LP *lp, SCIP_EVENTQUEUE *eventqueue, SCIP_VARTYPE vartype)
Definition: var.c:6178
SCIP_RETCODE SCIPvarFlattenAggregationGraph(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_EVENTQUEUE *eventqueue)
Definition: var.c:4424
SCIP_Longint SCIPvarGetNActiveConflicts(SCIP_VAR *var, SCIP_STAT *stat, SCIP_BRANCHDIR dir)
Definition: var.c:15267
void SCIPvarUpdateBestRootSol(SCIP_VAR *var, SCIP_SET *set, SCIP_Real rootsol, SCIP_Real rootredcost, SCIP_Real rootlpobjval)
Definition: var.c:13279
SCIP_RETCODE SCIPvarCreateOriginal(SCIP_VAR **var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, const char *name, SCIP_Real lb, SCIP_Real ub, SCIP_Real obj, SCIP_VARTYPE vartype, SCIP_Bool initial, SCIP_Bool removable, SCIP_DECL_VARDELORIG((*vardelorig)), SCIP_DECL_VARTRANS((*vartrans)), SCIP_DECL_VARDELTRANS((*vardeltrans)), SCIP_DECL_VARCOPY((*varcopy)), SCIP_VARDATA *vardata)
Definition: var.c:2074
SCIP_Real SCIPvarGetVSIDS_rec(SCIP_VAR *var, SCIP_STAT *stat, SCIP_BRANCHDIR dir)
Definition: var.c:15876
SCIP_RETCODE SCIPvarChgBdLocal(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, SCIP_Real newbound, SCIP_BOUNDTYPE boundtype)
Definition: var.c:8223
SCIP_RETCODE SCIPvarFixBinary(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, SCIP_CLIQUETABLE *cliquetable, SCIP_Bool value, SCIP_Bool *infeasible, int *nbdchgs)
Definition: var.c:11181
SCIP_RETCODE SCIPvarScaleVSIDS(SCIP_VAR *var, SCIP_Real scalar)
Definition: var.c:15136
static SCIP_RETCODE findValuehistoryEntry(SCIP_VAR *var, SCIP_Real value, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_HISTORY **history)
Definition: var.c:14995
SCIP_Real SCIPvarGetAvgConflictlength(SCIP_VAR *var, SCIP_BRANCHDIR dir)
Definition: var.c:15359
static SCIP_RETCODE varProcessChgUbGlobal(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, SCIP_CLIQUETABLE *cliquetable, SCIP_Real newbound)
Definition: var.c:7011
SCIP_Real SCIPvarGetPseudocostCountCurrentRun(SCIP_VAR *var, SCIP_BRANCHDIR dir)
Definition: var.c:14617
SCIP_RETCODE SCIPvarChgUbGlobal(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, SCIP_CLIQUETABLE *cliquetable, SCIP_Real newbound)
Definition: var.c:7328
static SCIP_RETCODE varEnsureParentvarsSize(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, int num)
Definition: var.c:2619
SCIP_RETCODE SCIPvarGetActiveRepresentatives(SCIP_SET *set, SCIP_VAR **vars, SCIP_Real *scalars, int *nvars, int varssize, SCIP_Real *constant, int *requiredsize, SCIP_Bool mergemultiples)
Definition: var.c:3929
#define MAX_CLIQUELENGTH
Definition: var.c:13463
SCIP_RETCODE SCIPvarParseTransformed(SCIP_VAR **var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, SCIP_STAT *stat, const char *str, SCIP_Bool initial, SCIP_Bool removable, SCIP_DECL_VARCOPY((*varcopy)), SCIP_DECL_VARDELORIG((*vardelorig)), SCIP_DECL_VARTRANS((*vartrans)), SCIP_DECL_VARDELTRANS((*vardeltrans)), SCIP_VARDATA *vardata, char **endptr, SCIP_Bool *success)
Definition: var.c:2560
SCIP_Real SCIPvarGetUbLP(SCIP_VAR *var, SCIP_SET *set)
Definition: var.c:13001
SCIP_RETCODE SCIPvarColumn(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_LP *lp)
Definition: var.c:3579
SCIP_RETCODE SCIPvarChgUbOriginal(SCIP_VAR *var, SCIP_SET *set, SCIP_Real newbound)
Definition: var.c:6626
SCIP_RETCODE SCIPvarChgUbDive(SCIP_VAR *var, SCIP_SET *set, SCIP_LP *lp, SCIP_Real newbound)
Definition: var.c:8339
static void domMerge(SCIP_DOM *dom, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_Real *newlb, SCIP_Real *newub)
Definition: var.c:268
SCIP_Real SCIPvarGetAvgInferences(SCIP_VAR *var, SCIP_STAT *stat, SCIP_BRANCHDIR dir)
Definition: var.c:16066
int SCIPvarGetConflictingBdchgDepth(SCIP_VAR *var, SCIP_SET *set, SCIP_BOUNDTYPE boundtype, SCIP_Real bound)
Definition: var.c:17044
static SCIP_RETCODE varEventVarUnlocked(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_EVENTQUEUE *eventqueue)
Definition: var.c:3146
SCIP_Real SCIPvarGetMultaggrUbGlobal(SCIP_VAR *var, SCIP_SET *set)
Definition: var.c:8632
void SCIPvarGetClosestVlb(SCIP_VAR *var, SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_Real *closestvlb, int *closestvlbidx)
Definition: var.c:14122
SCIP_RETCODE SCIPvarChgUbLazy(SCIP_VAR *var, SCIP_SET *set, SCIP_Real lazyub)
Definition: var.c:7492
static SCIP_RETCODE varAddVbound(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_EVENTQUEUE *eventqueue, SCIP_BOUNDTYPE vbtype, SCIP_VAR *vbvar, SCIP_Real vbcoef, SCIP_Real vbconstant)
Definition: var.c:9283
SCIP_Bool SCIPvarPscostThresholdProbabilityTest(SCIP_SET *set, SCIP_STAT *stat, SCIP_VAR *var, SCIP_Real frac, SCIP_Real threshold, SCIP_BRANCHDIR dir, SCIP_CONFIDENCELEVEL clevel)
Definition: var.c:14926
SCIP_RETCODE SCIPdomchgApplyGlobal(SCIP_DOMCHG *domchg, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, SCIP_CLIQUETABLE *cliquetable, SCIP_Bool *cutoff)
Definition: var.c:1383
SCIP_RETCODE SCIPvarTryAggregateVars(SCIP_SET *set, BMS_BLKMEM *blkmem, SCIP_STAT *stat, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_PRIMAL *primal, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_CLIQUETABLE *cliquetable, SCIP_BRANCHCAND *branchcand, SCIP_EVENTFILTER *eventfilter, SCIP_EVENTQUEUE *eventqueue, SCIP_VAR *varx, SCIP_VAR *vary, SCIP_Real scalarx, SCIP_Real scalary, SCIP_Real rhs, SCIP_Bool *infeasible, SCIP_Bool *aggregated)
Definition: var.c:5292
SCIP_RETCODE SCIPboundchgUndo(SCIP_BOUNDCHG *boundchg, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue)
Definition: var.c:825
void SCIPvarMarkDeleted(SCIP_VAR *var)
Definition: var.c:6095
#define MAXIMPLSCLOSURE
Definition: var.c:77
static SCIP_RETCODE varSetName(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_STAT *stat, const char *name)
Definition: var.c:1897
void SCIPvarMergeHistories(SCIP_VAR *targetvar, SCIP_VAR *othervar, SCIP_STAT *stat)
Definition: var.c:4519
static SCIP_RETCODE varEventGholeAdded(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_EVENTQUEUE *eventqueue, SCIP_Real left, SCIP_Real right)
Definition: var.c:6762
static void printHolelist(SCIP_MESSAGEHDLR *messagehdlr, FILE *file, SCIP_HOLELIST *holelist, const char *name)
Definition: var.c:2972
static SCIP_RETCODE varAddUbchginfo(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_Real oldbound, SCIP_Real newbound, int depth, int pos, SCIP_VAR *infervar, SCIP_CONS *infercons, SCIP_PROP *inferprop, int inferinfo, SCIP_BOUNDTYPE inferboundtype, SCIP_BOUNDCHGTYPE boundchgtype)
Definition: var.c:554
SCIP_RETCODE SCIPvarCatchEvent(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_EVENTTYPE eventtype, SCIP_EVENTHDLR *eventhdlr, SCIP_EVENTDATA *eventdata, int *filterpos)
Definition: var.c:18557
SCIP_RETCODE SCIPvarAddHoleLocal(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_EVENTQUEUE *eventqueue, SCIP_Real left, SCIP_Real right, SCIP_Bool *added)
Definition: var.c:9121
SCIP_Bool SCIPvarIsMarkedDeleteGlobalStructures(SCIP_VAR *var)
Definition: var.c:17685
SCIP_RETCODE SCIPdomchgApply(SCIP_DOMCHG *domchg, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, int depth, SCIP_Bool *cutoff)
Definition: var.c:1299
SCIP_RETCODE SCIPvarDelClique(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_CLIQUETABLE *cliquetable, SCIP_Bool value, SCIP_CLIQUE *clique)
Definition: var.c:11431
SCIP_RETCODE SCIPvarAggregate(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_PRIMAL *primal, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_CLIQUETABLE *cliquetable, SCIP_BRANCHCAND *branchcand, SCIP_EVENTFILTER *eventfilter, SCIP_EVENTQUEUE *eventqueue, SCIP_VAR *aggvar, SCIP_Real scalar, SCIP_Real constant, SCIP_Bool *infeasible, SCIP_Bool *aggregated)
Definition: var.c:4741
SCIP_Real SCIPvarGetRelaxSol(SCIP_VAR *var, SCIP_SET *set)
Definition: var.c:13922
SCIP_RETCODE SCIPvarDelCliqueFromList(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_Bool value, SCIP_CLIQUE *clique)
Definition: var.c:11414
int SCIPbdchgidxGetPos(SCIP_BDCHGIDX *bdchgidx)
Definition: var.c:18609
SCIP_RETCODE SCIPvarChgBdGlobal(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, SCIP_CLIQUETABLE *cliquetable, SCIP_Real newbound, SCIP_BOUNDTYPE boundtype)
Definition: var.c:7518
static SCIP_Bool useValuehistory(SCIP_VAR *var, SCIP_Real value, SCIP_SET *set)
Definition: var.c:15022
static SCIP_Real adjustedUb(SCIP_SET *set, SCIP_VARTYPE vartype, SCIP_Real ub)
Definition: var.c:1588
SCIP_RETCODE SCIPvarAddImplic(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_CLIQUETABLE *cliquetable, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, SCIP_Bool varfixing, SCIP_VAR *implvar, SCIP_BOUNDTYPE impltype, SCIP_Real implbound, SCIP_Bool transitive, SCIP_Bool *infeasible, int *nbdchgs)
Definition: var.c:10911
SCIP_RETCODE SCIPvarsAddClique(SCIP_VAR **vars, SCIP_Bool *values, int nvars, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_CLIQUE *clique)
Definition: var.c:11354
SCIP_RETCODE SCIPvarMarkDoNotAggr(SCIP_VAR *var)
Definition: var.c:6106
static SCIP_RETCODE varProcessChgBranchFactor(SCIP_VAR *var, SCIP_SET *set, SCIP_Real branchfactor)
Definition: var.c:11495
SCIP_RETCODE SCIPdomchgAddBoundchg(SCIP_DOMCHG **domchg, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_VAR *var, SCIP_Real newbound, SCIP_BOUNDTYPE boundtype, SCIP_BOUNDCHGTYPE boundchgtype, SCIP_Real lpsolval, SCIP_VAR *infervar, SCIP_CONS *infercons, SCIP_PROP *inferprop, int inferinfo, SCIP_BOUNDTYPE inferboundtype)
Definition: var.c:1422
SCIP_RETCODE SCIPvarChgLbLocal(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, SCIP_Real newbound)
Definition: var.c:7970
SCIP_RETCODE SCIPvarLoose(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_EVENTQUEUE *eventqueue, SCIP_PROB *prob, SCIP_LP *lp)
Definition: var.c:3613
static SCIP_RETCODE varFreeParents(SCIP_VAR **var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_EVENTQUEUE *eventqueue, SCIP_LP *lp)
Definition: var.c:2671
static SCIP_BDCHGIDX initbdchgidx
Definition: var.c:16986
SCIP_RETCODE SCIPvarChgBranchPriority(SCIP_VAR *var, int branchpriority)
Definition: var.c:11686
static SCIP_RETCODE domchgCreate(SCIP_DOMCHG **domchg, BMS_BLKMEM *blkmem)
Definition: var.c:1039
SCIP_RETCODE SCIPvarMarkDoNotMultaggr(SCIP_VAR *var)
Definition: var.c:6142
static SCIP_RETCODE holelistCreate(SCIP_HOLELIST **holelist, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_Real left, SCIP_Real right)
Definition: var.c:152
SCIP_RETCODE SCIPvarAddLocks(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_EVENTQUEUE *eventqueue, SCIP_LOCKTYPE locktype, int addnlocksdown, int addnlocksup)
Definition: var.c:3167
SCIP_RETCODE SCIPvarNegate(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_VAR **negvar)
Definition: var.c:5917
SCIP_Real SCIPvarGetMultaggrUbLocal(SCIP_VAR *var, SCIP_SET *set)
Definition: var.c:8500
SCIP_RETCODE SCIPbdchginfoCreate(SCIP_BDCHGINFO **bdchginfo, BMS_BLKMEM *blkmem, SCIP_VAR *var, SCIP_BOUNDTYPE boundtype, SCIP_Real oldbound, SCIP_Real newbound)
Definition: var.c:16532
static SCIP_RETCODE varAddTransitiveImplic(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_CLIQUETABLE *cliquetable, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, SCIP_Bool varfixing, SCIP_VAR *implvar, SCIP_BOUNDTYPE impltype, SCIP_Real implbound, SCIP_Bool transitive, SCIP_Bool *infeasible, int *nbdchgs)
Definition: var.c:9792
SCIP_Real SCIPvarGetMinPseudocostScore(SCIP_VAR *var, SCIP_STAT *stat, SCIP_SET *set, SCIP_Real solval)
Definition: var.c:14660
SCIP_RETCODE SCIPvarGetProbvarSum(SCIP_VAR **var, SCIP_SET *set, SCIP_Real *scalar, SCIP_Real *constant)
Definition: var.c:12646
SCIP_RETCODE SCIPvarIncGMIeffSum(SCIP_VAR *var, SCIP_STAT *stat, SCIP_Real gmieff)
Definition: var.c:16398
static void holelistFree(SCIP_HOLELIST **holelist, BMS_BLKMEM *blkmem)
Definition: var.c:176
static SCIP_RETCODE varProcessChgLbGlobal(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, SCIP_CLIQUETABLE *cliquetable, SCIP_Real newbound)
Definition: var.c:6835
static SCIP_RETCODE applyImplic(BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, SCIP_CLIQUETABLE *cliquetable, SCIP_VAR *implvar, SCIP_BOUNDTYPE impltype, SCIP_Real implbound, SCIP_Bool *infeasible, int *nbdchgs)
Definition: var.c:9412
SCIP_Real SCIPvarGetLastGMIScore(SCIP_VAR *var, SCIP_STAT *stat)
Definition: var.c:16442
void SCIPvarAdjustUb(SCIP_VAR *var, SCIP_SET *set, SCIP_Real *ub)
Definition: var.c:6534
SCIP_Real SCIPbdchginfoGetRelaxedBound(SCIP_BDCHGINFO *bdchginfo)
Definition: var.c:18798
static SCIP_Real getImplVarRedcost(SCIP_VAR *var, SCIP_SET *set, SCIP_Bool varfixing, SCIP_STAT *stat, SCIP_LP *lp)
Definition: var.c:13414
SCIP_RETCODE SCIPvarChgLbDive(SCIP_VAR *var, SCIP_SET *set, SCIP_LP *lp, SCIP_Real newbound)
Definition: var.c:8249
SCIP_RETCODE SCIPvarMultiaggregate(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_PRIMAL *primal, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_CLIQUETABLE *cliquetable, SCIP_BRANCHCAND *branchcand, SCIP_EVENTFILTER *eventfilter, SCIP_EVENTQUEUE *eventqueue, int naggvars, SCIP_VAR **aggvars, SCIP_Real *scalars, SCIP_Real constant, SCIP_Bool *infeasible, SCIP_Bool *aggregated)
Definition: var.c:5446
static SCIP_Real SCIPvarGetPseudoSol_rec(SCIP_VAR *var)
Definition: var.c:13189
#define MAXABSVBCOEF
Definition: var.c:79
SCIP_Real SCIPvarGetAvgConflictlengthCurrentRun(SCIP_VAR *var, SCIP_BRANCHDIR dir)
Definition: var.c:15403
SCIP_RETCODE SCIPvarChgUbLocal(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, SCIP_Real newbound)
Definition: var.c:8097
static SCIP_RETCODE domchgMakeDynamic(SCIP_DOMCHG **domchg, BMS_BLKMEM *blkmem)
Definition: var.c:1109
SCIP_RETCODE SCIPvarAddVlb(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_CLIQUETABLE *cliquetable, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, SCIP_VAR *vlbvar, SCIP_Real vlbcoef, SCIP_Real vlbconstant, SCIP_Bool transitive, SCIP_Bool *infeasible, int *nbdchgs)
Definition: var.c:10000
SCIP_RETCODE SCIPvarParseOriginal(SCIP_VAR **var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, SCIP_STAT *stat, const char *str, SCIP_Bool initial, SCIP_Bool removable, SCIP_DECL_VARCOPY((*varcopy)), SCIP_DECL_VARDELORIG((*vardelorig)), SCIP_DECL_VARTRANS((*vartrans)), SCIP_DECL_VARDELTRANS((*vardeltrans)), SCIP_VARDATA *vardata, char **endptr, SCIP_Bool *success)
Definition: var.c:2496
static SCIP_RETCODE parseBounds(SCIP_SET *set, const char *str, char *type, SCIP_Real *lb, SCIP_Real *ub, char **endptr)
Definition: var.c:2304
SCIP_Real SCIPvarGetVSIDSCurrentRun(SCIP_VAR *var, SCIP_STAT *stat, SCIP_BRANCHDIR dir)
Definition: var.c:15927
static void varIncRootboundchgs(SCIP_VAR *var, SCIP_SET *set, SCIP_STAT *stat)
Definition: var.c:6794
void SCIPvarSetNamePointer(SCIP_VAR *var, const char *name)
Definition: var.c:6041
static SCIP_RETCODE holelistDuplicate(SCIP_HOLELIST **target, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_HOLELIST *source)
Definition: var.c:202
SCIP_RETCODE SCIPvarChgName(SCIP_VAR *var, BMS_BLKMEM *blkmem, const char *name)
Definition: var.c:2913
void SCIPvarSetHistory(SCIP_VAR *var, SCIP_HISTORY *history, SCIP_STAT *stat)
Definition: var.c:4535
static SCIP_RETCODE varProcessAddHoleGlobal(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_EVENTQUEUE *eventqueue, SCIP_Real left, SCIP_Real right, SCIP_Bool *added)
Definition: var.c:8745
void SCIPvarSetProbindex(SCIP_VAR *var, int probindex)
Definition: var.c:6026
SCIP_RETCODE SCIPvarAddVub(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_CLIQUETABLE *cliquetable, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, SCIP_VAR *vubvar, SCIP_Real vubcoef, SCIP_Real vubconstant, SCIP_Bool transitive, SCIP_Bool *infeasible, int *nbdchgs)
Definition: var.c:10464
static SCIP_RETCODE varAddParent(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_VAR *parentvar)
Definition: var.c:2643
SCIP_Real SCIPvarGetMultaggrLbGlobal(SCIP_VAR *var, SCIP_SET *set)
Definition: var.c:8566
SCIP_RETCODE SCIPvarSetRelaxSol(SCIP_VAR *var, SCIP_SET *set, SCIP_RELAXATION *relaxation, SCIP_Real solval, SCIP_Bool updateobj)
Definition: var.c:13861
SCIP_RETCODE SCIPvarChgBranchFactor(SCIP_VAR *var, SCIP_SET *set, SCIP_Real branchfactor)
Definition: var.c:11559
static SCIP_RETCODE boundchgReleaseData(SCIP_BOUNDCHG *boundchg, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_EVENTQUEUE *eventqueue, SCIP_LP *lp)
Definition: var.c:1002
SCIP_Longint SCIPvarGetNActiveConflictsCurrentRun(SCIP_VAR *var, SCIP_STAT *stat, SCIP_BRANCHDIR dir)
Definition: var.c:15314
SCIP_RETCODE SCIPvarAddClique(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, SCIP_CLIQUETABLE *cliquetable, SCIP_Bool value, SCIP_CLIQUE *clique, SCIP_Bool *infeasible, int *nbdchgs)
Definition: var.c:11269
static SCIP_RETCODE boundchgCaptureData(SCIP_BOUNDCHG *boundchg)
Definition: var.c:970
static SCIP_RETCODE varProcessChgBranchDirection(SCIP_VAR *var, SCIP_BRANCHDIR branchdirection)
Definition: var.c:11750
SCIP_Real SCIPvarGetAvgCutoffsCurrentRun(SCIP_VAR *var, SCIP_STAT *stat, SCIP_BRANCHDIR dir)
Definition: var.c:16311
SCIP_Bool SCIPvarDoNotMultaggr(SCIP_VAR *var)
Definition: var.c:5881
SCIP_RETCODE SCIPvarRemoveCliquesImplicsVbs(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_CLIQUETABLE *cliquetable, SCIP_SET *set, SCIP_Bool irrelevantvar, SCIP_Bool onlyredundant, SCIP_Bool removefromvar)
Definition: var.c:1609
static void varSetProbindex(SCIP_VAR *var, int probindex)
Definition: var.c:6007
static SCIP_RETCODE varAddTransitiveBinaryClosureImplic(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_CLIQUETABLE *cliquetable, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, SCIP_Bool varfixing, SCIP_VAR *implvar, SCIP_Bool implvarfixing, SCIP_Bool *infeasible, int *nbdchgs)
Definition: var.c:9719
internal methods for problem variables