Scippy

SCIP

Solving Constraint Integer Programs

conflict.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-2020 Konrad-Zuse-Zentrum */
7 /* fuer Informationstechnik Berlin */
8 /* */
9 /* SCIP is distributed under the terms of the ZIB Academic License. */
10 /* */
11 /* You should have received a copy of the ZIB Academic License */
12 /* along with SCIP; see the file COPYING. If not visit scipopt.org. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 /**@file conflict.c
16  * @ingroup OTHER_CFILES
17  * @brief methods and datastructures for conflict analysis
18  * @author Tobias Achterberg
19  * @author Timo Berthold
20  * @author Stefan Heinz
21  * @author Marc Pfetsch
22  * @author Michael Winkler
23  * @author Jakob Witzig
24  *
25  * This file implements a conflict analysis method like the one used in modern
26  * SAT solvers like zchaff. The algorithm works as follows:
27  *
28  * Given is a set of bound changes that are not allowed being applied simultaneously, because they
29  * render the current node infeasible (e.g. because a single constraint is infeasible in the these
30  * bounds, or because the LP relaxation is infeasible). The goal is to deduce a clause on variables
31  * -- a conflict clause -- representing the "reason" for this conflict, i.e., the branching decisions
32  * or the deductions (applied e.g. in domain propagation) that lead to the conflict. This clause can
33  * then be added to the constraint set to help cutting off similar parts of the branch and bound
34  * tree, that would lead to the same conflict. A conflict clause can also be generated, if the
35  * conflict was detected by a locally valid constraint. In this case, the resulting conflict clause
36  * is also locally valid in the same depth as the conflict detecting constraint. If all involved
37  * variables are binary, a linear (set covering) constraint can be generated, otherwise a bound
38  * disjunction constraint is generated. Details are given in
39  *
40  * Tobias Achterberg, Conflict Analysis in Mixed Integer Programming@n
41  * Discrete Optimization, 4, 4-20 (2007)
42  *
43  * See also @ref CONF. Here is an outline of the algorithm:
44  *
45  * -# Put all the given bound changes to a priority queue, which is ordered,
46  * such that the bound change that was applied last due to branching or deduction
47  * is at the top of the queue. The variables in the queue are always active
48  * problem variables. Because binary variables are preferred over general integer
49  * variables, integer variables are put on the priority queue prior to the binary
50  * variables. Create an empty conflict set.
51  * -# Remove the top bound change b from the priority queue.
52  * -# Perform the following case distinction:
53  * -# If the remaining queue is non-empty, and bound change b' (the one that is now
54  * on the top of the queue) was applied at the same depth level as b, and if
55  * b was a deduction with known inference reason, and if the inference constraint's
56  * valid depth is smaller or equal to the conflict detecting constraint's valid
57  * depth:
58  * - Resolve bound change b by asking the constraint that inferred the
59  * bound change to put all the bound changes on the priority queue, that
60  * lead to the deduction of b.
61  * Note that these bound changes have at most the same inference depth
62  * level as b, and were deduced earlier than b.
63  * -# Otherwise, the bound change b was a branching decision or a deduction with
64  * missing inference reason, or the inference constraint's validity is more local
65  * than the one of the conflict detecting constraint.
66  * - If a the bound changed corresponds to a binary variable, add it or its
67  * negation to the conflict set, depending on which of them is currently fixed to
68  * FALSE (i.e., the conflict set consists of literals that cannot be FALSE
69  * altogether at the same time).
70  * - Otherwise put the bound change into the conflict set.
71  * Note that if the bound change was a branching, all deduced bound changes
72  * remaining in the priority queue have smaller inference depth level than b,
73  * since deductions are always applied after the branching decisions. However,
74  * there is the possibility, that b was a deduction, where the inference
75  * reason was not given or the inference constraint was too local.
76  * With this lack of information, we must treat the deduced bound change like
77  * a branching, and there may exist other deduced bound changes of the same
78  * inference depth level in the priority queue.
79  * -# If priority queue is non-empty, goto step 2.
80  * -# The conflict set represents the conflict clause saying that at least one
81  * of the conflict variables must take a different value. The conflict set is then passed
82  * to the conflict handlers, that may create a corresponding constraint (e.g. a logicor
83  * constraint or bound disjunction constraint) out of these conflict variables and
84  * add it to the problem.
85  *
86  * If all deduced bound changes come with (global) inference information, depending on
87  * the conflict analyzing strategy, the resulting conflict set has the following property:
88  * - 1-FirstUIP: In the depth level where the conflict was found, at most one variable
89  * assigned at that level is member of the conflict set. This conflict variable is the
90  * first unique implication point of its depth level (FUIP).
91  * - All-FirstUIP: For each depth level, at most one variable assigned at that level is
92  * member of the conflict set. This conflict variable is the first unique implication
93  * point of its depth level (FUIP).
94  *
95  * The user has to do the following to get the conflict analysis running in its
96  * current implementation:
97  * - A constraint handler or propagator supporting the conflict analysis must implement
98  * the CONSRESPROP/PROPRESPROP call, that processes a bound change inference b and puts all
99  * the reason bounds leading to the application of b with calls to
100  * SCIPaddConflictBound() on the conflict queue (algorithm step 3.(a)).
101  * - If the current bounds lead to a deduction of a bound change (e.g. in domain
102  * propagation), a constraint handler should call SCIPinferVarLbCons() or
103  * SCIPinferVarUbCons(), thus providing the constraint that infered the bound change.
104  * A propagator should call SCIPinferVarLbProp() or SCIPinferVarUbProp() instead,
105  * thus providing a pointer to itself.
106  * - If (in the current bounds) an infeasibility is detected, the constraint handler or
107  * propagator should
108  * 1. call SCIPinitConflictAnalysis() to initialize the conflict queue,
109  * 2. call SCIPaddConflictBound() for each bound that lead to the conflict,
110  * 3. call SCIPanalyzeConflictCons() or SCIPanalyzeConflict() to analyze the conflict
111  * and add an appropriate conflict constraint.
112  */
113 
114 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
115 
116 #include "lpi/lpi.h"
117 #include "scip/clock.h"
118 #include "scip/conflict.h"
119 #include "scip/conflictstore.h"
120 #include "scip/cons.h"
121 #include "scip/cons_linear.h"
122 #include "scip/cuts.h"
123 #include "scip/history.h"
124 #include "scip/lp.h"
125 #include "scip/presolve.h"
126 #include "scip/prob.h"
127 #include "scip/prop.h"
128 #include "scip/pub_conflict.h"
129 #include "scip/pub_cons.h"
130 #include "scip/pub_lp.h"
131 #include "scip/pub_message.h"
132 #include "scip/pub_misc.h"
133 #include "scip/pub_misc_sort.h"
134 #include "scip/pub_paramset.h"
135 #include "scip/pub_prop.h"
136 #include "scip/pub_tree.h"
137 #include "scip/pub_var.h"
138 #include "scip/scip_conflict.h"
139 #include "scip/scip_cons.h"
140 #include "scip/scip_mem.h"
141 #include "scip/scip_sol.h"
142 #include "scip/scip_var.h"
143 #include "scip/set.h"
144 #include "scip/sol.h"
145 #include "scip/struct_conflict.h"
146 #include "scip/struct_lp.h"
147 #include "scip/struct_prob.h"
148 #include "scip/struct_set.h"
149 #include "scip/struct_stat.h"
150 #include "scip/struct_tree.h"
151 #include "scip/struct_var.h"
152 #include "scip/tree.h"
153 #include "scip/var.h"
154 #include "scip/visual.h"
155 #include <string.h>
156 #if defined(_WIN32) || defined(_WIN64)
157 #else
158 #include <strings.h> /*lint --e{766}*/
159 #endif
160 
161 
162 
163 #define BOUNDSWITCH 0.51 /**< threshold for bound switching - see cuts.c */
164 #define POSTPROCESS FALSE /**< apply postprocessing to the cut - see cuts.c */
165 #define USEVBDS FALSE /**< use variable bounds - see cuts.c */
166 #define ALLOWLOCAL FALSE /**< allow to generate local cuts - see cuts. */
167 #define MINFRAC 0.05 /**< minimal fractionality of floor(rhs) - see cuts.c */
168 #define MAXFRAC 0.999 /**< maximal fractionality of floor(rhs) - see cuts.c */
169 
170 /*#define SCIP_CONFGRAPH*/
171 
172 
173 #ifdef SCIP_CONFGRAPH
174 /*
175  * Output of Conflict Graph
176  */
177 
178 #include <stdio.h>
179 
180 static FILE* confgraphfile = NULL; /**< output file for current conflict graph */
181 static SCIP_BDCHGINFO* confgraphcurrentbdchginfo = NULL; /**< currently resolved bound change */
182 static int confgraphnconflictsets = 0; /**< number of conflict sets marked in the graph */
183 
184 /** writes a node section to the conflict graph file */
185 static
186 void confgraphWriteNode(
187  void* idptr, /**< id of the node */
188  const char* label, /**< label of the node */
189  const char* nodetype, /**< type of the node */
190  const char* fillcolor, /**< color of the node's interior */
191  const char* bordercolor /**< color of the node's border */
192  )
193 {
194  assert(confgraphfile != NULL);
195 
196  SCIPgmlWriteNode(confgraphfile, (unsigned int)(size_t)idptr, label, nodetype, fillcolor, bordercolor);
197 }
198 
199 /** writes an edge section to the conflict graph file */
200 static
201 void confgraphWriteEdge(
202  void* source, /**< source node of the edge */
203  void* target, /**< target node of the edge */
204  const char* color /**< color of the edge */
205  )
206 {
207  assert(confgraphfile != NULL);
208 
209 #ifndef SCIP_CONFGRAPH_EDGE
210  SCIPgmlWriteArc(confgraphfile, (unsigned int)(size_t)source, (unsigned int)(size_t)target, NULL, color);
211 #else
212  SCIPgmlWriteEdge(confgraphfile, (unsigned int)(size_t)source, (unsigned int)(size_t)target, NULL, color);
213 #endif
214 }
215 
216 /** creates a file to output the current conflict graph into; adds the conflict vertex to the graph */
217 static
218 SCIP_RETCODE confgraphCreate(
219  SCIP_SET* set, /**< global SCIP settings */
220  SCIP_CONFLICT* conflict /**< conflict analysis data */
221  )
222 {
223  char fname[SCIP_MAXSTRLEN];
224 
225  assert(conflict != NULL);
226  assert(confgraphfile == NULL);
227 
228  (void) SCIPsnprintf(fname, SCIP_MAXSTRLEN, "conf%p%d.gml", conflict, conflict->count);
229  SCIPinfoMessage(set->scip, NULL, "storing conflict graph in file <%s>\n", fname);
230 
231  confgraphfile = fopen(fname, "w");
232 
233  if( confgraphfile == NULL )
234  {
235  SCIPerrorMessage("cannot open graph file <%s>\n", fname);
236  SCIPABORT(); /*lint !e527*/
237  return SCIP_WRITEERROR;
238  }
239 
240  SCIPgmlWriteOpening(confgraphfile, TRUE);
241 
242  confgraphWriteNode(NULL, "conflict", "ellipse", "#ff0000", "#000000");
243 
244  confgraphcurrentbdchginfo = NULL;
245 
246  return SCIP_OKAY;
247 }
248 
249 /** closes conflict graph file */
250 static
251 void confgraphFree(
252  void
253  )
254 {
255  if( confgraphfile != NULL )
256  {
257  SCIPgmlWriteClosing(confgraphfile);
258 
259  fclose(confgraphfile);
260 
261  confgraphfile = NULL;
262  confgraphnconflictsets = 0;
263  }
264 }
265 
266 /** adds a bound change node to the conflict graph and links it to the currently resolved bound change */
267 static
268 void confgraphAddBdchg(
269  SCIP_BDCHGINFO* bdchginfo /**< bound change to add to the conflict graph */
270  )
271 {
272  const char* colors[] = {
273  "#8888ff", /* blue for constraint resolving */
274  "#ffff00", /* yellow for propagator resolving */
275  "#55ff55" /* green branching decision */
276  };
277  char label[SCIP_MAXSTRLEN];
278  char depth[SCIP_MAXSTRLEN];
279  int col;
280 
281  switch( SCIPbdchginfoGetChgtype(bdchginfo) )
282  {
284  col = 2;
285  break;
287  col = 0;
288  break;
290  col = (SCIPbdchginfoGetInferProp(bdchginfo) == NULL ? 1 : 0);
291  break;
292  default:
293  SCIPerrorMessage("invalid bound change type\n");
294  col = 0;
295  SCIPABORT();
296  break;
297  }
298 
299  if( SCIPbdchginfoGetDepth(bdchginfo) == INT_MAX )
300  (void) SCIPsnprintf(depth, SCIP_MAXSTRLEN, "dive");
301  else
302  (void) SCIPsnprintf(depth, SCIP_MAXSTRLEN, "%d", SCIPbdchginfoGetDepth(bdchginfo));
303  (void) SCIPsnprintf(label, SCIP_MAXSTRLEN, "%s %s %g\n[%s:%d]", SCIPvarGetName(SCIPbdchginfoGetVar(bdchginfo)),
304  SCIPbdchginfoGetBoundtype(bdchginfo) == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=",
305  SCIPbdchginfoGetNewbound(bdchginfo), depth, SCIPbdchginfoGetPos(bdchginfo));
306  confgraphWriteNode(bdchginfo, label, "ellipse", colors[col], "#000000");
307  confgraphWriteEdge(bdchginfo, confgraphcurrentbdchginfo, "#000000");
308 }
309 
310 /** links the already existing bound change node to the currently resolved bound change */
311 static
312 void confgraphLinkBdchg(
313  SCIP_BDCHGINFO* bdchginfo /**< bound change to add to the conflict graph */
314  )
315 {
316  confgraphWriteEdge(bdchginfo, confgraphcurrentbdchginfo, "#000000");
317 }
318 
319 /** marks the given bound change to be the currently resolved bound change */
320 static
321 void confgraphSetCurrentBdchg(
322  SCIP_BDCHGINFO* bdchginfo /**< bound change to add to the conflict graph */
323  )
324 {
325  confgraphcurrentbdchginfo = bdchginfo;
326 }
327 
328 /** marks given conflict set in the conflict graph */
329 static
330 void confgraphMarkConflictset(
331  SCIP_CONFLICTSET* conflictset /**< conflict set */
332  )
333 {
334  char label[SCIP_MAXSTRLEN];
335  int i;
336 
337  assert(conflictset != NULL);
338 
339  confgraphnconflictsets++;
340  (void) SCIPsnprintf(label, SCIP_MAXSTRLEN, "conf %d (%d)", confgraphnconflictsets, conflictset->validdepth);
341  confgraphWriteNode((void*)(size_t)confgraphnconflictsets, label, "rectangle", "#ff00ff", "#000000");
342  for( i = 0; i < conflictset->nbdchginfos; ++i )
343  confgraphWriteEdge((void*)(size_t)confgraphnconflictsets, conflictset->bdchginfos[i], "#ff00ff");
344 }
345 
346 #endif
347 
348 /*
349  * Conflict Handler
350  */
351 
352 /** compares two conflict handlers w. r. to their priority */
353 SCIP_DECL_SORTPTRCOMP(SCIPconflicthdlrComp)
354 { /*lint --e{715}*/
355  return ((SCIP_CONFLICTHDLR*)elem2)->priority - ((SCIP_CONFLICTHDLR*)elem1)->priority;
356 }
357 
358 /** comparison method for sorting conflict handler w.r.t. to their name */
359 SCIP_DECL_SORTPTRCOMP(SCIPconflicthdlrCompName)
360 {
362 }
363 
364 /** method to call, when the priority of a conflict handler was changed */
365 static
366 SCIP_DECL_PARAMCHGD(paramChgdConflicthdlrPriority)
367 { /*lint --e{715}*/
368  SCIP_PARAMDATA* paramdata;
369 
370  paramdata = SCIPparamGetData(param);
371  assert(paramdata != NULL);
372 
373  /* use SCIPsetConflicthdlrPriority() to mark the conflicthdlrs unsorted */
374  SCIP_CALL( SCIPsetConflicthdlrPriority(scip, (SCIP_CONFLICTHDLR*)paramdata, SCIPparamGetInt(param)) ); /*lint !e740*/
375 
376  return SCIP_OKAY;
377 }
378 
379 /** copies the given conflict handler to a new scip */
381  SCIP_CONFLICTHDLR* conflicthdlr, /**< conflict handler */
382  SCIP_SET* set /**< SCIP_SET of SCIP to copy to */
383  )
384 {
385  assert(conflicthdlr != NULL);
386  assert(set != NULL);
387  assert(set->scip != NULL);
388 
389  if( conflicthdlr->conflictcopy != NULL )
390  {
391  SCIPsetDebugMsg(set, "including conflict handler %s in subscip %p\n", SCIPconflicthdlrGetName(conflicthdlr), (void*)set->scip);
392  SCIP_CALL( conflicthdlr->conflictcopy(set->scip, conflicthdlr) );
393  }
394 
395  return SCIP_OKAY;
396 }
397 
398 /** internal method for creating a conflict handler */
399 static
401  SCIP_CONFLICTHDLR** conflicthdlr, /**< pointer to conflict handler data structure */
402  SCIP_SET* set, /**< global SCIP settings */
403  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
404  BMS_BLKMEM* blkmem, /**< block memory for parameter settings */
405  const char* name, /**< name of conflict handler */
406  const char* desc, /**< description of conflict handler */
407  int priority, /**< priority of the conflict handler */
408  SCIP_DECL_CONFLICTCOPY((*conflictcopy)), /**< copy method of conflict handler or NULL if you don't want to copy your plugin into sub-SCIPs */
409  SCIP_DECL_CONFLICTFREE((*conflictfree)), /**< destructor of conflict handler */
410  SCIP_DECL_CONFLICTINIT((*conflictinit)), /**< initialize conflict handler */
411  SCIP_DECL_CONFLICTEXIT((*conflictexit)), /**< deinitialize conflict handler */
412  SCIP_DECL_CONFLICTINITSOL((*conflictinitsol)),/**< solving process initialization method of conflict handler */
413  SCIP_DECL_CONFLICTEXITSOL((*conflictexitsol)),/**< solving process deinitialization method of conflict handler */
414  SCIP_DECL_CONFLICTEXEC((*conflictexec)), /**< conflict processing method of conflict handler */
415  SCIP_CONFLICTHDLRDATA* conflicthdlrdata /**< conflict handler data */
416  )
417 {
419  char paramdesc[SCIP_MAXSTRLEN];
420 
421  assert(conflicthdlr != NULL);
422  assert(name != NULL);
423  assert(desc != NULL);
424 
425  SCIP_ALLOC( BMSallocMemory(conflicthdlr) );
426  BMSclearMemory(*conflicthdlr);
427 
428  SCIP_ALLOC( BMSduplicateMemoryArray(&(*conflicthdlr)->name, name, strlen(name)+1) );
429  SCIP_ALLOC( BMSduplicateMemoryArray(&(*conflicthdlr)->desc, desc, strlen(desc)+1) );
430  (*conflicthdlr)->priority = priority;
431  (*conflicthdlr)->conflictcopy = conflictcopy;
432  (*conflicthdlr)->conflictfree = conflictfree;
433  (*conflicthdlr)->conflictinit = conflictinit;
434  (*conflicthdlr)->conflictexit = conflictexit;
435  (*conflicthdlr)->conflictinitsol = conflictinitsol;
436  (*conflicthdlr)->conflictexitsol = conflictexitsol;
437  (*conflicthdlr)->conflictexec = conflictexec;
438  (*conflicthdlr)->conflicthdlrdata = conflicthdlrdata;
439  (*conflicthdlr)->initialized = FALSE;
440 
441  SCIP_CALL( SCIPclockCreate(&(*conflicthdlr)->setuptime, SCIP_CLOCKTYPE_DEFAULT) );
442  SCIP_CALL( SCIPclockCreate(&(*conflicthdlr)->conflicttime, SCIP_CLOCKTYPE_DEFAULT) );
443 
444  /* add parameters */
445  (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "conflict/%s/priority", name);
446  (void) SCIPsnprintf(paramdesc, SCIP_MAXSTRLEN, "priority of conflict handler <%s>", name);
447  SCIP_CALL( SCIPsetAddIntParam(set, messagehdlr, blkmem, paramname, paramdesc, &(*conflicthdlr)->priority, TRUE, \
448  priority, INT_MIN, INT_MAX, paramChgdConflicthdlrPriority, (SCIP_PARAMDATA*)(*conflicthdlr)) ); /*lint !e740*/
449 
450  return SCIP_OKAY;
451 }
452 
453 /** creates a conflict handler */
455  SCIP_CONFLICTHDLR** conflicthdlr, /**< pointer to conflict handler data structure */
456  SCIP_SET* set, /**< global SCIP settings */
457  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
458  BMS_BLKMEM* blkmem, /**< block memory for parameter settings */
459  const char* name, /**< name of conflict handler */
460  const char* desc, /**< description of conflict handler */
461  int priority, /**< priority of the conflict handler */
462  SCIP_DECL_CONFLICTCOPY((*conflictcopy)), /**< copy method of conflict handler or NULL if you don't want to
463  * copy your plugin into sub-SCIPs */
464  SCIP_DECL_CONFLICTFREE((*conflictfree)), /**< destructor of conflict handler */
465  SCIP_DECL_CONFLICTINIT((*conflictinit)), /**< initialize conflict handler */
466  SCIP_DECL_CONFLICTEXIT((*conflictexit)), /**< deinitialize conflict handler */
467  SCIP_DECL_CONFLICTINITSOL((*conflictinitsol)),/**< solving process initialization method of conflict handler */
468  SCIP_DECL_CONFLICTEXITSOL((*conflictexitsol)),/**< solving process deinitialization method of conflict handler */
469  SCIP_DECL_CONFLICTEXEC((*conflictexec)), /**< conflict processing method of conflict handler */
470  SCIP_CONFLICTHDLRDATA* conflicthdlrdata /**< conflict handler data */
471  )
472 {
473  assert(conflicthdlr != NULL);
474  assert(name != NULL);
475  assert(desc != NULL);
476 
477  SCIP_CALL_FINALLY( doConflicthdlrCreate(conflicthdlr, set, messagehdlr, blkmem, name, desc, priority,
478  conflictcopy, conflictfree, conflictinit, conflictexit, conflictinitsol, conflictexitsol, conflictexec,
479  conflicthdlrdata), (void) SCIPconflicthdlrFree(conflicthdlr, set) );
480 
481  return SCIP_OKAY;
482 }
483 
484 /** calls destructor and frees memory of conflict handler */
486  SCIP_CONFLICTHDLR** conflicthdlr, /**< pointer to conflict handler data structure */
487  SCIP_SET* set /**< global SCIP settings */
488  )
489 {
490  assert(conflicthdlr != NULL);
491  if( *conflicthdlr == NULL )
492  return SCIP_OKAY;
493  assert(!(*conflicthdlr)->initialized);
494  assert(set != NULL);
495 
496  /* call destructor of conflict handler */
497  if( (*conflicthdlr)->conflictfree != NULL )
498  {
499  SCIP_CALL( (*conflicthdlr)->conflictfree(set->scip, *conflicthdlr) );
500  }
501 
502  SCIPclockFree(&(*conflicthdlr)->conflicttime);
503  SCIPclockFree(&(*conflicthdlr)->setuptime);
504 
505  BMSfreeMemoryArrayNull(&(*conflicthdlr)->name);
506  BMSfreeMemoryArrayNull(&(*conflicthdlr)->desc);
507  BMSfreeMemory(conflicthdlr);
508 
509  return SCIP_OKAY;
510 }
511 
512 /** calls initialization method of conflict handler */
514  SCIP_CONFLICTHDLR* conflicthdlr, /**< conflict handler */
515  SCIP_SET* set /**< global SCIP settings */
516  )
517 {
518  assert(conflicthdlr != NULL);
519  assert(set != NULL);
520 
521  if( conflicthdlr->initialized )
522  {
523  SCIPerrorMessage("conflict handler <%s> already initialized\n", conflicthdlr->name);
524  return SCIP_INVALIDCALL;
525  }
526 
527  if( set->misc_resetstat )
528  {
529  SCIPclockReset(conflicthdlr->setuptime);
530  SCIPclockReset(conflicthdlr->conflicttime);
531  }
532 
533  /* call initialization method of conflict handler */
534  if( conflicthdlr->conflictinit != NULL )
535  {
536  /* start timing */
537  SCIPclockStart(conflicthdlr->setuptime, set);
538 
539  SCIP_CALL( conflicthdlr->conflictinit(set->scip, conflicthdlr) );
540 
541  /* stop timing */
542  SCIPclockStop(conflicthdlr->setuptime, set);
543  }
544  conflicthdlr->initialized = TRUE;
545 
546  return SCIP_OKAY;
547 }
548 
549 /** calls exit method of conflict handler */
551  SCIP_CONFLICTHDLR* conflicthdlr, /**< conflict handler */
552  SCIP_SET* set /**< global SCIP settings */
553  )
554 {
555  assert(conflicthdlr != NULL);
556  assert(set != NULL);
557 
558  if( !conflicthdlr->initialized )
559  {
560  SCIPerrorMessage("conflict handler <%s> not initialized\n", conflicthdlr->name);
561  return SCIP_INVALIDCALL;
562  }
563 
564  /* call deinitialization method of conflict handler */
565  if( conflicthdlr->conflictexit != NULL )
566  {
567  /* start timing */
568  SCIPclockStart(conflicthdlr->setuptime, set);
569 
570  SCIP_CALL( conflicthdlr->conflictexit(set->scip, conflicthdlr) );
571 
572  /* stop timing */
573  SCIPclockStop(conflicthdlr->setuptime, set);
574  }
575  conflicthdlr->initialized = FALSE;
576 
577  return SCIP_OKAY;
578 }
579 
580 /** informs conflict handler that the branch and bound process is being started */
582  SCIP_CONFLICTHDLR* conflicthdlr, /**< conflict handler */
583  SCIP_SET* set /**< global SCIP settings */
584  )
585 {
586  assert(conflicthdlr != NULL);
587  assert(set != NULL);
588 
589  /* call solving process initialization method of conflict handler */
590  if( conflicthdlr->conflictinitsol != NULL )
591  {
592  /* start timing */
593  SCIPclockStart(conflicthdlr->setuptime, set);
594 
595  SCIP_CALL( conflicthdlr->conflictinitsol(set->scip, conflicthdlr) );
596 
597  /* stop timing */
598  SCIPclockStop(conflicthdlr->setuptime, set);
599  }
600 
601  return SCIP_OKAY;
602 }
603 
604 /** informs conflict handler that the branch and bound process data is being freed */
606  SCIP_CONFLICTHDLR* conflicthdlr, /**< conflict handler */
607  SCIP_SET* set /**< global SCIP settings */
608  )
609 {
610  assert(conflicthdlr != NULL);
611  assert(set != NULL);
612 
613  /* call solving process deinitialization method of conflict handler */
614  if( conflicthdlr->conflictexitsol != NULL )
615  {
616  /* start timing */
617  SCIPclockStart(conflicthdlr->setuptime, set);
618 
619  SCIP_CALL( conflicthdlr->conflictexitsol(set->scip, conflicthdlr) );
620 
621  /* stop timing */
622  SCIPclockStop(conflicthdlr->setuptime, set);
623  }
624 
625  return SCIP_OKAY;
626 }
627 
628 /** calls execution method of conflict handler */
630  SCIP_CONFLICTHDLR* conflicthdlr, /**< conflict handler */
631  SCIP_SET* set, /**< global SCIP settings */
632  SCIP_NODE* node, /**< node to add conflict constraint to */
633  SCIP_NODE* validnode, /**< node at which the constraint is valid */
634  SCIP_BDCHGINFO** bdchginfos, /**< bound change resembling the conflict set */
635  SCIP_Real* relaxedbds, /**< array with relaxed bounds which are efficient to create a valid conflict */
636  int nbdchginfos, /**< number of bound changes in the conflict set */
637  SCIP_CONFTYPE conftype, /**< type of the conflict */
638  SCIP_Bool usescutoffbound, /**< depends the conflict on the cutoff bound? */
639  SCIP_Bool resolved, /**< was the conflict set already used to create a constraint? */
640  SCIP_RESULT* result /**< pointer to store the result of the callback method */
641  )
642 {
643  assert(conflicthdlr != NULL);
644  assert(set != NULL);
645  assert(bdchginfos != NULL || nbdchginfos == 0);
646  assert(result != NULL);
647 
648  /* call solution start method of conflict handler */
649  *result = SCIP_DIDNOTRUN;
650  if( conflicthdlr->conflictexec != NULL )
651  {
652  /* start timing */
653  SCIPclockStart(conflicthdlr->conflicttime, set);
654 
655  SCIP_CALL( conflicthdlr->conflictexec(set->scip, conflicthdlr, node, validnode, bdchginfos, relaxedbds, nbdchginfos,
656  conftype, usescutoffbound, set->conf_separate, (SCIPnodeGetDepth(validnode) > 0), set->conf_dynamic,
657  set->conf_removable, resolved, result) );
658 
659  /* stop timing */
660  SCIPclockStop(conflicthdlr->conflicttime, set);
661 
662  if( *result != SCIP_CONSADDED
663  && *result != SCIP_DIDNOTFIND
664  && *result != SCIP_DIDNOTRUN )
665  {
666  SCIPerrorMessage("execution method of conflict handler <%s> returned invalid result <%d>\n",
667  conflicthdlr->name, *result);
668  return SCIP_INVALIDRESULT;
669  }
670  }
671 
672  return SCIP_OKAY;
673 }
674 
675 /** gets user data of conflict handler */
677  SCIP_CONFLICTHDLR* conflicthdlr /**< conflict handler */
678  )
679 {
680  assert(conflicthdlr != NULL);
681 
682  return conflicthdlr->conflicthdlrdata;
683 }
684 
685 /** sets user data of conflict handler; user has to free old data in advance! */
687  SCIP_CONFLICTHDLR* conflicthdlr, /**< conflict handler */
688  SCIP_CONFLICTHDLRDATA* conflicthdlrdata /**< new conflict handler user data */
689  )
690 {
691  assert(conflicthdlr != NULL);
692 
693  conflicthdlr->conflicthdlrdata = conflicthdlrdata;
694 }
695 
696 /** set copy method of conflict handler */
698  SCIP_CONFLICTHDLR* conflicthdlr, /**< conflict handler */
699  SCIP_DECL_CONFLICTCOPY((*conflictcopy)) /**< copy method of the conflict handler */
700  )
701 {
702  assert(conflicthdlr != NULL);
703 
704  conflicthdlr->conflictcopy = conflictcopy;
705 }
706 
707 /** set destructor of conflict handler */
709  SCIP_CONFLICTHDLR* conflicthdlr, /**< conflict handler */
710  SCIP_DECL_CONFLICTFREE((*conflictfree)) /**< destructor of conflict handler */
711  )
712 {
713  assert(conflicthdlr != NULL);
714 
715  conflicthdlr->conflictfree = conflictfree;
716 }
717 
718 /** set initialization method of conflict handler */
720  SCIP_CONFLICTHDLR* conflicthdlr, /**< conflict handler */
721  SCIP_DECL_CONFLICTINIT((*conflictinit)) /**< initialization method conflict handler */
722  )
723 {
724  assert(conflicthdlr != NULL);
725 
726  conflicthdlr->conflictinit = conflictinit;
727 }
728 
729 /** set deinitialization method of conflict handler */
731  SCIP_CONFLICTHDLR* conflicthdlr, /**< conflict handler */
732  SCIP_DECL_CONFLICTEXIT((*conflictexit)) /**< deinitialization method conflict handler */
733  )
734 {
735  assert(conflicthdlr != NULL);
736 
737  conflicthdlr->conflictexit = conflictexit;
738 }
739 
740 /** set solving process initialization method of conflict handler */
742  SCIP_CONFLICTHDLR* conflicthdlr, /**< conflict handler */
743  SCIP_DECL_CONFLICTINITSOL((*conflictinitsol))/**< solving process initialization method of conflict handler */
744  )
745 {
746  assert(conflicthdlr != NULL);
747 
748  conflicthdlr->conflictinitsol = conflictinitsol;
749 }
750 
751 /** set solving process deinitialization method of conflict handler */
753  SCIP_CONFLICTHDLR* conflicthdlr, /**< conflict handler */
754  SCIP_DECL_CONFLICTEXITSOL((*conflictexitsol))/**< solving process deinitialization method of conflict handler */
755  )
756 {
757  assert(conflicthdlr != NULL);
758 
759  conflicthdlr->conflictexitsol = conflictexitsol;
760 }
761 
762 /** gets name of conflict handler */
764  SCIP_CONFLICTHDLR* conflicthdlr /**< conflict handler */
765  )
766 {
767  assert(conflicthdlr != NULL);
768 
769  return conflicthdlr->name;
770 }
771 
772 /** gets description of conflict handler */
774  SCIP_CONFLICTHDLR* conflicthdlr /**< conflict handler */
775  )
776 {
777  assert(conflicthdlr != NULL);
778 
779  return conflicthdlr->desc;
780 }
781 
782 /** gets priority of conflict handler */
784  SCIP_CONFLICTHDLR* conflicthdlr /**< conflict handler */
785  )
786 {
787  assert(conflicthdlr != NULL);
788 
789  return conflicthdlr->priority;
790 }
791 
792 /** sets priority of conflict handler */
794  SCIP_CONFLICTHDLR* conflicthdlr, /**< conflict handler */
795  SCIP_SET* set, /**< global SCIP settings */
796  int priority /**< new priority of the conflict handler */
797  )
798 {
799  assert(conflicthdlr != NULL);
800  assert(set != NULL);
801 
802  conflicthdlr->priority = priority;
803  set->conflicthdlrssorted = FALSE;
804 }
805 
806 /** is conflict handler initialized? */
808  SCIP_CONFLICTHDLR* conflicthdlr /**< conflict handler */
809  )
810 {
811  assert(conflicthdlr != NULL);
812 
813  return conflicthdlr->initialized;
814 }
815 
816 /** enables or disables all clocks of \p conflicthdlr, depending on the value of the flag */
818  SCIP_CONFLICTHDLR* conflicthdlr, /**< the conflict handler for which all clocks should be enabled or disabled */
819  SCIP_Bool enable /**< should the clocks of the conflict handler be enabled? */
820  )
821 {
822  assert(conflicthdlr != NULL);
823 
824  SCIPclockEnableOrDisable(conflicthdlr->setuptime, enable);
825  SCIPclockEnableOrDisable(conflicthdlr->conflicttime, enable);
826 }
827 
828 /** gets time in seconds used in this conflict handler for setting up for next stages */
830  SCIP_CONFLICTHDLR* conflicthdlr /**< conflict handler */
831  )
832 {
833  assert(conflicthdlr != NULL);
834 
835  return SCIPclockGetTime(conflicthdlr->setuptime);
836 }
837 
838 /** gets time in seconds used in this conflict handler */
840  SCIP_CONFLICTHDLR* conflicthdlr /**< conflict handler */
841  )
842 {
843  assert(conflicthdlr != NULL);
844 
845  return SCIPclockGetTime(conflicthdlr->conflicttime);
846 }
847 
848 /*
849  * Conflict LP Bound Changes
850  */
851 
852 
853 /** create conflict LP bound change data structure */
854 static
856  SCIP_LPBDCHGS** lpbdchgs, /**< pointer to store the conflict LP bound change data structure */
857  SCIP_SET* set, /**< global SCIP settings */
858  int ncols /**< number of columns */
859  )
860 {
861  SCIP_CALL( SCIPsetAllocBuffer(set, lpbdchgs) );
862 
863  SCIP_CALL( SCIPsetAllocBufferArray(set, &(*lpbdchgs)->bdchginds, ncols) );
864  SCIP_CALL( SCIPsetAllocBufferArray(set, &(*lpbdchgs)->bdchglbs, ncols) );
865  SCIP_CALL( SCIPsetAllocBufferArray(set, &(*lpbdchgs)->bdchgubs, ncols) );
866  SCIP_CALL( SCIPsetAllocBufferArray(set, &(*lpbdchgs)->bdchgcolinds, ncols) );
867  SCIP_CALL( SCIPsetAllocBufferArray(set, &(*lpbdchgs)->usedcols, ncols) );
868  BMSclearMemoryArray((*lpbdchgs)->usedcols, ncols);
869 
870  (*lpbdchgs)->nbdchgs = 0;
871 
872  return SCIP_OKAY;
873 }
874 
875 /** reset conflict LP bound change data structure */
876 static
878  SCIP_LPBDCHGS* lpbdchgs, /**< conflict LP bound change data structure */
879  int ncols /**< number of columns */
880  )
881 {
882  assert(lpbdchgs != NULL);
883 
884  BMSclearMemoryArray(lpbdchgs->usedcols, ncols);
885  lpbdchgs->nbdchgs = 0;
886 }
887 
888 /** free conflict LP bound change data structure */
889 static
891  SCIP_LPBDCHGS** lpbdchgs, /**< pointer to store the conflict LP bound change data structure */
892  SCIP_SET* set /**< global SCIP settings */
893  )
894 {
895  SCIPsetFreeBufferArray(set, &(*lpbdchgs)->usedcols);
896  SCIPsetFreeBufferArray(set, &(*lpbdchgs)->bdchgcolinds);
897  SCIPsetFreeBufferArray(set, &(*lpbdchgs)->bdchgubs);
898  SCIPsetFreeBufferArray(set, &(*lpbdchgs)->bdchglbs);
899  SCIPsetFreeBufferArray(set, &(*lpbdchgs)->bdchginds);
900 
901  SCIPsetFreeBuffer(set, lpbdchgs);
902 }
903 
904 /*
905  * Proof Sets
906  */
907 
908 /** return the char associated with the type of the variable */
909 static
911  SCIP_VAR* var /**< variable */
912  )
913 {
914  SCIP_VARTYPE vartype = SCIPvarGetType(var);
915 
916  return (!SCIPvarIsIntegral(var) ? 'C' :
917  (vartype == SCIP_VARTYPE_BINARY ? 'B' :
918  (vartype == SCIP_VARTYPE_INTEGER ? 'I' : 'M')));
919 }
920 
921 /** resets the data structure of a proofset */
922 static
924  SCIP_PROOFSET* proofset /**< proof set */
925  )
926 {
927  assert(proofset != NULL);
928 
929  proofset->nnz = 0;
930  proofset->rhs = 0.0;
931  proofset->validdepth = 0;
933 }
934 
935 /** creates a proofset */
936 static
938  SCIP_PROOFSET** proofset, /**< proof set */
939  BMS_BLKMEM* blkmem /**< block memory of transformed problem */
940  )
941 {
942  assert(proofset != NULL);
943 
944  SCIP_ALLOC( BMSallocBlockMemory(blkmem, proofset) );
945  (*proofset)->vals = NULL;
946  (*proofset)->inds = NULL;
947  (*proofset)->rhs = 0.0;
948  (*proofset)->nnz = 0;
949  (*proofset)->size = 0;
950  (*proofset)->validdepth = 0;
951  (*proofset)->conflicttype = SCIP_CONFTYPE_UNKNOWN;
952 
953  return SCIP_OKAY;
954 }
955 
956 /** creates and clears the proofset */
957 static
959  SCIP_CONFLICT* conflict, /**< conflict analysis data */
960  BMS_BLKMEM* blkmem /**< block memory of transformed problem */
961  )
962 {
963  assert(conflict != NULL);
964  assert(blkmem != NULL);
965 
966  SCIP_CALL( proofsetCreate(&conflict->proofset, blkmem) );
967 
968  return SCIP_OKAY;
969 }
970 
971 /** frees a proofset */
972 static
974  SCIP_PROOFSET** proofset, /**< proof set */
975  BMS_BLKMEM* blkmem /**< block memory */
976  )
977 {
978  assert(proofset != NULL);
979  assert(*proofset != NULL);
980  assert(blkmem != NULL);
981 
982  BMSfreeBlockMemoryArrayNull(blkmem, &(*proofset)->vals, (*proofset)->size);
983  BMSfreeBlockMemoryArrayNull(blkmem, &(*proofset)->inds, (*proofset)->size);
984  BMSfreeBlockMemory(blkmem, proofset);
985  (*proofset) = NULL;
986 }
987 
988 #ifdef SCIP_DEBUG
989 static
990 void proofsetPrint(
991  SCIP_PROOFSET* proofset,
992  SCIP_SET* set,
993  SCIP_PROB* transprob
994  )
995 {
996  SCIP_VAR** vars;
997  int i;
998 
999  assert(proofset != NULL);
1000 
1001  vars = SCIPprobGetVars(transprob);
1002  assert(vars != NULL);
1003 
1004  printf("proofset: ");
1005  for( i = 0; i < proofset->nnz; i++ )
1006  printf("%+.15g <%s> ", proofset->vals[i], SCIPvarGetName(vars[proofset->inds[i]]));
1007  printf(" <= %.15g\n", proofset->rhs);
1008 }
1009 #endif
1010 
1011 /** return the indices of variables in the proofset */
1012 static
1014  SCIP_PROOFSET* proofset /**< proof set */
1015  )
1016 {
1017  assert(proofset != NULL);
1018 
1019  return proofset->inds;
1020 }
1021 
1022 /** return coefficient of variable in the proofset with given probindex */
1023 static
1025  SCIP_PROOFSET* proofset /**< proof set */
1026  )
1027 {
1028  assert(proofset != NULL);
1029 
1030  return proofset->vals;
1031 }
1032 
1033 /** return the right-hand side if a proofset */
1034 static
1036  SCIP_PROOFSET* proofset /**< proof set */
1037  )
1038 {
1039  assert(proofset != NULL);
1040 
1041  return proofset->rhs;
1042 }
1043 
1044 /** returns the number of variables in the proofset */
1045 static
1047  SCIP_PROOFSET* proofset /**< proof set */
1048  )
1049 {
1050  assert(proofset != NULL);
1051 
1052  return proofset->nnz;
1053 }
1054 
1055 /** returns the number of variables in the proofset */
1056 static
1058  SCIP_PROOFSET* proofset /**< proof set */
1059  )
1060 {
1061  assert(proofset != NULL);
1062 
1063  return proofset->conflicttype;
1064 }
1065 
1066 /** adds given data as aggregation row to the proofset */
1067 static
1069  SCIP_PROOFSET* proofset, /**< proof set */
1070  BMS_BLKMEM* blkmem, /**< block memory */
1071  SCIP_Real* vals, /**< variable coefficients */
1072  int* inds, /**< variable array */
1073  int nnz, /**< size of variable and coefficient array */
1074  SCIP_Real rhs /**< right-hand side of the aggregation row */
1075  )
1076 {
1077  assert(proofset != NULL);
1078  assert(blkmem != NULL);
1079 
1080  if( proofset->size == 0 )
1081  {
1082  assert(proofset->vals == NULL);
1083  assert(proofset->inds == NULL);
1084 
1085  SCIP_ALLOC( BMSduplicateBlockMemoryArray(blkmem, &proofset->vals, vals, nnz) );
1086  SCIP_ALLOC( BMSduplicateBlockMemoryArray(blkmem, &proofset->inds, inds, nnz) );
1087 
1088  proofset->size = nnz;
1089  }
1090  else
1091  {
1092  int i;
1093 
1094  assert(proofset->vals != NULL);
1095  assert(proofset->inds != NULL);
1096 
1097  if( proofset->size < nnz )
1098  {
1099  SCIP_ALLOC( BMSreallocBlockMemoryArray(blkmem, &proofset->vals, proofset->size, nnz) );
1100  SCIP_ALLOC( BMSreallocBlockMemoryArray(blkmem, &proofset->inds, proofset->size, nnz) );
1101  proofset->size = nnz;
1102  }
1103 
1104  for( i = 0; i < nnz; i++ )
1105  {
1106  proofset->vals[i] = vals[i];
1107  proofset->inds[i] = inds[i];
1108  }
1109  }
1110 
1111  proofset->rhs = rhs;
1112  proofset->nnz = nnz;
1113 
1114  return SCIP_OKAY;
1115 }
1116 
1117 /** adds an aggregation row to the proofset */
1118 static
1120  SCIP_PROOFSET* proofset, /**< proof set */
1121  SCIP_SET* set, /**< global SCIP settings */
1122  BMS_BLKMEM* blkmem, /**< block memory */
1123  SCIP_AGGRROW* aggrrow /**< aggregation row to add */
1124  )
1125 {
1126  SCIP_Real* vals;
1127  int* inds;
1128  int nnz;
1129  int i;
1130 
1131  assert(proofset != NULL);
1132  assert(set != NULL);
1133 
1134  inds = SCIPaggrRowGetInds(aggrrow);
1135  assert(inds != NULL);
1136 
1137  nnz = SCIPaggrRowGetNNz(aggrrow);
1138  assert(nnz > 0);
1139 
1140  SCIP_CALL( SCIPsetAllocBufferArray(set, &vals, nnz) );
1141 
1142  for( i = 0; i < nnz; i++ )
1143  {
1144  vals[i] = SCIPaggrRowGetProbvarValue(aggrrow, inds[i]);
1145  }
1146 
1147  SCIP_CALL( proofsetAddSparseData(proofset, blkmem, vals, inds, nnz, SCIPaggrRowGetRhs(aggrrow)) );
1148 
1149  SCIPsetFreeBufferArray(set, &vals);
1150 
1151  return SCIP_OKAY;
1152 }
1153 
1154 /** Removes a given variable @p var from position @p pos from the proofset and updates the right-hand side according
1155  * to sign of the coefficient, i.e., rhs -= coef * bound, where bound = lb if coef >= 0 and bound = ub, otherwise.
1156  *
1157  * @note: The list of non-zero indices and coefficients will be updated by swapping the last non-zero index to @p pos.
1158  */
1159 static
1161  SCIP_PROOFSET* proofset,
1162  SCIP_SET* set,
1163  SCIP_VAR* var,
1164  int pos,
1165  SCIP_Bool* valid
1166  )
1167 {
1168  assert(proofset != NULL);
1169  assert(var != NULL);
1170  assert(pos >= 0 && pos < proofset->nnz);
1171  assert(valid != NULL);
1172 
1173  *valid = TRUE;
1174 
1175  /* cancel with lower bound */
1176  if( proofset->vals[pos] > 0.0 )
1177  {
1178  proofset->rhs -= proofset->vals[pos] * SCIPvarGetLbGlobal(var);
1179  }
1180  /* cancel with upper bound */
1181  else
1182  {
1183  assert(proofset->vals[pos] < 0.0);
1184  proofset->rhs -= proofset->vals[pos] * SCIPvarGetUbGlobal(var);
1185  }
1186 
1187  --proofset->nnz;
1188 
1189  proofset->vals[pos] = proofset->vals[proofset->nnz];
1190  proofset->inds[pos] = proofset->inds[proofset->nnz];
1191  proofset->vals[proofset->nnz] = 0.0;
1192  proofset->inds[proofset->nnz] = 0;
1193 
1194  if( SCIPsetIsInfinity(set, proofset->rhs) )
1195  *valid = FALSE;
1196 }
1197 
1198 /*
1199  * Conflict Sets
1200  */
1201 
1202 /** resizes the array of the temporary bound change informations to be able to store at least num bound change entries */
1203 static
1205  SCIP_CONFLICT* conflict, /**< conflict analysis data */
1206  SCIP_SET* set, /**< global SCIP settings */
1207  int num /**< minimal number of slots in arrays */
1208  )
1209 {
1210  assert(conflict != NULL);
1211  assert(set != NULL);
1212 
1213  if( num > conflict->tmpbdchginfossize )
1214  {
1215  int newsize;
1216 
1217  newsize = SCIPsetCalcMemGrowSize(set, num);
1218  SCIP_ALLOC( BMSreallocMemoryArray(&conflict->tmpbdchginfos, newsize) );
1219  conflict->tmpbdchginfossize = newsize;
1220  }
1221  assert(num <= conflict->tmpbdchginfossize);
1222 
1223  return SCIP_OKAY;
1224 }
1225 
1226 /** creates a temporary bound change information object that is destroyed after the conflict sets are flushed */
1227 static
1229  SCIP_CONFLICT* conflict, /**< conflict analysis data */
1230  BMS_BLKMEM* blkmem, /**< block memory */
1231  SCIP_SET* set, /**< global SCIP settings */
1232  SCIP_VAR* var, /**< active variable that changed the bounds */
1233  SCIP_BOUNDTYPE boundtype, /**< type of bound for var: lower or upper bound */
1234  SCIP_Real oldbound, /**< old value for bound */
1235  SCIP_Real newbound, /**< new value for bound */
1236  SCIP_BDCHGINFO** bdchginfo /**< pointer to store bound change information */
1237  )
1238 {
1239  assert(conflict != NULL);
1240 
1241  SCIP_CALL( conflictEnsureTmpbdchginfosMem(conflict, set, conflict->ntmpbdchginfos+1) );
1242  SCIP_CALL( SCIPbdchginfoCreate(&conflict->tmpbdchginfos[conflict->ntmpbdchginfos], blkmem,
1243  var, boundtype, oldbound, newbound) );
1244  *bdchginfo = conflict->tmpbdchginfos[conflict->ntmpbdchginfos];
1245  conflict->ntmpbdchginfos++;
1246 
1247  return SCIP_OKAY;
1248 }
1249 
1250 /** frees all temporarily created bound change information data */
1251 static
1253  SCIP_CONFLICT* conflict, /**< conflict analysis data */
1254  BMS_BLKMEM* blkmem /**< block memory */
1255  )
1256 {
1257  int i;
1258 
1259  assert(conflict != NULL);
1260 
1261  for( i = 0; i < conflict->ntmpbdchginfos; ++i )
1262  SCIPbdchginfoFree(&conflict->tmpbdchginfos[i], blkmem);
1263  conflict->ntmpbdchginfos = 0;
1264 }
1265 
1266 /** clears the given conflict set */
1267 static
1269  SCIP_CONFLICTSET* conflictset /**< conflict set */
1270  )
1271 {
1272  assert(conflictset != NULL);
1273 
1274  conflictset->nbdchginfos = 0;
1275  conflictset->validdepth = 0;
1276  conflictset->insertdepth = 0;
1277  conflictset->conflictdepth = 0;
1278  conflictset->repropdepth = 0;
1279  conflictset->repropagate = TRUE;
1280  conflictset->usescutoffbound = FALSE;
1281  conflictset->conflicttype = SCIP_CONFTYPE_UNKNOWN;
1282 }
1283 
1284 /** creates an empty conflict set */
1285 static
1287  SCIP_CONFLICTSET** conflictset, /**< pointer to store the conflict set */
1288  BMS_BLKMEM* blkmem /**< block memory of transformed problem */
1289  )
1290 {
1291  assert(conflictset != NULL);
1292 
1293  SCIP_ALLOC( BMSallocBlockMemory(blkmem, conflictset) );
1294  (*conflictset)->bdchginfos = NULL;
1295  (*conflictset)->relaxedbds = NULL;
1296  (*conflictset)->sortvals = NULL;
1297  (*conflictset)->bdchginfossize = 0;
1298 
1299  conflictsetClear(*conflictset);
1300 
1301  return SCIP_OKAY;
1302 }
1303 
1304 /** creates a copy of the given conflict set, allocating an additional amount of memory */
1305 static
1307  SCIP_CONFLICTSET** targetconflictset, /**< pointer to store the conflict set */
1308  BMS_BLKMEM* blkmem, /**< block memory of transformed problem */
1309  SCIP_CONFLICTSET* sourceconflictset, /**< source conflict set */
1310  int nadditionalelems /**< number of additional elements to allocate memory for */
1311  )
1312 {
1313  int targetsize;
1314 
1315  assert(targetconflictset != NULL);
1316  assert(sourceconflictset != NULL);
1317 
1318  targetsize = sourceconflictset->nbdchginfos + nadditionalelems;
1319  SCIP_ALLOC( BMSallocBlockMemory(blkmem, targetconflictset) );
1320  SCIP_ALLOC( BMSallocBlockMemoryArray(blkmem, &(*targetconflictset)->bdchginfos, targetsize) );
1321  SCIP_ALLOC( BMSallocBlockMemoryArray(blkmem, &(*targetconflictset)->relaxedbds, targetsize) );
1322  SCIP_ALLOC( BMSallocBlockMemoryArray(blkmem, &(*targetconflictset)->sortvals, targetsize) );
1323  (*targetconflictset)->bdchginfossize = targetsize;
1324 
1325  BMScopyMemoryArray((*targetconflictset)->bdchginfos, sourceconflictset->bdchginfos, sourceconflictset->nbdchginfos);
1326  BMScopyMemoryArray((*targetconflictset)->relaxedbds, sourceconflictset->relaxedbds, sourceconflictset->nbdchginfos);
1327  BMScopyMemoryArray((*targetconflictset)->sortvals, sourceconflictset->sortvals, sourceconflictset->nbdchginfos);
1328 
1329  (*targetconflictset)->nbdchginfos = sourceconflictset->nbdchginfos;
1330  (*targetconflictset)->validdepth = sourceconflictset->validdepth;
1331  (*targetconflictset)->insertdepth = sourceconflictset->insertdepth;
1332  (*targetconflictset)->conflictdepth = sourceconflictset->conflictdepth;
1333  (*targetconflictset)->repropdepth = sourceconflictset->repropdepth;
1334  (*targetconflictset)->usescutoffbound = sourceconflictset->usescutoffbound;
1335  (*targetconflictset)->conflicttype = sourceconflictset->conflicttype;
1336 
1337  return SCIP_OKAY;
1338 }
1339 
1340 /** frees a conflict set */
1341 static
1343  SCIP_CONFLICTSET** conflictset, /**< pointer to the conflict set */
1344  BMS_BLKMEM* blkmem /**< block memory of transformed problem */
1345  )
1346 {
1347  assert(conflictset != NULL);
1348  assert(*conflictset != NULL);
1349 
1350  BMSfreeBlockMemoryArrayNull(blkmem, &(*conflictset)->bdchginfos, (*conflictset)->bdchginfossize);
1351  BMSfreeBlockMemoryArrayNull(blkmem, &(*conflictset)->relaxedbds, (*conflictset)->bdchginfossize);
1352  BMSfreeBlockMemoryArrayNull(blkmem, &(*conflictset)->sortvals, (*conflictset)->bdchginfossize);
1353  BMSfreeBlockMemory(blkmem, conflictset);
1354 }
1355 
1356 /** resizes the arrays of the conflict set to be able to store at least num bound change entries */
1357 static
1359  SCIP_CONFLICTSET* conflictset, /**< conflict set */
1360  BMS_BLKMEM* blkmem, /**< block memory of transformed problem */
1361  SCIP_SET* set, /**< global SCIP settings */
1362  int num /**< minimal number of slots in arrays */
1363  )
1364 {
1365  assert(conflictset != NULL);
1366  assert(set != NULL);
1367 
1368  if( num > conflictset->bdchginfossize )
1369  {
1370  int newsize;
1371 
1372  newsize = SCIPsetCalcMemGrowSize(set, num);
1373  SCIP_ALLOC( BMSreallocBlockMemoryArray(blkmem, &conflictset->bdchginfos, conflictset->bdchginfossize, newsize) );
1374  SCIP_ALLOC( BMSreallocBlockMemoryArray(blkmem, &conflictset->relaxedbds, conflictset->bdchginfossize, newsize) );
1375  SCIP_ALLOC( BMSreallocBlockMemoryArray(blkmem, &conflictset->sortvals, conflictset->bdchginfossize, newsize) );
1376  conflictset->bdchginfossize = newsize;
1377  }
1378  assert(num <= conflictset->bdchginfossize);
1379 
1380  return SCIP_OKAY;
1381 }
1382 
1383 /** calculates the score of the conflict set
1384  *
1385  * the score is weighted sum of number of bound changes, repropagation depth, and valid depth
1386  */
1387 static
1389  SCIP_CONFLICTSET* conflictset, /**< conflict set */
1390  SCIP_SET* set /**< global SCIP settings */
1391  )
1392 {
1393  assert(conflictset != NULL);
1394 
1395  return -(set->conf_weightsize * conflictset->nbdchginfos
1396  + set->conf_weightrepropdepth * conflictset->repropdepth
1397  + set->conf_weightvaliddepth * conflictset->validdepth);
1398 }
1399 
1400 /** calculates the score of a bound change within a conflict */
1401 static
1403  SCIP_Real prooflhs, /**< lhs of proof constraint */
1404  SCIP_Real proofact, /**< activity of the proof constraint */
1405  SCIP_Real proofactdelta, /**< activity change */
1406  SCIP_Real proofcoef, /**< coefficient in proof constraint */
1407  int depth, /**< bound change depth */
1408  int currentdepth, /**< current depth */
1409  SCIP_VAR* var, /**< variable corresponding to bound change */
1410  SCIP_SET* set /**< global SCIP settings */
1411  )
1412 {
1413  SCIP_COL* col;
1414  SCIP_Real score;
1415 
1416  score = set->conf_proofscorefac * (1.0 - proofactdelta/(prooflhs - proofact));
1417  score = MAX(score, 0.0);
1418  score += set->conf_depthscorefac * (SCIP_Real)(depth+1)/(SCIP_Real)(currentdepth+1);
1419 
1421  col = SCIPvarGetCol(var);
1422  else
1423  col = NULL;
1424 
1425  if( proofcoef > 0.0 )
1426  {
1427  if( col != NULL && SCIPcolGetNNonz(col) > 0 )
1428  score += set->conf_uplockscorefac
1430  else
1431  score += set->conf_uplockscorefac * SCIPvarGetNLocksUpType(var, SCIP_LOCKTYPE_MODEL);
1432  }
1433  else
1434  {
1435  if( col != NULL && SCIPcolGetNNonz(col) > 0 )
1436  score += set->conf_downlockscorefac
1438  else
1439  score += set->conf_downlockscorefac * SCIPvarGetNLocksDownType(var, SCIP_LOCKTYPE_MODEL);
1440  }
1441 
1442  return score;
1443 }
1444 
1445 /** check if the bound change info (which is the potential next candidate which is queued) is valid for the current
1446  * conflict analysis; a bound change info can get invalid if after this one was added to the queue, a weaker bound
1447  * change was added to the queue (due the bound widening idea) which immediately makes this bound change redundant; due
1448  * to the priority we did not removed that bound change info since that cost O(log(n)); hence we have to skip/ignore it
1449  * now
1450  *
1451  * The following situations can occur before for example the bound change info (x >= 3) is potentially popped from the
1452  * queue.
1453  *
1454  * Postcondition: the reason why (x >= 3) was queued is that at this time point no lower bound of x was involved yet in
1455  * the current conflict or the lower bound which was involved until then was stronger, e.g., (x >= 2).
1456  *
1457  * 1) during the time until (x >= 3) gets potentially popped no weaker lower bound was added to the queue, in that case
1458  * the conflictlbcount is valid and conflictlb is 3; that is (var->conflictlbcount == conflict->count &&
1459  * var->conflictlb == 3)
1460  *
1461  * 2) a weaker bound change info gets queued (e.g., x >= 4); this bound change is popped before (x >= 3) since it has
1462  * higher priority (which is the time stamp of the bound change info and (x >= 4) has to be done after (x >= 3)
1463  * during propagation or branching)
1464  *
1465  * a) if (x >= 4) is popped and added to the conflict set the conflictlbcount is still valid and conflictlb is at
1466  * most 4; that is (var->conflictlbcount == conflict->count && var->conflictlb >= 4); it follows that any bound
1467  * change info which is stronger than (x >= 4) gets ignored (for example x >= 2)
1468  *
1469  * b) if (x >= 4) is popped and resolved without introducing a new lower bound on x until (x >= 3) is a potentially
1470  * candidate the conflictlbcount indicates that bound change is currently not present; that is
1471  * (var->conflictlbcount != conflict->count)
1472  *
1473  * c) if (x >= 4) is popped and resolved and a new lower bound on x (e.g., x >= 2) is introduced until (x >= 3) is
1474  * pooped, the conflictlbcount indicates that bound change is currently present; that is (var->conflictlbcount ==
1475  * conflict->count); however the (x >= 3) only has be explained if conflictlb matches that one; that is
1476  * (var->conflictlb == bdchginfo->newbound); otherwise it redundant/invalid.
1477  */
1478 static
1480  SCIP_CONFLICT* conflict, /**< conflict analysis data */
1481  SCIP_BDCHGINFO* bdchginfo /**< bound change information */
1482  )
1483 {
1484  SCIP_VAR* var;
1485 
1486  assert(bdchginfo != NULL);
1487 
1488  var = SCIPbdchginfoGetVar(bdchginfo);
1489  assert(var != NULL);
1490 
1491  /* the bound change info of a binary (domained) variable can never be invalid since the concepts of relaxed bounds
1492  * and bound widening do not make sense for these type of variables
1493  */
1494  if( SCIPvarIsBinary(var) )
1495  return FALSE;
1496 
1497  /* check if the bdchginfo is invaild since a tight/weaker bound change was already explained */
1499  {
1500  if( var->conflictlbcount != conflict->count || var->conflictlb != SCIPbdchginfoGetNewbound(bdchginfo) ) /*lint !e777*/
1501  {
1502  assert(!SCIPvarIsBinary(var));
1503  return TRUE;
1504  }
1505  }
1506  else
1507  {
1508  assert(SCIPbdchginfoGetBoundtype(bdchginfo) == SCIP_BOUNDTYPE_UPPER);
1509 
1510  if( var->conflictubcount != conflict->count || var->conflictub != SCIPbdchginfoGetNewbound(bdchginfo) ) /*lint !e777*/
1511  {
1512  assert(!SCIPvarIsBinary(var));
1513  return TRUE;
1514  }
1515  }
1516 
1517  return FALSE;
1518 }
1519 
1520 /** adds a bound change to a conflict set */
1521 static
1523  SCIP_CONFLICTSET* conflictset, /**< conflict set */
1524  BMS_BLKMEM* blkmem, /**< block memory of transformed problem */
1525  SCIP_SET* set, /**< global SCIP settings */
1526  SCIP_BDCHGINFO* bdchginfo, /**< bound change to add to the conflict set */
1527  SCIP_Real relaxedbd /**< relaxed bound */
1528  )
1529 {
1530  SCIP_BDCHGINFO** bdchginfos;
1531  SCIP_Real* relaxedbds;
1532  int* sortvals;
1533  SCIP_VAR* var;
1534  SCIP_BOUNDTYPE boundtype;
1535  int idx;
1536  int sortval;
1537  int pos;
1538 
1539  assert(conflictset != NULL);
1540  assert(bdchginfo != NULL);
1541 
1542  /* allocate memory for additional element */
1543  SCIP_CALL( conflictsetEnsureBdchginfosMem(conflictset, blkmem, set, conflictset->nbdchginfos+1) );
1544 
1545  /* insert the new bound change in the arrays sorted by increasing variable index and by bound type */
1546  bdchginfos = conflictset->bdchginfos;
1547  relaxedbds = conflictset->relaxedbds;
1548  sortvals = conflictset->sortvals;
1549  var = SCIPbdchginfoGetVar(bdchginfo);
1550  boundtype = SCIPbdchginfoGetBoundtype(bdchginfo);
1551  idx = SCIPvarGetIndex(var);
1552  assert(idx < INT_MAX/2);
1553  assert((int)boundtype == 0 || (int)boundtype == 1);
1554  sortval = 2*idx + (int)boundtype; /* first sorting criteria: variable index, second criteria: boundtype */
1555 
1556  /* insert new element into the sorted arrays; if an element exits with the same value insert the new element afterwards
1557  *
1558  * @todo check if it better (faster) to first search for the position O(log n) and compare the sort values and if
1559  * they are equal just replace the element and if not run the insert method O(n)
1560  */
1561 
1562  SCIPsortedvecInsertIntPtrReal(sortvals, (void**)bdchginfos, relaxedbds, sortval, (void*)bdchginfo, relaxedbd, &conflictset->nbdchginfos, &pos);
1563  assert(pos == conflictset->nbdchginfos - 1 || sortval < sortvals[pos+1]);
1564 
1565  /* merge multiple bound changes */
1566  if( pos > 0 && sortval == sortvals[pos-1] )
1567  {
1568  /* this is a multiple bound change */
1569  if( SCIPbdchginfoIsTighter(bdchginfo, bdchginfos[pos-1]) )
1570  {
1571  /* remove the "old" bound change since the "new" one in tighter */
1572  SCIPsortedvecDelPosIntPtrReal(sortvals, (void**)bdchginfos, relaxedbds, pos-1, &conflictset->nbdchginfos);
1573  }
1574  else if( SCIPbdchginfoIsTighter(bdchginfos[pos-1], bdchginfo) )
1575  {
1576  /* remove the "new" bound change since the "old" one is tighter */
1577  SCIPsortedvecDelPosIntPtrReal(sortvals, (void**)bdchginfos, relaxedbds, pos, &conflictset->nbdchginfos);
1578  }
1579  else
1580  {
1581  /* both bound change are equivalent; hence, keep the worse relaxed bound and remove one of them */
1582  relaxedbds[pos-1] = boundtype == SCIP_BOUNDTYPE_LOWER ? MAX(relaxedbds[pos-1], relaxedbd) : MIN(relaxedbds[pos-1], relaxedbd);
1583  SCIPsortedvecDelPosIntPtrReal(sortvals, (void**)bdchginfos, relaxedbds, pos, &conflictset->nbdchginfos);
1584  }
1585  }
1586 
1587  return SCIP_OKAY;
1588 }
1589 
1590 /** adds given bound changes to a conflict set */
1591 static
1593  SCIP_CONFLICT* conflict, /**< conflict analysis data */
1594  SCIP_CONFLICTSET* conflictset, /**< conflict set */
1595  BMS_BLKMEM* blkmem, /**< block memory of transformed problem */
1596  SCIP_SET* set, /**< global SCIP settings */
1597  SCIP_BDCHGINFO** bdchginfos, /**< bound changes to add to the conflict set */
1598  int nbdchginfos /**< number of bound changes to add */
1599  )
1600 {
1601  SCIP_BDCHGINFO** confbdchginfos;
1602  SCIP_BDCHGINFO* bdchginfo;
1603  SCIP_Real* confrelaxedbds;
1604  int* confsortvals;
1605  int confnbdchginfos;
1606  int idx;
1607  int sortval;
1608  int i;
1609  SCIP_BOUNDTYPE boundtype;
1610 
1611  assert(conflict != NULL);
1612  assert(conflictset != NULL);
1613  assert(blkmem != NULL);
1614  assert(set != NULL);
1615  assert(bdchginfos != NULL || nbdchginfos == 0);
1616 
1617  /* nothing to add */
1618  if( nbdchginfos == 0 )
1619  return SCIP_OKAY;
1620 
1621  assert(bdchginfos != NULL);
1622 
1623  /* only one element to add, use the single insertion method */
1624  if( nbdchginfos == 1 )
1625  {
1626  bdchginfo = bdchginfos[0];
1627  assert(bdchginfo != NULL);
1628 
1629  if( !bdchginfoIsInvalid(conflict, bdchginfo) )
1630  {
1631  SCIP_CALL( conflictsetAddBound(conflictset, blkmem, set, bdchginfo, SCIPbdchginfoGetRelaxedBound(bdchginfo)) );
1632  }
1633  else
1634  {
1635  SCIPsetDebugMsg(set, "-> bound change info [%d:<%s> %s %g] is invaild -> ignore it\n", SCIPbdchginfoGetDepth(bdchginfo),
1636  SCIPvarGetName(SCIPbdchginfoGetVar(bdchginfo)),
1637  SCIPbdchginfoGetBoundtype(bdchginfo) == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=",
1638  SCIPbdchginfoGetNewbound(bdchginfo));
1639  }
1640 
1641  return SCIP_OKAY;
1642  }
1643 
1644  confnbdchginfos = conflictset->nbdchginfos;
1645 
1646  /* allocate memory for additional element */
1647  SCIP_CALL( conflictsetEnsureBdchginfosMem(conflictset, blkmem, set, confnbdchginfos + nbdchginfos) );
1648 
1649  confbdchginfos = conflictset->bdchginfos;
1650  confrelaxedbds = conflictset->relaxedbds;
1651  confsortvals = conflictset->sortvals;
1652 
1653  assert(SCIP_BOUNDTYPE_LOWER == FALSE); /*lint !e641 !e506*/
1654  assert(SCIP_BOUNDTYPE_UPPER == TRUE); /*lint !e641 !e506*/
1655 
1656  for( i = 0; i < nbdchginfos; ++i )
1657  {
1658  bdchginfo = bdchginfos[i];
1659  assert(bdchginfo != NULL);
1660 
1661  /* add only valid bound change infos */
1662  if( !bdchginfoIsInvalid(conflict, bdchginfo) )
1663  {
1664  /* calculate sorting value */
1665  boundtype = SCIPbdchginfoGetBoundtype(bdchginfo);
1666  assert(SCIPbdchginfoGetVar(bdchginfo) != NULL);
1667 
1668  idx = SCIPvarGetIndex(SCIPbdchginfoGetVar(bdchginfo));
1669  assert(idx < INT_MAX/2);
1670 
1671  assert((int)boundtype == 0 || (int)boundtype == 1);
1672  sortval = 2*idx + (int)boundtype; /* first sorting criteria: variable index, second criteria: boundtype */
1673 
1674  /* add new element */
1675  confbdchginfos[confnbdchginfos] = bdchginfo;
1676  confrelaxedbds[confnbdchginfos] = SCIPbdchginfoGetRelaxedBound(bdchginfo);
1677  confsortvals[confnbdchginfos] = sortval;
1678  ++confnbdchginfos;
1679  }
1680  else
1681  {
1682  SCIPsetDebugMsg(set, "-> bound change info [%d:<%s> %s %g] is invaild -> ignore it\n", SCIPbdchginfoGetDepth(bdchginfo),
1683  SCIPvarGetName(SCIPbdchginfoGetVar(bdchginfo)),
1684  SCIPbdchginfoGetBoundtype(bdchginfo) == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=",
1685  SCIPbdchginfoGetNewbound(bdchginfo));
1686  }
1687  }
1688  assert(confnbdchginfos <= conflictset->nbdchginfos + nbdchginfos);
1689 
1690  /* sort and merge the new conflict set */
1691  if( confnbdchginfos > conflictset->nbdchginfos )
1692  {
1693  int k = 0;
1694 
1695  /* sort array */
1696  SCIPsortIntPtrReal(confsortvals, (void**)confbdchginfos, confrelaxedbds, confnbdchginfos);
1697 
1698  i = 1;
1699  /* merge multiple bound changes */
1700  while( i < confnbdchginfos )
1701  {
1702  assert(i > k);
1703 
1704  /* is this a multiple bound change */
1705  if( confsortvals[k] == confsortvals[i] )
1706  {
1707  if( SCIPbdchginfoIsTighter(confbdchginfos[k], confbdchginfos[i]) )
1708  ++i;
1709  else if( SCIPbdchginfoIsTighter(confbdchginfos[i], confbdchginfos[k]) )
1710  {
1711  /* replace worse bound change info by tighter bound change info */
1712  confbdchginfos[k] = confbdchginfos[i];
1713  confrelaxedbds[k] = confrelaxedbds[i];
1714  confsortvals[k] = confsortvals[i];
1715  ++i;
1716  }
1717  else
1718  {
1719  assert(confsortvals[k] == confsortvals[i]);
1720 
1721  /* both bound change are equivalent; hence, keep the worse relaxed bound and remove one of them */
1722  confrelaxedbds[k] = (confsortvals[k] % 2 == 0) ? MAX(confrelaxedbds[k], confrelaxedbds[i]) : MIN(confrelaxedbds[k], confrelaxedbds[i]);
1723  ++i;
1724  }
1725  }
1726  else
1727  {
1728  /* all bound change infos must be valid */
1729  assert(!bdchginfoIsInvalid(conflict, confbdchginfos[k]));
1730 
1731  ++k;
1732  /* move next comparison element to the correct position */
1733  if( k != i )
1734  {
1735  confbdchginfos[k] = confbdchginfos[i];
1736  confrelaxedbds[k] = confrelaxedbds[i];
1737  confsortvals[k] = confsortvals[i];
1738  }
1739  ++i;
1740  }
1741  }
1742  /* last bound change infos must also be valid */
1743  assert(!bdchginfoIsInvalid(conflict, confbdchginfos[k]));
1744  /* the number of bound change infos cannot be decreased, it would mean that the conflict set was not merged
1745  * before
1746  */
1747  assert(conflictset->nbdchginfos <= k + 1 );
1748  assert(k + 1 <= confnbdchginfos);
1749 
1750  conflictset->nbdchginfos = k + 1;
1751  }
1752 
1753  return SCIP_OKAY;
1754 }
1755 
1756 /** calculates the conflict and the repropagation depths of the conflict set */
1757 static
1759  SCIP_CONFLICTSET* conflictset /**< conflict set */
1760  )
1761 {
1762  int maxdepth[2];
1763  int i;
1764 
1765  assert(conflictset != NULL);
1766  assert(conflictset->validdepth <= conflictset->insertdepth);
1767 
1768  /* get the depth of the last and last but one bound change */
1769  maxdepth[0] = conflictset->validdepth;
1770  maxdepth[1] = conflictset->validdepth;
1771  for( i = 0; i < conflictset->nbdchginfos; ++i )
1772  {
1773  int depth;
1774 
1775  depth = SCIPbdchginfoGetDepth(conflictset->bdchginfos[i]);
1776  assert(depth >= 0);
1777  if( depth > maxdepth[0] )
1778  {
1779  maxdepth[1] = maxdepth[0];
1780  maxdepth[0] = depth;
1781  }
1782  else if( depth > maxdepth[1] )
1783  maxdepth[1] = depth;
1784  }
1785  assert(maxdepth[0] >= maxdepth[1]);
1786 
1787  conflictset->conflictdepth = maxdepth[0];
1788  conflictset->repropdepth = maxdepth[1];
1789 }
1790 
1791 /** identifies the depth, at which the conflict set should be added:
1792  * - if the branching rule operates on variables only, and if all branching variables up to a certain
1793  * depth level are member of the conflict, the conflict constraint can only be violated in the subtree
1794  * of the node at that depth, because in all other nodes, at least one of these branching variables
1795  * violates its conflicting bound, such that the conflict constraint is feasible
1796  * - if there is at least one branching variable in a node, we assume, that this branching was performed
1797  * on variables, and that the siblings of this node are disjunct w.r.t. the branching variables' fixings
1798  * - we have to add the conflict set at least in the valid depth of the initial conflict set,
1799  * so we start searching at the first branching after this depth level, i.e. validdepth+1
1800  */
1801 static
1803  SCIP_CONFLICTSET* conflictset, /**< conflict set */
1804  SCIP_SET* set, /**< global SCIP settings */
1805  SCIP_TREE* tree /**< branch and bound tree */
1806  )
1807 {
1808  SCIP_Bool* branchingincluded;
1809  int currentdepth;
1810  int i;
1811 
1812  assert(conflictset != NULL);
1813  assert(set != NULL);
1814  assert(tree != NULL);
1815 
1816  /* the conflict set must not be inserted prior to its valid depth */
1817  conflictset->insertdepth = conflictset->validdepth;
1818  assert(conflictset->insertdepth >= 0);
1819 
1820  currentdepth = SCIPtreeGetCurrentDepth(tree);
1821  assert(currentdepth == tree->pathlen-1);
1822 
1823  /* mark the levels for which a branching variable is included in the conflict set */
1824  SCIP_CALL( SCIPsetAllocBufferArray(set, &branchingincluded, currentdepth+2) );
1825  BMSclearMemoryArray(branchingincluded, currentdepth+2);
1826  for( i = 0; i < conflictset->nbdchginfos; ++i )
1827  {
1828  int depth;
1829 
1830  depth = SCIPbdchginfoGetDepth(conflictset->bdchginfos[i]);
1831  depth = MIN(depth, currentdepth+1); /* put diving/probing/strong branching changes in this depth level */
1832  branchingincluded[depth] = TRUE;
1833  }
1834 
1835  /* skip additional depth levels where branching on the conflict variables was applied */
1836  while( conflictset->insertdepth < currentdepth && branchingincluded[conflictset->insertdepth+1] )
1837  conflictset->insertdepth++;
1838 
1839  /* free temporary memory */
1840  SCIPsetFreeBufferArray(set, &branchingincluded);
1841 
1842  assert(conflictset->validdepth <= conflictset->insertdepth && conflictset->insertdepth <= currentdepth);
1843 
1844  return SCIP_OKAY;
1845 }
1846 
1847 /** checks whether the first conflict set is redundant to the second one */
1848 static
1850  SCIP_CONFLICTSET* conflictset1, /**< first conflict conflict set */
1851  SCIP_CONFLICTSET* conflictset2 /**< second conflict conflict set */
1852  )
1853 {
1854  int i1;
1855  int i2;
1856 
1857  assert(conflictset1 != NULL);
1858  assert(conflictset2 != NULL);
1859 
1860  /* if conflictset1 has smaller validdepth, it is definitely not redundant to conflictset2 */
1861  if( conflictset1->validdepth < conflictset2->validdepth )
1862  return FALSE;
1863 
1864  /* check, if all bound changes in conflictset2 are also present at least as tight in conflictset1;
1865  * we can stop immediately, if more bound changes are remaining in conflictset2 than in conflictset1
1866  */
1867  for( i1 = 0, i2 = 0; i2 < conflictset2->nbdchginfos && conflictset1->nbdchginfos - i1 >= conflictset2->nbdchginfos - i2;
1868  ++i1, ++i2 )
1869  {
1870  int sortval;
1871 
1872  assert(i2 == 0 || conflictset2->sortvals[i2-1] < conflictset2->sortvals[i2]);
1873 
1874  sortval = conflictset2->sortvals[i2];
1875  for( ; i1 < conflictset1->nbdchginfos && conflictset1->sortvals[i1] < sortval; ++i1 ) /*lint !e445*/
1876  {
1877  /* while scanning conflictset1, check consistency */
1878  assert(i1 == 0 || conflictset1->sortvals[i1-1] < conflictset1->sortvals[i1]);
1879  }
1880  if( i1 >= conflictset1->nbdchginfos || conflictset1->sortvals[i1] > sortval
1881  || SCIPbdchginfoIsTighter(conflictset2->bdchginfos[i2], conflictset1->bdchginfos[i1]) )
1882  return FALSE;
1883  }
1884 
1885  return (i2 == conflictset2->nbdchginfos);
1886 }
1887 
1888 #ifdef SCIP_DEBUG
1889 /** prints a conflict set to the screen */
1890 static
1891 void conflictsetPrint(
1892  SCIP_CONFLICTSET* conflictset /**< conflict set */
1893  )
1894 {
1895  int i;
1896 
1897  assert(conflictset != NULL);
1898  for( i = 0; i < conflictset->nbdchginfos; ++i )
1899  {
1900  SCIPdebugPrintf(" [%d:<%s> %s %g(%g)]", SCIPbdchginfoGetDepth(conflictset->bdchginfos[i]),
1901  SCIPvarGetName(SCIPbdchginfoGetVar(conflictset->bdchginfos[i])),
1902  SCIPbdchginfoGetBoundtype(conflictset->bdchginfos[i]) == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=",
1903  SCIPbdchginfoGetNewbound(conflictset->bdchginfos[i]), conflictset->relaxedbds[i]);
1904  }
1905  SCIPdebugPrintf("\n");
1906 }
1907 #endif
1908 
1909 /** resizes proofsets array to be able to store at least num entries */
1910 static
1912  SCIP_CONFLICT* conflict, /**< conflict analysis data */
1913  SCIP_SET* set, /**< global SCIP settings */
1914  int num /**< minimal number of slots in array */
1915  )
1916 {
1917  assert(conflict != NULL);
1918  assert(set != NULL);
1919 
1920  if( num > conflict->proofsetssize )
1921  {
1922  int newsize;
1923 
1924  newsize = SCIPsetCalcMemGrowSize(set, num);
1925  SCIP_ALLOC( BMSreallocMemoryArray(&conflict->proofsets, newsize) );
1926  conflict->proofsetssize = newsize;
1927  }
1928  assert(num <= conflict->proofsetssize);
1929 
1930  return SCIP_OKAY;
1931 }
1932 
1933 /** resizes conflictsets array to be able to store at least num entries */
1934 static
1936  SCIP_CONFLICT* conflict, /**< conflict analysis data */
1937  SCIP_SET* set, /**< global SCIP settings */
1938  int num /**< minimal number of slots in array */
1939  )
1940 {
1941  assert(conflict != NULL);
1942  assert(set != NULL);
1943 
1944  if( num > conflict->conflictsetssize )
1945  {
1946  int newsize;
1947 
1948  newsize = SCIPsetCalcMemGrowSize(set, num);
1949  SCIP_ALLOC( BMSreallocMemoryArray(&conflict->conflictsets, newsize) );
1950  SCIP_ALLOC( BMSreallocMemoryArray(&conflict->conflictsetscores, newsize) );
1951  conflict->conflictsetssize = newsize;
1952  }
1953  assert(num <= conflict->conflictsetssize);
1954 
1955  return SCIP_OKAY;
1956 }
1957 
1958 /** add a proofset to the list of all proofsets */
1959 static
1961  SCIP_CONFLICT* conflict, /**< conflict analysis data */
1962  SCIP_SET* set, /**< global SCIP settings */
1963  SCIP_PROOFSET* proofset /**< proof set to add */
1964  )
1965 {
1966  assert(conflict != NULL);
1967  assert(proofset != NULL);
1968 
1969  /* insert proofset into the sorted proofsets array */
1970  SCIP_CALL( conflictEnsureProofsetsMem(conflict, set, conflict->nproofsets + 1) );
1971 
1972  conflict->proofsets[conflict->nproofsets] = proofset;
1973  ++conflict->nproofsets;
1974 
1975  return SCIP_OKAY;
1976 }
1977 
1978 /** inserts conflict set into sorted conflictsets array and deletes the conflict set pointer */
1979 static
1981  SCIP_CONFLICT* conflict, /**< conflict analysis data */
1982  BMS_BLKMEM* blkmem, /**< block memory of transformed problem */
1983  SCIP_SET* set, /**< global SCIP settings */
1984  SCIP_CONFLICTSET** conflictset /**< pointer to conflict set to insert */
1985  )
1986 {
1987  SCIP_Real score;
1988  int pos;
1989  int i;
1990  int j;
1991 
1992  assert(conflict != NULL);
1993  assert(set != NULL);
1994  assert(conflictset != NULL);
1995  assert(*conflictset != NULL);
1996  assert((*conflictset)->validdepth <= (*conflictset)->insertdepth);
1997  assert(set->conf_allowlocal || (*conflictset)->validdepth == 0);
1998 
1999  /* calculate conflict and repropagation depth */
2000  conflictsetCalcConflictDepth(*conflictset);
2001 
2002  /* if we apply repropagations, the conflict set should be inserted at most at its repropdepth */
2003  if( set->conf_repropagate )
2004  (*conflictset)->insertdepth = MIN((*conflictset)->insertdepth, (*conflictset)->repropdepth);
2005  else
2006  (*conflictset)->repropdepth = INT_MAX;
2007  assert((*conflictset)->insertdepth <= (*conflictset)->repropdepth);
2008 
2009  SCIPsetDebugMsg(set, "inserting conflict set (valid: %d, insert: %d, conf: %d, reprop: %d):\n",
2010  (*conflictset)->validdepth, (*conflictset)->insertdepth, (*conflictset)->conflictdepth, (*conflictset)->repropdepth);
2011  SCIPdebug(conflictsetPrint(*conflictset));
2012 
2013  /* get the score of the conflict set */
2014  score = conflictsetCalcScore(*conflictset, set);
2015 
2016  /* check, if conflict set is redundant to a better conflict set */
2017  for( pos = 0; pos < conflict->nconflictsets && score < conflict->conflictsetscores[pos]; ++pos )
2018  {
2019  /* check if conflict set is redundant with respect to conflictsets[pos] */
2020  if( conflictsetIsRedundant(*conflictset, conflict->conflictsets[pos]) )
2021  {
2022  SCIPsetDebugMsg(set, " -> conflict set is redundant to: ");
2023  SCIPdebug(conflictsetPrint(conflict->conflictsets[pos]));
2024  conflictsetFree(conflictset, blkmem);
2025  return SCIP_OKAY;
2026  }
2027 
2028  /**@todo like in sepastore.c: calculate overlap between conflictsets -> large overlap reduces score */
2029  }
2030 
2031  /* insert conflictset into the sorted conflictsets array */
2032  SCIP_CALL( conflictEnsureConflictsetsMem(conflict, set, conflict->nconflictsets + 1) );
2033  for( i = conflict->nconflictsets; i > pos; --i )
2034  {
2035  assert(score >= conflict->conflictsetscores[i-1]);
2036  conflict->conflictsets[i] = conflict->conflictsets[i-1];
2037  conflict->conflictsetscores[i] = conflict->conflictsetscores[i-1];
2038  }
2039  conflict->conflictsets[pos] = *conflictset;
2040  conflict->conflictsetscores[pos] = score;
2041  conflict->nconflictsets++;
2042 
2043  /* remove worse conflictsets that are redundant to the new conflictset */
2044  for( i = pos+1, j = pos+1; i < conflict->nconflictsets; ++i )
2045  {
2046  if( conflictsetIsRedundant(conflict->conflictsets[i], *conflictset) )
2047  {
2048  SCIPsetDebugMsg(set, " -> conflict set dominates: ");
2049  SCIPdebug(conflictsetPrint(conflict->conflictsets[i]));
2050  conflictsetFree(&conflict->conflictsets[i], blkmem);
2051  }
2052  else
2053  {
2054  assert(j <= i);
2055  conflict->conflictsets[j] = conflict->conflictsets[i];
2056  conflict->conflictsetscores[j] = conflict->conflictsetscores[i];
2057  j++;
2058  }
2059  }
2060  assert(j <= conflict->nconflictsets);
2061  conflict->nconflictsets = j;
2062 
2063 #ifdef SCIP_CONFGRAPH
2064  confgraphMarkConflictset(*conflictset);
2065 #endif
2066 
2067  *conflictset = NULL; /* ownership of pointer is now in the conflictsets array */
2068 
2069  return SCIP_OKAY;
2070 }
2071 
2072 /** calculates the maximal size of conflict sets to be used */
2073 static
2075  SCIP_SET* set, /**< global SCIP settings */
2076  SCIP_PROB* prob /**< problem data */
2077  )
2078 {
2079  int maxsize;
2080 
2081  assert(set != NULL);
2082  assert(prob != NULL);
2083 
2084  maxsize = (int)(set->conf_maxvarsfac * (prob->nvars - prob->ncontvars));
2085  maxsize = MAX(maxsize, set->conf_minmaxvars);
2086 
2087  return maxsize;
2088 }
2089 
2090 /** increases the conflict score of the variable in the given direction */
2091 static
2093  SCIP_VAR* var, /**< problem variable */
2094  BMS_BLKMEM* blkmem, /**< block memory */
2095  SCIP_SET* set, /**< global SCIP settings */
2096  SCIP_STAT* stat, /**< dynamic problem statistics */
2097  SCIP_BOUNDTYPE boundtype, /**< type of bound for which the score should be increased */
2098  SCIP_Real value, /**< value of the bound */
2099  SCIP_Real weight /**< weight of this VSIDS updates */
2100  )
2101 {
2102  SCIP_BRANCHDIR branchdir;
2103 
2104  assert(var != NULL);
2105  assert(stat != NULL);
2106 
2107  /* weight the VSIDS by the given weight */
2108  weight *= stat->vsidsweight;
2109 
2110  if( SCIPsetIsZero(set, weight) )
2111  return SCIP_OKAY;
2112 
2113  branchdir = (boundtype == SCIP_BOUNDTYPE_LOWER ? SCIP_BRANCHDIR_UPWARDS : SCIP_BRANCHDIR_DOWNWARDS); /*lint !e641*/
2114  SCIP_CALL( SCIPvarIncVSIDS(var, blkmem, set, stat, branchdir, value, weight) );
2115  SCIPhistoryIncVSIDS(stat->glbhistory, branchdir, weight);
2116  SCIPhistoryIncVSIDS(stat->glbhistorycrun, branchdir, weight);
2117 
2118  return SCIP_OKAY;
2119 }
2120 
2121 /** update conflict statistics */
2122 static
2124  SCIP_CONFLICT* conflict, /**< conflict analysis data */
2125  BMS_BLKMEM* blkmem, /**< block memory */
2126  SCIP_SET* set, /**< global SCIP settings */
2127  SCIP_STAT* stat, /**< dynamic problem statistics */
2128  SCIP_CONFLICTSET* conflictset, /**< conflict set to add to the tree */
2129  int insertdepth /**< depth level at which the conflict set should be added */
2130  )
2131 {
2132  if( insertdepth > 0 )
2133  {
2134  conflict->nappliedlocconss++;
2135  conflict->nappliedlocliterals += conflictset->nbdchginfos;
2136  }
2137  else
2138  {
2139  int i;
2140  int conflictlength;
2141  conflictlength = conflictset->nbdchginfos;
2142 
2143  for( i = 0; i < conflictlength; i++ )
2144  {
2145  SCIP_VAR* var;
2146  SCIP_BRANCHDIR branchdir;
2147  SCIP_BOUNDTYPE boundtype;
2148  SCIP_Real bound;
2149 
2150  assert(stat != NULL);
2151 
2152  var = conflictset->bdchginfos[i]->var;
2153  boundtype = SCIPbdchginfoGetBoundtype(conflictset->bdchginfos[i]);
2154  bound = conflictset->relaxedbds[i];
2155 
2156  branchdir = (boundtype == SCIP_BOUNDTYPE_LOWER ? SCIP_BRANCHDIR_UPWARDS : SCIP_BRANCHDIR_DOWNWARDS); /*lint !e641*/
2157 
2158  SCIP_CALL( SCIPvarIncNActiveConflicts(var, blkmem, set, stat, branchdir, bound, (SCIP_Real)conflictlength) );
2159  SCIPhistoryIncNActiveConflicts(stat->glbhistory, branchdir, (SCIP_Real)conflictlength);
2160  SCIPhistoryIncNActiveConflicts(stat->glbhistorycrun, branchdir, (SCIP_Real)conflictlength);
2161 
2162  /* each variable which is part of the conflict gets an increase in the VSIDS */
2163  SCIP_CALL( incVSIDS(var, blkmem, set, stat, boundtype, bound, set->conf_conflictweight) );
2164  }
2165  conflict->nappliedglbconss++;
2166  conflict->nappliedglbliterals += conflictset->nbdchginfos;
2167  }
2168 
2169  return SCIP_OKAY;
2170 }
2171 
2172 
2173 /** check conflict set for redundancy, other conflicts in the same conflict analysis could have led to global reductions
2174  * an made this conflict set redundant
2175  */
2176 static
2178  SCIP_SET* set, /**< global SCIP settings */
2179  SCIP_CONFLICTSET* conflictset /**< conflict set */
2180  )
2181 {
2182  SCIP_BDCHGINFO** bdchginfos;
2183  SCIP_VAR* var;
2184  SCIP_Real* relaxedbds;
2185  SCIP_Real bound;
2186  int v;
2187 
2188  assert(set != NULL);
2189  assert(conflictset != NULL);
2190 
2191  bdchginfos = conflictset->bdchginfos;
2192  relaxedbds = conflictset->relaxedbds;
2193  assert(bdchginfos != NULL);
2194  assert(relaxedbds != NULL);
2195 
2196  /* check all boundtypes and bounds for redundancy */
2197  for( v = conflictset->nbdchginfos - 1; v >= 0; --v )
2198  {
2199  var = SCIPbdchginfoGetVar(bdchginfos[v]);
2200  assert(var != NULL);
2201  assert(SCIPvarGetProbindex(var) >= 0);
2202 
2203  /* check if the relaxed bound is really a relaxed bound */
2204  assert(SCIPbdchginfoGetBoundtype(bdchginfos[v]) == SCIP_BOUNDTYPE_LOWER || SCIPsetIsGE(set, relaxedbds[v], SCIPbdchginfoGetNewbound(bdchginfos[v])));
2205  assert(SCIPbdchginfoGetBoundtype(bdchginfos[v]) == SCIP_BOUNDTYPE_UPPER || SCIPsetIsLE(set, relaxedbds[v], SCIPbdchginfoGetNewbound(bdchginfos[v])));
2206 
2207  bound = relaxedbds[v];
2208 
2209  if( SCIPbdchginfoGetBoundtype(bdchginfos[v]) == SCIP_BOUNDTYPE_UPPER )
2210  {
2212  {
2213  assert(SCIPsetIsIntegral(set, bound));
2214  bound += 1.0;
2215  }
2216 
2217  /* check if the bound is already fulfilled globally */
2218  if( SCIPsetIsFeasGE(set, SCIPvarGetLbGlobal(var), bound) )
2219  return TRUE;
2220  }
2221  else
2222  {
2223  assert(SCIPbdchginfoGetBoundtype(bdchginfos[v]) == SCIP_BOUNDTYPE_LOWER);
2224 
2226  {
2227  assert(SCIPsetIsIntegral(set, bound));
2228  bound -= 1.0;
2229  }
2230 
2231  /* check if the bound is already fulfilled globally */
2232  if( SCIPsetIsFeasLE(set, SCIPvarGetUbGlobal(var), bound) )
2233  return TRUE;
2234  }
2235  }
2236 
2237  return FALSE;
2238 }
2239 
2240 /** find global fixings which can be derived from the new conflict set */
2241 static
2243  SCIP_SET* set, /**< global SCIP settings */
2244  SCIP_PROB* prob, /**< transformed problem after presolve */
2245  SCIP_CONFLICTSET* conflictset, /**< conflict set to add to the tree */
2246  int* nbdchgs, /**< number of global deducted bound changes due to the conflict set */
2247  int* nredvars, /**< number of redundant and removed variables from conflict set */
2248  SCIP_Bool* redundant /**< did we found a global reduction on a conflict set variable, which makes this conflict redundant */
2249  )
2250 {
2251  SCIP_BDCHGINFO** bdchginfos;
2252  SCIP_Real* relaxedbds;
2253  SCIP_VAR* var;
2254  SCIP_Bool* boundtypes;
2255  SCIP_Real* bounds;
2256  SCIP_Longint* nbinimpls;
2257  int* sortvals;
2258  SCIP_Real bound;
2259  SCIP_Bool isupper;
2260  int ntrivialredvars;
2261  int nbdchginfos;
2262  int nzeroimpls;
2263  int v;
2264 
2265  assert(set != NULL);
2266  assert(prob != NULL);
2267  assert(SCIPprobIsTransformed(prob));
2268  assert(conflictset != NULL);
2269  assert(nbdchgs != NULL);
2270  assert(nredvars != NULL);
2271  /* only check conflict sets with more than one variable */
2272  assert(conflictset->nbdchginfos > 1);
2273 
2274  *nbdchgs = 0;
2275  *nredvars = 0;
2276 
2277  /* due to other conflict in the same conflict analysis, this conflict set might have become redundant */
2278  *redundant = checkRedundancy(set, conflictset);
2279 
2280  if( *redundant )
2281  return SCIP_OKAY;
2282 
2283  bdchginfos = conflictset->bdchginfos;
2284  relaxedbds = conflictset->relaxedbds;
2285  nbdchginfos = conflictset->nbdchginfos;
2286  sortvals = conflictset->sortvals;
2287 
2288  assert(bdchginfos != NULL);
2289  assert(relaxedbds != NULL);
2290  assert(sortvals != NULL);
2291 
2292  /* check if the boolean representation of boundtypes matches the 'standard' definition */
2293  assert(SCIP_BOUNDTYPE_LOWER == FALSE); /*lint !e641 !e506*/
2294  assert(SCIP_BOUNDTYPE_UPPER == TRUE); /*lint !e641 !e506*/
2295 
2296  ntrivialredvars = 0;
2297 
2298  /* due to multiple conflict sets for one conflict, it can happen, that we already have redundant information in the
2299  * conflict set
2300  */
2301  for( v = nbdchginfos - 1; v >= 0; --v )
2302  {
2303  var = SCIPbdchginfoGetVar(bdchginfos[v]);
2304  bound = relaxedbds[v];
2305  isupper = (SCIP_Bool) SCIPboundtypeOpposite(SCIPbdchginfoGetBoundtype(bdchginfos[v]));
2306 
2307  /* for integral variable we can increase/decrease the conflicting bound */
2308  if( SCIPvarIsIntegral(var) )
2309  bound += (isupper ? -1.0 : +1.0);
2310 
2311  /* if conflict variable cannot fulfill the conflict we can remove it */
2312  if( (isupper && SCIPsetIsFeasLT(set, bound, SCIPvarGetLbGlobal(var))) ||
2313  (!isupper && SCIPsetIsFeasGT(set, bound, SCIPvarGetUbGlobal(var))) )
2314  {
2315  SCIPsetDebugMsg(set, "remove redundant variable <%s> from conflict set\n", SCIPvarGetName(var));
2316 
2317  bdchginfos[v] = bdchginfos[nbdchginfos - 1];
2318  relaxedbds[v] = relaxedbds[nbdchginfos - 1];
2319  sortvals[v] = sortvals[nbdchginfos - 1];
2320 
2321  --nbdchginfos;
2322  ++ntrivialredvars;
2323  }
2324  }
2325  assert(ntrivialredvars + nbdchginfos == conflictset->nbdchginfos);
2326 
2327  SCIPsetDebugMsg(set, "trivially removed %d redundant of %d variables from conflictset (%p)\n", ntrivialredvars, conflictset->nbdchginfos, (void*)conflictset);
2328  conflictset->nbdchginfos = nbdchginfos;
2329 
2330  /* all variables where removed, the conflict cannot be fulfilled, i.e., we have an infeasibility proof */
2331  if( conflictset->nbdchginfos == 0 )
2332  return SCIP_OKAY;
2333 
2334  /* do not check to big or trivial conflicts */
2335  if( conflictset->nbdchginfos > set->conf_maxvarsdetectimpliedbounds || conflictset->nbdchginfos == 1 )
2336  {
2337  *nredvars = ntrivialredvars;
2338  return SCIP_OKAY;
2339  }
2340 
2341  /* create array of boundtypes, and bound values in conflict set */
2342  SCIP_CALL( SCIPsetAllocBufferArray(set, &boundtypes, nbdchginfos) );
2343  SCIP_CALL( SCIPsetAllocBufferArray(set, &bounds, nbdchginfos) );
2344  /* memory for the estimates for binary implications used for sorting */
2345  SCIP_CALL( SCIPsetAllocBufferArray(set, &nbinimpls, nbdchginfos) );
2346 
2347  nzeroimpls = 0;
2348 
2349  /* collect estimates and initialize variables, boundtypes, and bounds array */
2350  for( v = 0; v < nbdchginfos; ++v )
2351  {
2352  var = SCIPbdchginfoGetVar(bdchginfos[v]);
2353  boundtypes[v] = (SCIP_Bool) SCIPboundtypeOpposite(SCIPbdchginfoGetBoundtype(bdchginfos[v]));
2354  bounds[v] = relaxedbds[v];
2355 
2356  assert(SCIPvarGetProbindex(var) >= 0);
2357 
2358  /* check if the relaxed bound is really a relaxed bound */
2359  assert(SCIPbdchginfoGetBoundtype(bdchginfos[v]) == SCIP_BOUNDTYPE_LOWER || SCIPsetIsGE(set, relaxedbds[v], SCIPbdchginfoGetNewbound(bdchginfos[v])));
2360  assert(SCIPbdchginfoGetBoundtype(bdchginfos[v]) == SCIP_BOUNDTYPE_UPPER || SCIPsetIsLE(set, relaxedbds[v], SCIPbdchginfoGetNewbound(bdchginfos[v])));
2361 
2362  /* for continuous variables, we can only use the relaxed version of the bounds negation: !(x <= u) -> x >= u */
2363  if( SCIPvarIsBinary(var) )
2364  {
2365  if( !boundtypes[v] )
2366  {
2367  assert(SCIPsetIsZero(set, bounds[v]));
2368  bounds[v] = 1.0;
2369  nbinimpls[v] = (SCIP_Longint)SCIPvarGetNCliques(var, TRUE) * 2;
2370  }
2371  else
2372  {
2373  assert(SCIPsetIsEQ(set, bounds[v], 1.0));
2374  bounds[v] = 0.0;
2375  nbinimpls[v] = (SCIP_Longint)SCIPvarGetNCliques(var, FALSE) * 2;
2376  }
2377  }
2378  else if( SCIPvarIsIntegral(var) )
2379  {
2380  assert(SCIPsetIsIntegral(set, bounds[v]));
2381 
2382  bounds[v] += ((!boundtypes[v]) ? +1.0 : -1.0);
2383  nbinimpls[v] = (boundtypes[v] ? SCIPvarGetNVlbs(var) : SCIPvarGetNVubs(var));
2384  }
2385  else if( ((!boundtypes[v]) && SCIPsetIsFeasEQ(set, SCIPvarGetLbGlobal(var), bounds[v]))
2386  || ((boundtypes[v]) && SCIPsetIsFeasEQ(set, SCIPvarGetUbGlobal(var), bounds[v])) )
2387  {
2388  /* the literal is satisfied in global bounds (may happen due to weak "negation" of continuous variables)
2389  * -> discard the conflict constraint
2390  */
2391  break;
2392  }
2393  else
2394  {
2395  nbinimpls[v] = (boundtypes[v] ? SCIPvarGetNVlbs(var) : SCIPvarGetNVubs(var));
2396  }
2397 
2398  if( nbinimpls[v] == 0 )
2399  ++nzeroimpls;
2400  }
2401 
2402  /* starting to derive global bound changes */
2403  if( v == nbdchginfos && ((!set->conf_fullshortenconflict && nzeroimpls < 2) || (set->conf_fullshortenconflict && nzeroimpls < nbdchginfos)) )
2404  {
2405  SCIP_VAR** vars;
2406  SCIP_Bool* redundants;
2407  SCIP_Bool glbinfeas;
2408 
2409  /* sort variables in increasing order of binary implications to gain speed later on */
2410  SCIPsortLongPtrRealRealBool(nbinimpls, (void**)bdchginfos, relaxedbds, bounds, boundtypes, v);
2411 
2412  SCIPsetDebugMsg(set, "checking for global reductions and redundant conflict variables(in %s) on conflict:\n", SCIPprobGetName(prob));
2413  SCIPsetDebugMsg(set, "[");
2414  for( v = 0; v < nbdchginfos; ++v )
2415  {
2416  SCIPsetDebugMsgPrint(set, "%s %s %g", SCIPvarGetName(SCIPbdchginfoGetVar(bdchginfos[v])), (!boundtypes[v]) ? ">=" : "<=", bounds[v]);
2417  if( v < nbdchginfos - 1 )
2418  SCIPsetDebugMsgPrint(set, ", ");
2419  }
2420  SCIPsetDebugMsgPrint(set, "]\n");
2421 
2422  SCIP_CALL( SCIPsetAllocBufferArray(set, &vars, v) );
2423  SCIP_CALL( SCIPsetAllocCleanBufferArray(set, &redundants, v) );
2424 
2425  /* initialize conflict variable data */
2426  for( v = 0; v < nbdchginfos; ++v )
2427  vars[v] = SCIPbdchginfoGetVar(bdchginfos[v]);
2428 
2429  SCIP_CALL( SCIPshrinkDisjunctiveVarSet(set->scip, vars, bounds, boundtypes, redundants, nbdchginfos, nredvars, \
2430  nbdchgs, redundant, &glbinfeas, set->conf_fullshortenconflict) );
2431 
2432  if( glbinfeas )
2433  {
2434  SCIPsetDebugMsg(set, "conflict set (%p) led to global infeasibility\n", (void*) conflictset);
2435 
2436  /* clear the memory array before freeing it */
2437  BMSclearMemoryArray(redundants, nbdchginfos);
2438  goto TERMINATE;
2439  }
2440 
2441 #ifdef SCIP_DEBUG
2442  if( *nbdchgs > 0 )
2443  {
2444  SCIPsetDebugMsg(set, "conflict set (%p) led to %d global bound reductions\n", (void*) conflictset, *nbdchgs);
2445  }
2446 #endif
2447 
2448  /* remove as redundant marked variables */
2449  if( *redundant )
2450  {
2451  SCIPsetDebugMsg(set, "conflict set (%p) is redundant because at least one global reduction, fulfills the conflict constraint\n", (void*)conflictset);
2452 
2453  /* clear the memory array before freeing it */
2454  BMSclearMemoryArray(redundants, nbdchginfos);
2455  }
2456  else if( *nredvars > 0 )
2457  {
2458  assert(bdchginfos == conflictset->bdchginfos);
2459  assert(relaxedbds == conflictset->relaxedbds);
2460  assert(sortvals == conflictset->sortvals);
2461 
2462  for( v = nbdchginfos - 1; v >= 0; --v )
2463  {
2464  /* if conflict variable was marked to be redundant remove it */
2465  if( redundants[v] )
2466  {
2467  SCIPsetDebugMsg(set, "remove redundant variable <%s> from conflict set\n", SCIPvarGetName(SCIPbdchginfoGetVar(bdchginfos[v])));
2468 
2469  bdchginfos[v] = bdchginfos[nbdchginfos - 1];
2470  relaxedbds[v] = relaxedbds[nbdchginfos - 1];
2471  sortvals[v] = sortvals[nbdchginfos - 1];
2472 
2473  /* reset redundants[v] to 0 */
2474  redundants[v] = 0;
2475 
2476  --nbdchginfos;
2477  }
2478  }
2479  assert((*nredvars) + nbdchginfos == conflictset->nbdchginfos);
2480 
2481  SCIPsetDebugMsg(set, "removed %d redundant of %d variables from conflictset (%p)\n", (*nredvars), conflictset->nbdchginfos, (void*)conflictset);
2482  conflictset->nbdchginfos = nbdchginfos;
2483  }
2484  else
2485  {
2486  /* clear the memory array before freeing it */
2487  BMSclearMemoryArray(redundants, nbdchginfos);
2488  }
2489 
2490  TERMINATE:
2491  SCIPsetFreeCleanBufferArray(set, &redundants);
2492  SCIPsetFreeBufferArray(set, &vars);
2493  }
2494 
2495  /* free temporary memory */
2496  SCIPsetFreeBufferArray(set, &nbinimpls);
2497  SCIPsetFreeBufferArray(set, &bounds);
2498  SCIPsetFreeBufferArray(set, &boundtypes);
2499 
2500  *nredvars += ntrivialredvars;
2501 
2502  return SCIP_OKAY;
2503 }
2504 
2505 /** tighten the bound of a singleton variable in a constraint
2506  *
2507  * if the bound is contradicting with a global bound we cannot tighten the bound directly.
2508  * in this case we need to create and add a constraint of size one such that propagating this constraint will
2509  * enforce the infeasibility.
2510  */
2511 static
2513  SCIP_CONFLICT* conflict, /**< conflict analysis data */
2514  SCIP_SET* set, /**< global SCIP settings */
2515  SCIP_STAT* stat, /**< dynamic SCIP statistics */
2516  SCIP_TREE* tree, /**< tree data */
2517  BMS_BLKMEM* blkmem, /**< block memory */
2518  SCIP_PROB* origprob, /**< original problem */
2519  SCIP_PROB* transprob, /**< transformed problem */
2520  SCIP_REOPT* reopt, /**< reoptimization data */
2521  SCIP_LP* lp, /**< LP data */
2522  SCIP_BRANCHCAND* branchcand, /**< branching candidates */
2523  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
2524  SCIP_CLIQUETABLE* cliquetable, /**< clique table */
2525  SCIP_VAR* var, /**< problem variable */
2526  SCIP_Real val, /**< coefficient of the variable */
2527  SCIP_Real rhs, /**< rhs of the constraint */
2528  SCIP_CONFTYPE prooftype, /**< type of the proof */
2529  int validdepth /**< depth where the bound change is valid */
2530  )
2531 {
2532  SCIP_Real newbound;
2533  SCIP_Bool applyglobal;
2534  SCIP_BOUNDTYPE boundtype;
2535 
2536  assert(tree != NULL);
2537  assert(validdepth >= 0);
2538 
2539  applyglobal = (validdepth <= SCIPtreeGetEffectiveRootDepth(tree));
2540 
2541  /* if variable and coefficient are integral the rhs can be rounded down */
2542  if( SCIPvarIsIntegral(var) && SCIPsetIsIntegral(set, val) )
2543  newbound = SCIPsetFeasFloor(set, rhs)/val;
2544  else
2545  newbound = rhs/val;
2546 
2547  boundtype = (val > 0.0 ? SCIP_BOUNDTYPE_UPPER : SCIP_BOUNDTYPE_LOWER);
2548  SCIPvarAdjustBd(var, set, boundtype, &newbound);
2549 
2550  /* skip numerical unstable bound changes */
2551  if( applyglobal
2552  && ((boundtype == SCIP_BOUNDTYPE_LOWER && SCIPsetIsLE(set, newbound, SCIPvarGetLbGlobal(var)))
2553  || (boundtype == SCIP_BOUNDTYPE_UPPER && SCIPsetIsGE(set, newbound, SCIPvarGetUbGlobal(var)))) )
2554  {
2555  return SCIP_OKAY;
2556  }
2557 
2558  /* the new bound contradicts a global bound, we can cutoff the root node immediately */
2559  if( applyglobal
2560  && ((boundtype == SCIP_BOUNDTYPE_LOWER && SCIPsetIsGT(set, newbound, SCIPvarGetUbGlobal(var)))
2561  || (boundtype == SCIP_BOUNDTYPE_UPPER && SCIPsetIsLT(set, newbound, SCIPvarGetLbGlobal(var)))) )
2562  {
2563  SCIPsetDebugMsg(set, "detected global infeasibility at var <%s>: locdom=[%g,%g] glbdom=[%g,%g] new %s bound=%g\n",
2564  SCIPvarGetName(var), SCIPvarGetLbLocal(var),
2566  (boundtype == SCIP_BOUNDTYPE_LOWER ? "lower" : "upper"), newbound);
2567  SCIP_CALL( SCIPnodeCutoff(tree->path[0], set, stat, tree, transprob, origprob, reopt, lp, blkmem) );
2568  }
2569  else
2570  {
2571  if( lp->strongbranching || !applyglobal )
2572  {
2573  SCIP_CONS* cons;
2574  SCIP_Real conslhs;
2575  SCIP_Real consrhs;
2576  char name[SCIP_MAXSTRLEN];
2577 
2578  SCIPsetDebugMsg(set, "add constraint <%s>[%c] %s %g to node #%lld in depth %d\n",
2579  SCIPvarGetName(var), varGetChar(var), boundtype == SCIP_BOUNDTYPE_UPPER ? "<=" : ">=", newbound,
2580  SCIPnodeGetNumber(tree->path[validdepth]), validdepth);
2581 
2582  (void)SCIPsnprintf(name, SCIP_MAXSTRLEN, "pc_fix_%s", SCIPvarGetName(var));
2583 
2584  if( boundtype == SCIP_BOUNDTYPE_UPPER )
2585  {
2586  conslhs = -SCIPsetInfinity(set);
2587  consrhs = newbound;
2588  }
2589  else
2590  {
2591  conslhs = newbound;
2592  consrhs = SCIPsetInfinity(set);
2593  }
2594 
2595  SCIP_CALL( SCIPcreateConsLinear(set->scip, &cons, name, 0, NULL, NULL, conslhs, consrhs,
2597 
2598  SCIP_CALL( SCIPaddCoefLinear(set->scip, cons, var, 1.0) );
2599 
2600  if( applyglobal )
2601  {
2602  SCIP_CALL( SCIPprobAddCons(transprob, set, stat, cons) );
2603  }
2604  else
2605  {
2606  SCIP_CALL( SCIPnodeAddCons(tree->path[validdepth], blkmem, set, stat, tree, cons) );
2607  }
2608 
2609  SCIP_CALL( SCIPconsRelease(&cons, blkmem, set) );
2610  }
2611  else
2612  {
2613  assert(applyglobal);
2614 
2615  SCIPsetDebugMsg(set, "change global %s bound of <%s>[%c]: %g -> %g\n",
2616  (boundtype == SCIP_BOUNDTYPE_LOWER ? "lower" : "upper"),
2617  SCIPvarGetName(var), varGetChar(var),
2618  (boundtype == SCIP_BOUNDTYPE_LOWER ? SCIPvarGetLbGlobal(var) : SCIPvarGetUbGlobal(var)),
2619  newbound);
2620 
2621  SCIP_CALL( SCIPnodeAddBoundchg(tree->path[0], blkmem, set, stat, transprob, origprob, tree, reopt, lp, branchcand, \
2622  eventqueue, cliquetable, var, newbound, boundtype, FALSE) );
2623 
2624  /* mark the node in the validdepth to be propagated again */
2625  SCIPnodePropagateAgain(tree->path[0], set, stat, tree);
2626  }
2627  }
2628 
2629  if( applyglobal )
2630  ++conflict->nglbchgbds;
2631  else
2632  ++conflict->nlocchgbds;
2633 
2634  if( prooftype == SCIP_CONFTYPE_INFEASLP || prooftype == SCIP_CONFTYPE_ALTINFPROOF )
2635  {
2636  ++conflict->dualproofsinfnnonzeros; /* we count a global bound reduction as size 1 */
2637  ++conflict->ndualproofsinfsuccess;
2638  ++conflict->ninflpsuccess;
2639 
2640  if( applyglobal )
2641  ++conflict->ndualproofsinfglobal;
2642  else
2643  ++conflict->ndualproofsinflocal;
2644  }
2645  else
2646  {
2647  ++conflict->dualproofsbndnnonzeros; /* we count a global bound reduction as size 1 */
2648  ++conflict->ndualproofsbndsuccess;
2649  ++conflict->nboundlpsuccess;
2650 
2651  if( applyglobal )
2652  ++conflict->ndualproofsbndglobal;
2653  else
2654  ++conflict->ndualproofsbndlocal;
2655  }
2656 
2657  return SCIP_OKAY;
2658 }
2659 
2660 /** calculates the minimal activity of a given aggregation row */
2661 static
2663  SCIP_SET* set, /**< global SCIP settings */
2664  SCIP_PROB* transprob, /**< transformed problem data */
2665  SCIP_AGGRROW* aggrrow, /**< aggregation row */
2666  SCIP_Real* curvarlbs, /**< current lower bounds of active problem variables (or NULL for global bounds) */
2667  SCIP_Real* curvarubs, /**< current upper bounds of active problem variables (or NULL for global bounds) */
2668  SCIP_Bool* infdelta /**< pointer to store whether at least one variable contributes with an infinite value */
2669  )
2670 {
2671  SCIP_VAR** vars;
2672  SCIP_Real QUAD(minact);
2673  int* inds;
2674  int nnz;
2675  int i;
2676 
2677  vars = SCIPprobGetVars(transprob);
2678  assert(vars != NULL);
2679 
2680  nnz = SCIPaggrRowGetNNz(aggrrow);
2681  inds = SCIPaggrRowGetInds(aggrrow);
2682 
2683  QUAD_ASSIGN(minact, 0.0);
2684 
2685  if( infdelta != NULL )
2686  *infdelta = FALSE;
2687 
2688  for( i = 0; i < nnz; i++ )
2689  {
2690  SCIP_Real val;
2691  SCIP_Real QUAD(delta);
2692  int v = inds[i];
2693 
2694  assert(SCIPvarGetProbindex(vars[v]) == v);
2695 
2696  val = SCIPaggrRowGetProbvarValue(aggrrow, v);
2697 
2698  if( val > 0.0 )
2699  {
2700  SCIP_Real bnd = (curvarlbs == NULL ? SCIPvarGetLbGlobal(vars[v]) : curvarlbs[v]);
2701  SCIPquadprecProdDD(delta, val, bnd);
2702  }
2703  else
2704  {
2705  SCIP_Real bnd = (curvarubs == NULL ? SCIPvarGetUbGlobal(vars[v]) : curvarubs[v]);
2706  SCIPquadprecProdDD(delta, val, bnd);
2707  }
2708 
2709  /* update minimal activity */
2710  SCIPquadprecSumQQ(minact, minact, delta);
2711 
2712  if( infdelta != NULL && SCIPsetIsInfinity(set, REALABS(QUAD_TO_DBL(delta))) )
2713  {
2714  *infdelta = TRUE;
2715  goto TERMINATE;
2716  }
2717  }
2718 
2719  TERMINATE:
2720  /* check whether the minimal activity is infinite */
2721  if( SCIPsetIsInfinity(set, QUAD_TO_DBL(minact)) )
2722  return SCIPsetInfinity(set);
2723  if( SCIPsetIsInfinity(set, -QUAD_TO_DBL(minact)) )
2724  return -SCIPsetInfinity(set);
2725 
2726  return QUAD_TO_DBL(minact);
2727 }
2728 
2729 /** calculates the minimal activity of a given set of bounds and coefficients */
2730 static
2732  SCIP_SET* set, /**< global SCIP settings */
2733  SCIP_PROB* transprob, /**< transformed problem data */
2734  SCIP_Real* coefs, /**< coefficients in sparse representation */
2735  int* inds, /**< non-zero indices */
2736  int nnz, /**< number of non-zero indices */
2737  SCIP_Real* curvarlbs, /**< current lower bounds of active problem variables (or NULL for global bounds) */
2738  SCIP_Real* curvarubs /**< current upper bounds of active problem variables (or NULL for global bounds) */
2739  )
2740 {
2741  SCIP_VAR** vars;
2742  SCIP_Real QUAD(minact);
2743  int i;
2744 
2745  assert(coefs != NULL);
2746  assert(inds != NULL);
2747 
2748  vars = SCIPprobGetVars(transprob);
2749  assert(vars != NULL);
2750 
2751  QUAD_ASSIGN(minact, 0.0);
2752 
2753  for( i = 0; i < nnz; i++ )
2754  {
2755  SCIP_Real val;
2756  SCIP_Real QUAD(delta);
2757  int v = inds[i];
2758 
2759  assert(SCIPvarGetProbindex(vars[v]) == v);
2760 
2761  val = coefs[i];
2762 
2763  if( val > 0.0 )
2764  {
2765  SCIP_Real bnd;
2766 
2767  assert(curvarlbs == NULL || !SCIPsetIsInfinity(set, -curvarlbs[v]));
2768 
2769  bnd = (curvarlbs == NULL ? SCIPvarGetLbGlobal(vars[v]) : curvarlbs[v]);
2770  SCIPquadprecProdDD(delta, val, bnd);
2771  }
2772  else
2773  {
2774  SCIP_Real bnd;
2775 
2776  assert(curvarubs == NULL || !SCIPsetIsInfinity(set, curvarubs[v]));
2777 
2778  bnd = (curvarubs == NULL ? SCIPvarGetUbGlobal(vars[v]) : curvarubs[v]);
2779  SCIPquadprecProdDD(delta, val, bnd);
2780  }
2781 
2782  /* update minimal activity */
2783  SCIPquadprecSumQQ(minact, minact, delta);
2784  }
2785 
2786  /* check whether the minmal activity is infinite */
2787  if( SCIPsetIsInfinity(set, QUAD_TO_DBL(minact)) )
2788  return SCIPsetInfinity(set);
2789  if( SCIPsetIsInfinity(set, -QUAD_TO_DBL(minact)) )
2790  return -SCIPsetInfinity(set);
2791 
2792  return QUAD_TO_DBL(minact);
2793 }
2794 
2795 /** calculates the minimal activity of a given set of bounds and coefficients */
2796 static
2798  SCIP_SET* set, /**< global SCIP settings */
2799  SCIP_PROB* transprob, /**< transformed problem data */
2800  SCIP_Real* coefs, /**< coefficients in sparse representation */
2801  int* inds, /**< non-zero indices */
2802  int nnz, /**< number of non-zero indices */
2803  SCIP_Real* curvarlbs, /**< current lower bounds of active problem variables (or NULL for global bounds) */
2804  SCIP_Real* curvarubs /**< current upper bounds of active problem variables (or NULL for global bounds) */
2805  )
2806 {
2807  SCIP_VAR** vars;
2808  SCIP_Real QUAD(maxact);
2809  int i;
2810 
2811  assert(coefs != NULL);
2812  assert(inds != NULL);
2813 
2814  vars = SCIPprobGetVars(transprob);
2815  assert(vars != NULL);
2816 
2817  QUAD_ASSIGN(maxact, 0.0);
2818 
2819  for( i = 0; i < nnz; i++ )
2820  {
2821  SCIP_Real val;
2822  SCIP_Real QUAD(delta);
2823  int v = inds[i];
2824 
2825  assert(SCIPvarGetProbindex(vars[v]) == v);
2826 
2827  val = coefs[i];
2828 
2829  if( val < 0.0 )
2830  {
2831  SCIP_Real bnd;
2832 
2833  assert(curvarlbs == NULL || !SCIPsetIsInfinity(set, -curvarlbs[v]));
2834 
2835  bnd = (curvarlbs == NULL ? SCIPvarGetLbGlobal(vars[v]) : curvarlbs[v]);
2836  SCIPquadprecProdDD(delta, val, bnd);
2837  }
2838  else
2839  {
2840  SCIP_Real bnd;
2841 
2842  assert(curvarubs == NULL || !SCIPsetIsInfinity(set, curvarubs[v]));
2843 
2844  bnd = (curvarubs == NULL ? SCIPvarGetUbGlobal(vars[v]) : curvarubs[v]);
2845  SCIPquadprecProdDD(delta, val, bnd);
2846  }
2847 
2848  /* update maximal activity */
2849  SCIPquadprecSumQQ(maxact, maxact, delta);
2850  }
2851 
2852  /* check whether the maximal activity got infinite */
2853  if( SCIPsetIsInfinity(set, QUAD_TO_DBL(maxact)) )
2854  return SCIPsetInfinity(set);
2855  if( SCIPsetIsInfinity(set, -QUAD_TO_DBL(maxact)) )
2856  return -SCIPsetInfinity(set);
2857 
2858  return QUAD_TO_DBL(maxact);
2859 }
2860 
2861 static
2863  SCIP_CONFLICT* conflict, /**< conflict analysis data */
2864  SCIP_SET* set, /**< global SCIP settings */
2865  SCIP_STAT* stat, /**< dynamic SCIP statistics */
2866  SCIP_REOPT* reopt, /**< reoptimization data */
2867  SCIP_TREE* tree, /**< tree data */
2868  BMS_BLKMEM* blkmem, /**< block memory */
2869  SCIP_PROB* origprob, /**< original problem */
2870  SCIP_PROB* transprob, /**< transformed problem */
2871  SCIP_LP* lp, /**< LP data */
2872  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
2873  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
2874  SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
2875  SCIP_Real* coefs, /**< coefficients in sparse representation */
2876  int* inds, /**< non-zero indices */
2877  int nnz, /**< number of non-zero indices */
2878  SCIP_Real rhs, /**< right-hand side */
2879  SCIP_CONFTYPE conflicttype, /**< type of the conflict */
2880  int validdepth /**< depth where the proof is valid */
2881  )
2882 {
2883  SCIP_VAR** vars;
2884  SCIP_Real minact;
2885  int i;
2886 
2887  assert(coefs != NULL);
2888  assert(inds != NULL);
2889  assert(nnz >= 0);
2890 
2891  vars = SCIPprobGetVars(transprob);
2892  minact = getMinActivity(set, transprob, coefs, inds, nnz, NULL, NULL);
2893 
2894  /* we cannot find global tightenings */
2895  if( SCIPsetIsInfinity(set, -minact) )
2896  return SCIP_OKAY;
2897 
2898  for( i = 0; i < nnz; i++ )
2899  {
2900  SCIP_VAR* var;
2901  SCIP_Real val;
2902  SCIP_Real resminact;
2903  SCIP_Real lb;
2904  SCIP_Real ub;
2905  int pos;
2906 
2907  pos = inds[i];
2908  val = coefs[i];
2909  var = vars[pos];
2910  lb = SCIPvarGetLbGlobal(var);
2911  ub = SCIPvarGetUbGlobal(var);
2912 
2913  assert(!SCIPsetIsZero(set, val));
2914 
2915  resminact = minact;
2916 
2917  /* we got a potential new upper bound */
2918  if( val > 0.0 )
2919  {
2920  SCIP_Real newub;
2921 
2922  resminact -= (val * lb);
2923  newub = (rhs - resminact)/val;
2924 
2925  if( SCIPsetIsInfinity(set, newub) )
2926  continue;
2927 
2928  /* we cannot tighten the upper bound */
2929  if( SCIPsetIsGE(set, newub, ub) )
2930  continue;
2931 
2932  SCIP_CALL( tightenSingleVar(conflict, set, stat, tree, blkmem, origprob, transprob, reopt, lp, branchcand, \
2933  eventqueue, cliquetable, var, val, rhs-resminact, conflicttype, validdepth) );
2934  }
2935  /* we got a potential new lower bound */
2936  else
2937  {
2938  SCIP_Real newlb;
2939 
2940  resminact -= (val * ub);
2941  newlb = (rhs - resminact)/val;
2942 
2943  if( SCIPsetIsInfinity(set, -newlb) )
2944  continue;
2945 
2946  /* we cannot tighten the lower bound */
2947  if( SCIPsetIsLE(set, newlb, lb) )
2948  continue;
2949 
2950  SCIP_CALL( tightenSingleVar(conflict, set, stat, tree, blkmem, origprob, transprob, reopt, lp, branchcand, \
2951  eventqueue, cliquetable, var, val, rhs-resminact, conflicttype, validdepth) );
2952  }
2953 
2954  /* the minimal activity should stay unchanged because we tightened the bound that doesn't contribute to the
2955  * minimal activity
2956  */
2957  assert(SCIPsetIsEQ(set, minact, getMinActivity(set, transprob, coefs, inds, nnz, NULL, NULL)));
2958  }
2959 
2960  return SCIP_OKAY;
2961 }
2962 
2963 
2964 /** creates a proof constraint and tries to add it to the storage */
2965 static
2967  SCIP_CONFLICT* conflict, /**< conflict analysis data */
2968  SCIP_CONFLICTSTORE* conflictstore, /**< conflict pool data */
2969  SCIP_PROOFSET* proofset, /**< proof set */
2970  SCIP_SET* set, /**< global SCIP settings */
2971  SCIP_STAT* stat, /**< dynamic SCIP statistics */
2972  SCIP_PROB* origprob, /**< original problem */
2973  SCIP_PROB* transprob, /**< transformed problem */
2974  SCIP_TREE* tree, /**< tree data */
2975  SCIP_REOPT* reopt, /**< reoptimization data */
2976  SCIP_LP* lp, /**< LP data */
2977  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
2978  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
2979  SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
2980  BMS_BLKMEM* blkmem /**< block memory */
2981  )
2982 {
2983  SCIP_CONS* cons;
2984  SCIP_CONS* upgdcons;
2985  SCIP_VAR** vars;
2986  SCIP_Real* coefs;
2987  int* inds;
2988  SCIP_Real rhs;
2989  SCIP_Real fillin;
2990  SCIP_Real globalminactivity;
2991  SCIP_Bool applyglobal;
2992  SCIP_Bool toolong;
2993  SCIP_Bool contonly;
2994  SCIP_Bool hasrelaxvar;
2995  SCIP_CONFTYPE conflicttype;
2996  char name[SCIP_MAXSTRLEN];
2997  int nnz;
2998  int i;
2999 
3000  assert(conflict != NULL);
3001  assert(conflictstore != NULL);
3002  assert(proofset != NULL);
3003  assert(proofset->validdepth == 0 || proofset->validdepth < SCIPtreeGetFocusDepth(tree));
3004 
3005  nnz = proofsetGetNVars(proofset);
3006 
3007  if( nnz == 0 )
3008  return SCIP_OKAY;
3009 
3010  vars = SCIPprobGetVars(transprob);
3011 
3012  rhs = proofsetGetRhs(proofset);
3013  assert(!SCIPsetIsInfinity(set, rhs));
3014 
3015  coefs = proofsetGetVals(proofset);
3016  assert(coefs != NULL);
3017 
3018  inds = proofsetGetInds(proofset);
3019  assert(inds != NULL);
3020 
3021  conflicttype = proofsetGetConftype(proofset);
3022 
3023  applyglobal = (proofset->validdepth <= SCIPtreeGetEffectiveRootDepth(tree));
3024 
3025  if( applyglobal )
3026  {
3027  SCIP_Real globalmaxactivity = getMaxActivity(set, transprob, coefs, inds, nnz, NULL, NULL);
3028 
3029  /* check whether the alternative proof is redundant */
3030  if( SCIPsetIsLE(set, globalmaxactivity, rhs) )
3031  return SCIP_OKAY;
3032 
3033  /* check whether the constraint proves global infeasibility */
3034  globalminactivity = getMinActivity(set, transprob, coefs, inds, nnz, NULL, NULL);
3035  if( SCIPsetIsGT(set, globalminactivity, rhs) )
3036  {
3037  SCIPsetDebugMsg(set, "detect global infeasibility: minactivity=%g, rhs=%g\n", globalminactivity, rhs);
3038 
3039  SCIP_CALL( SCIPnodeCutoff(tree->path[proofset->validdepth], set, stat, tree, transprob, origprob, reopt, lp, blkmem) );
3040 
3041  goto UPDATESTATISTICS;
3042  }
3043  }
3044 
3045  if( set->conf_minmaxvars >= nnz )
3046  toolong = FALSE;
3047  else
3048  {
3049  SCIP_Real maxnnz;
3050 
3051  if( transprob->startnconss < 100 )
3052  maxnnz = 0.85 * transprob->nvars;
3053  else
3054  maxnnz = (SCIP_Real)transprob->nvars;
3055 
3056  fillin = nnz;
3057  if( conflicttype == SCIP_CONFTYPE_INFEASLP || conflicttype == SCIP_CONFTYPE_ALTINFPROOF )
3058  {
3059  fillin += SCIPconflictstoreGetNDualInfProofs(conflictstore) * SCIPconflictstoreGetAvgNnzDualInfProofs(conflictstore);
3060  fillin /= (SCIPconflictstoreGetNDualInfProofs(conflictstore) + 1.0);
3061  toolong = (fillin > MIN(2.0 * stat->avgnnz, maxnnz));
3062  }
3063  else
3064  {
3065  assert(conflicttype == SCIP_CONFTYPE_BNDEXCEEDING || conflicttype == SCIP_CONFTYPE_ALTBNDPROOF);
3066 
3067  fillin += SCIPconflictstoreGetNDualBndProofs(conflictstore) * SCIPconflictstoreGetAvgNnzDualBndProofs(conflictstore);
3068  fillin /= (SCIPconflictstoreGetNDualBndProofs(conflictstore) + 1.0);
3069  toolong = (fillin > MIN(1.5 * stat->avgnnz, maxnnz));
3070  }
3071 
3072  toolong = (toolong && (nnz > set->conf_maxvarsfac * transprob->nvars));
3073  }
3074 
3075  /* don't store global dual proofs that are too long / have too many non-zeros */
3076  if( toolong )
3077  {
3078  if( applyglobal )
3079  {
3080  SCIP_CALL( propagateLongProof(conflict, set, stat, reopt, tree, blkmem, origprob, transprob, lp, branchcand,
3081  eventqueue, cliquetable, coefs, inds, nnz, rhs, conflicttype, proofset->validdepth) );
3082  }
3083  return SCIP_OKAY;
3084  }
3085 
3086  /* check if conflict contains variables that are invalid after a restart to label it appropriately */
3087  hasrelaxvar = FALSE;
3088  contonly = TRUE;
3089  for( i = 0; i < nnz && (!hasrelaxvar || contonly); ++i )
3090  {
3091  hasrelaxvar |= SCIPvarIsRelaxationOnly(vars[inds[i]]);
3092 
3093  if( SCIPvarIsIntegral(vars[inds[i]]) )
3094  contonly = FALSE;
3095  }
3096 
3097  if( !applyglobal && contonly )
3098  return SCIP_OKAY;
3099 
3100  if( conflicttype == SCIP_CONFTYPE_INFEASLP || conflicttype == SCIP_CONFTYPE_ALTINFPROOF )
3101  (void)SCIPsnprintf(name, SCIP_MAXSTRLEN, "dualproof_inf_%" SCIP_LONGINT_FORMAT, conflict->ndualproofsinfsuccess);
3102  else if( conflicttype == SCIP_CONFTYPE_BNDEXCEEDING || conflicttype == SCIP_CONFTYPE_ALTBNDPROOF )
3103  (void)SCIPsnprintf(name, SCIP_MAXSTRLEN, "dualproof_bnd_%" SCIP_LONGINT_FORMAT, conflict->ndualproofsbndsuccess);
3104  else
3105  return SCIP_INVALIDCALL;
3106 
3107  SCIP_CALL( SCIPcreateConsLinear(set->scip, &cons, name, 0, NULL, NULL, -SCIPsetInfinity(set), rhs,
3108  FALSE, FALSE, FALSE, FALSE, TRUE, !applyglobal,
3109  FALSE, TRUE, TRUE, FALSE) );
3110 
3111  for( i = 0; i < nnz; i++ )
3112  {
3113  int v = inds[i];
3114  SCIP_CALL( SCIPaddCoefLinear(set->scip, cons, vars[v], coefs[i]) );
3115  }
3116 
3117  /* do not upgrade linear constraints of size 1 */
3118  if( nnz > 1 )
3119  {
3120  upgdcons = NULL;
3121  /* try to automatically convert a linear constraint into a more specific and more specialized constraint */
3122  SCIP_CALL( SCIPupgradeConsLinear(set->scip, cons, &upgdcons) );
3123  if( upgdcons != NULL )
3124  {
3125  SCIP_CALL( SCIPreleaseCons(set->scip, &cons) );
3126  cons = upgdcons;
3127 
3128  if( conflicttype == SCIP_CONFTYPE_INFEASLP )
3129  conflicttype = SCIP_CONFTYPE_ALTINFPROOF;
3130  else if( conflicttype == SCIP_CONFTYPE_BNDEXCEEDING )
3131  conflicttype = SCIP_CONFTYPE_ALTBNDPROOF;
3132  }
3133  }
3134 
3135  /* mark constraint to be a conflict */
3136  SCIPconsMarkConflict(cons);
3137 
3138  /* add constraint to storage */
3139  if( conflicttype == SCIP_CONFTYPE_INFEASLP || conflicttype == SCIP_CONFTYPE_ALTINFPROOF )
3140  {
3141  /* add dual proof to storage */
3142  SCIP_CALL( SCIPconflictstoreAddDualraycons(conflictstore, cons, blkmem, set, stat, transprob, reopt, hasrelaxvar) );
3143  }
3144  else
3145  {
3146  SCIP_Real scale = 1.0;
3147  SCIP_Bool updateside = FALSE;
3148 
3149  /* In some cases the constraint could not be updated to a more special type. However, it is possible that
3150  * constraint got scaled. Therefore, we need to be very careful when updating the lhs/rhs after the incumbent
3151  * solution has improved.
3152  */
3153  if( conflicttype == SCIP_CONFTYPE_BNDEXCEEDING )
3154  {
3155  SCIP_Real side;
3156 
3157 #ifndef NDEBUG
3158  SCIP_CONSHDLR* conshdlr = SCIPconsGetHdlr(cons);
3159 
3160  assert(conshdlr != NULL);
3161  assert(strcmp(SCIPconshdlrGetName(conshdlr), "linear") == 0);
3162 #endif
3163  side = SCIPgetLhsLinear(set->scip, cons);
3164 
3165  if( !SCIPsetIsInfinity(set, -side) )
3166  {
3167  if( SCIPsetIsZero(set, side) )
3168  {
3169  scale = 1.0;
3170  }
3171  else
3172  {
3173  scale = proofsetGetRhs(proofset) / side;
3174  assert(SCIPsetIsNegative(set, scale));
3175  }
3176  }
3177  else
3178  {
3179  side = SCIPgetRhsLinear(set->scip, cons);
3180  assert(!SCIPsetIsInfinity(set, side));
3181 
3182  if( SCIPsetIsZero(set, side) )
3183  {
3184  scale = 1.0;
3185  }
3186  else
3187  {
3188  scale = proofsetGetRhs(proofset) / side;
3189  assert(SCIPsetIsPositive(set, scale));
3190  }
3191  }
3192  updateside = TRUE;
3193  }
3194 
3195  /* add dual proof to storage */
3196  SCIP_CALL( SCIPconflictstoreAddDualsolcons(conflictstore, cons, blkmem, set, stat, transprob, reopt, scale, updateside, hasrelaxvar) );
3197  }
3198 
3199  if( applyglobal ) /*lint !e774*/
3200  {
3201  /* add the constraint to the global problem */
3202  SCIP_CALL( SCIPprobAddCons(transprob, set, stat, cons) );
3203  }
3204  else
3205  {
3206  SCIP_CALL( SCIPnodeAddCons(tree->path[proofset->validdepth], blkmem, set, stat, tree, cons) );
3207  }
3208 
3209  SCIPsetDebugMsg(set, "added proof-constraint to node %p (#%lld) in depth %d (nproofconss %d)\n",
3210  (void*)tree->path[proofset->validdepth], SCIPnodeGetNumber(tree->path[proofset->validdepth]),
3211  proofset->validdepth,
3212  (conflicttype == SCIP_CONFTYPE_INFEASLP || conflicttype == SCIP_CONFTYPE_ALTINFPROOF)
3214 
3215  /* release the constraint */
3216  SCIP_CALL( SCIPreleaseCons(set->scip, &cons) );
3217 
3218  UPDATESTATISTICS:
3219  /* update statistics */
3220  if( conflicttype == SCIP_CONFTYPE_INFEASLP || conflicttype == SCIP_CONFTYPE_ALTINFPROOF )
3221  {
3222  conflict->dualproofsinfnnonzeros += nnz;
3223  if( applyglobal ) /*lint !e774*/
3224  ++conflict->ndualproofsinfglobal;
3225  else
3226  ++conflict->ndualproofsinflocal;
3227  ++conflict->ndualproofsinfsuccess;
3228  }
3229  else
3230  {
3231  assert(conflicttype == SCIP_CONFTYPE_BNDEXCEEDING || conflicttype == SCIP_CONFTYPE_ALTBNDPROOF);
3232  conflict->dualproofsbndnnonzeros += nnz;
3233  if( applyglobal ) /*lint !e774*/
3234  ++conflict->ndualproofsbndglobal;
3235  else
3236  ++conflict->ndualproofsbndlocal;
3237 
3238  ++conflict->ndualproofsbndsuccess;
3239  }
3240  return SCIP_OKAY;
3241 }
3242 
3243 /* create proof constraints out of proof sets */
3244 static
3246  SCIP_CONFLICT* conflict, /**< conflict analysis data */
3247  SCIP_CONFLICTSTORE* conflictstore, /**< conflict store */
3248  BMS_BLKMEM* blkmem, /**< block memory */
3249  SCIP_SET* set, /**< global SCIP settings */
3250  SCIP_STAT* stat, /**< dynamic problem statistics */
3251  SCIP_PROB* transprob, /**< transformed problem after presolve */
3252  SCIP_PROB* origprob, /**< original problem */
3253  SCIP_TREE* tree, /**< branch and bound tree */
3254  SCIP_REOPT* reopt, /**< reoptimization data structure */
3255  SCIP_LP* lp, /**< current LP data */
3256  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
3257  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
3258  SCIP_CLIQUETABLE* cliquetable /**< clique table data structure */
3259  )
3260 {
3261  assert(conflict != NULL);
3262 
3264  {
3265  /* only one variable has a coefficient different to zero, we add this bound change instead of a constraint */
3266  if( proofsetGetNVars(conflict->proofset) == 1 )
3267  {
3268  SCIP_VAR** vars;
3269  SCIP_Real* coefs;
3270  int* inds;
3271  SCIP_Real rhs;
3272 
3273  vars = SCIPprobGetVars(transprob);
3274 
3275  coefs = proofsetGetVals(conflict->proofset);
3276  inds = proofsetGetInds(conflict->proofset);
3277  rhs = proofsetGetRhs(conflict->proofset);
3278 
3279  SCIP_CALL( tightenSingleVar(conflict, set, stat, tree, blkmem, origprob, transprob, reopt, lp, \
3280  branchcand, eventqueue, cliquetable, vars[inds[0]], coefs[0], rhs, conflict->proofset->conflicttype,
3281  conflict->proofset->validdepth) );
3282  }
3283  else
3284  {
3285  SCIP_Bool skipinitialproof = FALSE;
3286 
3287  /* prefer an infeasibility proof
3288  *
3289  * todo: check whether this is really what we want
3290  */
3291  if( set->conf_prefinfproof && proofsetGetConftype(conflict->proofset) == SCIP_CONFTYPE_BNDEXCEEDING )
3292  {
3293  int i;
3294 
3295  for( i = 0; i < conflict->nproofsets; i++ )
3296  {
3298  {
3299  skipinitialproof = TRUE;
3300  break;
3301  }
3302  }
3303  }
3304 
3305  if( !skipinitialproof )
3306  {
3307  /* create and add the original proof */
3308  SCIP_CALL( createAndAddProofcons(conflict, conflictstore, conflict->proofset, set, stat, origprob, transprob, \
3309  tree, reopt, lp, branchcand, eventqueue, cliquetable, blkmem) );
3310  }
3311  }
3312 
3313  /* clear the proof set anyway */
3314  proofsetClear(conflict->proofset);
3315  }
3316 
3317  if( conflict->nproofsets > 0 )
3318  {
3319  int i;
3320 
3321  for( i = 0; i < conflict->nproofsets; i++ )
3322  {
3323  assert(conflict->proofsets[i] != NULL);
3324  assert(proofsetGetConftype(conflict->proofsets[i]) != SCIP_CONFTYPE_UNKNOWN);
3325 
3326  /* only one variable has a coefficient different to zero, we add this bound change instead of a constraint */
3327  if( proofsetGetNVars(conflict->proofsets[i]) == 1 )
3328  {
3329  SCIP_VAR** vars;
3330  SCIP_Real* coefs;
3331  int* inds;
3332  SCIP_Real rhs;
3333 
3334  vars = SCIPprobGetVars(transprob);
3335 
3336  coefs = proofsetGetVals(conflict->proofsets[i]);
3337  inds = proofsetGetInds(conflict->proofsets[i]);
3338  rhs = proofsetGetRhs(conflict->proofsets[i]);
3339 
3340  SCIP_CALL( tightenSingleVar(conflict, set, stat, tree, blkmem, origprob, transprob, reopt, lp,
3341  branchcand, eventqueue, cliquetable, vars[inds[0]], coefs[0], rhs,
3342  conflict->proofsets[i]->conflicttype, conflict->proofsets[i]->validdepth) );
3343  }
3344  else
3345  {
3346  /* create and add proof constraint */
3347  SCIP_CALL( createAndAddProofcons(conflict, conflictstore, conflict->proofsets[i], set, stat, origprob, \
3348  transprob, tree, reopt, lp, branchcand, eventqueue, cliquetable, blkmem) );
3349  }
3350  }
3351 
3352  /* free all proofsets */
3353  for( i = 0; i < conflict->nproofsets; i++ )
3354  proofsetFree(&conflict->proofsets[i], blkmem);
3355 
3356  conflict->nproofsets = 0;
3357  }
3358 
3359  return SCIP_OKAY;
3360 }
3361 
3362 /** adds the given conflict set as conflict constraint to the problem */
3363 static
3365  SCIP_CONFLICT* conflict, /**< conflict analysis data */
3366  BMS_BLKMEM* blkmem, /**< block memory */
3367  SCIP_SET* set, /**< global SCIP settings */
3368  SCIP_STAT* stat, /**< dynamic problem statistics */
3369  SCIP_PROB* transprob, /**< transformed problem after presolve */
3370  SCIP_PROB* origprob, /**< original problem */
3371  SCIP_TREE* tree, /**< branch and bound tree */
3372  SCIP_REOPT* reopt, /**< reoptimization data structure */
3373  SCIP_LP* lp, /**< current LP data */
3374  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
3375  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
3376  SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
3377  SCIP_CONFLICTSET* conflictset, /**< conflict set to add to the tree */
3378  int insertdepth, /**< depth level at which the conflict set should be added */
3379  SCIP_Bool* success /**< pointer to store whether the addition was successful */
3380  )
3381 {
3382  SCIP_Bool redundant;
3383  int h;
3384 
3385  assert(conflict != NULL);
3386  assert(tree != NULL);
3387  assert(tree->path != NULL);
3388  assert(conflictset != NULL);
3389  assert(conflictset->validdepth <= insertdepth);
3390  assert(success != NULL);
3391 
3392  *success = FALSE;
3393  redundant = FALSE;
3394 
3395  /* try to derive global bound changes and shorten the conflictset by using implication and clique and variable bound
3396  * information
3397  */
3398  if( conflictset->nbdchginfos > 1 && insertdepth == 0 && !lp->strongbranching )
3399  {
3400  int nbdchgs;
3401  int nredvars;
3402 #ifdef SCIP_DEBUG
3403  int oldnbdchginfos = conflictset->nbdchginfos;
3404 #endif
3405  assert(conflictset->validdepth == 0);
3406 
3407  /* check conflict set on debugging solution */
3408  SCIP_CALL( SCIPdebugCheckConflict(blkmem, set, tree->root, conflictset->bdchginfos, conflictset->relaxedbds, conflictset->nbdchginfos) );
3409 
3410  SCIPclockStart(conflict->dIBclock, set);
3411 
3412  /* find global bound changes which can be derived from the new conflict set */
3413  SCIP_CALL( detectImpliedBounds(set, transprob, conflictset, &nbdchgs, &nredvars, &redundant) );
3414 
3415  /* all variables where removed, we have an infeasibility proof */
3416  if( conflictset->nbdchginfos == 0 )
3417  return SCIP_OKAY;
3418 
3419  /* debug check for reduced conflict set */
3420  if( nredvars > 0 )
3421  {
3422  /* check conflict set on debugging solution */
3423  SCIP_CALL( SCIPdebugCheckConflict(blkmem, set, tree->root, conflictset->bdchginfos, conflictset->relaxedbds, conflictset->nbdchginfos) ); /*lint !e506 !e774*/
3424  }
3425 
3426 #ifdef SCIP_DEBUG
3427  SCIPsetDebugMsg(set, " -> conflict set removed %d redundant variables (old nvars %d, new nvars = %d)\n", nredvars, oldnbdchginfos, conflictset->nbdchginfos);
3428  SCIPsetDebugMsg(set, " -> conflict set led to %d global bound changes %s(cdpt:%d, fdpt:%d, confdpt:%d, len:%d):\n",
3429  nbdchgs, redundant ? "(conflict became redundant) " : "", SCIPtreeGetCurrentDepth(tree), SCIPtreeGetFocusDepth(tree),
3430  conflictset->conflictdepth, conflictset->nbdchginfos);
3431  conflictsetPrint(conflictset);
3432 #endif
3433 
3434  SCIPclockStop(conflict->dIBclock, set);
3435 
3436  if( redundant )
3437  {
3438  if( nbdchgs > 0 )
3439  *success = TRUE;
3440 
3441  return SCIP_OKAY;
3442  }
3443  }
3444 
3445  /* in case the conflict set contains only one bound change which is globally valid we apply that bound change
3446  * directly (except if we are in strong branching or diving - in this case a bound change would yield an unflushed LP
3447  * and is not handled when restoring the information)
3448  *
3449  * @note A bound change can only be applied if it is are related to the active node or if is a global bound
3450  * change. Bound changes which are related to any other node cannot be handled at point due to the internal
3451  * data structure
3452  */
3453  if( conflictset->nbdchginfos == 1 && insertdepth == 0 && !lp->strongbranching && !lp->diving )
3454  {
3455  SCIP_VAR* var;
3456  SCIP_Real bound;
3457  SCIP_BOUNDTYPE boundtype;
3458 
3459  var = conflictset->bdchginfos[0]->var;
3460  assert(var != NULL);
3461 
3462  boundtype = SCIPboundtypeOpposite((SCIP_BOUNDTYPE) conflictset->bdchginfos[0]->boundtype);
3463  bound = conflictset->relaxedbds[0];
3464 
3465  /* for continuous variables, we can only use the relaxed version of the bounds negation: !(x <= u) -> x >= u */
3466  if( SCIPvarIsIntegral(var) )
3467  {
3468  assert(SCIPsetIsIntegral(set, bound));
3469  bound += (boundtype == SCIP_BOUNDTYPE_LOWER ? +1.0 : -1.0);
3470  }
3471 
3472  SCIPsetDebugMsg(set, " -> apply global bound change: <%s> %s %g\n",
3473  SCIPvarGetName(var), boundtype == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=", bound);
3474 
3475  SCIP_CALL( SCIPnodeAddBoundchg(tree->path[conflictset->validdepth], blkmem, set, stat, transprob, origprob, tree,
3476  reopt, lp, branchcand, eventqueue, cliquetable, var, bound, boundtype, FALSE) );
3477 
3478  *success = TRUE;
3479  SCIP_CALL( updateStatistics(conflict, blkmem, set, stat, conflictset, insertdepth) );
3480  }
3481  else
3482  {
3483  /* sort conflict handlers by priority */
3485 
3486  /* call conflict handlers to create a conflict constraint */
3487  for( h = 0; h < set->nconflicthdlrs; ++h )
3488  {
3489  SCIP_RESULT result;
3490 
3491  assert(conflictset->conflicttype != SCIP_CONFTYPE_UNKNOWN);
3492 
3493  SCIP_CALL( SCIPconflicthdlrExec(set->conflicthdlrs[h], set, tree->path[insertdepth],
3494  tree->path[conflictset->validdepth], conflictset->bdchginfos, conflictset->relaxedbds,
3495  conflictset->nbdchginfos, conflictset->conflicttype, conflictset->usescutoffbound, *success, &result) );
3496  if( result == SCIP_CONSADDED )
3497  {
3498  *success = TRUE;
3499  SCIP_CALL( updateStatistics(conflict, blkmem, set, stat, conflictset, insertdepth) );
3500  }
3501 
3502  SCIPsetDebugMsg(set, " -> call conflict handler <%s> (prio=%d) to create conflict set with %d bounds returned result %d\n",
3503  SCIPconflicthdlrGetName(set->conflicthdlrs[h]), SCIPconflicthdlrGetPriority(set->conflicthdlrs[h]),
3504  conflictset->nbdchginfos, result);
3505  }
3506  }
3507 
3508  return SCIP_OKAY;
3509 }
3510 
3511 /** adds the collected conflict constraints to the corresponding nodes; the best set->conf_maxconss conflict constraints
3512  * are added to the node of their validdepth; additionally (if not yet added, and if repropagation is activated), the
3513  * conflict constraint that triggers the earliest repropagation is added to the node of its validdepth
3514  */
3516  SCIP_CONFLICT* conflict, /**< conflict analysis data */
3517  BMS_BLKMEM* blkmem, /**< block memory of transformed problem */
3518  SCIP_SET* set, /**< global SCIP settings */
3519  SCIP_STAT* stat, /**< dynamic problem statistics */
3520  SCIP_PROB* transprob, /**< transformed problem */
3521  SCIP_PROB* origprob, /**< original problem */
3522  SCIP_TREE* tree, /**< branch and bound tree */
3523  SCIP_REOPT* reopt, /**< reoptimization data structure */
3524  SCIP_LP* lp, /**< current LP data */
3525  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
3526  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
3527  SCIP_CLIQUETABLE* cliquetable /**< clique table data structure */
3528  )
3529 {
3530  assert(conflict != NULL);
3531  assert(set != NULL);
3532  assert(stat != NULL);
3533  assert(transprob != NULL);
3534  assert(tree != NULL);
3535 
3536  /* is there anything to do? */
3537  if( conflict->nconflictsets > 0 )
3538  {
3539  SCIP_CONFLICTSET* repropconflictset;
3540  int nconflictsetsused;
3541  int focusdepth;
3542 #ifndef NDEBUG
3543  int currentdepth;
3544 #endif
3545  int cutoffdepth;
3546  int repropdepth;
3547  int maxconflictsets;
3548  int maxsize;
3549  int i;
3550 
3551  /* calculate the maximal number of conflict sets to accept, and the maximal size of each accepted conflict set */
3552  maxconflictsets = (set->conf_maxconss == -1 ? INT_MAX : set->conf_maxconss);
3553  maxsize = conflictCalcMaxsize(set, transprob);
3554 
3555  focusdepth = SCIPtreeGetFocusDepth(tree);
3556 #ifndef NDEBUG
3557  currentdepth = SCIPtreeGetCurrentDepth(tree);
3558  assert(focusdepth <= currentdepth);
3559  assert(currentdepth == tree->pathlen-1);
3560 #endif
3561 
3562  SCIPsetDebugMsg(set, "flushing %d conflict sets at focus depth %d (maxconflictsets: %d, maxsize: %d)\n",
3563  conflict->nconflictsets, focusdepth, maxconflictsets, maxsize);
3564 
3565  /* mark the focus node to have produced conflict sets in the visualization output */
3566  SCIPvisualFoundConflict(stat->visual, stat, tree->path[focusdepth]);
3567 
3568  /* insert the conflict sets at the corresponding nodes */
3569  nconflictsetsused = 0;
3570  cutoffdepth = INT_MAX;
3571  repropdepth = INT_MAX;
3572  repropconflictset = NULL;
3573  for( i = 0; i < conflict->nconflictsets && nconflictsetsused < maxconflictsets; ++i )
3574  {
3575  SCIP_CONFLICTSET* conflictset;
3576 
3577  conflictset = conflict->conflictsets[i];
3578  assert(conflictset != NULL);
3579  assert(0 <= conflictset->validdepth);
3580  assert(conflictset->validdepth <= conflictset->insertdepth);
3581  assert(conflictset->insertdepth <= focusdepth);
3582  assert(conflictset->insertdepth <= conflictset->repropdepth);
3583  assert(conflictset->repropdepth <= currentdepth || conflictset->repropdepth == INT_MAX); /* INT_MAX for dive/probing/strong */
3584  assert(conflictset->conflictdepth <= currentdepth || conflictset->conflictdepth == INT_MAX); /* INT_MAX for dive/probing/strong */
3585 
3586  /* ignore conflict sets that are only valid at a node that was already cut off */
3587  if( conflictset->insertdepth >= cutoffdepth )
3588  {
3589  SCIPsetDebugMsg(set, " -> ignoring conflict set with insertdepth %d >= cutoffdepth %d\n",
3590  conflictset->validdepth, cutoffdepth);
3591  continue;
3592  }
3593 
3594  /* if no conflict bounds exist, the node and its sub tree in the conflict set's valid depth can be
3595  * cut off completely
3596  */
3597  if( conflictset->nbdchginfos == 0 )
3598  {
3599  SCIPsetDebugMsg(set, " -> empty conflict set in depth %d cuts off sub tree at depth %d\n",
3600  focusdepth, conflictset->validdepth);
3601 
3602  SCIP_CALL( SCIPnodeCutoff(tree->path[conflictset->validdepth], set, stat, tree, transprob, origprob, reopt, lp, blkmem) );
3603  cutoffdepth = conflictset->validdepth;
3604  continue;
3605  }
3606 
3607  /* if the conflict set is too long, use the conflict set only if it decreases the repropagation depth */
3608  if( conflictset->nbdchginfos > maxsize )
3609  {
3610  SCIPsetDebugMsg(set, " -> conflict set is too long: %d > %d literals\n", conflictset->nbdchginfos, maxsize);
3611  if( set->conf_keepreprop && conflictset->repropagate && conflictset->repropdepth < repropdepth )
3612  {
3613  repropdepth = conflictset->repropdepth;
3614  repropconflictset = conflictset;
3615  }
3616  }
3617  else
3618  {
3619  SCIP_Bool success;
3620 
3621  /* call conflict handlers to create a conflict constraint */
3622  SCIP_CALL( conflictAddConflictCons(conflict, blkmem, set, stat, transprob, origprob, tree, reopt, lp, \
3623  branchcand, eventqueue, cliquetable, conflictset, conflictset->insertdepth, &success) );
3624 
3625  /* if no conflict bounds exist, the node and its sub tree in the conflict set's valid depth can be
3626  * cut off completely
3627  */
3628  if( conflictset->nbdchginfos == 0 )
3629  {
3630  assert(!success);
3631 
3632  SCIPsetDebugMsg(set, " -> empty conflict set in depth %d cuts off sub tree at depth %d\n",
3633  focusdepth, conflictset->validdepth);
3634 
3635  SCIP_CALL( SCIPnodeCutoff(tree->path[conflictset->validdepth], set, stat, tree, transprob, origprob, \
3636  reopt, lp, blkmem) );
3637  cutoffdepth = conflictset->validdepth;
3638  continue;
3639  }
3640 
3641  if( success )
3642  {
3643  SCIPsetDebugMsg(set, " -> conflict set %d/%d added (cdpt:%d, fdpt:%d, insert:%d, valid:%d, conf:%d, reprop:%d, len:%d):\n",
3644  nconflictsetsused+1, maxconflictsets, SCIPtreeGetCurrentDepth(tree), SCIPtreeGetFocusDepth(tree),
3645  conflictset->insertdepth, conflictset->validdepth, conflictset->conflictdepth, conflictset->repropdepth,
3646  conflictset->nbdchginfos);
3647  SCIPdebug(conflictsetPrint(conflictset));
3648 
3649  if( conflictset->repropagate && conflictset->repropdepth <= repropdepth )
3650  {
3651  repropdepth = conflictset->repropdepth;
3652  repropconflictset = NULL;
3653  }
3654  nconflictsetsused++;
3655  }
3656  }
3657  }
3658 
3659  /* reactivate propagation on the first node where one of the new conflict sets trigger a deduction */
3660  if( set->conf_repropagate && repropdepth < cutoffdepth && repropdepth < tree->pathlen )
3661  {
3662  assert(0 <= repropdepth && repropdepth < tree->pathlen);
3663  assert((int) tree->path[repropdepth]->depth == repropdepth);
3664 
3665  /* if the conflict constraint of smallest repropagation depth was not yet added, insert it now */
3666  if( repropconflictset != NULL )
3667  {
3668  SCIP_Bool success;
3669 
3670  assert(repropconflictset->repropagate);
3671  assert(repropconflictset->repropdepth == repropdepth);
3672 
3673  SCIP_CALL( conflictAddConflictCons(conflict, blkmem, set, stat, transprob, origprob, tree, reopt, lp, \
3674  branchcand, eventqueue, cliquetable, repropconflictset, repropdepth, &success) );
3675 
3676  /* if no conflict bounds exist, the node and its sub tree in the conflict set's valid depth can be
3677  * cut off completely
3678  */
3679  if( repropconflictset->nbdchginfos == 0 )
3680  {
3681  assert(!success);
3682 
3683  SCIPsetDebugMsg(set, " -> empty reprop conflict set in depth %d cuts off sub tree at depth %d\n",
3684  focusdepth, repropconflictset->validdepth);
3685 
3686  SCIP_CALL( SCIPnodeCutoff(tree->path[repropconflictset->validdepth], set, stat, tree, transprob, \
3687  origprob, reopt, lp, blkmem) );
3688  }
3689 
3690 #ifdef SCIP_DEBUG
3691  if( success )
3692  {
3693  SCIPsetDebugMsg(set, " -> additional reprop conflict set added (cdpt:%d, fdpt:%d, insert:%d, valid:%d, conf:%d, reprop:%d, len:%d):\n",
3695  repropconflictset->insertdepth, repropconflictset->validdepth, repropconflictset->conflictdepth,
3696  repropconflictset->repropdepth, repropconflictset->nbdchginfos);
3697  SCIPdebug(conflictsetPrint(repropconflictset));
3698  }
3699 #endif
3700  }
3701 
3702  /* mark the node in the repropdepth to be propagated again */
3703  SCIPnodePropagateAgain(tree->path[repropdepth], set, stat, tree);
3704 
3705  SCIPsetDebugMsg(set, "marked node %p in depth %d to be repropagated due to conflicts found in depth %d\n",
3706  (void*)tree->path[repropdepth], repropdepth, focusdepth);
3707  }
3708 
3709  /* free the conflict store */
3710  for( i = 0; i < conflict->nconflictsets; ++i )
3711  {
3712  conflictsetFree(&conflict->conflictsets[i], blkmem);
3713  }
3714  conflict->nconflictsets = 0;
3715  }
3716 
3717  /* free all temporarily created bound change information data */
3718  conflictFreeTmpBdchginfos(conflict, blkmem);
3719 
3720  return SCIP_OKAY;
3721 }
3722 
3723 /** returns the current number of conflict sets in the conflict set storage */
3725  SCIP_CONFLICT* conflict /**< conflict analysis data */
3726  )
3727 {
3728  assert(conflict != NULL);
3729 
3730  return conflict->nconflictsets;
3731 }
3732 
3733 /** returns the total number of conflict constraints that were added to the problem */
3735  SCIP_CONFLICT* conflict /**< conflict analysis data */
3736  )
3737 {
3738  assert(conflict != NULL);
3739 
3740  return conflict->nappliedglbconss + conflict->nappliedlocconss;
3741 }
3742 
3743 /** returns the total number of literals in conflict constraints that were added to the problem */
3745  SCIP_CONFLICT* conflict /**< conflict analysis data */
3746  )
3747 {
3748  assert(conflict != NULL);
3749 
3750  return conflict->nappliedglbliterals + conflict->nappliedlocliterals;
3751 }
3752 
3753 /** returns the total number of global bound changes applied by the conflict analysis */
3755  SCIP_CONFLICT* conflict /**< conflict analysis data */
3756  )
3757 {
3758  assert(conflict != NULL);
3759 
3760  return conflict->nglbchgbds;
3761 }
3762 
3763 /** returns the total number of conflict constraints that were added globally to the problem */
3765  SCIP_CONFLICT* conflict /**< conflict analysis data */
3766  )
3767 {
3768  assert(conflict != NULL);
3769 
3770  return conflict->nappliedglbconss;
3771 }
3772 
3773 /** returns the total number of literals in conflict constraints that were added globally to the problem */
3775  SCIP_CONFLICT* conflict /**< conflict analysis data */
3776  )
3777 {
3778  assert(conflict != NULL);
3779 
3780  return conflict->nappliedglbliterals;
3781 }
3782 
3783 /** returns the total number of local bound changes applied by the conflict analysis */
3785  SCIP_CONFLICT* conflict /**< conflict analysis data */
3786  )
3787 {
3788  assert(conflict != NULL);
3789 
3790  return conflict->nlocchgbds;
3791 }
3792 
3793 /** returns the total number of conflict constraints that were added locally to the problem */
3795  SCIP_CONFLICT* conflict /**< conflict analysis data */
3796  )
3797 {
3798  assert(conflict != NULL);
3799 
3800  return conflict->nappliedlocconss;
3801 }
3802 
3803 /** returns the total number of literals in conflict constraints that were added locally to the problem */
3805  SCIP_CONFLICT* conflict /**< conflict analysis data */
3806  )
3807 {
3808  assert(conflict != NULL);
3809 
3810  return conflict->nappliedlocliterals;
3811 }
3812 
3813 
3814 
3815 
3816 /*
3817  * Propagation Conflict Analysis
3818  */
3819 
3820 /** returns whether bound change has a valid reason that can be resolved in conflict analysis */
3821 static
3823  SCIP_BDCHGINFO* bdchginfo /**< bound change information */
3824  )
3825 {
3826  assert(bdchginfo != NULL);
3827  assert(!SCIPbdchginfoIsRedundant(bdchginfo));
3828 
3831  && SCIPbdchginfoGetInferProp(bdchginfo) != NULL));
3832 }
3833 
3834 /** compares two conflict set entries, such that bound changes infered later are
3835  * ordered prior to ones that were infered earlier
3836  */
3837 static
3838 SCIP_DECL_SORTPTRCOMP(conflictBdchginfoComp)
3839 { /*lint --e{715}*/
3840  SCIP_BDCHGINFO* bdchginfo1;
3841  SCIP_BDCHGINFO* bdchginfo2;
3842 
3843  bdchginfo1 = (SCIP_BDCHGINFO*)elem1;
3844  bdchginfo2 = (SCIP_BDCHGINFO*)elem2;
3845  assert(bdchginfo1 != NULL);
3846  assert(bdchginfo2 != NULL);
3847  assert(!SCIPbdchginfoIsRedundant(bdchginfo1));
3848  assert(!SCIPbdchginfoIsRedundant(bdchginfo2));
3849 
3850  if( bdchginfo1 == bdchginfo2 )
3851  return 0;
3852 
3854  return -1;
3855  else
3856  return +1;
3857 }
3858 
3859 /** return TRUE if conflict analysis is applicable; In case the function return FALSE there is no need to initialize the
3860  * conflict analysis since it will not be applied
3861  */
3863  SCIP_SET* set /**< global SCIP settings */
3864  )
3865 {
3866  /* check, if propagation conflict analysis is enabled */
3867  if( !set->conf_enable || !set->conf_useprop )
3868  return FALSE;
3869 
3870  /* check, if there are any conflict handlers to use a conflict set */
3871  if( set->nconflicthdlrs == 0 )
3872  return FALSE;
3873 
3874  return TRUE;
3875 }
3876 
3877 /** creates conflict analysis data for propagation conflicts */
3879  SCIP_CONFLICT** conflict, /**< pointer to conflict analysis data */
3880  BMS_BLKMEM* blkmem, /**< block memory of transformed problem */
3881  SCIP_SET* set /**< global SCIP settings */
3882  )
3883 {
3884  assert(conflict != NULL);
3885 
3886  SCIP_ALLOC( BMSallocMemory(conflict) );
3887 
3888  SCIP_CALL( SCIPclockCreate(&(*conflict)->dIBclock, SCIP_CLOCKTYPE_DEFAULT) );
3889  SCIP_CALL( SCIPclockCreate(&(*conflict)->propanalyzetime, SCIP_CLOCKTYPE_DEFAULT) );
3890  SCIP_CALL( SCIPclockCreate(&(*conflict)->inflpanalyzetime, SCIP_CLOCKTYPE_DEFAULT) );
3891  SCIP_CALL( SCIPclockCreate(&(*conflict)->boundlpanalyzetime, SCIP_CLOCKTYPE_DEFAULT) );
3892  SCIP_CALL( SCIPclockCreate(&(*conflict)->sbanalyzetime, SCIP_CLOCKTYPE_DEFAULT) );
3893  SCIP_CALL( SCIPclockCreate(&(*conflict)->pseudoanalyzetime, SCIP_CLOCKTYPE_DEFAULT) );
3894 
3895  /* enable or disable timing depending on the parameter statistic timing */
3896  SCIPconflictEnableOrDisableClocks((*conflict), set->time_statistictiming);
3897 
3898  SCIP_CALL( SCIPpqueueCreate(&(*conflict)->bdchgqueue, set->mem_arraygrowinit, set->mem_arraygrowfac,
3899  conflictBdchginfoComp, NULL) );
3900  SCIP_CALL( SCIPpqueueCreate(&(*conflict)->forcedbdchgqueue, set->mem_arraygrowinit, set->mem_arraygrowfac,
3901  conflictBdchginfoComp, NULL) );
3902  SCIP_CALL( conflictsetCreate(&(*conflict)->conflictset, blkmem) );
3903  (*conflict)->conflictsets = NULL;
3904  (*conflict)->conflictsetscores = NULL;
3905  (*conflict)->tmpbdchginfos = NULL;
3906  (*conflict)->conflictsetssize = 0;
3907  (*conflict)->nconflictsets = 0;
3908  (*conflict)->proofsets = NULL;
3909  (*conflict)->proofsetssize = 0;
3910  (*conflict)->nproofsets = 0;
3911  (*conflict)->tmpbdchginfossize = 0;
3912  (*conflict)->ntmpbdchginfos = 0;
3913  (*conflict)->count = 0;
3914  (*conflict)->nglbchgbds = 0;
3915  (*conflict)->nappliedglbconss = 0;
3916  (*conflict)->nappliedglbliterals = 0;
3917  (*conflict)->nlocchgbds = 0;
3918  (*conflict)->nappliedlocconss = 0;
3919  (*conflict)->nappliedlocliterals = 0;
3920  (*conflict)->npropcalls = 0;
3921  (*conflict)->npropsuccess = 0;
3922  (*conflict)->npropconfconss = 0;
3923  (*conflict)->npropconfliterals = 0;
3924  (*conflict)->npropreconvconss = 0;
3925  (*conflict)->npropreconvliterals = 0;
3926  (*conflict)->ninflpcalls = 0;
3927  (*conflict)->ninflpsuccess = 0;
3928  (*conflict)->ninflpconfconss = 0;
3929  (*conflict)->ninflpconfliterals = 0;
3930  (*conflict)->ninflpreconvconss = 0;
3931  (*conflict)->ninflpreconvliterals = 0;
3932  (*conflict)->ninflpiterations = 0;
3933  (*conflict)->nboundlpcalls = 0;
3934  (*conflict)->nboundlpsuccess = 0;
3935  (*conflict)->nboundlpconfconss = 0;
3936  (*conflict)->nboundlpconfliterals = 0;
3937  (*conflict)->nboundlpreconvconss = 0;
3938  (*conflict)->nboundlpreconvliterals = 0;
3939  (*conflict)->nboundlpiterations = 0;
3940  (*conflict)->nsbcalls = 0;
3941  (*conflict)->nsbsuccess = 0;
3942  (*conflict)->nsbconfconss = 0;
3943  (*conflict)->nsbconfliterals = 0;
3944  (*conflict)->nsbreconvconss = 0;
3945  (*conflict)->nsbreconvliterals = 0;
3946  (*conflict)->nsbiterations = 0;
3947  (*conflict)->npseudocalls = 0;
3948  (*conflict)->npseudosuccess = 0;
3949  (*conflict)->npseudoconfconss = 0;
3950  (*conflict)->npseudoconfliterals = 0;
3951  (*conflict)->npseudoreconvconss = 0;
3952  (*conflict)->npseudoreconvliterals = 0;
3953  (*conflict)->ndualproofsinfglobal = 0;
3954  (*conflict)->ndualproofsinflocal = 0;
3955  (*conflict)->ndualproofsinfsuccess = 0;
3956  (*conflict)->dualproofsinfnnonzeros = 0;
3957  (*conflict)->ndualproofsbndglobal = 0;
3958  (*conflict)->ndualproofsbndlocal = 0;
3959  (*conflict)->ndualproofsbndsuccess = 0;
3960  (*conflict)->dualproofsbndnnonzeros = 0;
3961 
3962  SCIP_CALL( conflictInitProofset((*conflict), blkmem) );
3963 
3964  return SCIP_OKAY;
3965 }
3966 
3967 /** frees conflict analysis data for propagation conflicts */
3969  SCIP_CONFLICT** conflict, /**< pointer to conflict analysis data */
3970  BMS_BLKMEM* blkmem /**< block memory of transformed problem */
3971  )
3972 {
3973  assert(conflict != NULL);
3974  assert(*conflict != NULL);
3975  assert((*conflict)->nconflictsets == 0);
3976  assert((*conflict)->ntmpbdchginfos == 0);
3977 
3978 #ifdef SCIP_CONFGRAPH
3979  confgraphFree();
3980 #endif
3981 
3982  SCIPclockFree(&(*conflict)->dIBclock);
3983  SCIPclockFree(&(*conflict)->propanalyzetime);
3984  SCIPclockFree(&(*conflict)->inflpanalyzetime);
3985  SCIPclockFree(&(*conflict)->boundlpanalyzetime);
3986  SCIPclockFree(&(*conflict)->sbanalyzetime);
3987  SCIPclockFree(&(*conflict)->pseudoanalyzetime);
3988  SCIPpqueueFree(&(*conflict)->bdchgqueue);
3989  SCIPpqueueFree(&(*conflict)->forcedbdchgqueue);
3990  conflictsetFree(&(*conflict)->conflictset, blkmem);
3991  proofsetFree(&(*conflict)->proofset, blkmem);
3992 
3993  BMSfreeMemoryArrayNull(&(*conflict)->conflictsets);
3994  BMSfreeMemoryArrayNull(&(*conflict)->conflictsetscores);
3995  BMSfreeMemoryArrayNull(&(*conflict)->proofsets);
3996  BMSfreeMemoryArrayNull(&(*conflict)->tmpbdchginfos);
3997  BMSfreeMemory(conflict);
3998 
3999  return SCIP_OKAY;
4000 }
4001 
4002 /** clears the conflict queue and the current conflict set */
4003 static
4005  SCIP_CONFLICT* conflict /**< conflict analysis data */
4006  )
4007 {
4008  assert(conflict != NULL);
4009 
4010  SCIPpqueueClear(conflict->bdchgqueue);
4011  SCIPpqueueClear(conflict->forcedbdchgqueue);
4012  conflictsetClear(conflict->conflictset);
4013 }
4014 
4015 /** initializes the propagation conflict analysis by clearing the conflict candidate queue */
4017  SCIP_CONFLICT* conflict, /**< conflict analysis data */
4018  SCIP_SET* set, /**< global SCIP settings */
4019  SCIP_STAT* stat, /**< problem statistics */
4020  SCIP_PROB* prob, /**< problem data */
4021  SCIP_CONFTYPE conftype, /**< type of the conflict */
4022  SCIP_Bool usescutoffbound /**< depends the conflict on a cutoff bound? */
4023  )
4024 {
4025  assert(conflict != NULL);
4026  assert(set != NULL);
4027  assert(stat != NULL);
4028  assert(prob != NULL);
4029 
4030  SCIPsetDebugMsg(set, "initializing conflict analysis\n");
4031 
4032  /* clear the conflict candidate queue and the conflict set */
4033  conflictClear(conflict);
4034 
4035  /* set conflict type */
4036  assert(conftype == SCIP_CONFTYPE_BNDEXCEEDING || conftype == SCIP_CONFTYPE_INFEASLP
4037  || conftype == SCIP_CONFTYPE_PROPAGATION);
4038  conflict->conflictset->conflicttype = conftype;
4039 
4040  /* set whether a cutoff bound is involved */
4041  conflict->conflictset->usescutoffbound = usescutoffbound;
4042 
4043  /* increase the conflict counter, such that binary variables of new conflict set and new conflict queue are labeled
4044  * with this new counter
4045  */
4046  conflict->count++;
4047  if( conflict->count == 0 ) /* make sure, 0 is not a valid conflict counter (may happen due to integer overflow) */
4048  conflict->count = 1;
4049 
4050  /* increase the conflict score weight for history updates of future conflict reasons */
4051  if( stat->nnodes > stat->lastconflictnode )
4052  {
4053  assert(0.0 < set->conf_scorefac && set->conf_scorefac <= 1.0);
4054  stat->vsidsweight /= set->conf_scorefac;
4055  assert(stat->vsidsweight > 0.0);
4056 
4057  /* if the conflict score for the next conflict exceeds 1000.0, rescale all history conflict scores */
4058  if( stat->vsidsweight >= 1000.0 )
4059  {
4060  int v;
4061 
4062  for( v = 0; v < prob->nvars; ++v )
4063  {
4064  SCIP_CALL( SCIPvarScaleVSIDS(prob->vars[v], 1.0/stat->vsidsweight) );
4065  }
4066  SCIPhistoryScaleVSIDS(stat->glbhistory, 1.0/stat->vsidsweight);
4068  stat->vsidsweight = 1.0;
4069  }
4070  stat->lastconflictnode = stat->nnodes;
4071  }
4072 
4073 #ifdef SCIP_CONFGRAPH
4074  confgraphFree();
4075  SCIP_CALL( confgraphCreate(set, conflict) );
4076 #endif
4077 
4078  return SCIP_OKAY;
4079 }
4080 
4081 /** marks bound to be present in the current conflict and returns whether a bound which is at least as tight was already
4082  * member of the current conflict (i.e., the given bound change does not need to be added)
4083  */
4084 static
4086  SCIP_CONFLICT* conflict, /**< conflict analysis data */
4087  SCIP_SET* set, /**< global SCIP settings */
4088  SCIP_BDCHGINFO* bdchginfo, /**< bound change to add to the conflict set */
4089  SCIP_Real relaxedbd /**< relaxed bound */
4090  )
4091 {
4092  SCIP_VAR* var;
4093  SCIP_Real newbound;
4094 
4095  assert(conflict != NULL);
4096 
4097  var = SCIPbdchginfoGetVar(bdchginfo);
4098  newbound = SCIPbdchginfoGetNewbound(bdchginfo);
4099  assert(var != NULL);
4100 
4101  switch( SCIPbdchginfoGetBoundtype(bdchginfo) )
4102  {
4103  case SCIP_BOUNDTYPE_LOWER:
4104  /* check if the variables lower bound is already member of the conflict */
4105  if( var->conflictlbcount == conflict->count )
4106  {
4107  /* the variable is already member of the conflict; hence check if the new bound is redundant */
4108  if( var->conflictlb > newbound )
4109  {
4110  SCIPsetDebugMsg(set, "ignoring redundant bound change <%s> >= %g since a stronger lower bound exist <%s> >= %g\n",
4111  SCIPvarGetName(var), newbound, SCIPvarGetName(var), var->conflictlb);
4112  return TRUE;
4113  }
4114  else if( var->conflictlb == newbound ) /*lint !e777*/
4115  {
4116  SCIPsetDebugMsg(set, "ignoring redundant bound change <%s> >= %g since this lower bound is already present\n", SCIPvarGetName(var), newbound);
4117  SCIPsetDebugMsg(set, "adjust relaxed lower bound <%g> -> <%g>\n", var->conflictlb, relaxedbd);
4118  var->conflictrelaxedlb = MAX(var->conflictrelaxedlb, relaxedbd);
4119  return TRUE;
4120  }
4121  }
4122 
4123  /* add the variable lower bound to the current conflict */
4124  var->conflictlbcount = conflict->count;
4125 
4126  /* remember the lower bound and relaxed bound to allow only better/tighter lower bounds for that variables
4127  * w.r.t. this conflict
4128  */
4129  var->conflictlb = newbound;
4130  var->conflictrelaxedlb = relaxedbd;
4131 
4132  return FALSE;
4133 
4134  case SCIP_BOUNDTYPE_UPPER:
4135  /* check if the variables upper bound is already member of the conflict */
4136  if( var->conflictubcount == conflict->count )
4137  {
4138  /* the variable is already member of the conflict; hence check if the new bound is redundant */
4139  if( var->conflictub < newbound )
4140  {
4141  SCIPsetDebugMsg(set, "ignoring redundant bound change <%s> <= %g since a stronger upper bound exist <%s> <= %g\n",
4142  SCIPvarGetName(var), newbound, SCIPvarGetName(var), var->conflictub);
4143  return TRUE;
4144  }
4145  else if( var->conflictub == newbound ) /*lint !e777*/
4146  {
4147  SCIPsetDebugMsg(set, "ignoring redundant bound change <%s> <= %g since this upper bound is already present\n", SCIPvarGetName(var), newbound);
4148  SCIPsetDebugMsg(set, "adjust relaxed upper bound <%g> -> <%g>\n", var->conflictub, relaxedbd);
4149  var->conflictrelaxedub = MIN(var->conflictrelaxedub, relaxedbd);
4150  return TRUE;
4151  }
4152  }
4153 
4154  /* add the variable upper bound to the current conflict */
4155  var->conflictubcount = conflict->count;
4156 
4157  /* remember the upper bound and relaxed bound to allow only better/tighter upper bounds for that variables
4158  * w.r.t. this conflict
4159  */
4160  var->conflictub = newbound;
4161  var->conflictrelaxedub = relaxedbd;
4162 
4163  return FALSE;
4164 
4165  default:
4166  SCIPerrorMessage("invalid bound type %d\n", SCIPbdchginfoGetBoundtype(bdchginfo));
4167  SCIPABORT();
4168  return FALSE; /*lint !e527*/
4169  }
4170 }
4171 
4172 /** puts bound change into the current conflict set */
4173 static
4175  SCIP_CONFLICT* conflict, /**< conflict analysis data */
4176  BMS_BLKMEM* blkmem, /**< block memory of transformed problem */
4177  SCIP_SET* set, /**< global SCIP settings */
4178  SCIP_BDCHGINFO* bdchginfo, /**< bound change to add to the conflict set */
4179  SCIP_Real relaxedbd /**< relaxed bound */
4180  )
4181 {
4182  assert(conflict != NULL);
4183  assert(!SCIPbdchginfoIsRedundant(bdchginfo));
4184 
4185  /* check if the relaxed bound is really a relaxed bound */
4186  assert(SCIPbdchginfoGetBoundtype(bdchginfo) == SCIP_BOUNDTYPE_LOWER || SCIPsetIsGE(set, relaxedbd, SCIPbdchginfoGetNewbound(bdchginfo)));
4187  assert(SCIPbdchginfoGetBoundtype(bdchginfo) == SCIP_BOUNDTYPE_UPPER || SCIPsetIsLE(set, relaxedbd, SCIPbdchginfoGetNewbound(bdchginfo)));
4188 
4189  SCIPsetDebugMsg(set, "putting bound change <%s> %s %g(%g) at depth %d to current conflict set\n",
4190  SCIPvarGetName(SCIPbdchginfoGetVar(bdchginfo)),
4191  SCIPbdchginfoGetBoundtype(bdchginfo) == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=", SCIPbdchginfoGetNewbound(bdchginfo),
4192  relaxedbd, SCIPbdchginfoGetDepth(bdchginfo));
4193 
4194  /* mark the bound to be member of the conflict and check if a bound which is at least as tight is already member of
4195  * the conflict
4196  */
4197  if( !conflictMarkBoundCheckPresence(conflict, set, bdchginfo, relaxedbd) )
4198  {
4199  /* add the bound change to the current conflict set */
4200  SCIP_CALL( conflictsetAddBound(conflict->conflictset, blkmem, set, bdchginfo, relaxedbd) );
4201 
4202 #ifdef SCIP_CONFGRAPH
4203  if( bdchginfo != confgraphcurrentbdchginfo )
4204  confgraphAddBdchg(bdchginfo);
4205 #endif
4206  }
4207 #ifdef SCIP_CONFGRAPH
4208  else
4209  confgraphLinkBdchg(bdchginfo);
4210 #endif
4211 
4212  return SCIP_OKAY;
4213 }
4214 
4215 /** returns whether the negation of the given bound change would lead to a globally valid literal */
4216 static
4218  SCIP_SET* set, /**< global SCIP settings */
4219  SCIP_BDCHGINFO* bdchginfo /**< bound change information */
4220  )
4221 {
4222  SCIP_VAR* var;
4223  SCIP_BOUNDTYPE boundtype;
4224  SCIP_Real bound;
4225 
4226  var = SCIPbdchginfoGetVar(bdchginfo);
4227  boundtype = SCIPbdchginfoGetBoundtype(bdchginfo);
4228  bound = SCIPbdchginfoGetNewbound(bdchginfo);
4229 
4230  return (SCIPvarGetType(var) == SCIP_VARTYPE_CONTINUOUS
4231  && ((boundtype == SCIP_BOUNDTYPE_LOWER && SCIPsetIsFeasGE(set, bound, SCIPvarGetUbGlobal(var)))
4232  || (boundtype == SCIP_BOUNDTYPE_UPPER && SCIPsetIsFeasLE(set, bound, SCIPvarGetLbGlobal(var)))));
4233 }
4234 
4235 /** adds given bound change information to the conflict candidate queue */
4236 static
4238  SCIP_CONFLICT* conflict, /**< conflict analysis data */
4239  SCIP_SET* set, /**< global SCIP settings */
4240  SCIP_BDCHGINFO* bdchginfo, /**< bound change information */
4241  SCIP_Real relaxedbd /**< relaxed bound */
4242  )
4243 {
4244  assert(conflict != NULL);
4245  assert(set != NULL);
4246  assert(bdchginfo != NULL);
4247  assert(!SCIPbdchginfoIsRedundant(bdchginfo));
4248 
4249  /* check if the relaxed bound is really a relaxed bound */
4250  assert(SCIPbdchginfoGetBoundtype(bdchginfo) == SCIP_BOUNDTYPE_LOWER || SCIPsetIsGE(set, relaxedbd, SCIPbdchginfoGetNewbound(bdchginfo)));
4251  assert(SCIPbdchginfoGetBoundtype(bdchginfo) == SCIP_BOUNDTYPE_UPPER || SCIPsetIsLE(set, relaxedbd, SCIPbdchginfoGetNewbound(bdchginfo)));
4252 
4253  /* mark the bound to be member of the conflict and check if a bound which is at least as tight is already member of
4254  * the conflict
4255  */
4256  if( !conflictMarkBoundCheckPresence(conflict, set, bdchginfo, relaxedbd) )
4257  {
4258  /* insert the bound change into the conflict queue */
4259  if( (!set->conf_preferbinary || SCIPvarIsBinary(SCIPbdchginfoGetVar(bdchginfo)))
4260  && !isBoundchgUseless(set, bdchginfo) )
4261  {
4262  SCIP_CALL( SCIPpqueueInsert(conflict->bdchgqueue, (void*)bdchginfo) );
4263  }
4264  else
4265  {
4266  SCIP_CALL( SCIPpqueueInsert(conflict->forcedbdchgqueue, (void*)bdchginfo) );
4267  }
4268 
4269 #ifdef SCIP_CONFGRAPH
4270  confgraphAddBdchg(bdchginfo);
4271 #endif
4272  }
4273 #ifdef SCIP_CONFGRAPH
4274  else
4275  confgraphLinkBdchg(bdchginfo);
4276 #endif
4277 
4278  return SCIP_OKAY;
4279 }
4280 
4281 /** convert variable and bound change to active variable */
4282 static
4284  SCIP_VAR** var, /**< pointer to variable */
4285  SCIP_SET* set, /**< global SCIP settings */
4286  SCIP_BOUNDTYPE* boundtype, /**< pointer to type of bound that was changed: lower or upper bound */
4287  SCIP_Real* bound /**< pointer to bound to convert, or NULL */
4288  )
4289 {
4290  SCIP_Real scalar;
4291  SCIP_Real constant;
4292 
4293  scalar = 1.0;
4294  constant = 0.0;
4295 
4296  /* transform given varibale to active varibale */
4297  SCIP_CALL( SCIPvarGetProbvarSum(var, set, &scalar, &constant) );
4298  assert(SCIPvarGetStatus(*var) == SCIP_VARSTATUS_FIXED || scalar != 0.0); /*lint !e777*/
4299 
4300  if( SCIPvarGetStatus(*var) == SCIP_VARSTATUS_FIXED )
4301  return SCIP_OKAY;
4302 
4303  /* if the scalar of the aggregation is negative, we have to switch the bound type */
4304  if( scalar < 0.0 )
4305  (*boundtype) = SCIPboundtypeOpposite(*boundtype);
4306 
4307  if( bound != NULL )
4308  {
4309  (*bound) -= constant;
4310  (*bound) /= scalar;
4311  }
4312 
4313  return SCIP_OKAY;
4314 }
4315 
4316 /** adds variable's bound to conflict candidate queue */
4317 static
4319  SCIP_CONFLICT* conflict, /**< conflict analysis data */
4320  BMS_BLKMEM* blkmem, /**< block memory */
4321  SCIP_SET* set, /**< global SCIP settings */
4322  SCIP_STAT* stat, /**< dynamic problem statistics */
4323  SCIP_VAR* var, /**< problem variable */
4324  SCIP_BOUNDTYPE boundtype, /**< type of bound that was changed: lower or upper bound */
4325  SCIP_BDCHGINFO* bdchginfo, /**< bound change info, or NULL */
4326  SCIP_Real relaxedbd /**< relaxed bound */
4327  )
4328 {
4329  assert(SCIPvarIsActive(var));
4330  assert(bdchginfo != NULL);
4331  assert(!SCIPbdchginfoIsRedundant(bdchginfo));
4332 
4333  SCIPsetDebugMsg(set, " -> adding bound <%s> %s %.15g(%.15g) [status:%d, type:%d, depth:%d, pos:%d, reason:<%s>, info:%d] to candidates\n",
4334  SCIPvarGetName(var),
4335  boundtype == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=",
4336  SCIPbdchginfoGetNewbound(bdchginfo), relaxedbd,
4337  SCIPvarGetStatus(var), SCIPvarGetType(var),
4338  SCIPbdchginfoGetDepth(bdchginfo), SCIPbdchginfoGetPos(bdchginfo),
4339  SCIPbdchginfoGetChgtype(bdchginfo) == SCIP_BOUNDCHGTYPE_BRANCHING ? "branch"
4343  : "none")),
4345 
4346  /* the local bound change may be resolved and has to be put on the candidate queue;
4347  * we even put bound changes without inference information on the queue in order to automatically
4348  * eliminate multiple insertions of the same bound change
4349  */
4350  assert(SCIPbdchginfoGetVar(bdchginfo) == var);
4351  assert(SCIPbdchginfoGetBoundtype(bdchginfo) == boundtype);
4352  assert(SCIPbdchginfoGetDepth(bdchginfo) >= 0);
4353  assert(SCIPbdchginfoGetPos(bdchginfo) >= 0);
4354 
4355  /* the relaxed bound should be a relaxation */
4356  assert(boundtype == SCIP_BOUNDTYPE_LOWER ? SCIPsetIsLE(set, relaxedbd, SCIPbdchginfoGetNewbound(bdchginfo)) : SCIPsetIsGE(set, relaxedbd, SCIPbdchginfoGetNewbound(bdchginfo)));
4357 
4358  /* the relaxed bound should be worse then the old bound of the bound change info */
4359  assert(boundtype == SCIP_BOUNDTYPE_LOWER ? SCIPsetIsGT(set, relaxedbd, SCIPbdchginfoGetOldbound(bdchginfo)) : SCIPsetIsLT(set, relaxedbd, SCIPbdchginfoGetOldbound(bdchginfo)));
4360 
4361  /* put bound change information into priority queue */
4362  SCIP_CALL( conflictQueueBound(conflict, set, bdchginfo, relaxedbd) );
4363 
4364  /* each variable which is add to the conflict graph gets an increase in the VSIDS
4365  *
4366  * @note That is different to the VSIDS preseted in the literature
4367  */
4368  SCIP_CALL( incVSIDS(var, blkmem, set, stat, boundtype, relaxedbd, set->conf_conflictgraphweight) );
4369 
4370  return SCIP_OKAY;
4371 }
4372 
4373 /** adds variable's bound to conflict candidate queue */
4375  SCIP_CONFLICT* conflict, /**< conflict analysis data */
4376  BMS_BLKMEM* blkmem, /**< block memory */
4377  SCIP_SET* set, /**< global SCIP settings */
4378  SCIP_STAT* stat, /**< dynamic problem statistics */
4379  SCIP_VAR* var, /**< problem variable */
4380  SCIP_BOUNDTYPE boundtype, /**< type of bound that was changed: lower or upper bound */
4381  SCIP_BDCHGIDX* bdchgidx /**< bound change index (time stamp of bound change), or NULL for current time */
4382  )
4383 {
4384  SCIP_BDCHGINFO* bdchginfo;
4385 
4386  assert(conflict != NULL);
4387  assert(stat != NULL);
4388  assert(var != NULL);
4389 
4390  /* convert bound to active problem variable */
4391  SCIP_CALL( convertToActiveVar(&var, set, &boundtype, NULL) );
4392 
4393  /* we can ignore fixed variables */
4395  return SCIP_OKAY;
4396 
4397  /* if the variable is multi-aggregated, add the bounds of all aggregation variables */
4399  {
4400  SCIP_VAR** vars;
4401  SCIP_Real* scalars;
4402  int nvars;
4403  int i;
4404 
4405  vars = SCIPvarGetMultaggrVars(var);
4406  scalars = SCIPvarGetMultaggrScalars(var);
4407  nvars = SCIPvarGetMultaggrNVars(var);
4408  for( i = 0; i < nvars; ++i )
4409  {
4410  SCIP_CALL( SCIPconflictAddBound(conflict, blkmem, set, stat, vars[i],
4411  (scalars[i] < 0.0 ? SCIPboundtypeOpposite(boundtype) : boundtype), bdchgidx) );
4412  }
4413 
4414  return SCIP_OKAY;
4415  }
4416  assert(SCIPvarIsActive(var));
4417 
4418  /* get bound change information */
4419  bdchginfo = SCIPvarGetBdchgInfo(var, boundtype, bdchgidx, FALSE);
4420 
4421  /* if bound of variable was not changed (this means it is still the global bound), we can ignore the conflicting
4422  * bound
4423  */
4424  if( bdchginfo == NULL )
4425  return SCIP_OKAY;
4426 
4427  assert(SCIPbdchgidxIsEarlier(SCIPbdchginfoGetIdx(bdchginfo), bdchgidx));
4428 
4429  SCIP_CALL( conflictAddBound(conflict, blkmem, set, stat, var, boundtype, bdchginfo, SCIPbdchginfoGetNewbound(bdchginfo)) );
4430 
4431  return SCIP_OKAY;
4432 }
4433 
4434 /** adds variable's bound to conflict candidate queue */
4436  SCIP_CONFLICT* conflict, /**< conflict analysis data */
4437  BMS_BLKMEM* blkmem, /**< block memory */
4438  SCIP_SET* set, /**< global SCIP settings */
4439  SCIP_STAT* stat, /**< dynamic problem statistics */
4440  SCIP_VAR* var, /**< problem variable */
4441  SCIP_BOUNDTYPE boundtype, /**< type of bound that was changed: lower or upper bound */
4442  SCIP_BDCHGIDX* bdchgidx, /**< bound change index (time stamp of bound change), or NULL for current time */
4443  SCIP_Real relaxedbd /**< the relaxed bound */
4444  )
4445 {
4446  SCIP_BDCHGINFO* bdchginfo;
4447  int nbdchgs;
4448 
4449  assert(conflict != NULL);
4450  assert(stat != NULL);
4451  assert(var != NULL);
4452 
4453  if( !SCIPvarIsActive(var) )
4454  {
4455  /* convert bound to active problem variable */
4456  SCIP_CALL( convertToActiveVar(&var, set, &boundtype, &relaxedbd) );
4457 
4458  /* we can ignore fixed variables */
4460  return SCIP_OKAY;
4461 
4462  /* if the variable is multi-aggregated, add the bounds of all aggregation variables */
4464  {
4465  SCIPsetDebugMsg(set, "ignoring relaxed bound information since variable <%s> is multi-aggregated active\n", SCIPvarGetName(var));
4466 
4467  SCIP_CALL( SCIPconflictAddBound(conflict, blkmem, set, stat, var, boundtype, bdchgidx) );
4468 
4469  return SCIP_OKAY;
4470  }
4471  }
4472  assert(SCIPvarIsActive(var));
4473 
4474  /* get bound change information */
4475  bdchginfo = SCIPvarGetBdchgInfo(var, boundtype, bdchgidx, FALSE);
4476 
4477  /* if bound of variable was not changed (this means it is still the global bound), we can ignore the conflicting
4478  * bound
4479  */
4480  if( bdchginfo == NULL )
4481  return SCIP_OKAY;
4482 
4483  /* check that the bound change info is not a temporary one */
4484  assert(SCIPbdchgidxGetPos(&bdchginfo->bdchgidx) >= 0);
4485 
4486  /* get the position of the bound change information within the bound change array of the variable */
4487  nbdchgs = (int) bdchginfo->pos;
4488  assert(nbdchgs >= 0);
4489 
4490  /* if the relaxed bound should be ignored, set the relaxed bound to the bound given by the bdchgidx; that ensures
4491  * that the loop(s) below will be skipped
4492  */
4493  if( set->conf_ignorerelaxedbd )
4494  relaxedbd = SCIPbdchginfoGetNewbound(bdchginfo);
4495 
4496  /* search for the bound change information which includes the relaxed bound */
4497  if( boundtype == SCIP_BOUNDTYPE_LOWER )
4498  {
4499  SCIP_Real newbound;
4500 
4501  /* adjust relaxed lower bound w.r.t. variable type */
4502  SCIPvarAdjustLb(var, set, &relaxedbd);
4503 
4504  /* due to numericis we compare the relaxed lower bound to the one present at the particular time point and take
4505  * the better one
4506  */
4507  newbound = SCIPbdchginfoGetNewbound(bdchginfo);
4508  relaxedbd = MIN(relaxedbd, newbound);
4509 
4510  /* check if relaxed lower bound is smaller or equal to global lower bound; if so we can ignore the conflicting
4511  * bound
4512  */
4513  if( SCIPsetIsLE(set, relaxedbd, SCIPvarGetLbGlobal(var)) )
4514  return SCIP_OKAY;
4515 
4516  while( nbdchgs > 0 )
4517  {
4518  assert(SCIPsetIsLE(set, relaxedbd, SCIPbdchginfoGetNewbound(bdchginfo)));
4519 
4520  /* check if the old lower bound is greater than or equal to relaxed lower bound; if not we found the bound
4521  * change info which we need to report
4522  */
4523  if( SCIPsetIsGT(set, relaxedbd, SCIPbdchginfoGetOldbound(bdchginfo)) )
4524  break;
4525 
4526  bdchginfo = SCIPvarGetBdchgInfoLb(var, nbdchgs-1);
4527 
4528  SCIPsetDebugMsg(set, "lower bound change %d oldbd=%.15g, newbd=%.15g, depth=%d, pos=%d, redundant=%u\n",
4529  nbdchgs, SCIPbdchginfoGetOldbound(bdchginfo), SCIPbdchginfoGetNewbound(bdchginfo),
4530  SCIPbdchginfoGetDepth(bdchginfo), SCIPbdchginfoGetPos(bdchginfo),
4531  SCIPbdchginfoIsRedundant(bdchginfo));
4532 
4533  /* if bound change is redundant (this means it now a global bound), we can ignore the conflicting bound */
4534  if( SCIPbdchginfoIsRedundant(bdchginfo) )
4535  return SCIP_OKAY;
4536 
4537  nbdchgs--;
4538  }
4539  assert(SCIPsetIsGT(set, relaxedbd, SCIPbdchginfoGetOldbound(bdchginfo)));
4540  }
4541  else
4542  {
4543  SCIP_Real newbound;
4544 
4545  assert(boundtype == SCIP_BOUNDTYPE_UPPER);
4546 
4547  /* adjust relaxed upper bound w.r.t. variable type */
4548  SCIPvarAdjustUb(var, set, &relaxedbd);
4549 
4550  /* due to numericis we compare the relaxed upper bound to the one present at the particular time point and take
4551  * the better one
4552  */
4553  newbound = SCIPbdchginfoGetNewbound(bdchginfo);
4554  relaxedbd = MAX(relaxedbd, newbound);
4555 
4556  /* check if relaxed upper bound is greater or equal to global upper bound; if so we can ignore the conflicting
4557  * bound
4558  */
4559  if( SCIPsetIsGE(set, relaxedbd, SCIPvarGetUbGlobal(var)) )
4560  return SCIP_OKAY;
4561 
4562  while( nbdchgs > 0 )
4563  {
4564  assert(SCIPsetIsGE(set, relaxedbd, SCIPbdchginfoGetNewbound(bdchginfo)));
4565 
4566  /* check if the old upper bound is smaller than or equal to the relaxed upper bound; if not we found the
4567  * bound change info which we need to report
4568  */
4569  if( SCIPsetIsLT(set, relaxedbd, SCIPbdchginfoGetOldbound(bdchginfo)) )
4570  break;
4571 
4572  bdchginfo = SCIPvarGetBdchgInfoUb(var, nbdchgs-1);
4573 
4574  SCIPsetDebugMsg(set, "upper bound change %d oldbd=%.15g, newbd=%.15g, depth=%d, pos=%d, redundant=%u\n",
4575  nbdchgs, SCIPbdchginfoGetOldbound(bdchginfo), SCIPbdchginfoGetNewbound(bdchginfo),
4576  SCIPbdchginfoGetDepth(bdchginfo), SCIPbdchginfoGetPos(bdchginfo),
4577  SCIPbdchginfoIsRedundant(bdchginfo));
4578 
4579  /* if bound change is redundant (this means it now a global bound), we can ignore the conflicting bound */
4580  if( SCIPbdchginfoIsRedundant(bdchginfo) )
4581  return SCIP_OKAY;
4582 
4583  nbdchgs--;
4584  }
4585  assert(SCIPsetIsLT(set, relaxedbd, SCIPbdchginfoGetOldbound(bdchginfo)));
4586  }
4587 
4588  assert(SCIPbdchgidxIsEarlier(SCIPbdchginfoGetIdx(bdchginfo), bdchgidx));
4589 
4590  /* put bound change information into priority queue */
4591  SCIP_CALL( conflictAddBound(conflict, blkmem, set, stat, var, boundtype, bdchginfo, relaxedbd) );
4592 
4593  return SCIP_OKAY;
4594 }
4595 
4596 /** checks if the given variable is already part of the current conflict set or queued for resolving with the same or
4597  * even stronger bound
4598  */
4600  SCIP_CONFLICT* conflict, /**< conflict analysis data */
4601  SCIP_VAR* var, /**< problem variable */
4602  SCIP_SET* set, /**< global SCIP settings */
4603  SCIP_BOUNDTYPE boundtype, /**< type of bound for which the score should be increased */
4604  SCIP_BDCHGIDX* bdchgidx, /**< bound change index (time stamp of bound change), or NULL for current time */
4605  SCIP_Bool* used /**< pointer to store if the variable is already used */
4606  )
4607 {
4608  SCIP_Real newbound;
4609 
4610  /* convert bound to active problem variable */
4611  SCIP_CALL( convertToActiveVar(&var, set, &boundtype, NULL) );
4612 
4614  *used = FALSE;
4615  else
4616  {
4617  assert(SCIPvarIsActive(var));
4618  assert(var != NULL);
4619 
4620  switch( boundtype )
4621  {
4622  case SCIP_BOUNDTYPE_LOWER:
4623 
4624  newbound = SCIPgetVarLbAtIndex(set->scip, var, bdchgidx, FALSE);
4625 
4626  if( var->conflictlbcount == conflict->count && var->conflictlb >= newbound )
4627  {
4628  SCIPsetDebugMsg(set, "already queued bound change <%s> >= %g\n", SCIPvarGetName(var), newbound);
4629  *used = TRUE;
4630  }
4631  else
4632  *used = FALSE;
4633  break;
4634  case SCIP_BOUNDTYPE_UPPER:
4635 
4636  newbound = SCIPgetVarUbAtIndex(set->scip, var, bdchgidx, FALSE);
4637 
4638  if( var->conflictubcount == conflict->count && var->conflictub <= newbound )
4639  {
4640  SCIPsetDebugMsg(set, "already queued bound change <%s> <= %g\n", SCIPvarGetName(var), newbound);
4641  *used = TRUE;
4642  }
4643  else
4644  *used = FALSE;
4645  break;
4646  default:
4647  SCIPerrorMessage("invalid bound type %d\n", boundtype);
4648  SCIPABORT();
4649  *used = FALSE; /*lint !e527*/
4650  }
4651  }
4652 
4653  return SCIP_OKAY;
4654 }
4655 
4656 /** returns the conflict lower bound if the variable is present in the current conflict set; otherwise the global lower
4657  * bound
4658  */
4660  SCIP_CONFLICT* conflict, /**< conflict analysis data */
4661  SCIP_VAR* var /**< problem variable */
4662  )
4663 {
4664  if( var->conflictlbcount == conflict->count )
4665  {
4666  assert(EPSGE(var->conflictlb, var->conflictrelaxedlb, 1e-09));
4667  return var->conflictrelaxedlb;
4668  }
4669 
4670  return SCIPvarGetLbGlobal(var);
4671 }
4672 
4673 /** returns the conflict upper bound if the variable is present in the current conflict set; otherwise the global upper
4674  * bound
4675  */
4677  SCIP_CONFLICT* conflict, /**< conflict analysis data */
4678  SCIP_VAR* var /**< problem variable */
4679  )
4680 {
4681  if( var->conflictubcount == conflict->count )
4682  {
4683  assert(EPSLE(var->conflictub, var->conflictrelaxedub, 1e-09));
4684  return var->conflictrelaxedub;
4685  }
4686 
4687  return SCIPvarGetUbGlobal(var);
4688 }
4689 
4690 /** removes and returns next conflict analysis candidate from the candidate queue */
4691 static
4693  SCIP_CONFLICT* conflict /**< conflict analysis data */
4694  )
4695 {
4696  SCIP_BDCHGINFO* bdchginfo;
4697  SCIP_VAR* var;
4698 
4699  assert(conflict != NULL);
4700 
4701  if( SCIPpqueueNElems(conflict->forcedbdchgqueue) > 0 )
4702  bdchginfo = (SCIP_BDCHGINFO*)(SCIPpqueueRemove(conflict->forcedbdchgqueue));
4703  else
4704  bdchginfo = (SCIP_BDCHGINFO*)(SCIPpqueueRemove(conflict->bdchgqueue));
4705 
4706  assert(!SCIPbdchginfoIsRedundant(bdchginfo));
4707 
4708  /* if we have a candidate this one should be valid for the current conflict analysis */
4709  assert(!bdchginfoIsInvalid(conflict, bdchginfo));
4710 
4711  /* mark the bound change to be no longer in the conflict (it will be either added again to the conflict set or
4712  * replaced by resolving, which might add a weaker change on the same bound to the queue)
4713  */
4714  var = SCIPbdchginfoGetVar(bdchginfo);
4716  {
4717  var->conflictlbcount = 0;
4719  }
4720  else
4721  {
4722  assert(SCIPbdchginfoGetBoundtype(bdchginfo) == SCIP_BOUNDTYPE_UPPER);
4723  var->conflictubcount = 0;
4725  }
4726 
4727 #ifdef SCIP_CONFGRAPH
4728  confgraphSetCurrentBdchg(bdchginfo);
4729 #endif
4730 
4731  return bdchginfo;
4732 }
4733 
4734 /** returns next conflict analysis candidate from the candidate queue without removing it */
4735 static
4737  SCIP_CONFLICT* conflict /**< conflict analysis data */
4738  )
4739 {
4740  SCIP_BDCHGINFO* bdchginfo;
4741 
4742  assert(conflict != NULL);
4743 
4744  if( SCIPpqueueNElems(conflict->forcedbdchgqueue) > 0 )
4745  {
4746  /* get next potetioal candidate */
4747  bdchginfo = (SCIP_BDCHGINFO*)(SCIPpqueueFirst(conflict->forcedbdchgqueue));
4748 
4749  /* check if this candidate is valid */
4750  if( bdchginfoIsInvalid(conflict, bdchginfo) )
4751  {
4752  SCIPdebugMessage("bound change info [%d:<%s> %s %g] is invaild -> pop it from the force queue\n", SCIPbdchginfoGetDepth(bdchginfo),
4753  SCIPvarGetName(SCIPbdchginfoGetVar(bdchginfo)),
4754  SCIPbdchginfoGetBoundtype(bdchginfo) == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=",
4755  SCIPbdchginfoGetNewbound(bdchginfo));
4756 
4757  /* pop the invalid bound change info from the queue */
4758  (void)(SCIPpqueueRemove(conflict->forcedbdchgqueue));
4759 
4760  /* call method recursively to get next conflict analysis candidate */
4761  bdchginfo = conflictFirstCand(conflict);
4762  }
4763  }
4764  else
4765  {
4766  bdchginfo = (SCIP_BDCHGINFO*)(SCIPpqueueFirst(conflict->bdchgqueue));
4767 
4768  /* check if this candidate is valid */
4769  if( bdchginfo != NULL && bdchginfoIsInvalid(conflict, bdchginfo) )
4770  {
4771  SCIPdebugMessage("bound change info [%d:<%s> %s %g] is invaild -> pop it from the queue\n", SCIPbdchginfoGetDepth(bdchginfo),
4772  SCIPvarGetName(SCIPbdchginfoGetVar(bdchginfo)),
4773  SCIPbdchginfoGetBoundtype(bdchginfo) == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=",
4774  SCIPbdchginfoGetNewbound(bdchginfo));
4775 
4776  /* pop the invalid bound change info from the queue */
4777  (void)(SCIPpqueueRemove(conflict->bdchgqueue));
4778 
4779  /* call method recursively to get next conflict analysis candidate */
4780  bdchginfo = conflictFirstCand(conflict);
4781  }
4782  }
4783  assert(bdchginfo == NULL || !SCIPbdchginfoIsRedundant(bdchginfo));
4784 
4785  return bdchginfo;
4786 }
4787 
4788 /** adds the current conflict set (extended by all remaining bound changes in the queue) to the pool of conflict sets */
4789 static
4791  SCIP_CONFLICT* conflict, /**< conflict analysis data */
4792  BMS_BLKMEM* blkmem, /**< block memory of transformed problem */
4793  SCIP_SET* set, /**< global SCIP settings */
4794  SCIP_STAT* stat, /**< dynamic problem statistics */
4795  SCIP_TREE* tree, /**< branch and bound tree */
4796  int validdepth, /**< minimal depth level at which the conflict set is valid */
4797  SCIP_Bool diving, /**< are we in strong branching or diving mode? */
4798  SCIP_Bool repropagate, /**< should the constraint trigger a repropagation? */
4799  SCIP_Bool* success, /**< pointer to store whether the conflict set is valid */
4800  int* nliterals /**< pointer to store the number of literals in the generated conflictset */
4801  )
4802 {
4803  SCIP_CONFLICTSET* conflictset;
4804  SCIP_BDCHGINFO** bdchginfos;
4805  int nbdchginfos;
4806  int currentdepth;
4807  int focusdepth;
4808 
4809  assert(conflict != NULL);
4810  assert(conflict->conflictset != NULL);
4811  assert(set != NULL);
4812  assert(stat != NULL);
4813  assert(tree != NULL);
4814  assert(success != NULL);
4815  assert(nliterals != NULL);
4816  assert(SCIPpqueueNElems(conflict->forcedbdchgqueue) == 0);
4817 
4818  *success = FALSE;
4819  *nliterals = 0;
4820 
4821  /* check, whether local conflicts are allowed */
4822  validdepth = MAX(validdepth, conflict->conflictset->validdepth);
4823  if( !set->conf_allowlocal && validdepth > 0 )
4824  return SCIP_OKAY;
4825 
4826  focusdepth = SCIPtreeGetFocusDepth(tree);
4827  currentdepth = SCIPtreeGetCurrentDepth(tree);
4828  assert(currentdepth == tree->pathlen-1);
4829  assert(focusdepth <= currentdepth);
4830  assert(0 <= conflict->conflictset->validdepth && conflict->conflictset->validdepth <= currentdepth);
4831  assert(0 <= validdepth && validdepth <= currentdepth);
4832 
4833  /* get the elements of the bound change queue */
4834  bdchginfos = (SCIP_BDCHGINFO**)SCIPpqueueElems(conflict->bdchgqueue);
4835  nbdchginfos = SCIPpqueueNElems(conflict->bdchgqueue);
4836 
4837  /* create a copy of the current conflict set, allocating memory for the additional elements of the queue */
4838  SCIP_CALL( conflictsetCopy(&conflictset, blkmem, conflict->conflictset, nbdchginfos) );
4839  conflictset->validdepth = validdepth;
4840  conflictset->repropagate = repropagate;
4841 
4842  /* add the valid queue elements to the conflict set */
4843  SCIPsetDebugMsg(set, "adding %d variables from the queue as temporary conflict variables\n", nbdchginfos);
4844  SCIP_CALL( conflictsetAddBounds(conflict, conflictset, blkmem, set, bdchginfos, nbdchginfos) );
4845 
4846  /* calculate the depth, at which the conflictset should be inserted */
4847  SCIP_CALL( conflictsetCalcInsertDepth(conflictset, set, tree) );
4848  assert(conflictset->validdepth <= conflictset->insertdepth && conflictset->insertdepth <= currentdepth);
4849  SCIPsetDebugMsg(set, " -> conflict with %d literals found at depth %d is active in depth %d and valid in depth %d\n",
4850  conflictset->nbdchginfos, currentdepth, conflictset->insertdepth, conflictset->validdepth);
4851 
4852  /* if all branching variables are in the conflict set, the conflict set is of no use;
4853  * don't use conflict sets that are only valid in the probing path but not in the problem tree
4854  */
4855  if( (diving || conflictset->insertdepth < currentdepth) && conflictset->insertdepth <= focusdepth )
4856  {
4857  /* if the conflict should not be located only in the subtree where it is useful, put it to its valid depth level */
4858  if( !set->conf_settlelocal )
4859  conflictset->insertdepth = conflictset->validdepth;
4860 
4861  *nliterals = conflictset->nbdchginfos;
4862  SCIPsetDebugMsg(set, " -> final conflict set has %d literals\n", *nliterals);
4863 
4864  /* check conflict set on debugging solution */
4865  SCIP_CALL( SCIPdebugCheckConflict(blkmem, set, tree->path[validdepth], \
4866  conflictset->bdchginfos, conflictset->relaxedbds, conflictset->nbdchginfos) ); /*lint !e506 !e774*/
4867 
4868  /* move conflictset to the conflictset storage */
4869  SCIP_CALL( conflictInsertConflictset(conflict, blkmem, set, &conflictset) );
4870  *success = TRUE;
4871  }
4872  else
4873  {
4874  /* free the temporary conflict set */
4875  conflictsetFree(&conflictset, blkmem);
4876  }
4877 
4878  return SCIP_OKAY;
4879 }
4880 
4881 /** tries to resolve given bound change
4882  * - resolutions on local constraints are only applied, if the constraint is valid at the
4883  * current minimal valid depth level, because this depth level is the topmost level to add the conflict
4884  * constraint to anyways
4885  *
4886  * @note it is sufficient to explain the relaxed bound change
4887  */
4888 static
4890  SCIP_CONFLICT* conflict, /**< conflict analysis data */
4891  SCIP_SET* set, /**< global SCIP settings */
4892  SCIP_BDCHGINFO* bdchginfo, /**< bound change to resolve */
4893  SCIP_Real relaxedbd, /**< the relaxed bound */
4894  int validdepth, /**< minimal depth level at which the conflict is valid */
4895  SCIP_Bool* resolved /**< pointer to store whether the bound change was resolved */
4896  )
4897 {
4898  SCIP_VAR* actvar;
4899  SCIP_CONS* infercons;
4900  SCIP_PROP* inferprop;
4901  SCIP_RESULT result;
4902 
4903 #ifndef NDEBUG
4904  int nforcedbdchgqueue;
4905  int nbdchgqueue;
4906 
4907  /* store the current size of the conflict queues */
4908  assert(conflict != NULL);
4909  nforcedbdchgqueue = SCIPpqueueNElems(conflict->forcedbdchgqueue);
4910  nbdchgqueue = SCIPpqueueNElems(conflict->bdchgqueue);
4911 #else
4912  assert(conflict != NULL);
4913 #endif
4914 
4915  assert(resolved != NULL);
4916  assert(!SCIPbdchginfoIsRedundant(bdchginfo));
4917 
4918  *resolved = FALSE;
4919 
4920  actvar = SCIPbdchginfoGetVar(bdchginfo);
4921  assert(actvar != NULL);
4922  assert(SCIPvarIsActive(actvar));
4923 
4924 #ifdef SCIP_DEBUG
4925  {
4926  int i;
4927  SCIPsetDebugMsg(set, "processing next conflicting bound (depth: %d, valid depth: %d, bdchgtype: %s [%s], vartype: %d): [<%s> %s %g(%g)]\n",
4928  SCIPbdchginfoGetDepth(bdchginfo), validdepth,
4929  SCIPbdchginfoGetChgtype(bdchginfo) == SCIP_BOUNDCHGTYPE_BRANCHING ? "branch"
4930  : SCIPbdchginfoGetChgtype(bdchginfo) == SCIP_BOUNDCHGTYPE_CONSINFER ? "cons" : "prop",
4934  : SCIPbdchginfoGetInferProp(bdchginfo) == NULL ? "-"
4936  SCIPvarGetType(actvar), SCIPvarGetName(actvar),
4937  SCIPbdchginfoGetBoundtype(bdchginfo) == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=",
4938  SCIPbdchginfoGetNewbound(bdchginfo), relaxedbd);
4939  SCIPsetDebugMsg(set, " - conflict set :");
4940 
4941  for( i = 0; i < conflict->conflictset->nbdchginfos; ++i )
4942  {
4943  SCIPsetDebugMsgPrint(set, " [%d:<%s> %s %g(%g)]", SCIPbdchginfoGetDepth(conflict->conflictset->bdchginfos[i]),
4945  SCIPbdchginfoGetBoundtype(conflict->conflictset->bdchginfos[i]) == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=",
4946  SCIPbdchginfoGetNewbound(conflict->conflictset->bdchginfos[i]), conflict->conflictset->relaxedbds[i]);
4947  }
4948  SCIPsetDebugMsgPrint(set, "\n");
4949  SCIPsetDebugMsg(set, " - forced candidates :");
4950 
4951  for( i = 0; i < SCIPpqueueNElems(conflict->forcedbdchgqueue); ++i )
4952  {
4954  SCIPsetDebugMsgPrint(set, " [%d:<%s> %s %g(%g)]", SCIPbdchginfoGetDepth(info), SCIPvarGetName(SCIPbdchginfoGetVar(info)),
4955  bdchginfoIsInvalid(conflict, info) ? "<!>" : SCIPbdchginfoGetBoundtype(info) == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=",
4957  }
4958  SCIPsetDebugMsgPrint(set, "\n");
4959  SCIPsetDebugMsg(set, " - optional candidates:");
4960 
4961  for( i = 0; i < SCIPpqueueNElems(conflict->bdchgqueue); ++i )
4962  {
4963  SCIP_BDCHGINFO* info = (SCIP_BDCHGINFO*)(SCIPpqueueElems(conflict->bdchgqueue)[i]);
4964  SCIPsetDebugMsgPrint(set, " [%d:<%s> %s %g(%g)]", SCIPbdchginfoGetDepth(info), SCIPvarGetName(SCIPbdchginfoGetVar(info)),
4965  bdchginfoIsInvalid(conflict, info) ? "<!>" : SCIPbdchginfoGetBoundtype(info) == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=",
4967  }
4968  SCIPsetDebugMsgPrint(set, "\n");
4969  }
4970 #endif
4971 
4972  /* check, if the bound change can and should be resolved:
4973  * - resolutions on local constraints should only be applied, if the constraint is valid at the
4974  * current minimal valid depth level (which is initialized with the valid depth level of the initial
4975  * conflict set), because this depth level is the topmost level to add the conflict constraint to anyways
4976  */
4977  switch( SCIPbdchginfoGetChgtype(bdchginfo) )
4978  {
4980  infercons = SCIPbdchginfoGetInferCons(bdchginfo);
4981  assert(infercons != NULL);
4982 
4983  if( SCIPconsIsGlobal(infercons) || SCIPconsGetValidDepth(infercons) <= validdepth )
4984  {
4985  SCIP_VAR* infervar;
4986  int inferinfo;
4987  SCIP_BOUNDTYPE inferboundtype;
4988  SCIP_BDCHGIDX* bdchgidx;
4989 
4990  /* resolve bound change by asking the constraint that infered the bound to put all bounds that were
4991  * the reasons for the conflicting bound change on the priority queue
4992  */
4993  infervar = SCIPbdchginfoGetInferVar(bdchginfo);
4994  inferinfo = SCIPbdchginfoGetInferInfo(bdchginfo);
4995  inferboundtype = SCIPbdchginfoGetInferBoundtype(bdchginfo);
4996  bdchgidx = SCIPbdchginfoGetIdx(bdchginfo);
4997  assert(infervar != NULL);
4998 
4999  SCIPsetDebugMsg(set, "resolving bound <%s> %s %g(%g) [status:%d, type:%d, depth:%d, pos:%d]: <%s> %s %g [cons:<%s>(%s), info:%d]\n",
5000  SCIPvarGetName(actvar),
5001  SCIPbdchginfoGetBoundtype(bdchginfo) == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=",
5002  SCIPbdchginfoGetNewbound(bdchginfo), relaxedbd,
5003  SCIPvarGetStatus(actvar), SCIPvarGetType(actvar),
5004  SCIPbdchginfoGetDepth(bdchginfo), SCIPbdchginfoGetPos(bdchginfo),
5005  SCIPvarGetName(infervar),
5006  inferboundtype == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=",
5007  SCIPgetVarBdAtIndex(set->scip, infervar, inferboundtype, bdchgidx, TRUE),
5008  SCIPconsGetName(infercons),
5009  SCIPconsIsGlobal(infercons) ? "global" : "local",
5010  inferinfo);
5011 
5012  /* in case the inference variables is not an active variables, we need to transform the relaxed bound */
5013  if( actvar != infervar )
5014  {
5015  SCIP_VAR* var;
5016  SCIP_Real scalar;
5017  SCIP_Real constant;
5018 
5019  assert(SCIPvarGetStatus(infervar) == SCIP_VARSTATUS_AGGREGATED
5021  || (SCIPvarGetStatus(infervar) == SCIP_VARSTATUS_MULTAGGR && SCIPvarGetMultaggrNVars(infervar) == 1));
5022 
5023  scalar = 1.0;
5024  constant = 0.0;
5025 
5026  var = infervar;
5027 
5028  /* transform given varibale to active varibale */
5029  SCIP_CALL( SCIPvarGetProbvarSum(&var, set, &scalar, &constant) );
5030  assert(var == actvar);
5031 
5032  relaxedbd *= scalar;
5033  relaxedbd += constant;
5034  }
5035 
5036  SCIP_CALL( SCIPconsResolvePropagation(infercons, set, infervar, inferinfo, inferboundtype, bdchgidx, relaxedbd, &result) );
5037  *resolved = (result == SCIP_SUCCESS);
5038  }
5039  break;
5040 
5042  inferprop = SCIPbdchginfoGetInferProp(bdchginfo);
5043  if( inferprop != NULL )
5044  {
5045  SCIP_VAR* infervar;
5046  int inferinfo;
5047  SCIP_BOUNDTYPE inferboundtype;
5048  SCIP_BDCHGIDX* bdchgidx;
5049 
5050  /* resolve bound change by asking the propagator that infered the bound to put all bounds that were
5051  * the reasons for the conflicting bound change on the priority queue
5052  */
5053  infervar = SCIPbdchginfoGetInferVar(bdchginfo);
5054  inferinfo = SCIPbdchginfoGetInferInfo(bdchginfo);
5055  inferboundtype = SCIPbdchginfoGetInferBoundtype(bdchginfo);
5056  bdchgidx = SCIPbdchginfoGetIdx(bdchginfo);
5057  assert(infervar != NULL);
5058 
5059  SCIPsetDebugMsg(set, "resolving bound <%s> %s %g(%g) [status:%d, depth:%d, pos:%d]: <%s> %s %g [prop:<%s>, info:%d]\n",
5060  SCIPvarGetName(actvar),
5061  SCIPbdchginfoGetBoundtype(bdchginfo) == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=",
5062  SCIPbdchginfoGetNewbound(bdchginfo), relaxedbd,
5063  SCIPvarGetStatus(actvar), SCIPbdchginfoGetDepth(bdchginfo), SCIPbdchginfoGetPos(bdchginfo),
5064  SCIPvarGetName(infervar),
5065  inferboundtype == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=",
5066  SCIPgetVarBdAtIndex(set->scip, infervar, inferboundtype, bdchgidx, TRUE),
5067  SCIPpropGetName(inferprop), inferinfo);
5068 
5069  SCIP_CALL( SCIPpropResolvePropagation(inferprop, set, infervar, inferinfo, inferboundtype, bdchgidx, relaxedbd, &result) );
5070  *resolved = (result == SCIP_SUCCESS);
5071  }
5072  break;
5073 
5075  assert(!(*resolved));
5076  break;
5077 
5078  default:
5079  SCIPerrorMessage("invalid bound change type <%d>\n", SCIPbdchginfoGetChgtype(bdchginfo));
5080  return SCIP_INVALIDDATA;
5081  }
5082 
5083  SCIPsetDebugMsg(set, "resolving status: %u\n", *resolved);
5084 
5085 #ifndef NDEBUG
5086  /* subtract the size of the conflicq queues */
5087  nforcedbdchgqueue -= SCIPpqueueNElems(conflict->forcedbdchgqueue);
5088  nbdchgqueue -= SCIPpqueueNElems(conflict->bdchgqueue);
5089 
5090  /* in case the bound change was not resolved, the conflict queues should have the same size (contents) */
5091  assert((*resolved) || (nforcedbdchgqueue == 0 && nbdchgqueue == 0));
5092 #endif
5093 
5094  return SCIP_OKAY;
5095 }
5096 
5097 /** if only one conflicting bound change of the last depth level was used, and if this can be resolved,
5098  * creates GRASP-like reconvergence conflict constraints in the conflict graph up to the branching variable of this
5099  * depth level
5100  */
5101 static
5103  SCIP_CONFLICT* conflict, /**< conflict analysis data */
5104  BMS_BLKMEM* blkmem, /**< block memory of transformed problem */
5105  SCIP_SET* set, /**< global SCIP settings */
5106  SCIP_STAT* stat, /**< problem statistics */
5107  SCIP_PROB* prob, /**< problem data */
5108  SCIP_TREE* tree, /**< branch and bound tree */
5109  SCIP_Bool diving, /**< are we in strong branching or diving mode? */
5110  int validdepth, /**< minimal depth level at which the initial conflict set is valid */
5111  SCIP_BDCHGINFO* firstuip, /**< first UIP of conflict graph */
5112  int* nreconvconss, /**< pointer to store the number of generated reconvergence constraints */
5113  int* nreconvliterals /**< pointer to store the number of literals generated reconvergence constraints */
5114  )
5115 {
5116  SCIP_BDCHGINFO* uip;
5117  SCIP_CONFTYPE conftype;
5118  SCIP_Bool usescutoffbound;
5119  int firstuipdepth;
5120  int focusdepth;
5121  int currentdepth;
5122  int maxvaliddepth;
5123 
5124  assert(conflict != NULL);
5125  assert(firstuip != NULL);
5126  assert(nreconvconss != NULL);
5127  assert(nreconvliterals != NULL);
5128  assert(!SCIPbdchginfoIsRedundant(firstuip));
5129 
5130  focusdepth = SCIPtreeGetFocusDepth(tree);
5131  currentdepth = SCIPtreeGetCurrentDepth(tree);
5132  assert(currentdepth == tree->pathlen-1);
5133  assert(focusdepth <= currentdepth);
5134 
5135  /* check, whether local constraints are allowed; however, don't generate reconvergence constraints that are only valid
5136  * in the probing path and not in the problem tree (i.e. that exceed the focusdepth)
5137  */
5138  maxvaliddepth = (set->conf_allowlocal ? MIN(currentdepth-1, focusdepth) : 0);
5139  if( validdepth > maxvaliddepth )
5140  return SCIP_OKAY;
5141 
5142  firstuipdepth = SCIPbdchginfoGetDepth(firstuip);
5143 
5144  conftype = conflict->conflictset->conflicttype;
5145  usescutoffbound = conflict->conflictset->usescutoffbound;
5146 
5147  /* for each succeeding UIP pair of the last depth level, create one reconvergence constraint */
5148  uip = firstuip;
5149  while( uip != NULL && SCIPbdchginfoGetDepth(uip) == SCIPbdchginfoGetDepth(firstuip) && bdchginfoIsResolvable(uip) )
5150  {
5151  SCIP_BDCHGINFO* oppositeuip;
5152  SCIP_BDCHGINFO* bdchginfo;
5153  SCIP_BDCHGINFO* nextuip;
5154  SCIP_VAR* uipvar;
5155  SCIP_Real oppositeuipbound;
5156  SCIP_BOUNDTYPE oppositeuipboundtype;
5157  int nresolutions;
5158 
5159  assert(!SCIPbdchginfoIsRedundant(uip));
5160 
5161  SCIPsetDebugMsg(set, "creating reconvergence constraint for UIP <%s> %s %g in depth %d pos %d\n",
5164 
5165  /* initialize conflict data */
5166  SCIP_CALL( SCIPconflictInit(conflict, set, stat, prob, conftype, usescutoffbound) );
5167 
5168  conflict->conflictset->conflicttype = conftype;
5169  conflict->conflictset->usescutoffbound = usescutoffbound;
5170 
5171  /* create a temporary bound change information for the negation of the UIP's bound change;
5172  * this bound change information is freed in the SCIPconflictFlushConss() call;
5173  * for reconvergence constraints for continuous variables we can only use the "negation" !(x <= u) == (x >= u);
5174  * during conflict analysis, we treat a continuous bound "x >= u" in the conflict set as "x > u", and in the
5175  * generated constraint this is negated again to "x <= u" which is correct.
5176  */
5177  uipvar = SCIPbdchginfoGetVar(uip);
5178  oppositeuipboundtype = SCIPboundtypeOpposite(SCIPbdchginfoGetBoundtype(uip));
5179  oppositeuipbound = SCIPbdchginfoGetNewbound(uip);
5180  if( SCIPvarIsIntegral(uipvar) )
5181  {
5182  assert(SCIPsetIsIntegral(set, oppositeuipbound));
5183  oppositeuipbound += (oppositeuipboundtype == SCIP_BOUNDTYPE_LOWER ? +1.0 : -1.0);
5184  }
5185  SCIP_CALL( conflictCreateTmpBdchginfo(conflict, blkmem, set, uipvar, oppositeuipboundtype, \
5186  oppositeuipboundtype == SCIP_BOUNDTYPE_LOWER ? SCIP_REAL_MIN : SCIP_REAL_MAX, oppositeuipbound, &oppositeuip) );
5187 
5188  /* put the negated UIP into the conflict set */
5189  SCIP_CALL( conflictAddConflictBound(conflict, blkmem, set, oppositeuip, oppositeuipbound) );
5190 
5191  /* put positive UIP into priority queue */
5192  SCIP_CALL( conflictQueueBound(conflict, set, uip, SCIPbdchginfoGetNewbound(uip) ) );
5193 
5194  /* resolve the queue until the next UIP is reached */
5195  bdchginfo = conflictFirstCand(conflict);
5196  nextuip = NULL;
5197  nresolutions = 0;
5198  while( bdchginfo != NULL && validdepth <= maxvaliddepth )
5199  {
5200  SCIP_BDCHGINFO* nextbdchginfo;
5201  SCIP_Real relaxedbd;
5202  SCIP_Bool forceresolve;
5203  int bdchgdepth;
5204 
5205  /* check if the next bound change must be resolved in every case */
5206  forceresolve = (SCIPpqueueNElems(conflict->forcedbdchgqueue) > 0);
5207 
5208  /* remove currently processed candidate and get next conflicting bound from the conflict candidate queue before
5209  * we remove the candidate we have to collect the relaxed bound since removing the candidate from the queue
5210  * invalidates the relaxed bound
5211  */
5212  assert(bdchginfo == conflictFirstCand(conflict));
5213  relaxedbd = SCIPbdchginfoGetRelaxedBound(bdchginfo);
5214  bdchginfo = conflictRemoveCand(conflict);
5215  nextbdchginfo = conflictFirstCand(conflict);
5216  bdchgdepth = SCIPbdchginfoGetDepth(bdchginfo);
5217  assert(bdchginfo != NULL);
5218  assert(!SCIPbdchginfoIsRedundant(bdchginfo));
5219  assert(nextbdchginfo == NULL || SCIPbdchginfoGetDepth(bdchginfo) >= SCIPbdchginfoGetDepth(nextbdchginfo)
5220  || forceresolve);
5221  assert(bdchgdepth <= firstuipdepth);
5222 
5223  /* bound changes that are higher in the tree than the valid depth of the conflict can be ignored;
5224  * multiple insertions of the same bound change can be ignored
5225  */
5226  if( bdchgdepth > validdepth && bdchginfo != nextbdchginfo )
5227  {
5228  SCIP_VAR* actvar;
5229  SCIP_Bool resolved;
5230 
5231  actvar = SCIPbdchginfoGetVar(bdchginfo);
5232  assert(actvar != NULL);
5233  assert(SCIPvarIsActive(actvar));
5234 
5235  /* check if we have to resolve the bound change in this depth level
5236  * - the starting uip has to be resolved
5237  * - a bound change should be resolved, if it is in the fuip's depth level and not the
5238  * next uip (i.e., if it is not the last bound change in the fuip's depth level)
5239  * - a forced bound change must be resolved in any case
5240  */
5241  resolved = FALSE;
5242  if( bdchginfo == uip
5243  || (bdchgdepth == firstuipdepth
5244  && nextbdchginfo != NULL
5245  && SCIPbdchginfoGetDepth(nextbdchginfo) == bdchgdepth)
5246  || forceresolve )
5247  {
5248  SCIP_CALL( conflictResolveBound(conflict, set, bdchginfo, relaxedbd, validdepth, &resolved) );
5249  }
5250 
5251  if( resolved )
5252  nresolutions++;
5253  else if( forceresolve )
5254  {
5255  /* variable cannot enter the conflict clause: we have to make the conflict clause local, s.t.
5256  * the unresolved bound change is active in the whole sub tree of the conflict clause
5257  */
5258  assert(bdchgdepth >= validdepth);
5259  validdepth = bdchgdepth;
5260 
5261  SCIPsetDebugMsg(set, "couldn't resolve forced bound change on <%s> -> new valid depth: %d\n",
5262  SCIPvarGetName(actvar), validdepth);
5263  }
5264  else if( bdchginfo != uip )
5265  {
5266  assert(conflict->conflictset != NULL);
5267  assert(conflict->conflictset->nbdchginfos >= 1); /* starting UIP is already member of the conflict set */
5268 
5269  /* if this is the first variable of the conflict set besides the current starting UIP, it is the next
5270  * UIP (or the first unresolvable bound change)
5271  */
5272  if( bdchgdepth == firstuipdepth && conflict->conflictset->nbdchginfos == 1 )
5273  {
5274  assert(nextuip == NULL);
5275  nextuip = bdchginfo;
5276  }
5277 
5278  /* put bound change into the conflict set */
5279  SCIP_CALL( conflictAddConflictBound(conflict, blkmem, set, bdchginfo, relaxedbd) );
5280  assert(conflict->conflictset->nbdchginfos >= 2);
5281  }
5282  else
5283  assert(conflictFirstCand(conflict) == NULL); /* the starting UIP was not resolved */
5284  }
5285 
5286  /* get next conflicting bound from the conflict candidate queue (this does not need to be nextbdchginfo, because
5287  * due to resolving the bound changes, a variable could be added to the queue which must be
5288  * resolved before nextbdchginfo)
5289  */
5290  bdchginfo = conflictFirstCand(conflict);
5291  }
5292  assert(nextuip != uip);
5293 
5294  /* if only one propagation was resolved, the reconvergence constraint is already member of the constraint set
5295  * (it is exactly the constraint that produced the propagation)
5296  */
5297  if( nextuip != NULL && nresolutions >= 2 && bdchginfo == NULL && validdepth <= maxvaliddepth )
5298  {
5299  int nlits;
5300  SCIP_Bool success;
5301 
5302  assert(SCIPbdchginfoGetDepth(nextuip) == SCIPbdchginfoGetDepth(uip));
5303 
5304  /* check conflict graph frontier on debugging solution */
5305  SCIP_CALL( SCIPdebugCheckConflictFrontier(blkmem, set, tree->path[validdepth], \
5306  bdchginfo, conflict->conflictset->bdchginfos, conflict->conflictset->relaxedbds, \
5307  conflict->conflictset->nbdchginfos, conflict->bdchgqueue, conflict->forcedbdchgqueue) ); /*lint !e506 !e774*/
5308 
5309  SCIPsetDebugMsg(set, "creating reconvergence constraint from UIP <%s> to UIP <%s> in depth %d with %d literals after %d resolutions\n",
5311  SCIPbdchginfoGetDepth(uip), conflict->conflictset->nbdchginfos, nresolutions);
5312 
5313  /* call the conflict handlers to create a conflict set */
5314  SCIP_CALL( conflictAddConflictset(conflict, blkmem, set, stat, tree, validdepth, diving, FALSE, &success, &nlits) );
5315  if( success )
5316  {
5317  (*nreconvconss)++;
5318  (*nreconvliterals) += nlits;
5319  }
5320  }
5321 
5322  /* clear the conflict candidate queue and the conflict set (to make sure, oppositeuip is not referenced anymore) */
5323  conflictClear(conflict);
5324 
5325  uip = nextuip;
5326  }
5327 
5328  conflict->conflictset->conflicttype = conftype;
5329  conflict->conflictset->usescutoffbound = usescutoffbound;
5330 
5331  return SCIP_OKAY;
5332 }
5333 
5334 /** analyzes conflicting bound changes that were added with calls to SCIPconflictAddBound() and
5335  * SCIPconflictAddRelaxedBound(), and on success, calls the conflict handlers to create a conflict constraint out of
5336  * the resulting conflict set; afterwards the conflict queue and the conflict set is cleared
5337  */
5338 static
5340  SCIP_CONFLICT* conflict, /**< conflict analysis data */
5341  BMS_BLKMEM* blkmem, /**< block memory of transformed problem */
5342  SCIP_SET* set, /**< global SCIP settings */
5343  SCIP_STAT* stat, /**< problem statistics */
5344  SCIP_PROB* prob, /**< problem data */
5345  SCIP_TREE* tree, /**< branch and bound tree */
5346  SCIP_Bool diving, /**< are we in strong branching or diving mode? */
5347  int validdepth, /**< minimal depth level at which the initial conflict set is valid */
5348  SCIP_Bool mustresolve, /**< should the conflict set only be used, if a resolution was applied? */
5349  int* nconss, /**< pointer to store the number of generated conflict constraints */
5350  int* nliterals, /**< pointer to store the number of literals in generated conflict constraints */
5351  int* nreconvconss, /**< pointer to store the number of generated reconvergence constraints */
5352  int* nreconvliterals /**< pointer to store the number of literals generated reconvergence constraints */
5353  )
5354 {
5355  SCIP_BDCHGINFO* bdchginfo;
5356  SCIP_BDCHGINFO** firstuips;
5357  SCIP_CONFTYPE conftype;
5358  int nfirstuips;
5359  int focusdepth;
5360  int currentdepth;
5361  int maxvaliddepth;
5362  int resolvedepth;
5363  int nresolutions;
5364  int lastconsnresolutions;
5365  int lastconsresoldepth;
5366 
5367  assert(conflict != NULL);
5368  assert(conflict->conflictset != NULL);
5369  assert(conflict->conflictset->nbdchginfos >= 0);
5370  assert(set != NULL);
5371  assert(stat != NULL);
5372  assert(0 <= validdepth && validdepth <= SCIPtreeGetCurrentDepth(tree));
5373  assert(nconss != NULL);
5374  assert(nliterals != NULL);
5375  assert(nreconvconss != NULL);
5376  assert(nreconvliterals != NULL);
5377 
5378  focusdepth = SCIPtreeGetFocusDepth(tree);
5379  currentdepth = SCIPtreeGetCurrentDepth(tree);
5380  assert(currentdepth == tree->pathlen-1);
5381  assert(focusdepth <= currentdepth);
5382 
5383  resolvedepth = ((set->conf_fuiplevels >= 0 && set->conf_fuiplevels <= currentdepth)
5384  ? currentdepth - set->conf_fuiplevels + 1 : 0);
5385  assert(0 <= resolvedepth && resolvedepth <= currentdepth + 1);
5386 
5387  /* if we must resolve at least one bound change, find the first UIP at least in the last depth level */
5388  if( mustresolve )
5389  resolvedepth = MIN(resolvedepth, currentdepth);
5390 
5391  SCIPsetDebugMsg(set, "analyzing conflict with %d+%d conflict candidates and starting conflict set of size %d in depth %d (resolvedepth=%d)\n",
5393  conflict->conflictset->nbdchginfos, currentdepth, resolvedepth);
5394 
5395  *nconss = 0;
5396  *nliterals = 0;
5397  *nreconvconss = 0;
5398  *nreconvliterals = 0;
5399 
5400  /* check, whether local conflicts are allowed; however, don't generate conflict constraints that are only valid in the
5401  * probing path and not in the problem tree (i.e. that exceed the focusdepth)
5402  */
5403  maxvaliddepth = (set->conf_allowlocal ? MIN(currentdepth-1, focusdepth) : 0);
5404  if( validdepth > maxvaliddepth )
5405  return SCIP_OKAY;
5406 
5407  /* allocate temporary memory for storing first UIPs (in each depth level, at most two bound changes can be flagged
5408  * as UIP, namely a binary and a non-binary bound change)
5409  */
5410  SCIP_CALL( SCIPsetAllocBufferArray(set, &firstuips, 2*(currentdepth+1)) ); /*lint !e647*/
5411 
5412  /* process all bound changes in the conflict candidate queue */
5413  nresolutions = 0;
5414  lastconsnresolutions = (mustresolve ? 0 : -1);
5415  lastconsresoldepth = (mustresolve ? currentdepth : INT_MAX);
5416  bdchginfo = conflictFirstCand(conflict);
5417  nfirstuips = 0;
5418 
5419  /* check if the initial reason on debugging solution */
5420  SCIP_CALL( SCIPdebugCheckConflictFrontier(blkmem, set, tree->path[validdepth], \
5421  NULL, conflict->conflictset->bdchginfos, conflict->conflictset->relaxedbds, conflict->conflictset->nbdchginfos, \
5422  conflict->bdchgqueue, conflict->forcedbdchgqueue) ); /*lint !e506 !e774*/
5423 
5424  while( bdchginfo != NULL && validdepth <= maxvaliddepth )
5425  {
5426  SCIP_BDCHGINFO* nextbdchginfo;
5427  SCIP_Real relaxedbd;
5428  SCIP_Bool forceresolve;
5429  int bdchgdepth;
5430 
5431  assert(!SCIPbdchginfoIsRedundant(bdchginfo));
5432 
5433  /* check if the next bound change must be resolved in every case */
5434  forceresolve = (SCIPpqueueNElems(conflict->forcedbdchgqueue) > 0);
5435 
5436  /* resolve next bound change in queue */
5437  bdchgdepth = SCIPbdchginfoGetDepth(bdchginfo);
5438  assert(0 <= bdchgdepth && bdchgdepth <= currentdepth);
5439  assert(SCIPvarIsActive(SCIPbdchginfoGetVar(bdchginfo)));
5440  assert(bdchgdepth < tree->pathlen);
5441  assert(tree->path[bdchgdepth] != NULL);
5442  assert(tree->path[bdchgdepth]->domchg != NULL);
5443  assert(SCIPbdchginfoGetPos(bdchginfo) < (int)tree->path[bdchgdepth]->domchg->domchgbound.nboundchgs);
5444  assert(tree->path[bdchgdepth]->domchg->domchgbound.boundchgs[SCIPbdchginfoGetPos(bdchginfo)].var
5445  == SCIPbdchginfoGetVar(bdchginfo));
5446  assert(tree->path[bdchgdepth]->domchg->domchgbound.boundchgs[SCIPbdchginfoGetPos(bdchginfo)].newbound
5447  == SCIPbdchginfoGetNewbound(bdchginfo)
5450  == SCIPbdchginfoGetNewbound(bdchginfo)); /*lint !e777*/
5451  assert((SCIP_BOUNDTYPE)tree->path[bdchgdepth]->domchg->domchgbound.boundchgs[SCIPbdchginfoGetPos(bdchginfo)].boundtype
5452  == SCIPbdchginfoGetBoundtype(bdchginfo));
5453 
5454  /* create intermediate conflict constraint */
5455  assert(nresolutions >= lastconsnresolutions);
5456  if( !forceresolve )
5457  {
5458  if( nresolutions == lastconsnresolutions )
5459  lastconsresoldepth = bdchgdepth; /* all intermediate depth levels consisted of only unresolved bound changes */
5460  else if( bdchgdepth < lastconsresoldepth && (set->conf_interconss == -1 || *nconss < set->conf_interconss) )
5461  {
5462  int nlits;
5463  SCIP_Bool success;
5464 
5465  /* call the conflict handlers to create a conflict set */
5466  SCIPsetDebugMsg(set, "creating intermediate conflictset after %d resolutions up to depth %d (valid at depth %d): %d conflict bounds, %d bounds in queue\n",
5467  nresolutions, bdchgdepth, validdepth, conflict->conflictset->nbdchginfos,
5468  SCIPpqueueNElems(conflict->bdchgqueue));
5469 
5470  SCIP_CALL( conflictAddConflictset(conflict, blkmem, set, stat, tree, validdepth, diving, TRUE, &success, &nlits) );
5471  lastconsnresolutions = nresolutions;
5472  lastconsresoldepth = bdchgdepth;
5473  if( success )
5474  {
5475  (*nconss)++;
5476  (*nliterals) += nlits;
5477  }
5478  }
5479  }
5480 
5481  /* remove currently processed candidate and get next conflicting bound from the conflict candidate queue before
5482  * we remove the candidate we have to collect the relaxed bound since removing the candidate from the queue
5483  * invalidates the relaxed bound
5484  */
5485  assert(bdchginfo == conflictFirstCand(conflict));
5486  relaxedbd = SCIPbdchginfoGetRelaxedBound(bdchginfo);
5487  bdchginfo = conflictRemoveCand(conflict);
5488  nextbdchginfo = conflictFirstCand(conflict);
5489  assert(bdchginfo != NULL);
5490  assert(!SCIPbdchginfoIsRedundant(bdchginfo));
5491  assert(nextbdchginfo == NULL || SCIPbdchginfoGetDepth(bdchginfo) >= SCIPbdchginfoGetDepth(nextbdchginfo)
5492  || forceresolve);
5493 
5494  /* we don't need to resolve bound changes that are already active in the valid depth of the current conflict set,