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*/
1654  assert(SCIP_BOUNDTYPE_UPPER == TRUE);/*lint !e641*/
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 )
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*/
2294  assert(SCIP_BOUNDTYPE_UPPER == TRUE); /*lint !e641*/
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  goto TERMINATE;
2436  }
2437 
2438 #ifdef SCIP_DEBUG
2439  if( *nbdchgs > 0 )
2440  {
2441  SCIPsetDebugMsg(set, "conflict set (%p) led to %d global bound reductions\n", (void*) conflictset, *nbdchgs);
2442  }
2443 #endif
2444 
2445  /* remove as redundant marked variables */
2446  if( *redundant )
2447  {
2448  SCIPsetDebugMsg(set, "conflict set (%p) is redundant because at least one global reduction, fulfills the conflict constraint\n", (void*)conflictset);
2449 
2450  /* clear the memory array before freeing it */
2451  BMSclearMemoryArray(redundants, nbdchginfos);
2452  }
2453  else if( *nredvars > 0 )
2454  {
2455  assert(bdchginfos == conflictset->bdchginfos);
2456  assert(relaxedbds == conflictset->relaxedbds);
2457  assert(sortvals == conflictset->sortvals);
2458 
2459  for( v = nbdchginfos - 1; v >= 0; --v )
2460  {
2461  /* if conflict variable was marked to be redundant remove it */
2462  if( redundants[v] )
2463  {
2464  SCIPsetDebugMsg(set, "remove redundant variable <%s> from conflict set\n", SCIPvarGetName(SCIPbdchginfoGetVar(bdchginfos[v])));
2465 
2466  bdchginfos[v] = bdchginfos[nbdchginfos - 1];
2467  relaxedbds[v] = relaxedbds[nbdchginfos - 1];
2468  sortvals[v] = sortvals[nbdchginfos - 1];
2469 
2470  /* reset redundants[v] to 0 */
2471  redundants[v] = 0;
2472 
2473  --nbdchginfos;
2474  }
2475  }
2476  assert((*nredvars) + nbdchginfos == conflictset->nbdchginfos);
2477 
2478  SCIPsetDebugMsg(set, "removed %d redundant of %d variables from conflictset (%p)\n", (*nredvars), conflictset->nbdchginfos, (void*)conflictset);
2479  conflictset->nbdchginfos = nbdchginfos;
2480  }
2481  else
2482  {
2483  /* clear the memory array before freeing it */
2484  BMSclearMemoryArray(redundants, nbdchginfos);
2485  }
2486 
2487  TERMINATE:
2488  SCIPsetFreeCleanBufferArray(set, &redundants);
2489  SCIPsetFreeBufferArray(set, &vars);
2490  }
2491 
2492  /* free temporary memory */
2493  SCIPsetFreeBufferArray(set, &nbinimpls);
2494  SCIPsetFreeBufferArray(set, &bounds);
2495  SCIPsetFreeBufferArray(set, &boundtypes);
2496 
2497  *nredvars += ntrivialredvars;
2498 
2499  return SCIP_OKAY;
2500 }
2501 
2502 /** tighten the bound of a singleton variable in a constraint
2503  *
2504  * if the bound is contradicting with a global bound we cannot tighten the bound directly.
2505  * in this case we need to create and add a constraint of size one such that propagating this constraint will
2506  * enforce the infeasibility.
2507  */
2508 static
2510  SCIP_CONFLICT* conflict, /**< conflict analysis data */
2511  SCIP_SET* set, /**< global SCIP settings */
2512  SCIP_STAT* stat, /**< dynamic SCIP statistics */
2513  SCIP_TREE* tree, /**< tree data */
2514  BMS_BLKMEM* blkmem, /**< block memory */
2515  SCIP_PROB* origprob, /**< original problem */
2516  SCIP_PROB* transprob, /**< transformed problem */
2517  SCIP_REOPT* reopt, /**< reoptimization data */
2518  SCIP_LP* lp, /**< LP data */
2519  SCIP_BRANCHCAND* branchcand, /**< branching candidates */
2520  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
2521  SCIP_CLIQUETABLE* cliquetable, /**< clique table */
2522  SCIP_VAR* var, /**< problem variable */
2523  SCIP_Real val, /**< coefficient of the variable */
2524  SCIP_Real rhs, /**< rhs of the constraint */
2525  SCIP_CONFTYPE prooftype, /**< type of the proof */
2526  int validdepth /**< depth where the bound change is valid */
2527  )
2528 {
2529  SCIP_Real newbound;
2530  SCIP_Bool applyglobal;
2531  SCIP_BOUNDTYPE boundtype;
2532 
2533  assert(tree != NULL);
2534  assert(validdepth >= 0);
2535 
2536  applyglobal = (validdepth <= SCIPtreeGetEffectiveRootDepth(tree));
2537 
2538  /* if variable and coefficient are integral the rhs can be rounded down */
2539  if( SCIPvarIsIntegral(var) && SCIPsetIsIntegral(set, val) )
2540  newbound = SCIPsetFeasFloor(set, rhs)/val;
2541  else
2542  newbound = rhs/val;
2543 
2544  boundtype = (val > 0.0 ? SCIP_BOUNDTYPE_UPPER : SCIP_BOUNDTYPE_LOWER);
2545  SCIPvarAdjustBd(var, set, boundtype, &newbound);
2546 
2547  /* skip numerical unstable bound changes */
2548  if( applyglobal
2549  && ((boundtype == SCIP_BOUNDTYPE_LOWER && SCIPsetIsLE(set, newbound, SCIPvarGetLbGlobal(var)))
2550  || (boundtype == SCIP_BOUNDTYPE_UPPER && SCIPsetIsGE(set, newbound, SCIPvarGetUbGlobal(var)))) )
2551  {
2552  return SCIP_OKAY;
2553  }
2554 
2555  /* the new bound contradicts a global bound, we can cutoff the root node immediately */
2556  if( applyglobal
2557  && ((boundtype == SCIP_BOUNDTYPE_LOWER && SCIPsetIsGT(set, newbound, SCIPvarGetUbGlobal(var)))
2558  || (boundtype == SCIP_BOUNDTYPE_UPPER && SCIPsetIsLT(set, newbound, SCIPvarGetLbGlobal(var)))) )
2559  {
2560  SCIPsetDebugMsg(set, "detected global infeasibility at var <%s>: locdom=[%g,%g] glbdom=[%g,%g] new %s bound=%g\n",
2561  SCIPvarGetName(var), SCIPvarGetLbLocal(var),
2563  (boundtype == SCIP_BOUNDTYPE_LOWER ? "lower" : "upper"), newbound);
2564  SCIP_CALL( SCIPnodeCutoff(tree->path[0], set, stat, tree, transprob, origprob, reopt, lp, blkmem) );
2565  }
2566  else
2567  {
2568  if( lp->strongbranching || !applyglobal )
2569  {
2570  SCIP_CONS* cons;
2571  SCIP_Real conslhs;
2572  SCIP_Real consrhs;
2573  char name[SCIP_MAXSTRLEN];
2574 
2575  SCIPsetDebugMsg(set, "add constraint <%s>[%c] %s %g to node #%lld in depth %d\n",
2576  SCIPvarGetName(var), varGetChar(var), boundtype == SCIP_BOUNDTYPE_UPPER ? "<=" : ">=", newbound,
2577  SCIPnodeGetNumber(tree->path[validdepth]), validdepth);
2578 
2579  (void)SCIPsnprintf(name, SCIP_MAXSTRLEN, "pc_fix_%s", SCIPvarGetName(var));
2580 
2581  if( boundtype == SCIP_BOUNDTYPE_UPPER )
2582  {
2583  conslhs = -SCIPsetInfinity(set);
2584  consrhs = newbound;
2585  }
2586  else
2587  {
2588  conslhs = newbound;
2589  consrhs = SCIPsetInfinity(set);
2590  }
2591 
2592  SCIP_CALL( SCIPcreateConsLinear(set->scip, &cons, name, 0, NULL, NULL, conslhs, consrhs,
2594 
2595  SCIP_CALL( SCIPaddCoefLinear(set->scip, cons, var, 1.0) );
2596 
2597  if( applyglobal )
2598  {
2599  SCIP_CALL( SCIPprobAddCons(transprob, set, stat, cons) );
2600  }
2601  else
2602  {
2603  SCIP_CALL( SCIPnodeAddCons(tree->path[validdepth], blkmem, set, stat, tree, cons) );
2604  }
2605 
2606  SCIP_CALL( SCIPconsRelease(&cons, blkmem, set) );
2607  }
2608  else
2609  {
2610  assert(applyglobal);
2611 
2612  SCIPsetDebugMsg(set, "change global %s bound of <%s>[%c]: %g -> %g\n",
2613  (boundtype == SCIP_BOUNDTYPE_LOWER ? "lower" : "upper"),
2614  SCIPvarGetName(var), varGetChar(var),
2615  (boundtype == SCIP_BOUNDTYPE_LOWER ? SCIPvarGetLbGlobal(var) : SCIPvarGetUbGlobal(var)),
2616  newbound);
2617 
2618  SCIP_CALL( SCIPnodeAddBoundchg(tree->path[0], blkmem, set, stat, transprob, origprob, tree, reopt, lp, branchcand, \
2619  eventqueue, cliquetable, var, newbound, boundtype, FALSE) );
2620 
2621  /* mark the node in the validdepth to be propagated again */
2622  SCIPnodePropagateAgain(tree->path[0], set, stat, tree);
2623  }
2624  }
2625 
2626  if( applyglobal )
2627  ++conflict->nglbchgbds;
2628  else
2629  ++conflict->nlocchgbds;
2630 
2631  if( prooftype == SCIP_CONFTYPE_INFEASLP || prooftype == SCIP_CONFTYPE_ALTINFPROOF )
2632  {
2633  ++conflict->dualproofsinfnnonzeros; /* we count a global bound reduction as size 1 */
2634  ++conflict->ndualproofsinfsuccess;
2635  ++conflict->ninflpsuccess;
2636 
2637  if( applyglobal )
2638  ++conflict->ndualproofsinfglobal;
2639  else
2640  ++conflict->ndualproofsinflocal;
2641  }
2642  else
2643  {
2644  ++conflict->dualproofsbndnnonzeros; /* we count a global bound reduction as size 1 */
2645  ++conflict->ndualproofsbndsuccess;
2646  ++conflict->nboundlpsuccess;
2647 
2648  if( applyglobal )
2649  ++conflict->ndualproofsbndglobal;
2650  else
2651  ++conflict->ndualproofsbndlocal;
2652  }
2653 
2654  return SCIP_OKAY;
2655 }
2656 
2657 /** calculates the minimal activity of a given aggregation row */
2658 static
2660  SCIP_SET* set, /**< global SCIP settings */
2661  SCIP_PROB* transprob, /**< transformed problem data */
2662  SCIP_AGGRROW* aggrrow, /**< aggregation row */
2663  SCIP_Real* curvarlbs, /**< current lower bounds of active problem variables (or NULL for global bounds) */
2664  SCIP_Real* curvarubs, /**< current upper bounds of active problem variables (or NULL for global bounds) */
2665  SCIP_Bool* infdelta /**< pointer to store whether at least one variable contributes with an infinite value */
2666  )
2667 {
2668  SCIP_VAR** vars;
2669  SCIP_Real QUAD(minact);
2670  int* inds;
2671  int nnz;
2672  int i;
2673 
2674  vars = SCIPprobGetVars(transprob);
2675  assert(vars != NULL);
2676 
2677  nnz = SCIPaggrRowGetNNz(aggrrow);
2678  inds = SCIPaggrRowGetInds(aggrrow);
2679 
2680  QUAD_ASSIGN(minact, 0.0);
2681 
2682  if( infdelta != NULL )
2683  *infdelta = FALSE;
2684 
2685  for( i = 0; i < nnz; i++ )
2686  {
2687  SCIP_Real val;
2688  SCIP_Real QUAD(delta);
2689  int v = inds[i];
2690 
2691  assert(SCIPvarGetProbindex(vars[v]) == v);
2692 
2693  val = SCIPaggrRowGetProbvarValue(aggrrow, v);
2694 
2695  if( val > 0.0 )
2696  {
2697  SCIP_Real bnd = (curvarlbs == NULL ? SCIPvarGetLbGlobal(vars[v]) : curvarlbs[v]);
2698  SCIPquadprecProdDD(delta, val, bnd);
2699  }
2700  else
2701  {
2702  SCIP_Real bnd = (curvarubs == NULL ? SCIPvarGetUbGlobal(vars[v]) : curvarubs[v]);
2703  SCIPquadprecProdDD(delta, val, bnd);
2704  }
2705 
2706  /* update minimal activity */
2707  SCIPquadprecSumQQ(minact, minact, delta);
2708 
2709  if( infdelta != NULL && SCIPsetIsInfinity(set, REALABS(QUAD_TO_DBL(delta))) )
2710  {
2711  *infdelta = TRUE;
2712  goto TERMINATE;
2713  }
2714  }
2715 
2716  TERMINATE:
2717  /* check whether the minimal activity is infinite */
2718  if( SCIPsetIsInfinity(set, QUAD_TO_DBL(minact)) )
2719  return SCIPsetInfinity(set);
2720  if( SCIPsetIsInfinity(set, -QUAD_TO_DBL(minact)) )
2721  return -SCIPsetInfinity(set);
2722 
2723  return QUAD_TO_DBL(minact);
2724 }
2725 
2726 /** calculates the minimal activity of a given set of bounds and coefficients */
2727 static
2729  SCIP_SET* set, /**< global SCIP settings */
2730  SCIP_PROB* transprob, /**< transformed problem data */
2731  SCIP_Real* coefs, /**< coefficients in sparse representation */
2732  int* inds, /**< non-zero indices */
2733  int nnz, /**< number of non-zero indices */
2734  SCIP_Real* curvarlbs, /**< current lower bounds of active problem variables (or NULL for global bounds) */
2735  SCIP_Real* curvarubs /**< current upper bounds of active problem variables (or NULL for global bounds) */
2736  )
2737 {
2738  SCIP_VAR** vars;
2739  SCIP_Real QUAD(minact);
2740  int i;
2741 
2742  assert(coefs != NULL);
2743  assert(inds != NULL);
2744 
2745  vars = SCIPprobGetVars(transprob);
2746  assert(vars != NULL);
2747 
2748  QUAD_ASSIGN(minact, 0.0);
2749 
2750  for( i = 0; i < nnz; i++ )
2751  {
2752  SCIP_Real val;
2753  SCIP_Real QUAD(delta);
2754  int v = inds[i];
2755 
2756  assert(SCIPvarGetProbindex(vars[v]) == v);
2757 
2758  val = coefs[i];
2759 
2760  if( val > 0.0 )
2761  {
2762  SCIP_Real bnd;
2763 
2764  assert(curvarlbs == NULL || !SCIPsetIsInfinity(set, -curvarlbs[v]));
2765 
2766  bnd = (curvarlbs == NULL ? SCIPvarGetLbGlobal(vars[v]) : curvarlbs[v]);
2767  SCIPquadprecProdDD(delta, val, bnd);
2768  }
2769  else
2770  {
2771  SCIP_Real bnd;
2772 
2773  assert(curvarubs == NULL || !SCIPsetIsInfinity(set, curvarubs[v]));
2774 
2775  bnd = (curvarubs == NULL ? SCIPvarGetUbGlobal(vars[v]) : curvarubs[v]);
2776  SCIPquadprecProdDD(delta, val, bnd);
2777  }
2778 
2779  /* update minimal activity */
2780  SCIPquadprecSumQQ(minact, minact, delta);
2781  }
2782 
2783  /* check whether the minmal activity is infinite */
2784  if( SCIPsetIsInfinity(set, QUAD_TO_DBL(minact)) )
2785  return SCIPsetInfinity(set);
2786  if( SCIPsetIsInfinity(set, -QUAD_TO_DBL(minact)) )
2787  return -SCIPsetInfinity(set);
2788 
2789  return QUAD_TO_DBL(minact);
2790 }
2791 
2792 /** calculates the minimal activity of a given set of bounds and coefficients */
2793 static
2795  SCIP_SET* set, /**< global SCIP settings */
2796  SCIP_PROB* transprob, /**< transformed problem data */
2797  SCIP_Real* coefs, /**< coefficients in sparse representation */
2798  int* inds, /**< non-zero indices */
2799  int nnz, /**< number of non-zero indices */
2800  SCIP_Real* curvarlbs, /**< current lower bounds of active problem variables (or NULL for global bounds) */
2801  SCIP_Real* curvarubs /**< current upper bounds of active problem variables (or NULL for global bounds) */
2802  )
2803 {
2804  SCIP_VAR** vars;
2805  SCIP_Real QUAD(maxact);
2806  int i;
2807 
2808  assert(coefs != NULL);
2809  assert(inds != NULL);
2810 
2811  vars = SCIPprobGetVars(transprob);
2812  assert(vars != NULL);
2813 
2814  QUAD_ASSIGN(maxact, 0.0);
2815 
2816  for( i = 0; i < nnz; i++ )
2817  {
2818  SCIP_Real val;
2819  SCIP_Real QUAD(delta);
2820  int v = inds[i];
2821 
2822  assert(SCIPvarGetProbindex(vars[v]) == v);
2823 
2824  val = coefs[i];
2825 
2826  if( val < 0.0 )
2827  {
2828  SCIP_Real bnd;
2829 
2830  assert(curvarlbs == NULL || !SCIPsetIsInfinity(set, -curvarlbs[v]));
2831 
2832  bnd = (curvarlbs == NULL ? SCIPvarGetLbGlobal(vars[v]) : curvarlbs[v]);
2833  SCIPquadprecProdDD(delta, val, bnd);
2834  }
2835  else
2836  {
2837  SCIP_Real bnd;
2838 
2839  assert(curvarubs == NULL || !SCIPsetIsInfinity(set, curvarubs[v]));
2840 
2841  bnd = (curvarubs == NULL ? SCIPvarGetUbGlobal(vars[v]) : curvarubs[v]);
2842  SCIPquadprecProdDD(delta, val, bnd);
2843  }
2844 
2845  /* update maximal activity */
2846  SCIPquadprecSumQQ(maxact, maxact, delta);
2847  }
2848 
2849  /* check whether the maximal activity got infinite */
2850  if( SCIPsetIsInfinity(set, QUAD_TO_DBL(maxact)) )
2851  return SCIPsetInfinity(set);
2852  if( SCIPsetIsInfinity(set, -QUAD_TO_DBL(maxact)) )
2853  return -SCIPsetInfinity(set);
2854 
2855  return QUAD_TO_DBL(maxact);
2856 }
2857 
2858 static
2860  SCIP_CONFLICT* conflict, /**< conflict analysis data */
2861  SCIP_SET* set, /**< global SCIP settings */
2862  SCIP_STAT* stat, /**< dynamic SCIP statistics */
2863  SCIP_REOPT* reopt, /**< reoptimization data */
2864  SCIP_TREE* tree, /**< tree data */
2865  BMS_BLKMEM* blkmem, /**< block memory */
2866  SCIP_PROB* origprob, /**< original problem */
2867  SCIP_PROB* transprob, /**< transformed problem */
2868  SCIP_LP* lp, /**< LP data */
2869  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
2870  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
2871  SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
2872  SCIP_Real* coefs, /**< coefficients in sparse representation */
2873  int* inds, /**< non-zero indices */
2874  int nnz, /**< number of non-zero indices */
2875  SCIP_Real rhs, /**< right-hand side */
2876  SCIP_CONFTYPE conflicttype, /**< type of the conflict */
2877  int validdepth /**< depth where the proof is valid */
2878  )
2879 {
2880  SCIP_VAR** vars;
2881  SCIP_Real minact;
2882  int i;
2883 
2884  assert(coefs != NULL);
2885  assert(inds != NULL);
2886  assert(nnz >= 0);
2887 
2888  vars = SCIPprobGetVars(transprob);
2889  minact = getMinActivity(set, transprob, coefs, inds, nnz, NULL, NULL);
2890 
2891  /* we cannot find global tightenings */
2892  if( SCIPsetIsInfinity(set, -minact) )
2893  return SCIP_OKAY;
2894 
2895  for( i = 0; i < nnz; i++ )
2896  {
2897  SCIP_VAR* var;
2898  SCIP_Real val;
2899  SCIP_Real resminact;
2900  SCIP_Real lb;
2901  SCIP_Real ub;
2902  int pos;
2903 
2904  pos = inds[i];
2905  val = coefs[i];
2906  var = vars[pos];
2907  lb = SCIPvarGetLbGlobal(var);
2908  ub = SCIPvarGetUbGlobal(var);
2909 
2910  assert(!SCIPsetIsZero(set, val));
2911 
2912  resminact = minact;
2913 
2914  /* we got a potential new upper bound */
2915  if( val > 0.0 )
2916  {
2917  SCIP_Real newub;
2918 
2919  resminact -= (val * lb);
2920  newub = (rhs - resminact)/val;
2921 
2922  if( SCIPsetIsInfinity(set, newub) )
2923  continue;
2924 
2925  /* we cannot tighten the upper bound */
2926  if( SCIPsetIsGE(set, newub, ub) )
2927  continue;
2928 
2929  SCIP_CALL( tightenSingleVar(conflict, set, stat, tree, blkmem, origprob, transprob, reopt, lp, branchcand, \
2930  eventqueue, cliquetable, var, val, rhs-resminact, conflicttype, validdepth) );
2931  }
2932  /* we got a potential new lower bound */
2933  else
2934  {
2935  SCIP_Real newlb;
2936 
2937  resminact -= (val * ub);
2938  newlb = (rhs - resminact)/val;
2939 
2940  if( SCIPsetIsInfinity(set, -newlb) )
2941  continue;
2942 
2943  /* we cannot tighten the lower bound */
2944  if( SCIPsetIsLE(set, newlb, lb) )
2945  continue;
2946 
2947  SCIP_CALL( tightenSingleVar(conflict, set, stat, tree, blkmem, origprob, transprob, reopt, lp, branchcand, \
2948  eventqueue, cliquetable, var, val, rhs-resminact, conflicttype, validdepth) );
2949  }
2950 
2951  /* the minimal activity should stay unchanged because we tightened the bound that doesn't contribute to the
2952  * minimal activity
2953  */
2954  assert(SCIPsetIsEQ(set, minact, getMinActivity(set, transprob, coefs, inds, nnz, NULL, NULL)));
2955  }
2956 
2957  return SCIP_OKAY;
2958 }
2959 
2960 
2961 /** creates a proof constraint and tries to add it to the storage */
2962 static
2964  SCIP_CONFLICT* conflict, /**< conflict analysis data */
2965  SCIP_CONFLICTSTORE* conflictstore, /**< conflict pool data */
2966  SCIP_PROOFSET* proofset, /**< proof set */
2967  SCIP_SET* set, /**< global SCIP settings */
2968  SCIP_STAT* stat, /**< dynamic SCIP statistics */
2969  SCIP_PROB* origprob, /**< original problem */
2970  SCIP_PROB* transprob, /**< transformed problem */
2971  SCIP_TREE* tree, /**< tree data */
2972  SCIP_REOPT* reopt, /**< reoptimization data */
2973  SCIP_LP* lp, /**< LP data */
2974  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
2975  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
2976  SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
2977  BMS_BLKMEM* blkmem /**< block memory */
2978  )
2979 {
2980  SCIP_CONS* cons;
2981  SCIP_CONS* upgdcons;
2982  SCIP_VAR** vars;
2983  SCIP_Real* coefs;
2984  int* inds;
2985  SCIP_Real rhs;
2986  SCIP_Real fillin;
2987  SCIP_Real globalminactivity;
2988  SCIP_Bool applyglobal;
2989  SCIP_Bool toolong;
2990  SCIP_Bool contonly;
2991  SCIP_Bool hasrelaxvar;
2992  SCIP_CONFTYPE conflicttype;
2993  char name[SCIP_MAXSTRLEN];
2994  int nnz;
2995  int i;
2996 
2997  assert(conflict != NULL);
2998  assert(conflictstore != NULL);
2999  assert(proofset != NULL);
3000  assert(proofset->validdepth == 0 || proofset->validdepth < SCIPtreeGetFocusDepth(tree));
3001 
3002  nnz = proofsetGetNVars(proofset);
3003 
3004  if( nnz == 0 )
3005  return SCIP_OKAY;
3006 
3007  vars = SCIPprobGetVars(transprob);
3008 
3009  rhs = proofsetGetRhs(proofset);
3010  assert(!SCIPsetIsInfinity(set, rhs));
3011 
3012  coefs = proofsetGetVals(proofset);
3013  assert(coefs != NULL);
3014 
3015  inds = proofsetGetInds(proofset);
3016  assert(inds != NULL);
3017 
3018  conflicttype = proofsetGetConftype(proofset);
3019 
3020  applyglobal = (proofset->validdepth <= SCIPtreeGetEffectiveRootDepth(tree));
3021 
3022  if( applyglobal )
3023  {
3024  SCIP_Real globalmaxactivity = getMaxActivity(set, transprob, coefs, inds, nnz, NULL, NULL);
3025 
3026  /* check whether the alternative proof is redundant */
3027  if( SCIPsetIsLE(set, globalmaxactivity, rhs) )
3028  return SCIP_OKAY;
3029 
3030  /* check whether the constraint proves global infeasibility */
3031  globalminactivity = getMinActivity(set, transprob, coefs, inds, nnz, NULL, NULL);
3032  if( SCIPsetIsGT(set, globalminactivity, rhs) )
3033  {
3034  SCIPsetDebugMsg(set, "detect global infeasibility: minactivity=%g, rhs=%g\n", globalminactivity, rhs);
3035 
3036  SCIP_CALL( SCIPnodeCutoff(tree->path[proofset->validdepth], set, stat, tree, transprob, origprob, reopt, lp, blkmem) );
3037 
3038  goto UPDATESTATISTICS;
3039  }
3040  }
3041 
3042  if( set->conf_minmaxvars >= nnz )
3043  toolong = FALSE;
3044  else
3045  {
3046  SCIP_Real maxnnz;
3047 
3048  if( transprob->startnconss < 100 )
3049  maxnnz = 0.85 * transprob->nvars;
3050  else
3051  maxnnz = (SCIP_Real)transprob->nvars;
3052 
3053  fillin = nnz;
3054  if( conflicttype == SCIP_CONFTYPE_INFEASLP || conflicttype == SCIP_CONFTYPE_ALTINFPROOF )
3055  {
3056  fillin += SCIPconflictstoreGetNDualInfProofs(conflictstore) * SCIPconflictstoreGetAvgNnzDualInfProofs(conflictstore);
3057  fillin /= (SCIPconflictstoreGetNDualInfProofs(conflictstore) + 1.0);
3058  toolong = (fillin > MIN(2.0 * stat->avgnnz, maxnnz));
3059  }
3060  else
3061  {
3062  assert(conflicttype == SCIP_CONFTYPE_BNDEXCEEDING || conflicttype == SCIP_CONFTYPE_ALTBNDPROOF);
3063 
3064  fillin += SCIPconflictstoreGetNDualBndProofs(conflictstore) * SCIPconflictstoreGetAvgNnzDualBndProofs(conflictstore);
3065  fillin /= (SCIPconflictstoreGetNDualBndProofs(conflictstore) + 1.0);
3066  toolong = (fillin > MIN(1.5 * stat->avgnnz, maxnnz));
3067  }
3068 
3069  toolong = (toolong && (nnz > set->conf_maxvarsfac * transprob->nvars));
3070  }
3071 
3072  /* don't store global dual proofs that are too long / have too many non-zeros */
3073  if( toolong )
3074  {
3075  if( applyglobal )
3076  {
3077  SCIP_CALL( propagateLongProof(conflict, set, stat, reopt, tree, blkmem, origprob, transprob, lp, branchcand,
3078  eventqueue, cliquetable, coefs, inds, nnz, rhs, conflicttype, proofset->validdepth) );
3079  }
3080  return SCIP_OKAY;
3081  }
3082 
3083  /* check if conflict contains variables that are invalid after a restart to label it appropriately */
3084  hasrelaxvar = FALSE;
3085  contonly = TRUE;
3086  for( i = 0; i < nnz && (!hasrelaxvar || contonly); ++i )
3087  {
3088  hasrelaxvar |= SCIPvarIsRelaxationOnly(vars[inds[i]]);
3089 
3090  if( SCIPvarIsIntegral(vars[inds[i]]) )
3091  contonly = FALSE;
3092  }
3093 
3094  if( !applyglobal && contonly )
3095  return SCIP_OKAY;
3096 
3097  if( conflicttype == SCIP_CONFTYPE_INFEASLP || conflicttype == SCIP_CONFTYPE_ALTINFPROOF )
3098  (void)SCIPsnprintf(name, SCIP_MAXSTRLEN, "dualproof_inf_%d", conflict->ndualproofsinfsuccess);
3099  else if( conflicttype == SCIP_CONFTYPE_BNDEXCEEDING || conflicttype == SCIP_CONFTYPE_ALTBNDPROOF )
3100  (void)SCIPsnprintf(name, SCIP_MAXSTRLEN, "dualproof_bnd_%d", conflict->ndualproofsbndsuccess);
3101  else
3102  return SCIP_INVALIDCALL;
3103 
3104  SCIP_CALL( SCIPcreateConsLinear(set->scip, &cons, name, 0, NULL, NULL, -SCIPsetInfinity(set), rhs,
3105  FALSE, FALSE, FALSE, FALSE, TRUE, !applyglobal,
3106  FALSE, TRUE, TRUE, FALSE) );
3107 
3108  for( i = 0; i < nnz; i++ )
3109  {
3110  int v = inds[i];
3111  SCIP_CALL( SCIPaddCoefLinear(set->scip, cons, vars[v], coefs[i]) );
3112  }
3113 
3114  /* do not upgrade linear constraints of size 1 */
3115  if( nnz > 1 )
3116  {
3117  upgdcons = NULL;
3118  /* try to automatically convert a linear constraint into a more specific and more specialized constraint */
3119  SCIP_CALL( SCIPupgradeConsLinear(set->scip, cons, &upgdcons) );
3120  if( upgdcons != NULL )
3121  {
3122  SCIP_CALL( SCIPreleaseCons(set->scip, &cons) );
3123  cons = upgdcons;
3124 
3125  if( conflicttype == SCIP_CONFTYPE_INFEASLP )
3126  conflicttype = SCIP_CONFTYPE_ALTINFPROOF;
3127  else if( conflicttype == SCIP_CONFTYPE_BNDEXCEEDING )
3128  conflicttype = SCIP_CONFTYPE_ALTBNDPROOF;
3129  }
3130  }
3131 
3132  /* mark constraint to be a conflict */
3133  SCIPconsMarkConflict(cons);
3134 
3135  /* add constraint to storage */
3136  if( conflicttype == SCIP_CONFTYPE_INFEASLP || conflicttype == SCIP_CONFTYPE_ALTINFPROOF )
3137  {
3138  /* add dual proof to storage */
3139  SCIP_CALL( SCIPconflictstoreAddDualraycons(conflictstore, cons, blkmem, set, stat, transprob, reopt, hasrelaxvar) );
3140  }
3141  else
3142  {
3143  SCIP_Real scale = 1.0;
3144  SCIP_Bool updateside = FALSE;
3145 
3146  /* In some cases the constraint could not be updated to a more special type. However, it is possible that
3147  * constraint got scaled. Therefore, we need to be very careful when updating the lhs/rhs after the incumbent
3148  * solution has improved.
3149  */
3150  if( conflicttype == SCIP_CONFTYPE_BNDEXCEEDING )
3151  {
3152  SCIP_Real side;
3153 
3154 #ifndef NDEBUG
3155  SCIP_CONSHDLR* conshdlr = SCIPconsGetHdlr(cons);
3156 
3157  assert(conshdlr != NULL);
3158  assert(strcmp(SCIPconshdlrGetName(conshdlr), "linear") == 0);
3159 #endif
3160  side = SCIPgetLhsLinear(set->scip, cons);
3161 
3162  if( !SCIPsetIsInfinity(set, -side) )
3163  {
3164  if( SCIPsetIsZero(set, side) )
3165  {
3166  scale = 1.0;
3167  }
3168  else
3169  {
3170  scale = proofsetGetRhs(proofset) / side;
3171  assert(SCIPsetIsNegative(set, scale));
3172  }
3173  }
3174  else
3175  {
3176  side = SCIPgetRhsLinear(set->scip, cons);
3177  assert(!SCIPsetIsInfinity(set, side));
3178 
3179  if( SCIPsetIsZero(set, side) )
3180  {
3181  scale = 1.0;
3182  }
3183  else
3184  {
3185  scale = proofsetGetRhs(proofset) / side;
3186  assert(SCIPsetIsPositive(set, scale));
3187  }
3188  }
3189  updateside = TRUE;
3190  }
3191 
3192  /* add dual proof to storage */
3193  SCIP_CALL( SCIPconflictstoreAddDualsolcons(conflictstore, cons, blkmem, set, stat, transprob, reopt, scale, updateside, hasrelaxvar) );
3194  }
3195 
3196  if( applyglobal )
3197  {
3198  /* add the constraint to the global problem */
3199  SCIP_CALL( SCIPprobAddCons(transprob, set, stat, cons) );
3200  }
3201  else
3202  {
3203  SCIP_CALL( SCIPnodeAddCons(tree->path[proofset->validdepth], blkmem, set, stat, tree, cons) );
3204  }
3205 
3206  SCIPsetDebugMsg(set, "added proof-constraint to node %p (#%lld) in depth %d (nproofconss %d)\n",
3207  (void*)tree->path[proofset->validdepth], SCIPnodeGetNumber(tree->path[proofset->validdepth]),
3208  proofset->validdepth,
3209  (conflicttype == SCIP_CONFTYPE_INFEASLP || conflicttype == SCIP_CONFTYPE_ALTINFPROOF)
3211 
3212  /* release the constraint */
3213  SCIP_CALL( SCIPreleaseCons(set->scip, &cons) );
3214 
3215  UPDATESTATISTICS:
3216  /* update statistics */
3217  if( conflicttype == SCIP_CONFTYPE_INFEASLP || conflicttype == SCIP_CONFTYPE_ALTINFPROOF )
3218  {
3219  conflict->dualproofsinfnnonzeros += nnz;
3220  if( applyglobal )
3221  ++conflict->ndualproofsinfglobal;
3222  else
3223  ++conflict->ndualproofsinflocal;
3224  ++conflict->ndualproofsinfsuccess;
3225  }
3226  else
3227  {
3228  assert(conflicttype == SCIP_CONFTYPE_BNDEXCEEDING || conflicttype == SCIP_CONFTYPE_ALTBNDPROOF);
3229  conflict->dualproofsbndnnonzeros += nnz;
3230  if( applyglobal )
3231  ++conflict->ndualproofsbndglobal;
3232  else
3233  ++conflict->ndualproofsbndlocal;
3234 
3235  ++conflict->ndualproofsbndsuccess;
3236  }
3237  return SCIP_OKAY;
3238 }
3239 
3240 /* create proof constraints out of proof sets */
3241 static
3243  SCIP_CONFLICT* conflict, /**< conflict analysis data */
3244  SCIP_CONFLICTSTORE* conflictstore, /**< conflict store */
3245  BMS_BLKMEM* blkmem, /**< block memory */
3246  SCIP_SET* set, /**< global SCIP settings */
3247  SCIP_STAT* stat, /**< dynamic problem statistics */
3248  SCIP_PROB* transprob, /**< transformed problem after presolve */
3249  SCIP_PROB* origprob, /**< original problem */
3250  SCIP_TREE* tree, /**< branch and bound tree */
3251  SCIP_REOPT* reopt, /**< reoptimization data structure */
3252  SCIP_LP* lp, /**< current LP data */
3253  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
3254  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
3255  SCIP_CLIQUETABLE* cliquetable /**< clique table data structure */
3256  )
3257 {
3258  assert(conflict != NULL);
3259 
3261  {
3262  /* only one variable has a coefficient different to zero, we add this bound change instead of a constraint */
3263  if( proofsetGetNVars(conflict->proofset) == 1 )
3264  {
3265  SCIP_VAR** vars;
3266  SCIP_Real* coefs;
3267  int* inds;
3268  SCIP_Real rhs;
3269 
3270  vars = SCIPprobGetVars(transprob);
3271 
3272  coefs = proofsetGetVals(conflict->proofset);
3273  inds = proofsetGetInds(conflict->proofset);
3274  rhs = proofsetGetRhs(conflict->proofset);
3275 
3276  SCIP_CALL( tightenSingleVar(conflict, set, stat, tree, blkmem, origprob, transprob, reopt, lp, \
3277  branchcand, eventqueue, cliquetable, vars[inds[0]], coefs[0], rhs, conflict->proofset->conflicttype,
3278  conflict->proofset->validdepth) );
3279  }
3280  else
3281  {
3282  SCIP_Bool skipinitialproof = FALSE;
3283 
3284  /* prefer an infeasibility proof
3285  *
3286  * todo: check whether this is really what we want
3287  */
3288  if( set->conf_prefinfproof && proofsetGetConftype(conflict->proofset) == SCIP_CONFTYPE_BNDEXCEEDING )
3289  {
3290  int i;
3291 
3292  for( i = 0; i < conflict->nproofsets; i++ )
3293  {
3295  {
3296  skipinitialproof = TRUE;
3297  break;
3298  }
3299  }
3300  }
3301 
3302  if( !skipinitialproof )
3303  {
3304  /* create and add the original proof */
3305  SCIP_CALL( createAndAddProofcons(conflict, conflictstore, conflict->proofset, set, stat, origprob, transprob, \
3306  tree, reopt, lp, branchcand, eventqueue, cliquetable, blkmem) );
3307  }
3308  }
3309 
3310  /* clear the proof set anyway */
3311  proofsetClear(conflict->proofset);
3312  }
3313 
3314  if( conflict->nproofsets > 0 )
3315  {
3316  int i;
3317 
3318  for( i = 0; i < conflict->nproofsets; i++ )
3319  {
3320  assert(conflict->proofsets[i] != NULL);
3321  assert(proofsetGetConftype(conflict->proofsets[i]) != SCIP_CONFTYPE_UNKNOWN);
3322 
3323  /* only one variable has a coefficient different to zero, we add this bound change instead of a constraint */
3324  if( proofsetGetNVars(conflict->proofsets[i]) == 1 )
3325  {
3326  SCIP_VAR** vars;
3327  SCIP_Real* coefs;
3328  int* inds;
3329  SCIP_Real rhs;
3330 
3331  vars = SCIPprobGetVars(transprob);
3332 
3333  coefs = proofsetGetVals(conflict->proofsets[i]);
3334  inds = proofsetGetInds(conflict->proofsets[i]);
3335  rhs = proofsetGetRhs(conflict->proofsets[i]);
3336 
3337  SCIP_CALL( tightenSingleVar(conflict, set, stat, tree, blkmem, origprob, transprob, reopt, lp,
3338  branchcand, eventqueue, cliquetable, vars[inds[0]], coefs[0], rhs,
3339  conflict->proofsets[i]->conflicttype, conflict->proofsets[i]->validdepth) );
3340  }
3341  else
3342  {
3343  /* create and add proof constraint */
3344  SCIP_CALL( createAndAddProofcons(conflict, conflictstore, conflict->proofsets[i], set, stat, origprob, \
3345  transprob, tree, reopt, lp, branchcand, eventqueue, cliquetable, blkmem) );
3346  }
3347  }
3348 
3349  /* free all proofsets */
3350  for( i = 0; i < conflict->nproofsets; i++ )
3351  proofsetFree(&conflict->proofsets[i], blkmem);
3352 
3353  conflict->nproofsets = 0;
3354  }
3355 
3356  return SCIP_OKAY;
3357 }
3358 
3359 /** adds the given conflict set as conflict constraint to the problem */
3360 static
3362  SCIP_CONFLICT* conflict, /**< conflict analysis data */
3363  BMS_BLKMEM* blkmem, /**< block memory */
3364  SCIP_SET* set, /**< global SCIP settings */
3365  SCIP_STAT* stat, /**< dynamic problem statistics */
3366  SCIP_PROB* transprob, /**< transformed problem after presolve */
3367  SCIP_PROB* origprob, /**< original problem */
3368  SCIP_TREE* tree, /**< branch and bound tree */
3369  SCIP_REOPT* reopt, /**< reoptimization data structure */
3370  SCIP_LP* lp, /**< current LP data */
3371  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
3372  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
3373  SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
3374  SCIP_CONFLICTSET* conflictset, /**< conflict set to add to the tree */
3375  int insertdepth, /**< depth level at which the conflict set should be added */
3376  SCIP_Bool* success /**< pointer to store whether the addition was successful */
3377  )
3378 {
3379  SCIP_Bool redundant;
3380  int h;
3381 
3382  assert(conflict != NULL);
3383  assert(tree != NULL);
3384  assert(tree->path != NULL);
3385  assert(conflictset != NULL);
3386  assert(conflictset->validdepth <= insertdepth);
3387  assert(success != NULL);
3388 
3389  *success = FALSE;
3390  redundant = FALSE;
3391 
3392  /* try to derive global bound changes and shorten the conflictset by using implication and clique and variable bound
3393  * information
3394  */
3395  if( conflictset->nbdchginfos > 1 && insertdepth == 0 && !lp->strongbranching )
3396  {
3397  int nbdchgs;
3398  int nredvars;
3399 #ifdef SCIP_DEBUG
3400  int oldnbdchginfos = conflictset->nbdchginfos;
3401 #endif
3402  assert(conflictset->validdepth == 0);
3403 
3404  /* check conflict set on debugging solution */
3405  SCIP_CALL( SCIPdebugCheckConflict(blkmem, set, tree->root, conflictset->bdchginfos, conflictset->relaxedbds, conflictset->nbdchginfos) );
3406 
3407  SCIPclockStart(conflict->dIBclock, set);
3408 
3409  /* find global bound changes which can be derived from the new conflict set */
3410  SCIP_CALL( detectImpliedBounds(set, transprob, conflictset, &nbdchgs, &nredvars, &redundant) );
3411 
3412  /* all variables where removed, we have an infeasibility proof */
3413  if( conflictset->nbdchginfos == 0 )
3414  return SCIP_OKAY;
3415 
3416  /* debug check for reduced conflict set */
3417  if( nredvars > 0 )
3418  {
3419  /* check conflict set on debugging solution */
3420  SCIP_CALL( SCIPdebugCheckConflict(blkmem, set, tree->root, conflictset->bdchginfos, conflictset->relaxedbds, conflictset->nbdchginfos) ); /*lint !e506 !e774*/
3421  }
3422 
3423 #ifdef SCIP_DEBUG
3424  SCIPsetDebugMsg(set, " -> conflict set removed %d redundant variables (old nvars %d, new nvars = %d)\n", nredvars, oldnbdchginfos, conflictset->nbdchginfos);
3425  SCIPsetDebugMsg(set, " -> conflict set led to %d global bound changes %s(cdpt:%d, fdpt:%d, confdpt:%d, len:%d):\n",
3426  nbdchgs, redundant ? "(conflict became redundant) " : "", SCIPtreeGetCurrentDepth(tree), SCIPtreeGetFocusDepth(tree),
3427  conflictset->conflictdepth, conflictset->nbdchginfos);
3428  conflictsetPrint(conflictset);
3429 #endif
3430 
3431  SCIPclockStop(conflict->dIBclock, set);
3432 
3433  if( redundant )
3434  {
3435  if( nbdchgs > 0 )
3436  *success = TRUE;
3437 
3438  return SCIP_OKAY;
3439  }
3440  }
3441 
3442  /* in case the conflict set contains only one bound change which is globally valid we apply that bound change
3443  * directly (except if we are in strong branching or diving - in this case a bound change would yield an unflushed LP
3444  * and is not handled when restoring the information)
3445  *
3446  * @note A bound change can only be applied if it is are related to the active node or if is a global bound
3447  * change. Bound changes which are related to any other node cannot be handled at point due to the internal
3448  * data structure
3449  */
3450  if( conflictset->nbdchginfos == 1 && insertdepth == 0 && !lp->strongbranching && !lp->diving )
3451  {
3452  SCIP_VAR* var;
3453  SCIP_Real bound;
3454  SCIP_BOUNDTYPE boundtype;
3455 
3456  var = conflictset->bdchginfos[0]->var;
3457  assert(var != NULL);
3458 
3459  boundtype = SCIPboundtypeOpposite((SCIP_BOUNDTYPE) conflictset->bdchginfos[0]->boundtype);
3460  bound = conflictset->relaxedbds[0];
3461 
3462  /* for continuous variables, we can only use the relaxed version of the bounds negation: !(x <= u) -> x >= u */
3463  if( SCIPvarIsIntegral(var) )
3464  {
3465  assert(SCIPsetIsIntegral(set, bound));
3466  bound += (boundtype == SCIP_BOUNDTYPE_LOWER ? +1.0 : -1.0);
3467  }
3468 
3469  SCIPsetDebugMsg(set, " -> apply global bound change: <%s> %s %g\n",
3470  SCIPvarGetName(var), boundtype == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=", bound);
3471 
3472  SCIP_CALL( SCIPnodeAddBoundchg(tree->path[conflictset->validdepth], blkmem, set, stat, transprob, origprob, tree,
3473  reopt, lp, branchcand, eventqueue, cliquetable, var, bound, boundtype, FALSE) );
3474 
3475  *success = TRUE;
3476  SCIP_CALL( updateStatistics(conflict, blkmem, set, stat, conflictset, insertdepth) );
3477  }
3478  else
3479  {
3480  /* sort conflict handlers by priority */
3482 
3483  /* call conflict handlers to create a conflict constraint */
3484  for( h = 0; h < set->nconflicthdlrs; ++h )
3485  {
3486  SCIP_RESULT result;
3487 
3488  assert(conflictset->conflicttype != SCIP_CONFTYPE_UNKNOWN);
3489 
3490  SCIP_CALL( SCIPconflicthdlrExec(set->conflicthdlrs[h], set, tree->path[insertdepth],
3491  tree->path[conflictset->validdepth], conflictset->bdchginfos, conflictset->relaxedbds,
3492  conflictset->nbdchginfos, conflictset->conflicttype, conflictset->usescutoffbound, *success, &result) );
3493  if( result == SCIP_CONSADDED )
3494  {
3495  *success = TRUE;
3496  SCIP_CALL( updateStatistics(conflict, blkmem, set, stat, conflictset, insertdepth) );
3497  }
3498 
3499  SCIPsetDebugMsg(set, " -> call conflict handler <%s> (prio=%d) to create conflict set with %d bounds returned result %d\n",
3500  SCIPconflicthdlrGetName(set->conflicthdlrs[h]), SCIPconflicthdlrGetPriority(set->conflicthdlrs[h]),
3501  conflictset->nbdchginfos, result);
3502  }
3503  }
3504 
3505  return SCIP_OKAY;
3506 }
3507 
3508 /** adds the collected conflict constraints to the corresponding nodes; the best set->conf_maxconss conflict constraints
3509  * are added to the node of their validdepth; additionally (if not yet added, and if repropagation is activated), the
3510  * conflict constraint that triggers the earliest repropagation is added to the node of its validdepth
3511  */
3513  SCIP_CONFLICT* conflict, /**< conflict analysis data */
3514  BMS_BLKMEM* blkmem, /**< block memory of transformed problem */
3515  SCIP_SET* set, /**< global SCIP settings */
3516  SCIP_STAT* stat, /**< dynamic problem statistics */
3517  SCIP_PROB* transprob, /**< transformed problem */
3518  SCIP_PROB* origprob, /**< original problem */
3519  SCIP_TREE* tree, /**< branch and bound tree */
3520  SCIP_REOPT* reopt, /**< reoptimization data structure */
3521  SCIP_LP* lp, /**< current LP data */
3522  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
3523  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
3524  SCIP_CLIQUETABLE* cliquetable /**< clique table data structure */
3525  )
3526 {
3527  assert(conflict != NULL);
3528  assert(set != NULL);
3529  assert(stat != NULL);
3530  assert(transprob != NULL);
3531  assert(tree != NULL);
3532 
3533  /* is there anything to do? */
3534  if( conflict->nconflictsets > 0 )
3535  {
3536  SCIP_CONFLICTSET* repropconflictset;
3537  int nconflictsetsused;
3538  int focusdepth;
3539 #ifndef NDEBUG
3540  int currentdepth;
3541 #endif
3542  int cutoffdepth;
3543  int repropdepth;
3544  int maxconflictsets;
3545  int maxsize;
3546  int i;
3547 
3548  /* calculate the maximal number of conflict sets to accept, and the maximal size of each accepted conflict set */
3549  maxconflictsets = (set->conf_maxconss == -1 ? INT_MAX : set->conf_maxconss);
3550  maxsize = conflictCalcMaxsize(set, transprob);
3551 
3552  focusdepth = SCIPtreeGetFocusDepth(tree);
3553 #ifndef NDEBUG
3554  currentdepth = SCIPtreeGetCurrentDepth(tree);
3555  assert(focusdepth <= currentdepth);
3556  assert(currentdepth == tree->pathlen-1);
3557 #endif
3558 
3559  SCIPsetDebugMsg(set, "flushing %d conflict sets at focus depth %d (maxconflictsets: %d, maxsize: %d)\n",
3560  conflict->nconflictsets, focusdepth, maxconflictsets, maxsize);
3561 
3562  /* mark the focus node to have produced conflict sets in the visualization output */
3563  SCIPvisualFoundConflict(stat->visual, stat, tree->path[focusdepth]);
3564 
3565  /* insert the conflict sets at the corresponding nodes */
3566  nconflictsetsused = 0;
3567  cutoffdepth = INT_MAX;
3568  repropdepth = INT_MAX;
3569  repropconflictset = NULL;
3570  for( i = 0; i < conflict->nconflictsets && nconflictsetsused < maxconflictsets; ++i )
3571  {
3572  SCIP_CONFLICTSET* conflictset;
3573 
3574  conflictset = conflict->conflictsets[i];
3575  assert(conflictset != NULL);
3576  assert(0 <= conflictset->validdepth);
3577  assert(conflictset->validdepth <= conflictset->insertdepth);
3578  assert(conflictset->insertdepth <= focusdepth);
3579  assert(conflictset->insertdepth <= conflictset->repropdepth);
3580  assert(conflictset->repropdepth <= currentdepth || conflictset->repropdepth == INT_MAX); /* INT_MAX for dive/probing/strong */
3581  assert(conflictset->conflictdepth <= currentdepth || conflictset->conflictdepth == INT_MAX); /* INT_MAX for dive/probing/strong */
3582 
3583  /* ignore conflict sets that are only valid at a node that was already cut off */
3584  if( conflictset->insertdepth >= cutoffdepth )
3585  {
3586  SCIPsetDebugMsg(set, " -> ignoring conflict set with insertdepth %d >= cutoffdepth %d\n",
3587  conflictset->validdepth, cutoffdepth);
3588  continue;
3589  }
3590 
3591  /* if no conflict bounds exist, the node and its sub tree in the conflict set's valid depth can be
3592  * cut off completely
3593  */
3594  if( conflictset->nbdchginfos == 0 )
3595  {
3596  SCIPsetDebugMsg(set, " -> empty conflict set in depth %d cuts off sub tree at depth %d\n",
3597  focusdepth, conflictset->validdepth);
3598 
3599  SCIP_CALL( SCIPnodeCutoff(tree->path[conflictset->validdepth], set, stat, tree, transprob, origprob, reopt, lp, blkmem) );
3600  cutoffdepth = conflictset->validdepth;
3601  continue;
3602  }
3603 
3604  /* if the conflict set is too long, use the conflict set only if it decreases the repropagation depth */
3605  if( conflictset->nbdchginfos > maxsize )
3606  {
3607  SCIPsetDebugMsg(set, " -> conflict set is too long: %d > %d literals\n", conflictset->nbdchginfos, maxsize);
3608  if( set->conf_keepreprop && conflictset->repropagate && conflictset->repropdepth < repropdepth )
3609  {
3610  repropdepth = conflictset->repropdepth;
3611  repropconflictset = conflictset;
3612  }
3613  }
3614  else
3615  {
3616  SCIP_Bool success;
3617 
3618  /* call conflict handlers to create a conflict constraint */
3619  SCIP_CALL( conflictAddConflictCons(conflict, blkmem, set, stat, transprob, origprob, tree, reopt, lp, \
3620  branchcand, eventqueue, cliquetable, conflictset, conflictset->insertdepth, &success) );
3621 
3622  /* if no conflict bounds exist, the node and its sub tree in the conflict set's valid depth can be
3623  * cut off completely
3624  */
3625  if( conflictset->nbdchginfos == 0 )
3626  {
3627  assert(!success);
3628 
3629  SCIPsetDebugMsg(set, " -> empty conflict set in depth %d cuts off sub tree at depth %d\n",
3630  focusdepth, conflictset->validdepth);
3631 
3632  SCIP_CALL( SCIPnodeCutoff(tree->path[conflictset->validdepth], set, stat, tree, transprob, origprob, \
3633  reopt, lp, blkmem) );
3634  cutoffdepth = conflictset->validdepth;
3635  continue;
3636  }
3637 
3638  if( success )
3639  {
3640  SCIPsetDebugMsg(set, " -> conflict set %d/%d added (cdpt:%d, fdpt:%d, insert:%d, valid:%d, conf:%d, reprop:%d, len:%d):\n",
3641  nconflictsetsused+1, maxconflictsets, SCIPtreeGetCurrentDepth(tree), SCIPtreeGetFocusDepth(tree),
3642  conflictset->insertdepth, conflictset->validdepth, conflictset->conflictdepth, conflictset->repropdepth,
3643  conflictset->nbdchginfos);
3644  SCIPdebug(conflictsetPrint(conflictset));
3645 
3646  if( conflictset->repropagate && conflictset->repropdepth <= repropdepth )
3647  {
3648  repropdepth = conflictset->repropdepth;
3649  repropconflictset = NULL;
3650  }
3651  nconflictsetsused++;
3652  }
3653  }
3654  }
3655 
3656  /* reactivate propagation on the first node where one of the new conflict sets trigger a deduction */
3657  if( set->conf_repropagate && repropdepth < cutoffdepth && repropdepth < tree->pathlen )
3658  {
3659  assert(0 <= repropdepth && repropdepth < tree->pathlen);
3660  assert((int) tree->path[repropdepth]->depth == repropdepth);
3661 
3662  /* if the conflict constraint of smallest repropagation depth was not yet added, insert it now */
3663  if( repropconflictset != NULL )
3664  {
3665  SCIP_Bool success;
3666 
3667  assert(repropconflictset->repropagate);
3668  assert(repropconflictset->repropdepth == repropdepth);
3669 
3670  SCIP_CALL( conflictAddConflictCons(conflict, blkmem, set, stat, transprob, origprob, tree, reopt, lp, \
3671  branchcand, eventqueue, cliquetable, repropconflictset, repropdepth, &success) );
3672 
3673  /* if no conflict bounds exist, the node and its sub tree in the conflict set's valid depth can be
3674  * cut off completely
3675  */
3676  if( repropconflictset->nbdchginfos == 0 )
3677  {
3678  assert(!success);
3679 
3680  SCIPsetDebugMsg(set, " -> empty reprop conflict set in depth %d cuts off sub tree at depth %d\n",
3681  focusdepth, repropconflictset->validdepth);
3682 
3683  SCIP_CALL( SCIPnodeCutoff(tree->path[repropconflictset->validdepth], set, stat, tree, transprob, \
3684  origprob, reopt, lp, blkmem) );
3685  }
3686 
3687 #ifdef SCIP_DEBUG
3688  if( success )
3689  {
3690  SCIPsetDebugMsg(set, " -> additional reprop conflict set added (cdpt:%d, fdpt:%d, insert:%d, valid:%d, conf:%d, reprop:%d, len:%d):\n",
3692  repropconflictset->insertdepth, repropconflictset->validdepth, repropconflictset->conflictdepth,
3693  repropconflictset->repropdepth, repropconflictset->nbdchginfos);
3694  SCIPdebug(conflictsetPrint(repropconflictset));
3695  }
3696 #endif
3697  }
3698 
3699  /* mark the node in the repropdepth to be propagated again */
3700  SCIPnodePropagateAgain(tree->path[repropdepth], set, stat, tree);
3701 
3702  SCIPsetDebugMsg(set, "marked node %p in depth %d to be repropagated due to conflicts found in depth %d\n",
3703  (void*)tree->path[repropdepth], repropdepth, focusdepth);
3704  }
3705 
3706  /* free the conflict store */
3707  for( i = 0; i < conflict->nconflictsets; ++i )
3708  {
3709  conflictsetFree(&conflict->conflictsets[i], blkmem);
3710  }
3711  conflict->nconflictsets = 0;
3712  }
3713 
3714  /* free all temporarily created bound change information data */
3715  conflictFreeTmpBdchginfos(conflict, blkmem);
3716 
3717  return SCIP_OKAY;
3718 }
3719 
3720 /** returns the current number of conflict sets in the conflict set storage */
3722  SCIP_CONFLICT* conflict /**< conflict analysis data */
3723  )
3724 {
3725  assert(conflict != NULL);
3726 
3727  return conflict->nconflictsets;
3728 }
3729 
3730 /** returns the total number of conflict constraints that were added to the problem */
3732  SCIP_CONFLICT* conflict /**< conflict analysis data */
3733  )
3734 {
3735  assert(conflict != NULL);
3736 
3737  return conflict->nappliedglbconss + conflict->nappliedlocconss;
3738 }
3739 
3740 /** returns the total number of literals in conflict constraints that were added to the problem */
3742  SCIP_CONFLICT* conflict /**< conflict analysis data */
3743  )
3744 {
3745  assert(conflict != NULL);
3746 
3747  return conflict->nappliedglbliterals + conflict->nappliedlocliterals;
3748 }
3749 
3750 /** returns the total number of global bound changes applied by the conflict analysis */
3752  SCIP_CONFLICT* conflict /**< conflict analysis data */
3753  )
3754 {
3755  assert(conflict != NULL);
3756 
3757  return conflict->nglbchgbds;
3758 }
3759 
3760 /** returns the total number of conflict constraints that were added globally to the problem */
3762  SCIP_CONFLICT* conflict /**< conflict analysis data */
3763  )
3764 {
3765  assert(conflict != NULL);
3766 
3767  return conflict->nappliedglbconss;
3768 }
3769 
3770 /** returns the total number of literals in conflict constraints that were added globally to the problem */
3772  SCIP_CONFLICT* conflict /**< conflict analysis data */
3773  )
3774 {
3775  assert(conflict != NULL);
3776 
3777  return conflict->nappliedglbliterals;
3778 }
3779 
3780 /** returns the total number of local bound changes applied by the conflict analysis */
3782  SCIP_CONFLICT* conflict /**< conflict analysis data */
3783  )
3784 {
3785  assert(conflict != NULL);
3786 
3787  return conflict->nlocchgbds;
3788 }
3789 
3790 /** returns the total number of conflict constraints that were added locally to the problem */
3792  SCIP_CONFLICT* conflict /**< conflict analysis data */
3793  )
3794 {
3795  assert(conflict != NULL);
3796 
3797  return conflict->nappliedlocconss;
3798 }
3799 
3800 /** returns the total number of literals in conflict constraints that were added locally to the problem */
3802  SCIP_CONFLICT* conflict /**< conflict analysis data */
3803  )
3804 {
3805  assert(conflict != NULL);
3806 
3807  return conflict->nappliedlocliterals;
3808 }
3809 
3810 
3811 
3812 
3813 /*
3814  * Propagation Conflict Analysis
3815  */
3816 
3817 /** returns whether bound change has a valid reason that can be resolved in conflict analysis */
3818 static
3820  SCIP_BDCHGINFO* bdchginfo /**< bound change information */
3821  )
3822 {
3823  assert(bdchginfo != NULL);
3824  assert(!SCIPbdchginfoIsRedundant(bdchginfo));
3825 
3828  && SCIPbdchginfoGetInferProp(bdchginfo) != NULL));
3829 }
3830 
3831 /** compares two conflict set entries, such that bound changes infered later are
3832  * ordered prior to ones that were infered earlier
3833  */
3834 static
3835 SCIP_DECL_SORTPTRCOMP(conflictBdchginfoComp)
3836 { /*lint --e{715}*/
3837  SCIP_BDCHGINFO* bdchginfo1;
3838  SCIP_BDCHGINFO* bdchginfo2;
3839 
3840  bdchginfo1 = (SCIP_BDCHGINFO*)elem1;
3841  bdchginfo2 = (SCIP_BDCHGINFO*)elem2;
3842  assert(bdchginfo1 != NULL);
3843  assert(bdchginfo2 != NULL);
3844  assert(!SCIPbdchginfoIsRedundant(bdchginfo1));
3845  assert(!SCIPbdchginfoIsRedundant(bdchginfo2));
3846 
3847  if( bdchginfo1 == bdchginfo2 )
3848  return 0;
3849 
3851  return -1;
3852  else
3853  return +1;
3854 }
3855 
3856 /** return TRUE if conflict analysis is applicable; In case the function return FALSE there is no need to initialize the
3857  * conflict analysis since it will not be applied
3858  */
3860  SCIP_SET* set /**< global SCIP settings */
3861  )
3862 {
3863  /* check, if propagation conflict analysis is enabled */
3864  if( !set->conf_enable || !set->conf_useprop )
3865  return FALSE;
3866 
3867  /* check, if there are any conflict handlers to use a conflict set */
3868  if( set->nconflicthdlrs == 0 )
3869  return FALSE;
3870 
3871  return TRUE;
3872 }
3873 
3874 /** creates conflict analysis data for propagation conflicts */
3876  SCIP_CONFLICT** conflict, /**< pointer to conflict analysis data */
3877  BMS_BLKMEM* blkmem, /**< block memory of transformed problem */
3878  SCIP_SET* set /**< global SCIP settings */
3879  )
3880 {
3881  assert(conflict != NULL);
3882 
3883  SCIP_ALLOC( BMSallocMemory(conflict) );
3884 
3885  SCIP_CALL( SCIPclockCreate(&(*conflict)->dIBclock, SCIP_CLOCKTYPE_DEFAULT) );
3886  SCIP_CALL( SCIPclockCreate(&(*conflict)->propanalyzetime, SCIP_CLOCKTYPE_DEFAULT) );
3887  SCIP_CALL( SCIPclockCreate(&(*conflict)->inflpanalyzetime, SCIP_CLOCKTYPE_DEFAULT) );
3888  SCIP_CALL( SCIPclockCreate(&(*conflict)->boundlpanalyzetime, SCIP_CLOCKTYPE_DEFAULT) );
3889  SCIP_CALL( SCIPclockCreate(&(*conflict)->sbanalyzetime, SCIP_CLOCKTYPE_DEFAULT) );
3890  SCIP_CALL( SCIPclockCreate(&(*conflict)->pseudoanalyzetime, SCIP_CLOCKTYPE_DEFAULT) );
3891 
3892  /* enable or disable timing depending on the parameter statistic timing */
3893  SCIPconflictEnableOrDisableClocks((*conflict), set->time_statistictiming);
3894 
3895  SCIP_CALL( SCIPpqueueCreate(&(*conflict)->bdchgqueue, set->mem_arraygrowinit, set->mem_arraygrowfac,
3896  conflictBdchginfoComp, NULL) );
3897  SCIP_CALL( SCIPpqueueCreate(&(*conflict)->forcedbdchgqueue, set->mem_arraygrowinit, set->mem_arraygrowfac,
3898  conflictBdchginfoComp, NULL) );
3899  SCIP_CALL( conflictsetCreate(&(*conflict)->conflictset, blkmem) );
3900  (*conflict)->conflictsets = NULL;
3901  (*conflict)->conflictsetscores = NULL;
3902  (*conflict)->tmpbdchginfos = NULL;
3903  (*conflict)->conflictsetssize = 0;
3904  (*conflict)->nconflictsets = 0;
3905  (*conflict)->proofsets = NULL;
3906  (*conflict)->proofsetssize = 0;
3907  (*conflict)->nproofsets = 0;
3908  (*conflict)->tmpbdchginfossize = 0;
3909  (*conflict)->ntmpbdchginfos = 0;
3910  (*conflict)->count = 0;
3911  (*conflict)->nglbchgbds = 0;
3912  (*conflict)->nappliedglbconss = 0;
3913  (*conflict)->nappliedglbliterals = 0;
3914  (*conflict)->nlocchgbds = 0;
3915  (*conflict)->nappliedlocconss = 0;
3916  (*conflict)->nappliedlocliterals = 0;
3917  (*conflict)->npropcalls = 0;
3918  (*conflict)->npropsuccess = 0;
3919  (*conflict)->npropconfconss = 0;
3920  (*conflict)->npropconfliterals = 0;
3921  (*conflict)->npropreconvconss = 0;
3922  (*conflict)->npropreconvliterals = 0;
3923  (*conflict)->ninflpcalls = 0;
3924  (*conflict)->ninflpsuccess = 0;
3925  (*conflict)->ninflpconfconss = 0;
3926  (*conflict)->ninflpconfliterals = 0;
3927  (*conflict)->ninflpreconvconss = 0;
3928  (*conflict)->ninflpreconvliterals = 0;
3929  (*conflict)->ninflpiterations = 0;
3930  (*conflict)->nboundlpcalls = 0;
3931  (*conflict)->nboundlpsuccess = 0;
3932  (*conflict)->nboundlpconfconss = 0;
3933  (*conflict)->nboundlpconfliterals = 0;
3934  (*conflict)->nboundlpreconvconss = 0;
3935  (*conflict)->nboundlpreconvliterals = 0;
3936  (*conflict)->nboundlpiterations = 0;
3937  (*conflict)->nsbcalls = 0;
3938  (*conflict)->nsbsuccess = 0;
3939  (*conflict)->nsbconfconss = 0;
3940  (*conflict)->nsbconfliterals = 0;
3941  (*conflict)->nsbreconvconss = 0;
3942  (*conflict)->nsbreconvliterals = 0;
3943  (*conflict)->nsbiterations = 0;
3944  (*conflict)->npseudocalls = 0;
3945  (*conflict)->npseudosuccess = 0;
3946  (*conflict)->npseudoconfconss = 0;
3947  (*conflict)->npseudoconfliterals = 0;
3948  (*conflict)->npseudoreconvconss = 0;
3949  (*conflict)->npseudoreconvliterals = 0;
3950  (*conflict)->ndualproofsinfglobal = 0;
3951  (*conflict)->ndualproofsinflocal = 0;
3952  (*conflict)->ndualproofsinfsuccess = 0;
3953  (*conflict)->dualproofsinfnnonzeros = 0;
3954  (*conflict)->ndualproofsbndglobal = 0;
3955  (*conflict)->ndualproofsbndlocal = 0;
3956  (*conflict)->ndualproofsbndsuccess = 0;
3957  (*conflict)->dualproofsbndnnonzeros = 0;
3958 
3959  SCIP_CALL( conflictInitProofset((*conflict), blkmem) );
3960 
3961  return SCIP_OKAY;
3962 }
3963 
3964 /** frees conflict analysis data for propagation conflicts */
3966  SCIP_CONFLICT** conflict, /**< pointer to conflict analysis data */
3967  BMS_BLKMEM* blkmem /**< block memory of transformed problem */
3968  )
3969 {
3970  assert(conflict != NULL);
3971  assert(*conflict != NULL);
3972  assert((*conflict)->nconflictsets == 0);
3973  assert((*conflict)->ntmpbdchginfos == 0);
3974 
3975 #ifdef SCIP_CONFGRAPH
3976  confgraphFree();
3977 #endif
3978 
3979  SCIPclockFree(&(*conflict)->dIBclock);
3980  SCIPclockFree(&(*conflict)->propanalyzetime);
3981  SCIPclockFree(&(*conflict)->inflpanalyzetime);
3982  SCIPclockFree(&(*conflict)->boundlpanalyzetime);
3983  SCIPclockFree(&(*conflict)->sbanalyzetime);
3984  SCIPclockFree(&(*conflict)->pseudoanalyzetime);
3985  SCIPpqueueFree(&(*conflict)->bdchgqueue);
3986  SCIPpqueueFree(&(*conflict)->forcedbdchgqueue);
3987  conflictsetFree(&(*conflict)->conflictset, blkmem);
3988  proofsetFree(&(*conflict)->proofset, blkmem);
3989 
3990  BMSfreeMemoryArrayNull(&(*conflict)->conflictsets);
3991  BMSfreeMemoryArrayNull(&(*conflict)->conflictsetscores);
3992  BMSfreeMemoryArrayNull(&(*conflict)->proofsets);
3993  BMSfreeMemoryArrayNull(&(*conflict)->tmpbdchginfos);
3994  BMSfreeMemory(conflict);
3995 
3996  return SCIP_OKAY;
3997 }
3998 
3999 /** clears the conflict queue and the current conflict set */
4000 static
4002  SCIP_CONFLICT* conflict /**< conflict analysis data */
4003  )
4004 {
4005  assert(conflict != NULL);
4006 
4007  SCIPpqueueClear(conflict->bdchgqueue);
4008  SCIPpqueueClear(conflict->forcedbdchgqueue);
4009  conflictsetClear(conflict->conflictset);
4010 }
4011 
4012 /** initializes the propagation conflict analysis by clearing the conflict candidate queue */
4014  SCIP_CONFLICT* conflict, /**< conflict analysis data */
4015  SCIP_SET* set, /**< global SCIP settings */
4016  SCIP_STAT* stat, /**< problem statistics */
4017  SCIP_PROB* prob, /**< problem data */
4018  SCIP_CONFTYPE conftype, /**< type of the conflict */
4019  SCIP_Bool usescutoffbound /**< depends the conflict on a cutoff bound? */
4020  )
4021 {
4022  assert(conflict != NULL);
4023  assert(set != NULL);
4024  assert(stat != NULL);
4025  assert(prob != NULL);
4026 
4027  SCIPsetDebugMsg(set, "initializing conflict analysis\n");
4028 
4029  /* clear the conflict candidate queue and the conflict set */
4030  conflictClear(conflict);
4031 
4032  /* set conflict type */
4033  assert(conftype == SCIP_CONFTYPE_BNDEXCEEDING || conftype == SCIP_CONFTYPE_INFEASLP
4034  || conftype == SCIP_CONFTYPE_PROPAGATION);
4035  conflict->conflictset->conflicttype = conftype;
4036 
4037  /* set whether a cutoff bound is involved */
4038  conflict->conflictset->usescutoffbound = usescutoffbound;
4039 
4040  /* increase the conflict counter, such that binary variables of new conflict set and new conflict queue are labeled
4041  * with this new counter
4042  */
4043  conflict->count++;
4044  if( conflict->count == 0 ) /* make sure, 0 is not a valid conflict counter (may happen due to integer overflow) */
4045  conflict->count = 1;
4046 
4047  /* increase the conflict score weight for history updates of future conflict reasons */
4048  if( stat->nnodes > stat->lastconflictnode )
4049  {
4050  assert(0.0 < set->conf_scorefac && set->conf_scorefac <= 1.0);
4051  stat->vsidsweight /= set->conf_scorefac;
4052  assert(stat->vsidsweight > 0.0);
4053 
4054  /* if the conflict score for the next conflict exceeds 1000.0, rescale all history conflict scores */
4055  if( stat->vsidsweight >= 1000.0 )
4056  {
4057  int v;
4058 
4059  for( v = 0; v < prob->nvars; ++v )
4060  {
4061  SCIP_CALL( SCIPvarScaleVSIDS(prob->vars[v], 1.0/stat->vsidsweight) );
4062  }
4063  SCIPhistoryScaleVSIDS(stat->glbhistory, 1.0/stat->vsidsweight);
4065  stat->vsidsweight = 1.0;
4066  }
4067  stat->lastconflictnode = stat->nnodes;
4068  }
4069 
4070 #ifdef SCIP_CONFGRAPH
4071  confgraphFree();
4072  SCIP_CALL( confgraphCreate(set, conflict) );
4073 #endif
4074 
4075  return SCIP_OKAY;
4076 }
4077 
4078 /** marks bound to be present in the current conflict and returns whether a bound which is at least as tight was already
4079  * member of the current conflict (i.e., the given bound change does not need to be added)
4080  */
4081 static
4083  SCIP_CONFLICT* conflict, /**< conflict analysis data */
4084  SCIP_SET* set, /**< global SCIP settings */
4085  SCIP_BDCHGINFO* bdchginfo, /**< bound change to add to the conflict set */
4086  SCIP_Real relaxedbd /**< relaxed bound */
4087  )
4088 {
4089  SCIP_VAR* var;
4090  SCIP_Real newbound;
4091 
4092  assert(conflict != NULL);
4093 
4094  var = SCIPbdchginfoGetVar(bdchginfo);
4095  newbound = SCIPbdchginfoGetNewbound(bdchginfo);
4096  assert(var != NULL);
4097 
4098  switch( SCIPbdchginfoGetBoundtype(bdchginfo) )
4099  {
4100  case SCIP_BOUNDTYPE_LOWER:
4101  /* check if the variables lower bound is already member of the conflict */
4102  if( var->conflictlbcount == conflict->count )
4103  {
4104  /* the variable is already member of the conflict; hence check if the new bound is redundant */
4105  if( var->conflictlb > newbound )
4106  {
4107  SCIPsetDebugMsg(set, "ignoring redundant bound change <%s> >= %g since a stronger lower bound exist <%s> >= %g\n",
4108  SCIPvarGetName(var), newbound, SCIPvarGetName(var), var->conflictlb);
4109  return TRUE;
4110  }
4111  else if( var->conflictlb == newbound ) /*lint !e777*/
4112  {
4113  SCIPsetDebugMsg(set, "ignoring redundant bound change <%s> >= %g since this lower bound is already present\n", SCIPvarGetName(var), newbound);
4114  SCIPsetDebugMsg(set, "adjust relaxed lower bound <%g> -> <%g>\n", var->conflictlb, relaxedbd);
4115  var->conflictrelaxedlb = MAX(var->conflictrelaxedlb, relaxedbd);
4116  return TRUE;
4117  }
4118  }
4119 
4120  /* add the variable lower bound to the current conflict */
4121  var->conflictlbcount = conflict->count;
4122 
4123  /* remember the lower bound and relaxed bound to allow only better/tighter lower bounds for that variables
4124  * w.r.t. this conflict
4125  */
4126  var->conflictlb = newbound;
4127  var->conflictrelaxedlb = relaxedbd;
4128 
4129  return FALSE;
4130 
4131  case SCIP_BOUNDTYPE_UPPER:
4132  /* check if the variables upper bound is already member of the conflict */
4133  if( var->conflictubcount == conflict->count )
4134  {
4135  /* the variable is already member of the conflict; hence check if the new bound is redundant */
4136  if( var->conflictub < newbound )
4137  {
4138  SCIPsetDebugMsg(set, "ignoring redundant bound change <%s> <= %g since a stronger upper bound exist <%s> <= %g\n",
4139  SCIPvarGetName(var), newbound, SCIPvarGetName(var), var->conflictub);
4140  return TRUE;
4141  }
4142  else if( var->conflictub == newbound ) /*lint !e777*/
4143  {
4144  SCIPsetDebugMsg(set, "ignoring redundant bound change <%s> <= %g since this upper bound is already present\n", SCIPvarGetName(var), newbound);
4145  SCIPsetDebugMsg(set, "adjust relaxed upper bound <%g> -> <%g>\n", var->conflictub, relaxedbd);
4146  var->conflictrelaxedub = MIN(var->conflictrelaxedub, relaxedbd);
4147  return TRUE;
4148  }
4149  }
4150 
4151  /* add the variable upper bound to the current conflict */
4152  var->conflictubcount = conflict->count;
4153 
4154  /* remember the upper bound and relaxed bound to allow only better/tighter upper bounds for that variables
4155  * w.r.t. this conflict
4156  */
4157  var->conflictub = newbound;
4158  var->conflictrelaxedub = relaxedbd;
4159 
4160  return FALSE;
4161 
4162  default:
4163  SCIPerrorMessage("invalid bound type %d\n", SCIPbdchginfoGetBoundtype(bdchginfo));
4164  SCIPABORT();
4165  return FALSE; /*lint !e527*/
4166  }
4167 }
4168 
4169 /** puts bound change into the current conflict set */
4170 static
4172  SCIP_CONFLICT* conflict, /**< conflict analysis data */
4173  BMS_BLKMEM* blkmem, /**< block memory of transformed problem */
4174  SCIP_SET* set, /**< global SCIP settings */
4175  SCIP_BDCHGINFO* bdchginfo, /**< bound change to add to the conflict set */
4176  SCIP_Real relaxedbd /**< relaxed bound */
4177  )
4178 {
4179  assert(conflict != NULL);
4180  assert(!SCIPbdchginfoIsRedundant(bdchginfo));
4181 
4182  /* check if the relaxed bound is really a relaxed bound */
4183  assert(SCIPbdchginfoGetBoundtype(bdchginfo) == SCIP_BOUNDTYPE_LOWER || SCIPsetIsGE(set, relaxedbd, SCIPbdchginfoGetNewbound(bdchginfo)));
4184  assert(SCIPbdchginfoGetBoundtype(bdchginfo) == SCIP_BOUNDTYPE_UPPER || SCIPsetIsLE(set, relaxedbd, SCIPbdchginfoGetNewbound(bdchginfo)));
4185 
4186  SCIPsetDebugMsg(set, "putting bound change <%s> %s %g(%g) at depth %d to current conflict set\n",
4187  SCIPvarGetName(SCIPbdchginfoGetVar(bdchginfo)),
4188  SCIPbdchginfoGetBoundtype(bdchginfo) == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=", SCIPbdchginfoGetNewbound(bdchginfo),
4189  relaxedbd, SCIPbdchginfoGetDepth(bdchginfo));
4190 
4191  /* mark the bound to be member of the conflict and check if a bound which is at least as tight is already member of
4192  * the conflict
4193  */
4194  if( !conflictMarkBoundCheckPresence(conflict, set, bdchginfo, relaxedbd) )
4195  {
4196  /* add the bound change to the current conflict set */
4197  SCIP_CALL( conflictsetAddBound(conflict->conflictset, blkmem, set, bdchginfo, relaxedbd) );
4198 
4199 #ifdef SCIP_CONFGRAPH
4200  if( bdchginfo != confgraphcurrentbdchginfo )
4201  confgraphAddBdchg(bdchginfo);
4202 #endif
4203  }
4204 #ifdef SCIP_CONFGRAPH
4205  else
4206  confgraphLinkBdchg(bdchginfo);
4207 #endif
4208 
4209  return SCIP_OKAY;
4210 }
4211 
4212 /** returns whether the negation of the given bound change would lead to a globally valid literal */
4213 static
4215  SCIP_SET* set, /**< global SCIP settings */
4216  SCIP_BDCHGINFO* bdchginfo /**< bound change information */
4217  )
4218 {
4219  SCIP_VAR* var;
4220  SCIP_BOUNDTYPE boundtype;
4221  SCIP_Real bound;
4222 
4223  var = SCIPbdchginfoGetVar(bdchginfo);
4224  boundtype = SCIPbdchginfoGetBoundtype(bdchginfo);
4225  bound = SCIPbdchginfoGetNewbound(bdchginfo);
4226 
4227  return (SCIPvarGetType(var) == SCIP_VARTYPE_CONTINUOUS
4228  && ((boundtype == SCIP_BOUNDTYPE_LOWER && SCIPsetIsFeasGE(set, bound, SCIPvarGetUbGlobal(var)))
4229  || (boundtype == SCIP_BOUNDTYPE_UPPER && SCIPsetIsFeasLE(set, bound, SCIPvarGetLbGlobal(var)))));
4230 }
4231 
4232 /** adds given bound change information to the conflict candidate queue */
4233 static
4235  SCIP_CONFLICT* conflict, /**< conflict analysis data */
4236  SCIP_SET* set, /**< global SCIP settings */
4237  SCIP_BDCHGINFO* bdchginfo, /**< bound change information */
4238  SCIP_Real relaxedbd /**< relaxed bound */
4239  )
4240 {
4241  assert(conflict != NULL);
4242  assert(set != NULL);
4243  assert(bdchginfo != NULL);
4244  assert(!SCIPbdchginfoIsRedundant(bdchginfo));
4245 
4246  /* check if the relaxed bound is really a relaxed bound */
4247  assert(SCIPbdchginfoGetBoundtype(bdchginfo) == SCIP_BOUNDTYPE_LOWER || SCIPsetIsGE(set, relaxedbd, SCIPbdchginfoGetNewbound(bdchginfo)));
4248  assert(SCIPbdchginfoGetBoundtype(bdchginfo) == SCIP_BOUNDTYPE_UPPER || SCIPsetIsLE(set, relaxedbd, SCIPbdchginfoGetNewbound(bdchginfo)));
4249 
4250  /* mark the bound to be member of the conflict and check if a bound which is at least as tight is already member of
4251  * the conflict
4252  */
4253  if( !conflictMarkBoundCheckPresence(conflict, set, bdchginfo, relaxedbd) )
4254  {
4255  /* insert the bound change into the conflict queue */
4256  if( (!set->conf_preferbinary || SCIPvarIsBinary(SCIPbdchginfoGetVar(bdchginfo)))
4257  && !isBoundchgUseless(set, bdchginfo) )
4258  {
4259  SCIP_CALL( SCIPpqueueInsert(conflict->bdchgqueue, (void*)bdchginfo) );
4260  }
4261  else
4262  {
4263  SCIP_CALL( SCIPpqueueInsert(conflict->forcedbdchgqueue, (void*)bdchginfo) );
4264  }
4265 
4266 #ifdef SCIP_CONFGRAPH
4267  confgraphAddBdchg(bdchginfo);
4268 #endif
4269  }
4270 #ifdef SCIP_CONFGRAPH
4271  else
4272  confgraphLinkBdchg(bdchginfo);
4273 #endif
4274 
4275  return SCIP_OKAY;
4276 }
4277 
4278 /** convert variable and bound change to active variable */
4279 static
4281  SCIP_VAR** var, /**< pointer to variable */
4282  SCIP_SET* set, /**< global SCIP settings */
4283  SCIP_BOUNDTYPE* boundtype, /**< pointer to type of bound that was changed: lower or upper bound */
4284  SCIP_Real* bound /**< pointer to bound to convert, or NULL */
4285  )
4286 {
4287  SCIP_Real scalar;
4288  SCIP_Real constant;
4289 
4290  scalar = 1.0;
4291  constant = 0.0;
4292 
4293  /* transform given varibale to active varibale */
4294  SCIP_CALL( SCIPvarGetProbvarSum(var, set, &scalar, &constant) );
4295  assert(SCIPvarGetStatus(*var) == SCIP_VARSTATUS_FIXED || scalar != 0.0); /*lint !e777*/
4296 
4297  if( SCIPvarGetStatus(*var) == SCIP_VARSTATUS_FIXED )
4298  return SCIP_OKAY;
4299 
4300  /* if the scalar of the aggregation is negative, we have to switch the bound type */
4301  if( scalar < 0.0 )
4302  (*boundtype) = SCIPboundtypeOpposite(*boundtype);
4303 
4304  if( bound != NULL )
4305  {
4306  (*bound) -= constant;
4307  (*bound) /= scalar;
4308  }
4309 
4310  return SCIP_OKAY;
4311 }
4312 
4313 /** adds variable's bound to conflict candidate queue */
4314 static
4316  SCIP_CONFLICT* conflict, /**< conflict analysis data */
4317  BMS_BLKMEM* blkmem, /**< block memory */
4318  SCIP_SET* set, /**< global SCIP settings */
4319  SCIP_STAT* stat, /**< dynamic problem statistics */
4320  SCIP_VAR* var, /**< problem variable */
4321  SCIP_BOUNDTYPE boundtype, /**< type of bound that was changed: lower or upper bound */
4322  SCIP_BDCHGINFO* bdchginfo, /**< bound change info, or NULL */
4323  SCIP_Real relaxedbd /**< relaxed bound */
4324  )
4325 {
4326  assert(SCIPvarIsActive(var));
4327  assert(bdchginfo != NULL);
4328  assert(!SCIPbdchginfoIsRedundant(bdchginfo));
4329 
4330  SCIPsetDebugMsg(set, " -> adding bound <%s> %s %.15g(%.15g) [status:%d, type:%d, depth:%d, pos:%d, reason:<%s>, info:%d] to candidates\n",
4331  SCIPvarGetName(var),
4332  boundtype == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=",
4333  SCIPbdchginfoGetNewbound(bdchginfo), relaxedbd,
4334  SCIPvarGetStatus(var), SCIPvarGetType(var),
4335  SCIPbdchginfoGetDepth(bdchginfo), SCIPbdchginfoGetPos(bdchginfo),
4336  SCIPbdchginfoGetChgtype(bdchginfo) == SCIP_BOUNDCHGTYPE_BRANCHING ? "branch"
4340  : "none")),
4342 
4343  /* the local bound change may be resolved and has to be put on the candidate queue;
4344  * we even put bound changes without inference information on the queue in order to automatically
4345  * eliminate multiple insertions of the same bound change
4346  */
4347  assert(SCIPbdchginfoGetVar(bdchginfo) == var);
4348  assert(SCIPbdchginfoGetBoundtype(bdchginfo) == boundtype);
4349  assert(SCIPbdchginfoGetDepth(bdchginfo) >= 0);
4350  assert(SCIPbdchginfoGetPos(bdchginfo) >= 0);
4351 
4352  /* the relaxed bound should be a relaxation */
4353  assert(boundtype == SCIP_BOUNDTYPE_LOWER ? SCIPsetIsLE(set, relaxedbd, SCIPbdchginfoGetNewbound(bdchginfo)) : SCIPsetIsGE(set, relaxedbd, SCIPbdchginfoGetNewbound(bdchginfo)));
4354 
4355  /* the relaxed bound should be worse then the old bound of the bound change info */
4356  assert(boundtype == SCIP_BOUNDTYPE_LOWER ? SCIPsetIsGT(set, relaxedbd, SCIPbdchginfoGetOldbound(bdchginfo)) : SCIPsetIsLT(set, relaxedbd, SCIPbdchginfoGetOldbound(bdchginfo)));
4357 
4358  /* put bound change information into priority queue */
4359  SCIP_CALL( conflictQueueBound(conflict, set, bdchginfo, relaxedbd) );
4360 
4361  /* each variable which is add to the conflict graph gets an increase in the VSIDS
4362  *
4363  * @note That is different to the VSIDS preseted in the literature
4364  */
4365  SCIP_CALL( incVSIDS(var, blkmem, set, stat, boundtype, relaxedbd, set->conf_conflictgraphweight) );
4366 
4367  return SCIP_OKAY;
4368 }
4369 
4370 /** adds variable's bound to conflict candidate queue */
4372  SCIP_CONFLICT* conflict, /**< conflict analysis data */
4373  BMS_BLKMEM* blkmem, /**< block memory */
4374  SCIP_SET* set, /**< global SCIP settings */
4375  SCIP_STAT* stat, /**< dynamic problem statistics */
4376  SCIP_VAR* var, /**< problem variable */
4377  SCIP_BOUNDTYPE boundtype, /**< type of bound that was changed: lower or upper bound */
4378  SCIP_BDCHGIDX* bdchgidx /**< bound change index (time stamp of bound change), or NULL for current time */
4379  )
4380 {
4381  SCIP_BDCHGINFO* bdchginfo;
4382 
4383  assert(conflict != NULL);
4384  assert(stat != NULL);
4385  assert(var != NULL);
4386 
4387  /* convert bound to active problem variable */
4388  SCIP_CALL( convertToActiveVar(&var, set, &boundtype, NULL) );
4389 
4390  /* we can ignore fixed variables */
4392  return SCIP_OKAY;
4393 
4394  /* if the variable is multi-aggregated, add the bounds of all aggregation variables */
4396  {
4397  SCIP_VAR** vars;
4398  SCIP_Real* scalars;
4399  int nvars;
4400  int i;
4401 
4402  vars = SCIPvarGetMultaggrVars(var);
4403  scalars = SCIPvarGetMultaggrScalars(var);
4404  nvars = SCIPvarGetMultaggrNVars(var);
4405  for( i = 0; i < nvars; ++i )
4406  {
4407  SCIP_CALL( SCIPconflictAddBound(conflict, blkmem, set, stat, vars[i],
4408  (scalars[i] < 0.0 ? SCIPboundtypeOpposite(boundtype) : boundtype), bdchgidx) );
4409  }
4410 
4411  return SCIP_OKAY;
4412  }
4413  assert(SCIPvarIsActive(var));
4414 
4415  /* get bound change information */
4416  bdchginfo = SCIPvarGetBdchgInfo(var, boundtype, bdchgidx, FALSE);
4417 
4418  /* if bound of variable was not changed (this means it is still the global bound), we can ignore the conflicting
4419  * bound
4420  */
4421  if( bdchginfo == NULL )
4422  return SCIP_OKAY;
4423 
4424  assert(SCIPbdchgidxIsEarlier(SCIPbdchginfoGetIdx(bdchginfo), bdchgidx));
4425 
4426  SCIP_CALL( conflictAddBound(conflict, blkmem, set, stat, var, boundtype, bdchginfo, SCIPbdchginfoGetNewbound(bdchginfo)) );
4427 
4428  return SCIP_OKAY;
4429 }
4430 
4431 /** adds variable's bound to conflict candidate queue */
4433  SCIP_CONFLICT* conflict, /**< conflict analysis data */
4434  BMS_BLKMEM* blkmem, /**< block memory */
4435  SCIP_SET* set, /**< global SCIP settings */
4436  SCIP_STAT* stat, /**< dynamic problem statistics */
4437  SCIP_VAR* var, /**< problem variable */
4438  SCIP_BOUNDTYPE boundtype, /**< type of bound that was changed: lower or upper bound */
4439  SCIP_BDCHGIDX* bdchgidx, /**< bound change index (time stamp of bound change), or NULL for current time */
4440  SCIP_Real relaxedbd /**< the relaxed bound */
4441  )
4442 {
4443  SCIP_BDCHGINFO* bdchginfo;
4444  int nbdchgs;
4445 
4446  assert(conflict != NULL);
4447  assert(stat != NULL);
4448  assert(var != NULL);
4449 
4450  if( !SCIPvarIsActive(var) )
4451  {
4452  /* convert bound to active problem variable */
4453  SCIP_CALL( convertToActiveVar(&var, set, &boundtype, &relaxedbd) );
4454 
4455  /* we can ignore fixed variables */
4457  return SCIP_OKAY;
4458 
4459  /* if the variable is multi-aggregated, add the bounds of all aggregation variables */
4461  {
4462  SCIPsetDebugMsg(set, "ignoring relaxed bound information since variable <%s> is multi-aggregated active\n", SCIPvarGetName(var));
4463 
4464  SCIP_CALL( SCIPconflictAddBound(conflict, blkmem, set, stat, var, boundtype, bdchgidx) );
4465 
4466  return SCIP_OKAY;
4467  }
4468  }
4469  assert(SCIPvarIsActive(var));
4470 
4471  /* get bound change information */
4472  bdchginfo = SCIPvarGetBdchgInfo(var, boundtype, bdchgidx, FALSE);
4473 
4474  /* if bound of variable was not changed (this means it is still the global bound), we can ignore the conflicting
4475  * bound
4476  */
4477  if( bdchginfo == NULL )
4478  return SCIP_OKAY;
4479 
4480  /* check that the bound change info is not a temporary one */
4481  assert(SCIPbdchgidxGetPos(&bdchginfo->bdchgidx) >= 0);
4482 
4483  /* get the position of the bound change information within the bound change array of the variable */
4484  nbdchgs = (int) bdchginfo->pos;
4485  assert(nbdchgs >= 0);
4486 
4487  /* if the relaxed bound should be ignored, set the relaxed bound to the bound given by the bdchgidx; that ensures
4488  * that the loop(s) below will be skipped
4489  */
4490  if( set->conf_ignorerelaxedbd )
4491  relaxedbd = SCIPbdchginfoGetNewbound(bdchginfo);
4492 
4493  /* search for the bound change information which includes the relaxed bound */
4494  if( boundtype == SCIP_BOUNDTYPE_LOWER )
4495  {
4496  SCIP_Real newbound;
4497 
4498  /* adjust relaxed lower bound w.r.t. variable type */
4499  SCIPvarAdjustLb(var, set, &relaxedbd);
4500 
4501  /* due to numericis we compare the relaxed lower bound to the one present at the particular time point and take
4502  * the better one
4503  */
4504  newbound = SCIPbdchginfoGetNewbound(bdchginfo);
4505  relaxedbd = MIN(relaxedbd, newbound);
4506 
4507  /* check if relaxed lower bound is smaller or equal to global lower bound; if so we can ignore the conflicting
4508  * bound
4509  */
4510  if( SCIPsetIsLE(set, relaxedbd, SCIPvarGetLbGlobal(var)) )
4511  return SCIP_OKAY;
4512 
4513  while( nbdchgs > 0 )
4514  {
4515  assert(SCIPsetIsLE(set, relaxedbd, SCIPbdchginfoGetNewbound(bdchginfo)));
4516 
4517  /* check if the old lower bound is greater than or equal to relaxed lower bound; if not we found the bound
4518  * change info which we need to report
4519  */
4520  if( SCIPsetIsGT(set, relaxedbd, SCIPbdchginfoGetOldbound(bdchginfo)) )
4521  break;
4522 
4523  bdchginfo = SCIPvarGetBdchgInfoLb(var, nbdchgs-1);
4524 
4525  SCIPsetDebugMsg(set, "lower bound change %d oldbd=%.15g, newbd=%.15g, depth=%d, pos=%d, redundant=%u\n",
4526  nbdchgs, SCIPbdchginfoGetOldbound(bdchginfo), SCIPbdchginfoGetNewbound(bdchginfo),
4527  SCIPbdchginfoGetDepth(bdchginfo), SCIPbdchginfoGetPos(bdchginfo),
4528  SCIPbdchginfoIsRedundant(bdchginfo));
4529 
4530  /* if bound change is redundant (this means it now a global bound), we can ignore the conflicting bound */
4531  if( SCIPbdchginfoIsRedundant(bdchginfo) )
4532  return SCIP_OKAY;
4533 
4534  nbdchgs--;
4535  }
4536  assert(SCIPsetIsGT(set, relaxedbd, SCIPbdchginfoGetOldbound(bdchginfo)));
4537  }
4538  else
4539  {
4540  SCIP_Real newbound;
4541 
4542  assert(boundtype == SCIP_BOUNDTYPE_UPPER);
4543 
4544  /* adjust relaxed upper bound w.r.t. variable type */
4545  SCIPvarAdjustUb(var, set, &relaxedbd);
4546 
4547  /* due to numericis we compare the relaxed upper bound to the one present at the particular time point and take
4548  * the better one
4549  */
4550  newbound = SCIPbdchginfoGetNewbound(bdchginfo);
4551  relaxedbd = MAX(relaxedbd, newbound);
4552 
4553  /* check if relaxed upper bound is greater or equal to global upper bound; if so we can ignore the conflicting
4554  * bound
4555  */
4556  if( SCIPsetIsGE(set, relaxedbd, SCIPvarGetUbGlobal(var)) )
4557  return SCIP_OKAY;
4558 
4559  while( nbdchgs > 0 )
4560  {
4561  assert(SCIPsetIsGE(set, relaxedbd, SCIPbdchginfoGetNewbound(bdchginfo)));
4562 
4563  /* check if the old upper bound is smaller than or equal to the relaxed upper bound; if not we found the
4564  * bound change info which we need to report
4565  */
4566  if( SCIPsetIsLT(set, relaxedbd, SCIPbdchginfoGetOldbound(bdchginfo)) )
4567  break;
4568 
4569  bdchginfo = SCIPvarGetBdchgInfoUb(var, nbdchgs-1);
4570 
4571  SCIPsetDebugMsg(set, "upper bound change %d oldbd=%.15g, newbd=%.15g, depth=%d, pos=%d, redundant=%u\n",
4572  nbdchgs, SCIPbdchginfoGetOldbound(bdchginfo), SCIPbdchginfoGetNewbound(bdchginfo),
4573  SCIPbdchginfoGetDepth(bdchginfo), SCIPbdchginfoGetPos(bdchginfo),
4574  SCIPbdchginfoIsRedundant(bdchginfo));
4575 
4576  /* if bound change is redundant (this means it now a global bound), we can ignore the conflicting bound */
4577  if( SCIPbdchginfoIsRedundant(bdchginfo) )
4578  return SCIP_OKAY;
4579 
4580  nbdchgs--;
4581  }
4582  assert(SCIPsetIsLT(set, relaxedbd, SCIPbdchginfoGetOldbound(bdchginfo)));
4583  }
4584 
4585  assert(SCIPbdchgidxIsEarlier(SCIPbdchginfoGetIdx(bdchginfo), bdchgidx));
4586 
4587  /* put bound change information into priority queue */
4588  SCIP_CALL( conflictAddBound(conflict, blkmem, set, stat, var, boundtype, bdchginfo, relaxedbd) );
4589 
4590  return SCIP_OKAY;
4591 }
4592 
4593 /** checks if the given variable is already part of the current conflict set or queued for resolving with the same or
4594  * even stronger bound
4595  */
4597  SCIP_CONFLICT* conflict, /**< conflict analysis data */
4598  SCIP_VAR* var, /**< problem variable */
4599  SCIP_SET* set, /**< global SCIP settings */
4600  SCIP_BOUNDTYPE boundtype, /**< type of bound for which the score should be increased */
4601  SCIP_BDCHGIDX* bdchgidx, /**< bound change index (time stamp of bound change), or NULL for current time */
4602  SCIP_Bool* used /**< pointer to store if the variable is already used */
4603  )
4604 {
4605  SCIP_Real newbound;
4606 
4607  /* convert bound to active problem variable */
4608  SCIP_CALL( convertToActiveVar(&var, set, &boundtype, NULL) );
4609 
4611  *used = FALSE;
4612  else
4613  {
4614  assert(SCIPvarIsActive(var));
4615  assert(var != NULL);
4616 
4617  switch( boundtype )
4618  {
4619  case SCIP_BOUNDTYPE_LOWER:
4620 
4621  newbound = SCIPgetVarLbAtIndex(set->scip, var, bdchgidx, FALSE);
4622 
4623  if( var->conflictlbcount == conflict->count && var->conflictlb >= newbound )
4624  {
4625  SCIPsetDebugMsg(set, "already queued bound change <%s> >= %g\n", SCIPvarGetName(var), newbound);
4626  *used = TRUE;
4627  }
4628  else
4629  *used = FALSE;
4630  break;
4631  case SCIP_BOUNDTYPE_UPPER:
4632 
4633  newbound = SCIPgetVarUbAtIndex(set->scip, var, bdchgidx, FALSE);
4634 
4635  if( var->conflictubcount == conflict->count && var->conflictub <= newbound )
4636  {
4637  SCIPsetDebugMsg(set, "already queued bound change <%s> <= %g\n", SCIPvarGetName(var), newbound);
4638  *used = TRUE;
4639  }
4640  else
4641  *used = FALSE;
4642  break;
4643  default:
4644  SCIPerrorMessage("invalid bound type %d\n", boundtype);
4645  SCIPABORT();
4646  *used = FALSE; /*lint !e527*/
4647  }
4648  }
4649 
4650  return SCIP_OKAY;
4651 }
4652 
4653 /** returns the conflict lower bound if the variable is present in the current conflict set; otherwise the global lower
4654  * bound
4655  */
4657  SCIP_CONFLICT* conflict, /**< conflict analysis data */
4658  SCIP_VAR* var /**< problem variable */
4659  )
4660 {
4661  if( var->conflictlbcount == conflict->count )
4662  {
4663  assert(EPSGE(var->conflictlb, var->conflictrelaxedlb, 1e-09));
4664  return var->conflictrelaxedlb;
4665  }
4666 
4667  return SCIPvarGetLbGlobal(var);
4668 }
4669 
4670 /** returns the conflict upper bound if the variable is present in the current conflict set; otherwise the global upper
4671  * bound
4672  */
4674  SCIP_CONFLICT* conflict, /**< conflict analysis data */
4675  SCIP_VAR* var /**< problem variable */
4676  )
4677 {
4678  if( var->conflictubcount == conflict->count )
4679  {
4680  assert(EPSLE(var->conflictub, var->conflictrelaxedub, 1e-09));
4681  return var->conflictrelaxedub;
4682  }
4683 
4684  return SCIPvarGetUbGlobal(var);
4685 }
4686 
4687 /** removes and returns next conflict analysis candidate from the candidate queue */
4688 static
4690  SCIP_CONFLICT* conflict /**< conflict analysis data */
4691  )
4692 {
4693  SCIP_BDCHGINFO* bdchginfo;
4694  SCIP_VAR* var;
4695 
4696  assert(conflict != NULL);
4697 
4698  if( SCIPpqueueNElems(conflict->forcedbdchgqueue) > 0 )
4699  bdchginfo = (SCIP_BDCHGINFO*)(SCIPpqueueRemove(conflict->forcedbdchgqueue));
4700  else
4701  bdchginfo = (SCIP_BDCHGINFO*)(SCIPpqueueRemove(conflict->bdchgqueue));
4702 
4703  assert(!SCIPbdchginfoIsRedundant(bdchginfo));
4704 
4705  /* if we have a candidate this one should be valid for the current conflict analysis */
4706  assert(!bdchginfoIsInvalid(conflict, bdchginfo));
4707 
4708  /* mark the bound change to be no longer in the conflict (it will be either added again to the conflict set or
4709  * replaced by resolving, which might add a weaker change on the same bound to the queue)
4710  */
4711  var = SCIPbdchginfoGetVar(bdchginfo);
4713  {
4714  var->conflictlbcount = 0;
4716  }
4717  else
4718  {
4719  assert(SCIPbdchginfoGetBoundtype(bdchginfo) == SCIP_BOUNDTYPE_UPPER);
4720  var->conflictubcount = 0;
4722  }
4723 
4724 #ifdef SCIP_CONFGRAPH
4725  confgraphSetCurrentBdchg(bdchginfo);
4726 #endif
4727 
4728  return bdchginfo;
4729 }
4730 
4731 /** returns next conflict analysis candidate from the candidate queue without removing it */
4732 static
4734  SCIP_CONFLICT* conflict /**< conflict analysis data */
4735  )
4736 {
4737  SCIP_BDCHGINFO* bdchginfo;
4738 
4739  assert(conflict != NULL);
4740 
4741  if( SCIPpqueueNElems(conflict->forcedbdchgqueue) > 0 )
4742  {
4743  /* get next potetioal candidate */
4744  bdchginfo = (SCIP_BDCHGINFO*)(SCIPpqueueFirst(conflict->forcedbdchgqueue));
4745 
4746  /* check if this candidate is valid */
4747  if( bdchginfoIsInvalid(conflict, bdchginfo) )
4748  {
4749  SCIPdebugMessage("bound change info [%d:<%s> %s %g] is invaild -> pop it from the force queue\n", SCIPbdchginfoGetDepth(bdchginfo),
4750  SCIPvarGetName(SCIPbdchginfoGetVar(bdchginfo)),
4751  SCIPbdchginfoGetBoundtype(bdchginfo) == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=",
4752  SCIPbdchginfoGetNewbound(bdchginfo));
4753 
4754  /* pop the invalid bound change info from the queue */
4755  (void)(SCIPpqueueRemove(conflict->forcedbdchgqueue));
4756 
4757  /* call method recursively to get next conflict analysis candidate */
4758  bdchginfo = conflictFirstCand(conflict);
4759  }
4760  }
4761  else
4762  {
4763  bdchginfo = (SCIP_BDCHGINFO*)(SCIPpqueueFirst(conflict->bdchgqueue));
4764 
4765  /* check if this candidate is valid */
4766  if( bdchginfo != NULL && bdchginfoIsInvalid(conflict, bdchginfo) )
4767  {
4768  SCIPdebugMessage("bound change info [%d:<%s> %s %g] is invaild -> pop it from the queue\n", SCIPbdchginfoGetDepth(bdchginfo),
4769  SCIPvarGetName(SCIPbdchginfoGetVar(bdchginfo)),
4770  SCIPbdchginfoGetBoundtype(bdchginfo) == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=",
4771  SCIPbdchginfoGetNewbound(bdchginfo));
4772 
4773  /* pop the invalid bound change info from the queue */
4774  (void)(SCIPpqueueRemove(conflict->bdchgqueue));
4775 
4776  /* call method recursively to get next conflict analysis candidate */
4777  bdchginfo = conflictFirstCand(conflict);
4778  }
4779  }
4780  assert(bdchginfo == NULL || !SCIPbdchginfoIsRedundant(bdchginfo));
4781 
4782  return bdchginfo;
4783 }
4784 
4785 /** adds the current conflict set (extended by all remaining bound changes in the queue) to the pool of conflict sets */
4786 static
4788  SCIP_CONFLICT* conflict, /**< conflict analysis data */
4789  BMS_BLKMEM* blkmem, /**< block memory of transformed problem */
4790  SCIP_SET* set, /**< global SCIP settings */
4791  SCIP_STAT* stat, /**< dynamic problem statistics */
4792  SCIP_TREE* tree, /**< branch and bound tree */
4793  int validdepth, /**< minimal depth level at which the conflict set is valid */
4794  SCIP_Bool diving, /**< are we in strong branching or diving mode? */
4795  SCIP_Bool repropagate, /**< should the constraint trigger a repropagation? */
4796  SCIP_Bool* success, /**< pointer to store whether the conflict set is valid */
4797  int* nliterals /**< pointer to store the number of literals in the generated conflictset */
4798  )
4799 {
4800  SCIP_CONFLICTSET* conflictset;
4801  SCIP_BDCHGINFO** bdchginfos;
4802  int nbdchginfos;
4803  int currentdepth;
4804  int focusdepth;
4805 
4806  assert(conflict != NULL);
4807  assert(conflict->conflictset != NULL);
4808  assert(set != NULL);
4809  assert(stat != NULL);
4810  assert(tree != NULL);
4811  assert(success != NULL);
4812  assert(nliterals != NULL);
4813  assert(SCIPpqueueNElems(conflict->forcedbdchgqueue) == 0);
4814 
4815  *success = FALSE;
4816  *nliterals = 0;
4817 
4818  /* check, whether local conflicts are allowed */
4819  validdepth = MAX(validdepth, conflict->conflictset->validdepth);
4820  if( !set->conf_allowlocal && validdepth > 0 )
4821  return SCIP_OKAY;
4822 
4823  focusdepth = SCIPtreeGetFocusDepth(tree);
4824  currentdepth = SCIPtreeGetCurrentDepth(tree);
4825  assert(currentdepth == tree->pathlen-1);
4826  assert(focusdepth <= currentdepth);
4827  assert(0 <= conflict->conflictset->validdepth && conflict->conflictset->validdepth <= currentdepth);
4828  assert(0 <= validdepth && validdepth <= currentdepth);
4829 
4830  /* get the elements of the bound change queue */
4831  bdchginfos = (SCIP_BDCHGINFO**)SCIPpqueueElems(conflict->bdchgqueue);
4832  nbdchginfos = SCIPpqueueNElems(conflict->bdchgqueue);
4833 
4834  /* create a copy of the current conflict set, allocating memory for the additional elements of the queue */
4835  SCIP_CALL( conflictsetCopy(&conflictset, blkmem, conflict->conflictset, nbdchginfos) );
4836  conflictset->validdepth = validdepth;
4837  conflictset->repropagate = repropagate;
4838 
4839  /* add the valid queue elements to the conflict set */
4840  SCIPsetDebugMsg(set, "adding %d variables from the queue as temporary conflict variables\n", nbdchginfos);
4841  SCIP_CALL( conflictsetAddBounds(conflict, conflictset, blkmem, set, bdchginfos, nbdchginfos) );
4842 
4843  /* calculate the depth, at which the conflictset should be inserted */
4844  SCIP_CALL( conflictsetCalcInsertDepth(conflictset, set, tree) );
4845  assert(conflictset->validdepth <= conflictset->insertdepth && conflictset->insertdepth <= currentdepth);
4846  SCIPsetDebugMsg(set, " -> conflict with %d literals found at depth %d is active in depth %d and valid in depth %d\n",
4847  conflictset->nbdchginfos, currentdepth, conflictset->insertdepth, conflictset->validdepth);
4848 
4849  /* if all branching variables are in the conflict set, the conflict set is of no use;
4850  * don't use conflict sets that are only valid in the probing path but not in the problem tree
4851  */
4852  if( (diving || conflictset->insertdepth < currentdepth) && conflictset->insertdepth <= focusdepth )
4853  {
4854  /* if the conflict should not be located only in the subtree where it is useful, put it to its valid depth level */
4855  if( !set->conf_settlelocal )
4856  conflictset->insertdepth = conflictset->validdepth;
4857 
4858  *nliterals = conflictset->nbdchginfos;
4859  SCIPsetDebugMsg(set, " -> final conflict set has %d literals\n", *nliterals);
4860 
4861  /* check conflict set on debugging solution */
4862  SCIP_CALL( SCIPdebugCheckConflict(blkmem, set, tree->path[validdepth], \
4863  conflictset->bdchginfos, conflictset->relaxedbds, conflictset->nbdchginfos) ); /*lint !e506 !e774*/
4864 
4865  /* move conflictset to the conflictset storage */
4866  SCIP_CALL( conflictInsertConflictset(conflict, blkmem, set, &conflictset) );
4867  *success = TRUE;
4868  }
4869  else
4870  {
4871  /* free the temporary conflict set */
4872  conflictsetFree(&conflictset, blkmem);
4873  }
4874 
4875  return SCIP_OKAY;
4876 }
4877 
4878 /** tries to resolve given bound change
4879  * - resolutions on local constraints are only applied, if the constraint is valid at the
4880  * current minimal valid depth level, because this depth level is the topmost level to add the conflict
4881  * constraint to anyways
4882  *
4883  * @note it is sufficient to explain the relaxed bound change
4884  */
4885 static
4887  SCIP_CONFLICT* conflict, /**< conflict analysis data */
4888  SCIP_SET* set, /**< global SCIP settings */
4889  SCIP_BDCHGINFO* bdchginfo, /**< bound change to resolve */
4890  SCIP_Real relaxedbd, /**< the relaxed bound */
4891  int validdepth, /**< minimal depth level at which the conflict is valid */
4892  SCIP_Bool* resolved /**< pointer to store whether the bound change was resolved */
4893  )
4894 {
4895  SCIP_VAR* actvar;
4896  SCIP_CONS* infercons;
4897  SCIP_PROP* inferprop;
4898  SCIP_RESULT result;
4899 
4900 #ifndef NDEBUG
4901  int nforcedbdchgqueue;
4902  int nbdchgqueue;
4903 
4904  /* store the current size of the conflict queues */
4905  assert(conflict != NULL);
4906  nforcedbdchgqueue = SCIPpqueueNElems(conflict->forcedbdchgqueue);
4907  nbdchgqueue = SCIPpqueueNElems(conflict->bdchgqueue);
4908 #else
4909  assert(conflict != NULL);
4910 #endif
4911 
4912  assert(resolved != NULL);
4913  assert(!SCIPbdchginfoIsRedundant(bdchginfo));
4914 
4915  *resolved = FALSE;
4916 
4917  actvar = SCIPbdchginfoGetVar(bdchginfo);
4918  assert(actvar != NULL);
4919  assert(SCIPvarIsActive(actvar));
4920 
4921 #ifdef SCIP_DEBUG
4922  {
4923  int i;
4924  SCIPsetDebugMsg(set, "processing next conflicting bound (depth: %d, valid depth: %d, bdchgtype: %s [%s], vartype: %d): [<%s> %s %g(%g)]\n",
4925  SCIPbdchginfoGetDepth(bdchginfo), validdepth,
4926  SCIPbdchginfoGetChgtype(bdchginfo) == SCIP_BOUNDCHGTYPE_BRANCHING ? "branch"
4927  : SCIPbdchginfoGetChgtype(bdchginfo) == SCIP_BOUNDCHGTYPE_CONSINFER ? "cons" : "prop",
4931  : SCIPbdchginfoGetInferProp(bdchginfo) == NULL ? "-"
4933  SCIPvarGetType(actvar), SCIPvarGetName(actvar),
4934  SCIPbdchginfoGetBoundtype(bdchginfo) == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=",
4935  SCIPbdchginfoGetNewbound(bdchginfo), relaxedbd);
4936  SCIPsetDebugMsg(set, " - conflict set :");
4937 
4938  for( i = 0; i < conflict->conflictset->nbdchginfos; ++i )
4939  {
4940  SCIPsetDebugMsgPrint(set, " [%d:<%s> %s %g(%g)]", SCIPbdchginfoGetDepth(conflict->conflictset->bdchginfos[i]),
4942  SCIPbdchginfoGetBoundtype(conflict->conflictset->bdchginfos[i]) == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=",
4943  SCIPbdchginfoGetNewbound(conflict->conflictset->bdchginfos[i]), conflict->conflictset->relaxedbds[i]);
4944  }
4945  SCIPsetDebugMsgPrint(set, "\n");
4946  SCIPsetDebugMsg(set, " - forced candidates :");
4947 
4948  for( i = 0; i < SCIPpqueueNElems(conflict->forcedbdchgqueue); ++i )
4949  {
4951  SCIPsetDebugMsgPrint(set, " [%d:<%s> %s %g(%g)]", SCIPbdchginfoGetDepth(info), SCIPvarGetName(SCIPbdchginfoGetVar(info)),
4952  bdchginfoIsInvalid(conflict, info) ? "<!>" : SCIPbdchginfoGetBoundtype(info) == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=",
4954  }
4955  SCIPsetDebugMsgPrint(set, "\n");
4956  SCIPsetDebugMsg(set, " - optional candidates:");
4957 
4958  for( i = 0; i < SCIPpqueueNElems(conflict->bdchgqueue); ++i )
4959  {
4960  SCIP_BDCHGINFO* info = (SCIP_BDCHGINFO*)(SCIPpqueueElems(conflict->bdchgqueue)[i]);
4961  SCIPsetDebugMsgPrint(set, " [%d:<%s> %s %g(%g)]", SCIPbdchginfoGetDepth(info), SCIPvarGetName(SCIPbdchginfoGetVar(info)),
4962  bdchginfoIsInvalid(conflict, info) ? "<!>" : SCIPbdchginfoGetBoundtype(info) == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=",
4964  }
4965  SCIPsetDebugMsgPrint(set, "\n");
4966  }
4967 #endif
4968 
4969  /* check, if the bound change can and should be resolved:
4970  * - resolutions on local constraints should only be applied, if the constraint is valid at the
4971  * current minimal valid depth level (which is initialized with the valid depth level of the initial
4972  * conflict set), because this depth level is the topmost level to add the conflict constraint to anyways
4973  */
4974  switch( SCIPbdchginfoGetChgtype(bdchginfo) )
4975  {
4977  infercons = SCIPbdchginfoGetInferCons(bdchginfo);
4978  assert(infercons != NULL);
4979 
4980  if( SCIPconsIsGlobal(infercons) || SCIPconsGetValidDepth(infercons) <= validdepth )
4981  {
4982  SCIP_VAR* infervar;
4983  int inferinfo;
4984  SCIP_BOUNDTYPE inferboundtype;
4985  SCIP_BDCHGIDX* bdchgidx;
4986 
4987  /* resolve bound change by asking the constraint that infered the bound to put all bounds that were
4988  * the reasons for the conflicting bound change on the priority queue
4989  */
4990  infervar = SCIPbdchginfoGetInferVar(bdchginfo);
4991  inferinfo = SCIPbdchginfoGetInferInfo(bdchginfo);
4992  inferboundtype = SCIPbdchginfoGetInferBoundtype(bdchginfo);
4993  bdchgidx = SCIPbdchginfoGetIdx(bdchginfo);
4994  assert(infervar != NULL);
4995 
4996  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",
4997  SCIPvarGetName(actvar),
4998  SCIPbdchginfoGetBoundtype(bdchginfo) == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=",
4999  SCIPbdchginfoGetNewbound(bdchginfo), relaxedbd,
5000  SCIPvarGetStatus(actvar), SCIPvarGetType(actvar),
5001  SCIPbdchginfoGetDepth(bdchginfo), SCIPbdchginfoGetPos(bdchginfo),
5002  SCIPvarGetName(infervar),
5003  inferboundtype == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=",
5004  SCIPgetVarBdAtIndex(set->scip, infervar, inferboundtype, bdchgidx, TRUE),
5005  SCIPconsGetName(infercons),
5006  SCIPconsIsGlobal(infercons) ? "global" : "local",
5007  inferinfo);
5008 
5009  /* in case the inference variables is not an active variables, we need to transform the relaxed bound */
5010  if( actvar != infervar )
5011  {
5012  SCIP_VAR* var;
5013  SCIP_Real scalar;
5014  SCIP_Real constant;
5015 
5016  assert(SCIPvarGetStatus(infervar) == SCIP_VARSTATUS_AGGREGATED
5018  || (SCIPvarGetStatus(infervar) == SCIP_VARSTATUS_MULTAGGR && SCIPvarGetMultaggrNVars(infervar) == 1));
5019 
5020  scalar = 1.0;
5021  constant = 0.0;
5022 
5023  var = infervar;
5024 
5025  /* transform given varibale to active varibale */
5026  SCIP_CALL( SCIPvarGetProbvarSum(&var, set, &scalar, &constant) );
5027  assert(var == actvar);
5028 
5029  relaxedbd *= scalar;
5030  relaxedbd += constant;
5031  }
5032 
5033  SCIP_CALL( SCIPconsResolvePropagation(infercons, set, infervar, inferinfo, inferboundtype, bdchgidx, relaxedbd, &result) );
5034  *resolved = (result == SCIP_SUCCESS);
5035  }
5036  break;
5037 
5039  inferprop = SCIPbdchginfoGetInferProp(bdchginfo);
5040  if( inferprop != NULL )
5041  {
5042  SCIP_VAR* infervar;
5043  int inferinfo;
5044  SCIP_BOUNDTYPE inferboundtype;
5045  SCIP_BDCHGIDX* bdchgidx;
5046 
5047  /* resolve bound change by asking the propagator that infered the bound to put all bounds that were
5048  * the reasons for the conflicting bound change on the priority queue
5049  */
5050  infervar = SCIPbdchginfoGetInferVar(bdchginfo);
5051  inferinfo = SCIPbdchginfoGetInferInfo(bdchginfo);
5052  inferboundtype = SCIPbdchginfoGetInferBoundtype(bdchginfo);
5053  bdchgidx = SCIPbdchginfoGetIdx(bdchginfo);
5054  assert(infervar != NULL);
5055 
5056  SCIPsetDebugMsg(set, "resolving bound <%s> %s %g(%g) [status:%d, depth:%d, pos:%d]: <%s> %s %g [prop:<%s>, info:%d]\n",
5057  SCIPvarGetName(actvar),
5058  SCIPbdchginfoGetBoundtype(bdchginfo) == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=",
5059  SCIPbdchginfoGetNewbound(bdchginfo), relaxedbd,
5060  SCIPvarGetStatus(actvar), SCIPbdchginfoGetDepth(bdchginfo), SCIPbdchginfoGetPos(bdchginfo),
5061  SCIPvarGetName(infervar),
5062  inferboundtype == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=",
5063  SCIPgetVarBdAtIndex(set->scip, infervar, inferboundtype, bdchgidx, TRUE),
5064  SCIPpropGetName(inferprop), inferinfo);
5065 
5066  SCIP_CALL( SCIPpropResolvePropagation(inferprop, set, infervar, inferinfo, inferboundtype, bdchgidx, relaxedbd, &result) );
5067  *resolved = (result == SCIP_SUCCESS);
5068  }
5069  break;
5070 
5072  assert(!(*resolved));
5073  break;
5074 
5075  default:
5076  SCIPerrorMessage("invalid bound change type <%d>\n", SCIPbdchginfoGetChgtype(bdchginfo));
5077  return SCIP_INVALIDDATA;
5078  }
5079 
5080  SCIPsetDebugMsg(set, "resolving status: %u\n", *resolved);
5081 
5082 #ifndef NDEBUG
5083  /* subtract the size of the conflicq queues */
5084  nforcedbdchgqueue -= SCIPpqueueNElems(conflict->forcedbdchgqueue);
5085  nbdchgqueue -= SCIPpqueueNElems(conflict->bdchgqueue);
5086 
5087  /* in case the bound change was not resolved, the conflict queues should have the same size (contents) */
5088  assert((*resolved) || (nforcedbdchgqueue == 0 && nbdchgqueue == 0));
5089 #endif
5090 
5091  return SCIP_OKAY;
5092 }
5093 
5094 /** if only one conflicting bound change of the last depth level was used, and if this can be resolved,
5095  * creates GRASP-like reconvergence conflict constraints in the conflict graph up to the branching variable of this
5096  * depth level
5097  */
5098 static
5100  SCIP_CONFLICT* conflict, /**< conflict analysis data */
5101  BMS_BLKMEM* blkmem, /**< block memory of transformed problem */
5102  SCIP_SET* set, /**< global SCIP settings */
5103  SCIP_STAT* stat, /**< problem statistics */
5104  SCIP_PROB* prob, /**< problem data */
5105  SCIP_TREE* tree, /**< branch and bound tree */
5106  SCIP_Bool diving, /**< are we in strong branching or diving mode? */
5107  int validdepth, /**< minimal depth level at which the initial conflict set is valid */
5108  SCIP_BDCHGINFO* firstuip, /**< first UIP of conflict graph */
5109  int* nreconvconss, /**< pointer to store the number of generated reconvergence constraints */
5110  int* nreconvliterals /**< pointer to store the number of literals generated reconvergence constraints */
5111  )
5112 {
5113  SCIP_BDCHGINFO* uip;
5114  SCIP_CONFTYPE conftype;
5115  SCIP_Bool usescutoffbound;
5116  int firstuipdepth;
5117  int focusdepth;
5118  int currentdepth;
5119  int maxvaliddepth;
5120 
5121  assert(conflict != NULL);
5122  assert(firstuip != NULL);
5123  assert(nreconvconss != NULL);
5124  assert(nreconvliterals != NULL);
5125  assert(!SCIPbdchginfoIsRedundant(firstuip));
5126 
5127  focusdepth = SCIPtreeGetFocusDepth(tree);
5128  currentdepth = SCIPtreeGetCurrentDepth(tree);
5129  assert(currentdepth == tree->pathlen-1);
5130  assert(focusdepth <= currentdepth);
5131 
5132  /* check, whether local constraints are allowed; however, don't generate reconvergence constraints that are only valid
5133  * in the probing path and not in the problem tree (i.e. that exceed the focusdepth)
5134  */
5135  maxvaliddepth = (set->conf_allowlocal ? MIN(currentdepth-1, focusdepth) : 0);
5136  if( validdepth > maxvaliddepth )
5137  return SCIP_OKAY;
5138 
5139  firstuipdepth = SCIPbdchginfoGetDepth(firstuip);
5140 
5141  conftype = conflict->conflictset->conflicttype;
5142  usescutoffbound = conflict->conflictset->usescutoffbound;
5143 
5144  /* for each succeeding UIP pair of the last depth level, create one reconvergence constraint */
5145  uip = firstuip;
5146  while( uip != NULL && SCIPbdchginfoGetDepth(uip) == SCIPbdchginfoGetDepth(firstuip) && bdchginfoIsResolvable(uip) )
5147  {
5148  SCIP_BDCHGINFO* oppositeuip;
5149  SCIP_BDCHGINFO* bdchginfo;
5150  SCIP_BDCHGINFO* nextuip;
5151  SCIP_VAR* uipvar;
5152  SCIP_Real oppositeuipbound;
5153  SCIP_BOUNDTYPE oppositeuipboundtype;
5154  int nresolutions;
5155 
5156  assert(!SCIPbdchginfoIsRedundant(uip));
5157 
5158  SCIPsetDebugMsg(set, "creating reconvergence constraint for UIP <%s> %s %g in depth %d pos %d\n",
5161 
5162  /* initialize conflict data */
5163  SCIP_CALL( SCIPconflictInit(conflict, set, stat, prob, conftype, usescutoffbound) );
5164 
5165  conflict->conflictset->conflicttype = conftype;
5166  conflict->conflictset->usescutoffbound = usescutoffbound;
5167 
5168  /* create a temporary bound change information for the negation of the UIP's bound change;
5169  * this bound change information is freed in the SCIPconflictFlushConss() call;
5170  * for reconvergence constraints for continuous variables we can only use the "negation" !(x <= u) == (x >= u);
5171  * during conflict analysis, we treat a continuous bound "x >= u" in the conflict set as "x > u", and in the
5172  * generated constraint this is negated again to "x <= u" which is correct.
5173  */
5174  uipvar = SCIPbdchginfoGetVar(uip);
5175  oppositeuipboundtype = SCIPboundtypeOpposite(SCIPbdchginfoGetBoundtype(uip));
5176  oppositeuipbound = SCIPbdchginfoGetNewbound(uip);
5177  if( SCIPvarIsIntegral(uipvar) )
5178  {
5179  assert(SCIPsetIsIntegral(set, oppositeuipbound));
5180  oppositeuipbound += (oppositeuipboundtype == SCIP_BOUNDTYPE_LOWER ? +1.0 : -1.0);
5181  }
5182  SCIP_CALL( conflictCreateTmpBdchginfo(conflict, blkmem, set, uipvar, oppositeuipboundtype, \
5183  oppositeuipboundtype == SCIP_BOUNDTYPE_LOWER ? SCIP_REAL_MIN : SCIP_REAL_MAX, oppositeuipbound, &oppositeuip) );
5184 
5185  /* put the negated UIP into the conflict set */
5186  SCIP_CALL( conflictAddConflictBound(conflict, blkmem, set, oppositeuip, oppositeuipbound) );
5187 
5188  /* put positive UIP into priority queue */
5189  SCIP_CALL( conflictQueueBound(conflict, set, uip, SCIPbdchginfoGetNewbound(uip) ) );
5190 
5191  /* resolve the queue until the next UIP is reached */
5192  bdchginfo = conflictFirstCand(conflict);
5193  nextuip = NULL;
5194  nresolutions = 0;
5195  while( bdchginfo != NULL && validdepth <= maxvaliddepth )
5196  {
5197  SCIP_BDCHGINFO* nextbdchginfo;
5198  SCIP_Real relaxedbd;
5199  SCIP_Bool forceresolve;
5200  int bdchgdepth;
5201 
5202  /* check if the next bound change must be resolved in every case */
5203  forceresolve = (SCIPpqueueNElems(conflict->forcedbdchgqueue) > 0);
5204 
5205  /* remove currently processed candidate and get next conflicting bound from the conflict candidate queue before
5206  * we remove the candidate we have to collect the relaxed bound since removing the candidate from the queue
5207  * invalidates the relaxed bound
5208  */
5209  assert(bdchginfo == conflictFirstCand(conflict));
5210  relaxedbd = SCIPbdchginfoGetRelaxedBound(bdchginfo);
5211  bdchginfo = conflictRemoveCand(conflict);
5212  nextbdchginfo = conflictFirstCand(conflict);
5213  bdchgdepth = SCIPbdchginfoGetDepth(bdchginfo);
5214  assert(bdchginfo != NULL);
5215  assert(!SCIPbdchginfoIsRedundant(bdchginfo));
5216  assert(nextbdchginfo == NULL || SCIPbdchginfoGetDepth(bdchginfo) >= SCIPbdchginfoGetDepth(nextbdchginfo)
5217  || forceresolve);
5218  assert(bdchgdepth <= firstuipdepth);
5219 
5220  /* bound changes that are higher in the tree than the valid depth of the conflict can be ignored;
5221  * multiple insertions of the same bound change can be ignored
5222  */
5223  if( bdchgdepth > validdepth && bdchginfo != nextbdchginfo )
5224  {
5225  SCIP_VAR* actvar;
5226  SCIP_Bool resolved;
5227 
5228  actvar = SCIPbdchginfoGetVar(bdchginfo);
5229  assert(actvar != NULL);
5230  assert(SCIPvarIsActive(actvar));
5231 
5232  /* check if we have to resolve the bound change in this depth level
5233  * - the starting uip has to be resolved
5234  * - a bound change should be resolved, if it is in the fuip's depth level and not the
5235  * next uip (i.e., if it is not the last bound change in the fuip's depth level)
5236  * - a forced bound change must be resolved in any case
5237  */
5238  resolved = FALSE;
5239  if( bdchginfo == uip
5240  || (bdchgdepth == firstuipdepth
5241  && nextbdchginfo != NULL
5242  && SCIPbdchginfoGetDepth(nextbdchginfo) == bdchgdepth)
5243  || forceresolve )
5244  {
5245  SCIP_CALL( conflictResolveBound(conflict, set, bdchginfo, relaxedbd, validdepth, &resolved) );
5246  }
5247 
5248  if( resolved )
5249  nresolutions++;
5250  else if( forceresolve )
5251  {
5252  /* variable cannot enter the conflict clause: we have to make the conflict clause local, s.t.
5253  * the unresolved bound change is active in the whole sub tree of the conflict clause
5254  */
5255  assert(bdchgdepth >= validdepth);
5256  validdepth = bdchgdepth;
5257 
5258  SCIPsetDebugMsg(set, "couldn't resolve forced bound change on <%s> -> new valid depth: %d\n",
5259  SCIPvarGetName(actvar), validdepth);
5260  }
5261  else if( bdchginfo != uip )
5262  {
5263  assert(conflict->conflictset != NULL);
5264  assert(conflict->conflictset->nbdchginfos >= 1); /* starting UIP is already member of the conflict set */
5265 
5266  /* if this is the first variable of the conflict set besides the current starting UIP, it is the next
5267  * UIP (or the first unresolvable bound change)
5268  */
5269  if( bdchgdepth == firstuipdepth && conflict->conflictset->nbdchginfos == 1 )
5270  {
5271  assert(nextuip == NULL);
5272  nextuip = bdchginfo;
5273  }
5274 
5275  /* put bound change into the conflict set */
5276  SCIP_CALL( conflictAddConflictBound(conflict, blkmem, set, bdchginfo, relaxedbd) );
5277  assert(conflict->conflictset->nbdchginfos >= 2);
5278  }
5279  else
5280  assert(conflictFirstCand(conflict) == NULL); /* the starting UIP was not resolved */
5281  }
5282 
5283  /* get next conflicting bound from the conflict candidate queue (this does not need to be nextbdchginfo, because
5284  * due to resolving the bound changes, a variable could be added to the queue which must be
5285  * resolved before nextbdchginfo)
5286  */
5287  bdchginfo = conflictFirstCand(conflict);
5288  }
5289  assert(nextuip != uip);
5290 
5291  /* if only one propagation was resolved, the reconvergence constraint is already member of the constraint set
5292  * (it is exactly the constraint that produced the propagation)
5293  */
5294  if( nextuip != NULL && nresolutions >= 2 && bdchginfo == NULL && validdepth <= maxvaliddepth )
5295  {
5296  int nlits;
5297  SCIP_Bool success;
5298 
5299  assert(SCIPbdchginfoGetDepth(nextuip) == SCIPbdchginfoGetDepth(uip));
5300 
5301  /* check conflict graph frontier on debugging solution */
5302  SCIP_CALL( SCIPdebugCheckConflictFrontier(blkmem, set, tree->path[validdepth], \
5303  bdchginfo, conflict->conflictset->bdchginfos, conflict->conflictset->relaxedbds, \
5304  conflict->conflictset->nbdchginfos, conflict->bdchgqueue, conflict->forcedbdchgqueue) ); /*lint !e506 !e774*/
5305 
5306  SCIPsetDebugMsg(set, "creating reconvergence constraint from UIP <%s> to UIP <%s> in depth %d with %d literals after %d resolutions\n",
5308  SCIPbdchginfoGetDepth(uip), conflict->conflictset->nbdchginfos, nresolutions);
5309 
5310  /* call the conflict handlers to create a conflict set */
5311  SCIP_CALL( conflictAddConflictset(conflict, blkmem, set, stat, tree, validdepth, diving, FALSE, &success, &nlits) );
5312  if( success )
5313  {
5314  (*nreconvconss)++;
5315  (*nreconvliterals) += nlits;
5316  }
5317  }
5318 
5319  /* clear the conflict candidate queue and the conflict set (to make sure, oppositeuip is not referenced anymore) */
5320  conflictClear(conflict);
5321 
5322  uip = nextuip;
5323  }
5324 
5325  conflict->conflictset->conflicttype = conftype;
5326  conflict->conflictset->usescutoffbound = usescutoffbound;
5327 
5328  return SCIP_OKAY;
5329 }
5330 
5331 /** analyzes conflicting bound changes that were added with calls to SCIPconflictAddBound() and
5332  * SCIPconflictAddRelaxedBound(), and on success, calls the conflict handlers to create a conflict constraint out of
5333  * the resulting conflict set; afterwards the conflict queue and the conflict set is cleared
5334  */
5335 static
5337  SCIP_CONFLICT* conflict, /**< conflict analysis data */
5338  BMS_BLKMEM* blkmem, /**< block memory of transformed problem */
5339  SCIP_SET* set, /**< global SCIP settings */
5340  SCIP_STAT* stat, /**< problem statistics */
5341  SCIP_PROB* prob, /**< problem data */
5342  SCIP_TREE* tree, /**< branch and bound tree */
5343  SCIP_Bool diving, /**< are we in strong branching or diving mode? */
5344  int validdepth, /**< minimal depth level at which the initial conflict set is valid */
5345  SCIP_Bool mustresolve, /**< should the conflict set only be used, if a resolution was applied? */
5346  int* nconss, /**< pointer to store the number of generated conflict constraints */
5347  int* nliterals, /**< pointer to store the number of literals in generated conflict constraints */
5348  int* nreconvconss, /**< pointer to store the number of generated reconvergence constraints */
5349  int* nreconvliterals /**< pointer to store the number of literals generated reconvergence constraints */
5350  )
5351 {
5352  SCIP_BDCHGINFO* bdchginfo;
5353  SCIP_BDCHGINFO** firstuips;
5354  SCIP_CONFTYPE conftype;
5355  int nfirstuips;
5356  int focusdepth;
5357  int currentdepth;
5358  int maxvaliddepth;
5359  int resolvedepth;
5360  int nresolutions;
5361  int lastconsnresolutions;
5362  int lastconsresoldepth;
5363 
5364  assert(conflict != NULL);
5365  assert(conflict->conflictset != NULL);
5366  assert(conflict->conflictset->nbdchginfos >= 0);
5367  assert(set != NULL);
5368  assert(stat != NULL);
5369  assert(0 <= validdepth && validdepth <= SCIPtreeGetCurrentDepth(tree));
5370  assert(nconss != NULL);
5371  assert(nliterals != NULL);
5372  assert(nreconvconss != NULL);
5373  assert(nreconvliterals != NULL);
5374 
5375  focusdepth = SCIPtreeGetFocusDepth(tree);
5376  currentdepth = SCIPtreeGetCurrentDepth(tree);
5377  assert(currentdepth == tree->pathlen-1);
5378  assert(focusdepth <= currentdepth);
5379 
5380  resolvedepth = ((set->conf_fuiplevels >= 0 && set->conf_fuiplevels <= currentdepth)
5381  ? currentdepth - set->conf_fuiplevels + 1 : 0);
5382  assert(0 <= resolvedepth && resolvedepth <= currentdepth + 1);
5383 
5384  /* if we must resolve at least one bound change, find the first UIP at least in the last depth level */
5385  if( mustresolve )
5386  resolvedepth = MIN(resolvedepth, currentdepth);
5387 
5388  SCIPsetDebugMsg(set, "analyzing conflict with %d+%d conflict candidates and starting conflict set of size %d in depth %d (resolvedepth=%d)\n",
5390  conflict->conflictset->nbdchginfos, currentdepth, resolvedepth);
5391 
5392  *nconss = 0;
5393  *nliterals = 0;
5394  *nreconvconss = 0;
5395  *nreconvliterals = 0;
5396 
5397  /* check, whether local conflicts are allowed; however, don't generate conflict constraints that are only valid in the
5398  * probing path and not in the problem tree (i.e. that exceed the focusdepth)
5399  */
5400  maxvaliddepth = (set->conf_allowlocal ? MIN(currentdepth-1, focusdepth) : 0);
5401  if( validdepth > maxvaliddepth )
5402  return SCIP_OKAY;
5403 
5404  /* allocate temporary memory for storing first UIPs (in each depth level, at most two bound changes can be flagged
5405  * as UIP, namely a binary and a non-binary bound change)
5406  */
5407  SCIP_CALL( SCIPsetAllocBufferArray(set, &firstuips, 2*(currentdepth+1)) ); /*lint !e647*/
5408 
5409  /* process all bound changes in the conflict candidate queue */
5410  nresolutions = 0;
5411  lastconsnresolutions = (mustresolve ? 0 : -1);
5412  lastconsresoldepth = (mustresolve ? currentdepth : INT_MAX);
5413  bdchginfo = conflictFirstCand(conflict);
5414  nfirstuips = 0;
5415 
5416  /* check if the initial reason on debugging solution */
5417  SCIP_CALL( SCIPdebugCheckConflictFrontier(blkmem, set, tree->path[validdepth], \
5418  NULL, conflict->conflictset->bdchginfos, conflict->conflictset->relaxedbds, conflict->conflictset->nbdchginfos, \
5419  conflict->bdchgqueue, conflict->forcedbdchgqueue) ); /*lint !e506 !e774*/
5420 
5421  while( bdchginfo != NULL && validdepth <= maxvaliddepth )
5422  {
5423  SCIP_BDCHGINFO* nextbdchginfo;
5424  SCIP_Real relaxedbd;
5425  SCIP_Bool forceresolve;
5426  int bdchgdepth;
5427 
5428  assert(!SCIPbdchginfoIsRedundant(bdchginfo));
5429 
5430  /* check if the next bound change must be resolved in every case */
5431  forceresolve = (SCIPpqueueNElems(conflict->forcedbdchgqueue) > 0);
5432 
5433  /* resolve next bound change in queue */
5434  bdchgdepth = SCIPbdchginfoGetDepth(bdchginfo);
5435  assert(0 <= bdchgdepth && bdchgdepth <= currentdepth);
5436  assert(SCIPvarIsActive(SCIPbdchginfoGetVar(bdchginfo)));
5437  assert(bdchgdepth < tree->pathlen);
5438  assert(tree->path[bdchgdepth] != NULL);
5439  assert(tree->path[bdchgdepth]->domchg != NULL);
5440  assert(SCIPbdchginfoGetPos(bdchginfo) < (int)tree->path[bdchgdepth]->domchg->domchgbound.nboundchgs);
5441  assert(tree->path[bdchgdepth]->domchg->domchgbound.boundchgs[SCIPbdchginfoGetPos(bdchginfo)].var
5442  == SCIPbdchginfoGetVar(bdchginfo));
5443  assert(tree->path[bdchgdepth]->domchg->domchgbound.boundchgs[SCIPbdchginfoGetPos(bdchginfo)].newbound
5444  == SCIPbdchginfoGetNewbound(bdchginfo)
5447  == SCIPbdchginfoGetNewbound(bdchginfo)); /*lint !e777*/
5448  assert((SCIP_BOUNDTYPE)tree->path[bdchgdepth]->domchg->domchgbound.boundchgs[SCIPbdchginfoGetPos(bdchginfo)].boundtype
5449  == SCIPbdchginfoGetBoundtype(bdchginfo));
5450 
5451  /* create intermediate conflict constraint */
5452  assert(nresolutions >= lastconsnresolutions);
5453  if( !forceresolve )
5454  {
5455  if( nresolutions == lastconsnresolutions )
5456  lastconsresoldepth = bdchgdepth; /* all intermediate depth levels consisted of only unresolved bound changes */
5457  else if( bdchgdepth < lastconsresoldepth && (set->conf_interconss == -1 || *nconss < set->conf_interconss) )
5458  {
5459  int nlits;
5460  SCIP_Bool success;
5461 
5462  /* call the conflict handlers to create a conflict set */
5463  SCIPsetDebugMsg(set, "creating intermediate conflictset after %d resolutions up to depth %d (valid at depth %d): %d conflict bounds, %d bounds in queue\n",
5464  nresolutions, bdchgdepth, validdepth, conflict->conflictset->nbdchginfos,
5465  SCIPpqueueNElems(conflict->bdchgqueue));
5466 
5467  SCIP_CALL( conflictAddConflictset(conflict, blkmem, set, stat, tree, validdepth, diving, TRUE, &success, &nlits) );
5468  lastconsnresolutions = nresolutions;
5469  lastconsresoldepth = bdchgdepth;
5470  if( success )
5471  {
5472  (*nconss)++;
5473  (*nliterals) += nlits;
5474  }
5475  }
5476  }
5477 
5478  /* remove currently processed candidate and get next conflicting bound from the conflict candidate queue before
5479  * we remove the candidate we have to collect the relaxed bound since removing the candidate from the queue
5480  * invalidates the relaxed bound
5481  */
5482  assert(bdchginfo == conflictFirstCand(conflict));
5483  relaxedbd = SCIPbdchginfoGetRelaxedBound(bdchginfo);
5484  bdchginfo = conflictRemoveCand(conflict);
5485  nextbdchginfo = conflictFirstCand(conflict);
5486  assert(bdchginfo != NULL);
5487  assert(!SCIPbdchginfoIsRedundant(bdchginfo));
5488  assert(nextbdchginfo == NULL || SCIPbdchginfoGetDepth(bdchginfo) >= SCIPbdchginfoGetDepth(nextbdchginfo)
5489  || forceresolve);
5490 
5491  /* we don't need to resolve bound changes that are already active in the valid depth of the current conflict set,
5492  * because the conflict set can only be added locally at the valid depth, and all bound changes applied in this
5493  * depth or earlier can be removed from the conflict constraint, since they are already applied in the constraint's
5494  * subtree;
5495  * if the next bound change on the remaining queue is equal to the current bound change,
5496  * this is a multiple insertion in the conflict candidate queue and we can ignore the current
5497  * bound change
5498  */
5499  if( bdchgdepth > validdepth && bdchginfo != nextbdchginfo )
5500  {
5501  SCIP_VAR* actvar;
5502  SCIP_Bool resolved;
5503 
5504  actvar = SCIPbdchginfoGetVar(bdchginfo);
5505  assert(actvar != NULL);
5506  assert(SCIPvarIsActive(actvar));
5507 
5508  /* check if we want to resolve the bound change in this depth level
5509  * - bound changes should be resolved, if
5510  * (i) we must apply at least one resolution and didn't resolve a bound change yet, or
5511  * (ii) their depth level is at least equal to the minimal resolving depth, and
5512  * they are not the last remaining conflicting bound change in their depth level
5513  * (iii) the bound change resolving is forced (i.e., the forced queue was non-empty)
5514  */
5515  resolved = FALSE;
5516  if( (mustresolve && nresolutions == 0)
5517  || (bdchgdepth >= resolvedepth
5518  && nextbdchginfo != NULL
5519  && SCIPbdchginfoGetDepth(nextbdchginfo) == bdchgdepth)
5520  || forceresolve )
5521  {
5522  SCIP_CALL( conflictResolveBound(conflict, set, bdchginfo, relaxedbd, validdepth, &resolved) );
5523  }
5524 
5525  if( resolved )
5526  nresolutions++;
5527  else if( forceresolve )
5528  {
5529  /* variable cannot enter the conflict clause: we have to make the conflict clause local, s.t.
5530  * the unresolved bound change is active in the whole sub tree of the conflict clause
5531  */
5532  assert(bdchgdepth >= validdepth);
5533  validdepth = bdchgdepth;
5534 
5535  SCIPsetDebugMsg(set, "couldn't resolve forced bound change on <%s> -> new valid depth: %d\n",
5536  SCIPvarGetName(actvar), validdepth);
5537  }
5538  else
5539  {
5540  /* if this is a UIP (the last bound change in its depth level), it can be used to generate a
5541  * UIP reconvergence constraint
5542  */
5543  if( nextbdchginfo == NULL || SCIPbdchginfoGetDepth(nextbdchginfo) != bdchgdepth )
5544  {
5545  assert(nfirstuips < 2*(currentdepth+1));
5546  firstuips[nfirstuips] = bdchginfo;
5547  nfirstuips++;
5548  }
5549 
5550  /* put variable into the conflict set, using the literal that is currently fixed to FALSE */
5551  SCIP_CALL( conflictAddConflictBound(conflict, blkmem, set, bdchginfo, relaxedbd) );
5552  }
5553  }
5554 
5555  /* check conflict graph frontier on debugging solution */
5556  SCIP_CALL( SCIPdebugCheckConflictFrontier(blkmem, set, tree->path[validdepth], \
5557  bdchginfo, conflict->conflictset->bdchginfos, conflict->conflictset->relaxedbds, conflict->conflictset->nbdchginfos, \
5558  conflict->bdchgqueue, conflict->forcedbdchgqueue) ); /*lint !e506 !e774*/
5559 
5560  /* get next conflicting bound from the conflict candidate queue (this needs not to be nextbdchginfo, because
5561  * due to resolving the bound changes, a bound change could be added to the queue which must be
5562  * resolved before nextbdchginfo)
5563  */
5564  bdchginfo = conflictFirstCand(conflict);
5565  }
5566 
5567  /* check, if a valid conflict set was found */
5568  if( bdchginfo == NULL
5569  && nresolutions > lastconsnresolutions
5570  && validdepth <= maxvaliddepth
5571  && (!mustresolve || nresolutions > 0 || conflict->conflictset->nbdchginfos == 0)
5572  && SCIPpqueueNElems(conflict->forcedbdchgqueue) == 0 )
5573  {
5574  int nlits;
5575  SCIP_Bool success;
5576 
5577  /* call the conflict handlers to create a conflict set */
5578  SCIP_CALL( conflictAddConflictset(conflict, blkmem, set, stat, tree, validdepth, diving, TRUE, &success, &nlits) );
5579  if( success )
5580  {
5581  (*nconss)++;
5582  (*nliterals) += nlits;
5583  }
5584  }
5585 
5586  /* produce reconvergence constraints defined by succeeding UIP's of the last depth level */
5587  if( set->conf_reconvlevels != 0 && validdepth <= maxvaliddepth )
5588  {
5589  int reconvlevels;
5590  int i;
5591 
5592  reconvlevels = (set->conf_reconvlevels == -1 ? INT_MAX : set->conf_reconvlevels);
5593  for( i = 0; i < nfirstuips; ++i )
5594  {
5595  if( SCIPbdchginfoHasInferenceReason(firstuips[i])
5596  && currentdepth - SCIPbdchginfoGetDepth(firstuips[i]) < reconvlevels )
5597  {
5598  SCIP_CALL( conflictCreateReconvergenceConss(conflict, blkmem, set, stat, prob, tree, diving, \
5599  validdepth, firstuips[i], nreconvconss, nreconvliterals) );
5600  }
5601  }
5602  }
5603 
5604  /* free the temporary memory */
5605  SCIPsetFreeBufferArray(set, &firstuips);
5606 
5607  /* store last conflict type */
5608  conftype = conflict->conflictset->conflicttype;
5609 
5610  /* clear the conflict candidate queue and the conflict set */
5611  conflictClear(conflict);
5612 
5613  /* restore last conflict type */
5614  conflict->conflictset->conflicttype = conftype;
5615 
5616  return SCIP_OKAY;
5617 }
5618 
5619 /** analyzes conflicting bound changes that were added with calls to SCIPconflictAddBound(), and on success, calls the
5620  * conflict handlers to create a conflict constraint out of the resulting conflict set;
5621  * updates statistics for propagation conflict analysis
5622  */
5624  SCIP_CONFLICT* conflict, /**< conflict analysis data */
5625  BMS_BLKMEM* blkmem, /**< block memory of transformed problem */
5626  SCIP_SET* set, /**< global SCIP settings */
5627  SCIP_STAT* stat, /**< problem statistics */
5628  SCIP_PROB* prob, /**< problem data */
5629  SCIP_TREE* tree, /**< branch and bound tree */
5630  int validdepth, /**< minimal depth level at which the initial conflict set is valid */
5631  SCIP_Bool* success /**< pointer to store whether a conflict constraint was created, or NULL */
5632  )
5633 {
5634  int nconss;
5635  int nliterals;
5636  int nreconvconss;
5637  int nreconvliterals;
5638 
5639  assert(conflict != NULL);
5640  assert(conflict->conflictset != NULL);
5641  assert(set != NULL);
5642  assert(prob != NULL);
5643 
5644  if( success != NULL )
5645  *success = FALSE;
5646 
5647  /* check if the conflict analysis is applicable */
5648  if( !SCIPconflictApplicable(set) )
5649  return SCIP_OKAY;
5650 
5651  /* check, if the conflict set will get too large with high probability */
5652  if( conflict->conflictset->nbdchginfos + SCIPpqueueNElems(conflict->bdchgqueue)
5653  + SCIPpqueueNElems(conflict->forcedbdchgqueue) >= 2*conflictCalcMaxsize(set, prob) )
5654  return SCIP_OKAY;
5655 
5656  SCIPsetDebugMsg(set, "analyzing conflict after infeasible propagation in depth %d\n", SCIPtreeGetCurrentDepth(tree));
5657 
5658  /* start timing */
5659  SCIPclockStart(conflict->propanalyzetime, set);
5660 
5661  conflict->npropcalls++;
5662 
5663  /* analyze the conflict set, and create a conflict constraint on success */
5664  SCIP_CALL( conflictAnalyze(conflict, blkmem, set, stat, prob, tree, FALSE, validdepth, TRUE, &nconss, &nliterals, \
5665  &nreconvconss, &nreconvliterals) );
5666  conflict->npropsuccess += (nconss > 0 ? 1 : 0);
5667  conflict->npropconfconss += nconss;
5668  conflict->npropconfliterals += nliterals;
5669  conflict->npropreconvconss += nreconvconss;
5670  conflict->npropreconvliterals += nreconvliterals;
5671  if( success != NULL )
5672  *success = (nconss > 0);
5673 
5674  /* stop timing */
5675  SCIPclockStop(conflict->propanalyzetime, set);
5676 
5677  return SCIP_OKAY;
5678 }
5679 
5680 /** gets time in seconds used for preprocessing global conflict constraint before appliance */
5682  SCIP_CONFLICT* conflict /**< conflict analysis data */
5683  )
5684 {
5685  assert(conflict != NULL);
5686 
5687  return SCIPclockGetTime(conflict->dIBclock);
5688 }
5689 
5690 /** gets time in seconds used for analyzing propagation conflicts */
5692  SCIP_CONFLICT* conflict /**< conflict analysis data */
5693  )
5694 {
5695  assert(conflict != NULL);
5696 
5697  return SCIPclockGetTime(conflict->propanalyzetime);
5698 }
5699 
5700 /** gets number of calls to propagation conflict analysis */
5702  SCIP_CONFLICT* conflict /**< conflict analysis data */
5703  )
5704 {
5705  assert(conflict != NULL);
5706 
5707  return conflict->npropcalls;
5708 }
5709 
5710 /** gets number of calls to propagation conflict analysis that yield at least one conflict constraint */
5712  SCIP_CONFLICT* conflict /**< conflict analysis data */
5713  )
5714 {
5715  assert(conflict != NULL);
5716 
5717  return conflict->npropsuccess;
5718 }
5719 
5720 /** gets number of conflict constraints detected in propagation conflict analysis */
5722  SCIP_CONFLICT* conflict /**< conflict analysis data */
5723  )
5724 {
5725  assert(conflict != NULL);
5726 
5727  return conflict->npropconfconss;
5728 }
5729 
5730 /** gets total number of literals in conflict constraints created in propagation conflict analysis */
5732  SCIP_CONFLICT* conflict /**< conflict analysis data */
5733  )
5734 {
5735  assert(conflict != NULL);
5736 
5737  return conflict->npropconfliterals;
5738 }
5739 
5740 /** gets number of reconvergence constraints detected in propagation conflict analysis */
5742  SCIP_CONFLICT* conflict /**< conflict analysis data */
5743  )
5744 {
5745  assert(conflict != NULL);
5746 
5747  return conflict->npropreconvconss;
5748 }
5749 
5750 /** gets total number of literals in reconvergence constraints created in propagation conflict analysis */
5752  SCIP_CONFLICT* conflict /**< conflict analysis data */
5753  )
5754 {
5755  assert(conflict != NULL);
5756 
5757  return conflict->npropreconvliterals;
5758 }
5759 
5760 
5761 
5762 
5763 /*
5764  * Infeasible LP Conflict Analysis
5765  */
5766 
5767 /** ensures, that side change arrays can store at least num entries */
5768 static
5770  SCIP_SET* set, /**< global SCIP settings */
5771  int** sidechginds, /**< pointer to side change index array */
5772  SCIP_Real** sidechgoldlhss, /**< pointer to side change old left hand sides array */
5773  SCIP_Real** sidechgoldrhss, /**< pointer to side change old right hand sides array */
5774  SCIP_Real** sidechgnewlhss, /**< pointer to side change new left hand sides array */
5775  SCIP_Real** sidechgnewrhss, /**< pointer to side change new right hand sides array */
5776  int* sidechgssize, /**< pointer to size of side change arrays */
5777  int num /**< minimal number of entries to be able to store in side change arrays */
5778  )
5779 {
5780  assert(sidechginds != NULL);
5781  assert(sidechgoldlhss != NULL);
5782  assert(sidechgoldrhss != NULL);
5783  assert(sidechgnewlhss != NULL);
5784  assert(sidechgnewrhss != NULL);
5785  assert(sidechgssize != NULL);
5786 
5787  if( num > *sidechgssize )
5788  {
5789  int newsize;
5790 
5791  newsize = SCIPsetCalcMemGrowSize(set, num);
5792  SCIP_CALL( SCIPsetReallocBufferArray(set, sidechginds, newsize) );
5793  SCIP_CALL( SCIPsetReallocBufferArray(set, sidechgoldlhss, newsize) );
5794  SCIP_CALL( SCIPsetReallocBufferArray(set, sidechgoldrhss, newsize) );
5795  SCIP_CALL( SCIPsetReallocBufferArray(set, sidechgnewlhss, newsize) );
5796  SCIP_CALL( SCIPsetReallocBufferArray(set, sidechgnewrhss, newsize) );
5797  *sidechgssize = newsize;
5798  }
5799  assert(num <= *sidechgssize);
5800 
5801  return SCIP_OKAY;
5802 }
5803 
5804 /** adds removal of row's side to side change arrays; finite sides are only replaced by near infinite sides, such
5805  * that the row's sense in the LP solver is not changed
5806  */
5807 static
5809  SCIP_SET* set, /**< global SCIP settings */
5810  SCIP_ROW* row, /**< LP row to change the sides for */
5811  SCIP_Real lpiinfinity, /**< value treated as infinity in LP solver */
5812  int** sidechginds, /**< pointer to side change index array */
5813  SCIP_Real** sidechgoldlhss, /**< pointer to side change old left hand sides array */
5814  SCIP_Real** sidechgoldrhss, /**< pointer to side change old right hand sides array */
5815  SCIP_Real** sidechgnewlhss, /**< pointer to side change new left hand sides array */
5816  SCIP_Real** sidechgnewrhss, /**< pointer to side change new right hand sides array */
5817  int* sidechgssize, /**< pointer to size of side change arrays */
5818  int* nsidechgs /**< pointer to number of used slots in side change arrays */
5819  )
5820 {
5821  SCIP_Real lhs;
5822  SCIP_Real rhs;
5823  SCIP_Real constant;
5824 
5825  assert(sidechginds != NULL);
5826  assert(sidechgoldlhss != NULL);
5827  assert(sidechgoldrhss != NULL);
5828  assert(sidechgnewlhss != NULL);
5829  assert(sidechgnewrhss != NULL);
5830  assert(sidechgssize != NULL);
5831  assert(nsidechgs != NULL);
5832 
5833  lhs = SCIProwGetLhs(row);
5834  rhs = SCIProwGetRhs(row);
5835  constant = SCIProwGetConstant(row);
5836  assert(!SCIPsetIsInfinity(set, -lhs) || !SCIPsetIsInfinity(set, rhs));
5837 
5838  /* get memory to store additional side change */
5839  SCIP_CALL( ensureSidechgsSize(set, sidechginds, sidechgoldlhss, sidechgoldrhss, sidechgnewlhss, sidechgnewrhss, \
5840  sidechgssize, (*nsidechgs)+1) );
5841  assert(*nsidechgs < *sidechgssize);
5842  assert(*sidechginds != NULL);
5843  assert(*sidechgoldlhss != NULL);
5844  assert(*sidechgoldrhss != NULL);
5845  assert(*sidechgnewlhss != NULL);
5846  assert(*sidechgnewrhss != NULL);
5847 
5848  /* store side change */
5849  (*sidechginds)[*nsidechgs] = SCIProwGetLPPos(row);
5850  if( SCIPsetIsInfinity(set, -lhs) )
5851  {
5852  (*sidechgoldlhss)[*nsidechgs] = -lpiinfinity;
5853  (*sidechgnewlhss)[*nsidechgs] = -lpiinfinity;
5854  }
5855  else
5856  {
5857  (*sidechgoldlhss)[*nsidechgs] = lhs - constant;
5858  (*sidechgnewlhss)[*nsidechgs] = -lpiinfinity;
5859  }
5860  if( SCIPsetIsInfinity(set, rhs) )
5861  {
5862  (*sidechgoldrhss)[*nsidechgs] = lpiinfinity;
5863  (*sidechgnewrhss)[*nsidechgs] = lpiinfinity;
5864  }
5865  else
5866  {
5867  (*sidechgoldrhss)[*nsidechgs] = rhs - constant;
5868  (*sidechgnewrhss)[*nsidechgs] = lpiinfinity;
5869  }
5870  (*nsidechgs)++;
5871 
5872  return SCIP_OKAY;
5873 }
5874 
5875 /** inserts variable's new bounds into bound change arrays */
5876 static
5878  SCIP_SET* set, /**< global SCIP settings */
5879  SCIP_VAR* var, /**< variable to change the LP bounds for */
5880  SCIP_Real newlb, /**< new lower bound */
5881  SCIP_Real newub, /**< new upper bound */
5882  SCIP_LPBDCHGS* oldlpbdchgs, /**< old LP bound changes used for reset the LP bound change */
5883  SCIP_LPBDCHGS* relaxedlpbdchgs, /**< relaxed LP bound changes used for reset the LP bound change */
5884  SCIP_LPI* lpi /**< pointer to LPi to access infinity of LP solver; necessary to set correct value */
5885  )
5886 {
5887  assert(newlb <= newub);
5888  assert(oldlpbdchgs != NULL);
5889  assert(relaxedlpbdchgs != NULL);
5890 
5892  {
5893  SCIP_COL* col;
5894  int idx;
5895  int c;
5896 
5897  col = SCIPvarGetCol(var);
5898  c = SCIPcolGetLPPos(col);
5899 
5900  if( c >= 0 )
5901  {
5902  /* store old bound change for resetting the LP later */
5903  if( !oldlpbdchgs->usedcols[c] )
5904  {
5905  idx = oldlpbdchgs->nbdchgs;
5906  oldlpbdchgs->usedcols[c] = TRUE;
5907  oldlpbdchgs->bdchgcolinds[c] = idx;
5908  oldlpbdchgs->nbdchgs++;
5909 
5910  oldlpbdchgs->bdchginds[idx] = c;
5911  oldlpbdchgs->bdchglbs[idx] = SCIPvarGetLbLP(var, set);
5912  oldlpbdchgs->bdchgubs[idx] = SCIPvarGetUbLP(var, set);
5913  }
5914  assert(oldlpbdchgs->bdchginds[oldlpbdchgs->bdchgcolinds[c]] == c);
5915  assert((SCIPlpiIsInfinity(lpi, -oldlpbdchgs->bdchglbs[oldlpbdchgs->bdchgcolinds[c]]) && SCIPsetIsInfinity(set, -SCIPvarGetLbLP(var, set))) ||
5916  SCIPsetIsEQ(set, oldlpbdchgs->bdchglbs[oldlpbdchgs->bdchgcolinds[c]], SCIPvarGetLbLP(var, set)));
5917  assert((SCIPlpiIsInfinity(lpi, oldlpbdchgs->bdchgubs[oldlpbdchgs->bdchgcolinds[c]]) && SCIPsetIsInfinity(set, SCIPvarGetUbLP(var, set))) ||
5918  SCIPsetIsEQ(set, oldlpbdchgs->bdchgubs[oldlpbdchgs->bdchgcolinds[c]], SCIPvarGetUbLP(var, set)));
5919 
5920  /* store bound change for conflict analysis */
5921  if( !relaxedlpbdchgs->usedcols[c] )
5922  {
5923  idx = relaxedlpbdchgs->nbdchgs;
5924  relaxedlpbdchgs->usedcols[c] = TRUE;
5925  relaxedlpbdchgs->bdchgcolinds[c] = idx;
5926  relaxedlpbdchgs->nbdchgs++;
5927 
5928  /* remember the positive for later further bound widenings */
5929  relaxedlpbdchgs->bdchginds[idx] = c;
5930  }
5931  else
5932  {
5933  idx = relaxedlpbdchgs->bdchgcolinds[c];
5934  assert(relaxedlpbdchgs->bdchginds[idx] == c);
5935 
5936  /* the new bound should be the same or more relaxed */
5937  assert(relaxedlpbdchgs->bdchglbs[idx] >= newlb ||
5938  (SCIPlpiIsInfinity(lpi, -relaxedlpbdchgs->bdchglbs[idx]) && SCIPsetIsInfinity(set, -newlb)));
5939  assert(relaxedlpbdchgs->bdchgubs[idx] <= newub ||
5940  (SCIPlpiIsInfinity(lpi, relaxedlpbdchgs->bdchgubs[idx]) && SCIPsetIsInfinity(set, newub)));
5941  }
5942 
5943  /* set the new bounds for the LP with the correct infinity value */
5944  relaxedlpbdchgs->bdchglbs[idx] = SCIPsetIsInfinity(set, -newlb) ? -SCIPlpiInfinity(lpi) : newlb;
5945  relaxedlpbdchgs->bdchgubs[idx] = SCIPsetIsInfinity(set, newub) ? SCIPlpiInfinity(lpi) : newub;
5946  if( SCIPsetIsInfinity(set, -oldlpbdchgs->bdchglbs[idx]) )
5947  oldlpbdchgs->bdchglbs[idx] = -SCIPlpiInfinity(lpi);
5948  if( SCIPsetIsInfinity(set, oldlpbdchgs->bdchgubs[idx]) )
5949  oldlpbdchgs->bdchgubs[idx] = SCIPlpiInfinity(lpi);
5950  }
5951  }
5952 
5953  return SCIP_OKAY;
5954 }
5955 
5956 /** ensures, that candidate array can store at least num entries */
5957 static
5959  SCIP_SET* set, /**< global SCIP settings */
5960  SCIP_VAR*** cands, /**< pointer to candidate array */
5961  SCIP_Real** candscores, /**< pointer to candidate score array */
5962  SCIP_Real** newbounds, /**< pointer to candidate new bounds array */
5963  SCIP_Real** proofactdeltas, /**< pointer to candidate proof delta array */
5964  int* candssize, /**< pointer to size of array */
5965  int num /**< minimal number of candidates to store in array */
5966  )
5967 {
5968  assert(cands != NULL);
5969  assert(candssize != NULL);
5970 
5971  if( num > *candssize )
5972  {
5973  int newsize;
5974 
5975  newsize = SCIPsetCalcMemGrowSize(set, num);
5976  SCIP_CALL( SCIPsetReallocBufferArray(set, cands, newsize) );
5977  SCIP_CALL( SCIPsetReallocBufferArray(set, candscores, newsize) );
5978  SCIP_CALL( SCIPsetReallocBufferArray(set, newbounds, newsize) );
5979  SCIP_CALL( SCIPsetReallocBufferArray(set, proofactdeltas, newsize) );
5980  *candssize = newsize;
5981  }
5982  assert(num <= *candssize);
5983 
5984  return SCIP_OKAY;
5985 }
5986 
5987 /** adds variable to candidate list, if the current best bound corresponding to the proof coefficient is local;
5988  * returns the array position in the candidate list, where the new candidate was inserted, or -1 if the
5989  * variable can relaxed to global bounds immediately without increasing the proof's activity;
5990  * the candidates are sorted with respect to the following two criteria:
5991  * - prefer bound changes that have been applied deeper in the tree, to get a more global conflict
5992  * - prefer variables with small Farkas coefficient to get rid of as many bound changes as possible
5993  */
5994 static
5996  SCIP_SET* set, /**< global SCIP settings */
5997  int currentdepth, /**< current depth in the tree */
5998  SCIP_VAR* var, /**< variable to add to candidate array */
5999  int lbchginfopos, /**< positions of currently active lower bound change information in variable's array */
6000  int ubchginfopos, /**< positions of currently active upper bound change information in variable's array */
6001  SCIP_Real proofcoef, /**< coefficient of variable in infeasibility/bound proof */
6002  SCIP_Real prooflhs, /**< left hand side of infeasibility/bound proof */
6003  SCIP_Real proofact, /**< activity of infeasibility/bound proof row */
6004  SCIP_VAR*** cands, /**< pointer to candidate array for undoing bound changes */
6005  SCIP_Real** candscores, /**< pointer to candidate score array for undoing bound changes */
6006  SCIP_Real** newbounds, /**< pointer to candidate new bounds array for undoing bound changes */
6007  SCIP_Real** proofactdeltas, /**< pointer to proof activity increase array for undoing bound changes */
6008  int* candssize, /**< pointer to size of cands arrays */
6009  int* ncands, /**< pointer to count number of candidates in bound change list */
6010  int firstcand /**< position of first unprocessed bound change candidate */
6011  )
6012 {
6013  SCIP_Real oldbound;
6014  SCIP_Real newbound;
6015  SCIP_Real QUAD(proofactdelta);
6016  SCIP_Real score;
6017  int depth;
6018  int i;
6019  SCIP_Bool resolvable;
6020 
6021  assert(set != NULL);
6022  assert(var != NULL);
6023  assert(-1 <= lbchginfopos && lbchginfopos <= var->nlbchginfos);
6024  assert(-1 <= ubchginfopos && ubchginfopos <= var->nubchginfos);
6025  assert(!SCIPsetIsZero(set, proofcoef));
6026  assert(SCIPsetIsGT(set, prooflhs, proofact));
6027  assert(cands != NULL);
6028  assert(candscores != NULL);
6029  assert(newbounds != NULL);
6030  assert(proofactdeltas != NULL);
6031  assert(candssize != NULL);
6032  assert(ncands != NULL);
6033  assert(*ncands <= *candssize);
6034  assert(0 <= firstcand && firstcand <= *ncands);
6035 
6036  /* in the infeasibility or dual bound proof, the variable's bound is chosen to maximize the proof's activity */
6037  if( proofcoef > 0.0 )
6038  {
6039  assert(ubchginfopos >= 0); /* otherwise, undoBdchgsProof() should already have relaxed the local bound */
6040 
6041  /* calculate the difference of current bound to the previous bound the variable was set to */
6042  if( ubchginfopos == var->nubchginfos )
6043  {
6044  /* current bound is the strong branching or diving bound */
6045  oldbound = SCIPvarGetUbLP(var, set);
6046  newbound = SCIPvarGetUbLocal(var);
6047  depth = currentdepth+1;
6048  resolvable = FALSE;
6049  }
6050  else
6051  {
6052  /* current bound is the result of a local bound change */
6053  resolvable = bdchginfoIsResolvable(&var->ubchginfos[ubchginfopos]);
6054  depth = var->ubchginfos[ubchginfopos].bdchgidx.depth;
6055  oldbound = var->ubchginfos[ubchginfopos].newbound;
6056  newbound = var->ubchginfos[ubchginfopos].oldbound;
6057  }
6058  }
6059  else
6060  {
6061  assert(lbchginfopos >= 0); /* otherwise, undoBdchgsProof() should already have relaxed the local bound */
6062 
6063  /* calculate the difference of current bound to the previous bound the variable was set to */
6064  if( lbchginfopos == var->nlbchginfos )
6065  {
6066  /* current bound is the strong branching or diving bound */
6067  oldbound = SCIPvarGetLbLP(var, set);
6068  newbound = SCIPvarGetLbLocal(var);
6069  depth = currentdepth+1;
6070  resolvable = FALSE;
6071  }
6072  else
6073  {
6074  /* current bound is the result of a local bound change */
6075  resolvable = bdchginfoIsResolvable(&var->lbchginfos[lbchginfopos]);
6076  depth = var->lbchginfos[lbchginfopos].bdchgidx.depth;
6077  oldbound = var->lbchginfos[lbchginfopos].newbound;
6078  newbound = var->lbchginfos[lbchginfopos].oldbound;
6079  }
6080  }
6081 
6082  /* calculate the increase in the proof's activity */
6083  SCIPquadprecSumDD(proofactdelta, newbound, -oldbound);
6084  SCIPquadprecProdQD(proofactdelta, proofactdelta, proofcoef);
6085  assert(QUAD_TO_DBL(proofactdelta) > 0.0);
6086 
6087  /* calculate score for undoing the bound change */
6088  score = calcBdchgScore(prooflhs, proofact, QUAD_TO_DBL(proofactdelta), proofcoef, depth, currentdepth, var, set);
6089 
6090  if( !resolvable )
6091  {
6092  score += 10.0;
6093  if( !SCIPvarIsBinary(var) )
6094  score += 10.0;
6095  }
6096 
6097  /* get enough memory to store new candidate */
6098  SCIP_CALL( ensureCandsSize(set, cands, candscores, newbounds, proofactdeltas, candssize, (*ncands)+1) );
6099  assert(*cands != NULL);
6100  assert(*candscores != NULL);
6101  assert(*newbounds != NULL);
6102  assert(*proofactdeltas != NULL);
6103 
6104  SCIPsetDebugMsg(set, " -> local <%s> %s %g, relax <%s> %s %g, proofcoef=%g, dpt=%d, resolve=%u, delta=%g, score=%g\n",
6105  SCIPvarGetName(var), proofcoef > 0.0 ? "<=" : ">=", oldbound,
6106  SCIPvarGetName(var), proofcoef > 0.0 ? "<=" : ">=", newbound,
6107  proofcoef, depth, resolvable, QUAD_TO_DBL(proofactdelta), score);
6108 
6109  /* insert variable in candidate list without touching the already processed candidates */
6110  for( i = *ncands; i > firstcand && score > (*candscores)[i-1]; --i )
6111  {
6112  (*cands)[i] = (*cands)[i-1];
6113  (*candscores)[i] = (*candscores)[i-1];
6114  (*newbounds)[i] = (*newbounds)[i-1];
6115  (*proofactdeltas)[i] = (*proofactdeltas)[i-1];
6116  }
6117  (*cands)[i] = var;
6118  (*candscores)[i] = score;
6119  (*newbounds)[i] = newbound;
6120  (*proofactdeltas)[i] = QUAD_TO_DBL(proofactdelta);
6121  (*ncands)++;
6122 
6123  return SCIP_OKAY;
6124 }
6125 
6126 /** after changing the global bound of a variable, the bdchginfos that are now redundant are replaced with
6127  * oldbound = newbound = global bound; if the current bdchginfo is of such kind, the bound is equal to the
6128  * global bound and we can ignore it by installing a -1 as the corresponding bound change info position
6129  */
6130 static
6132  SCIP_VAR* var, /**< problem variable */
6133  int* lbchginfopos, /**< pointer to lower bound change information position */
6134  int* ubchginfopos /**< pointer to upper bound change information position */
6135  )
6136 {
6137  assert(var != NULL);
6138  assert(lbchginfopos != NULL);
6139  assert(ubchginfopos != NULL);
6140  assert(-1 <= *lbchginfopos && *lbchginfopos <= var->nlbchginfos);
6141  assert(-1 <= *ubchginfopos && *ubchginfopos <= var->nubchginfos);
6142  assert(*lbchginfopos == -1 || *lbchginfopos == var->nlbchginfos
6143  || var->lbchginfos[*lbchginfopos].redundant
6144  == (var->lbchginfos[*lbchginfopos].oldbound == var->lbchginfos[*lbchginfopos].newbound)); /*lint !e777*/
6145  assert(*ubchginfopos == -1 || *ubchginfopos == var->nubchginfos
6146  || var->ubchginfos[*ubchginfopos].redundant
6147  == (var->ubchginfos[*ubchginfopos].oldbound == var->ubchginfos[*ubchginfopos].newbound)); /*lint !e777*/
6148 
6149  if( *lbchginfopos >= 0 && *lbchginfopos < var->nlbchginfos && var->lbchginfos[*lbchginfopos].redundant )
6150  {
6151  assert(SCIPvarGetLbGlobal(var) == var->lbchginfos[*lbchginfopos].oldbound); /*lint !e777*/
6152  *lbchginfopos = -1;
6153  }
6154  if( *ubchginfopos >= 0 && *ubchginfopos < var->nubchginfos && var->ubchginfos[*ubchginfopos].redundant )
6155  {
6156  assert(SCIPvarGetUbGlobal(var) == var->ubchginfos[*ubchginfopos].oldbound); /*lint !e777*/
6157  *ubchginfopos = -1;
6158  }
6159 }
6160 
6161 /** undoes bound changes on variables, still leaving the given infeasibility proof valid */
6162 static
6164  SCIP_SET* set, /**< global SCIP settings */
6165  SCIP_PROB* prob, /**< problem data */
6166  int currentdepth, /**< current depth in the tree */
6167  SCIP_Real* proofcoefs, /**< coefficients in infeasibility proof */
6168  SCIP_Real prooflhs, /**< left hand side of proof */
6169  SCIP_Real* proofact, /**< current activity of proof */
6170  SCIP_Real* curvarlbs, /**< current lower bounds of active problem variables */
6171  SCIP_Real* curvarubs, /**< current upper bounds of active problem variables */
6172  int* lbchginfoposs, /**< positions of currently active lower bound change information in variables' arrays */
6173  int* ubchginfoposs, /**< positions of currently active upper bound change information in variables' arrays */
6174  SCIP_LPBDCHGS* oldlpbdchgs, /**< old LP bound changes used for reset the LP bound change, or NULL */
6175  SCIP_LPBDCHGS* relaxedlpbdchgs, /**< relaxed LP bound changes used for reset the LP bound change, or NULL */
6176  SCIP_Bool* resolve, /**< pointer to store whether the changed LP should be resolved again, or NULL */
6177  SCIP_LPI* lpi /**< pointer to LPi to access infinity of LP solver; necessary to set correct values */
6178  )
6179 {
6180  SCIP_VAR** vars;
6181  SCIP_VAR** cands;
6182  SCIP_Real* candscores;
6183  SCIP_Real* newbounds;
6184  SCIP_Real* proofactdeltas;
6185  int nvars;
6186  int ncands;
6187  int candssize;
6188  int v;
6189  int i;
6190 
6191  assert(prob != NULL);
6192  assert(proofcoefs != NULL);
6193  assert(SCIPsetIsFeasGT(set, prooflhs, (*proofact)));
6194  assert(curvarlbs != NULL);
6195  assert(curvarubs != NULL);
6196  assert(lbchginfoposs != NULL);
6197  assert(ubchginfoposs != NULL);
6198 
6199  if( resolve != NULL )
6200  *resolve = FALSE;
6201 
6202  vars = prob->vars;
6203  nvars = prob->nvars;
6204  assert(nvars == 0 || vars != NULL);
6205 
6206  /* calculate the order in which the bound changes are tried to be undone, and relax all bounds if this doesn't
6207  * increase the proof's activity
6208  */
6209  SCIP_CALL( SCIPsetAllocBufferArray(set, &cands, nvars) );
6210  SCIP_CALL( SCIPsetAllocBufferArray(set, &candscores, nvars) );
6211  SCIP_CALL( SCIPsetAllocBufferArray(set, &newbounds, nvars) );
6212  SCIP_CALL( SCIPsetAllocBufferArray(set, &proofactdeltas, nvars) );
6213  ncands = 0;
6214  candssize = nvars;
6215  for( v = 0; v < nvars; ++v )
6216  {
6217  SCIP_VAR* var;
6218  SCIP_Bool relaxed;
6219 
6220  var = vars[v];
6221 
6222  /* after changing the global bound of a variable, the bdchginfos that are now redundant are replaced with
6223  * oldbound = newbound = global bound; if the current bdchginfo is of such kind, the bound is equal to the
6224  * global bound and we can ignore it
6225  */
6226  skipRedundantBdchginfos(var, &lbchginfoposs[v], &ubchginfoposs[v]);
6227 
6228  /* ignore variables already relaxed to global bounds */
6229  if( (lbchginfoposs[v] == -1 && ubchginfoposs[v] == -1) )
6230  {
6231  proofcoefs[v] = 0.0;
6232  continue;
6233  }
6234 
6235  /* relax bounds that are not used in the proof to the global bounds */
6236  relaxed = FALSE;
6237  if( !SCIPsetIsNegative(set, proofcoefs[v]) )
6238  {
6239  /* the lower bound is not used */
6240  if( lbchginfoposs[v] >= 0 )
6241  {
6242  SCIPsetDebugMsg(set, " -> relaxing variable <%s>[%g,%g] to [%g,%g]: proofcoef=%g, %g <= %g\n",
6243  SCIPvarGetName(var), curvarlbs[v], curvarubs[v], SCIPvarGetLbGlobal(var), curvarubs[v],
6244  proofcoefs[v], prooflhs, (*proofact));
6245  curvarlbs[v] = SCIPvarGetLbGlobal(var);
6246  lbchginfoposs[v] = -1;
6247  relaxed = TRUE;
6248  }
6249  }
6250  if( !SCIPsetIsPositive(set, proofcoefs[v]) )
6251  {
6252  /* the upper bound is not used */
6253  if( ubchginfoposs[v] >= 0 )
6254  {
6255  SCIPsetDebugMsg(set, " -> relaxing variable <%s>[%g,%g] to [%g,%g]: proofcoef=%g, %g <= %g\n",
6256  SCIPvarGetName(var), curvarlbs[v], curvarubs[v], curvarlbs[v], SCIPvarGetUbGlobal(var),
6257  proofcoefs[v], prooflhs, (*proofact));
6258  curvarubs[v] = SCIPvarGetUbGlobal(var);
6259  ubchginfoposs[v] = -1;
6260  relaxed = TRUE;
6261  }
6262  }
6263  if( relaxed && oldlpbdchgs != NULL )
6264  {
6265  SCIP_CALL( addBdchg(set, var, curvarlbs[v], curvarubs[v], oldlpbdchgs, relaxedlpbdchgs, lpi) );
6266  }
6267 
6268  /* add bound to candidate list */
6269  if( lbchginfoposs[v] >= 0 || ubchginfoposs[v] >= 0 )
6270  {
6271  SCIP_CALL( addCand(set, currentdepth, var, lbchginfoposs[v], ubchginfoposs[v], proofcoefs[v],
6272  prooflhs, (*proofact), &cands, &candscores, &newbounds, &proofactdeltas, &candssize, &ncands, 0) );
6273  }
6274  /* we can set the proof coefficient to zero, because the variable is not needed */
6275  else
6276  proofcoefs[v] = 0.0;
6277  }
6278 
6279  /* try to undo remaining local bound changes while still keeping the proof row violated:
6280  * bound changes can be undone, if prooflhs > proofact + proofactdelta;
6281  * afterwards, the current proof activity has to be updated
6282  */
6283  for( i = 0; i < ncands; ++i )
6284  {
6285  assert(proofactdeltas[i] > 0.0);
6286  assert((lbchginfoposs[SCIPvarGetProbindex(cands[i])] >= 0) != (ubchginfoposs[SCIPvarGetProbindex(cands[i])] >= 0));
6287 
6288  /* when relaxing a constraint we still need to stay infeasible; therefore we need to do the comparison in
6289  * feasibility tolerance because if 'prooflhs' is (feas-))equal to 'proofact + proofactdeltas[i]' it would mean
6290  * that there is no violation
6291  */
6292  if( SCIPsetIsFeasGT(set, prooflhs, (*proofact) + proofactdeltas[i]) )
6293  {
6294  v = SCIPvarGetProbindex(cands[i]);
6295  assert(0 <= v && v < nvars);
6296  assert((lbchginfoposs[v] >= 0) != (ubchginfoposs[v] >= 0));
6297 
6298  SCIPsetDebugMsg(set, " -> relaxing variable <%s>[%g,%g] to [%g,%g]: proofcoef=%g, %g <= %g + %g\n",
6299  SCIPvarGetName(cands[i]), curvarlbs[v], curvarubs[v],
6300  proofcoefs[v] > 0.0 ? curvarlbs[v] : newbounds[i],
6301  proofcoefs[v] > 0.0 ? newbounds[i] : curvarubs[v],
6302  proofcoefs[v], prooflhs, (*proofact), proofactdeltas[i]);
6303 
6304 #ifndef NDEBUG
6305  {
6306  SCIP_Real QUAD(verifylb);
6307  SCIP_Real QUAD(verifyub);
6308 
6309  SCIPquadprecSumDD(verifylb, newbounds[i], -curvarlbs[v]);
6310  SCIPquadprecProdQD(verifylb, verifylb, proofcoefs[v]);
6311 
6312  SCIPquadprecSumDD(verifyub, newbounds[i], -curvarubs[v]);
6313  SCIPquadprecProdQD(verifyub, verifyub, proofcoefs[v]);
6314 
6315  assert((SCIPsetIsPositive(set, proofcoefs[v]) && SCIPsetIsGT(set, newbounds[i], curvarubs[v]))
6316  || (SCIPsetIsNegative(set, proofcoefs[v]) && SCIPsetIsLT(set, newbounds[i], curvarlbs[v])));
6317  assert((SCIPsetIsPositive(set, proofcoefs[v])
6318  && SCIPsetIsEQ(set, proofactdeltas[i], QUAD_TO_DBL(verifyub)))
6319  || (SCIPsetIsNegative(set, proofcoefs[v])
6320  && SCIPsetIsEQ(set, proofactdeltas[i], QUAD_TO_DBL(verifylb))));
6321  assert(!SCIPsetIsZero(set, proofcoefs[v]));
6322  }
6323 #endif
6324 
6325  if( proofcoefs[v] > 0.0 )
6326  {
6327  assert(ubchginfoposs[v] >= 0);
6328  assert(lbchginfoposs[v] == -1);
6329  curvarubs[v] = newbounds[i];
6330  ubchginfoposs[v]--;
6331  }
6332  else
6333  {
6334  assert(lbchginfoposs[v] >= 0);
6335  assert(ubchginfoposs[v] == -1);
6336  curvarlbs[v] = newbounds[i];
6337  lbchginfoposs[v]--;
6338  }
6339  if( oldlpbdchgs != NULL )
6340  {
6341  SCIP_CALL( addBdchg(set, cands[i], curvarlbs[v], curvarubs[v], oldlpbdchgs, relaxedlpbdchgs, lpi) );
6342  }
6343  (*proofact) += proofactdeltas[i];
6344  if( resolve != NULL && SCIPvarIsInLP(cands[i]) )
6345  *resolve = TRUE;
6346 
6347  /* after changing the global bound of a variable, the bdchginfos that are now redundant are replaced with
6348  * oldbound = newbound = global bound; if the current bdchginfo is of such kind, the bound is equal to the
6349  * global bound and we can ignore it
6350  */
6351  skipRedundantBdchginfos(cands[i], &lbchginfoposs[v], &ubchginfoposs[v]);
6352 
6353  /* insert the new local bound of the variable into the candidate list */
6354  if( lbchginfoposs[v] >= 0 || ubchginfoposs[v] >= 0 )
6355  {
6356  SCIP_CALL( addCand(set, currentdepth, cands[i], lbchginfoposs[v], ubchginfoposs[v], proofcoefs[v],
6357  prooflhs, (*proofact), &cands, &candscores, &newbounds, &proofactdeltas, &candssize, &ncands, i+1) );
6358  }
6359  else
6360  proofcoefs[v] = 0.0;
6361  }
6362  }
6363 
6364  /* free the buffer for the sorted bound change candidates */
6365  SCIPsetFreeBufferArray(set, &proofactdeltas);
6366  SCIPsetFreeBufferArray(set, &newbounds);
6367  SCIPsetFreeBufferArray(set, &candscores);
6368  SCIPsetFreeBufferArray(set, &cands);
6369 
6370  return SCIP_OKAY;
6371 }
6372 
6373 /* because calculations might cancel out some values, we stop the infeasibility analysis if a value is bigger than
6374  * 2^53 = 9007199254740992
6375  */
6376 #define NUMSTOP 9007199254740992.0
6377 
6378 /** analyzes an infeasible LP and undoes additional bound changes while staying infeasible */
6379 static
6381  SCIP_SET* set, /**< global SCIP settings */
6382  SCIP_PROB* prob, /**< problem data */
6383  SCIP_LP* lp, /**< LP data */
6384  int currentdepth, /**< current depth in the tree */
6385  SCIP_Real* curvarlbs, /**< current lower bounds of active problem variables */
6386  SCIP_Real* curvarubs, /**< current upper bounds of active problem variables */
6387  int* lbchginfoposs, /**< positions of currently active lower bound change information in variables' arrays */
6388  int* ubchginfoposs, /**< positions of currently active upper bound change information in variables' arrays */
6389  SCIP_LPBDCHGS* oldlpbdchgs, /**< old LP bound changes used for reset the LP bound change, or NULL */
6390  SCIP_LPBDCHGS* relaxedlpbdchgs, /**< relaxed LP bound changes used for reset the LP bound change, or NULL */
6391  SCIP_Bool* valid, /**< pointer to store whether the unfixings are valid */
6392  SCIP_Bool* resolve, /**< pointer to store whether the changed LP should be resolved again */
6393  SCIP_Real* farkascoefs, /**< coefficients in the proof constraint */
6394  SCIP_Real farkaslhs, /**< lhs of the proof constraint */
6395  SCIP_Real* farkasactivity /**< maximal activity of the proof constraint */
6396  )
6397 {
6398  SCIP_LPI* lpi;
6399 
6400  assert(prob != NULL);
6401  assert(lp != NULL);
6402  assert(lp->flushed);
6403  assert(lp->solved);
6404  assert(curvarlbs != NULL);
6405  assert(curvarubs != NULL);
6406  assert(lbchginfoposs != NULL);
6407  assert(ubchginfoposs != NULL);
6408  assert(valid != NULL);
6409  assert(resolve != NULL);
6410 
6411  SCIPsetDebugMsg(set, "undoing bound changes in infeasible LP: cutoff=%g\n", lp->cutoffbound);
6412 
6413  *valid = FALSE;
6414  *resolve = FALSE;
6415 
6416  lpi = SCIPlpGetLPI(lp);
6417 
6418  /* check, if the Farkas row is still violated (using current bounds and ignoring local rows) */
6419  if( SCIPsetIsFeasGT(set, farkaslhs, *farkasactivity) )
6420  {
6421  /* undo bound changes while keeping the infeasibility proof valid */
6422  SCIP_CALL( undoBdchgsProof(set, prob, currentdepth, farkascoefs, farkaslhs, farkasactivity, \
6423  curvarlbs, curvarubs, lbchginfoposs, ubchginfoposs, oldlpbdchgs, relaxedlpbdchgs, resolve, lpi) );
6424 
6425  *valid = TRUE;
6426 
6427  /* resolving does not make sense: the old dual ray is still valid -> resolving will not change the solution */
6428  *resolve = FALSE;
6429  }
6430 
6431  return SCIP_OKAY;
6432 }
6433 
6434 /** analyzes an LP exceeding the objective limit and undoes additional bound changes while staying beyond the
6435  * objective limit
6436  */
6437 static
6439  SCIP_SET* set, /**< global SCIP settings */
6440  SCIP_PROB* prob, /**< problem data */
6441  SCIP_LP* lp, /**< LP data */
6442  int currentdepth, /**< current depth in the tree */
6443  SCIP_Real* curvarlbs, /**< current lower bounds of active problem variables */
6444  SCIP_Real* curvarubs, /**< current upper bounds of active problem variables */
6445  int* lbchginfoposs, /**< positions of currently active lower bound change information in variables' arrays */
6446  int* ubchginfoposs, /**< positions of currently active upper bound change information in variables' arrays */
6447  SCIP_LPBDCHGS* oldlpbdchgs, /**< old LP bound changes used for reset the LP bound change, or NULL */
6448  SCIP_LPBDCHGS* relaxedlpbdchgs, /**< relaxed LP bound changes used for reset the LP bound change, or NULL */
6449  SCIP_Bool* valid, /**< pointer to store whether the unfixings are valid */
6450  SCIP_Bool* resolve, /**< pointer to store whether the changed LP should be resolved again */
6451  SCIP_Real* dualcoefs, /**< coefficients in the proof constraint */
6452  SCIP_Real duallhs, /**< lhs of the proof constraint */
6453  SCIP_Real* dualactivity /**< maximal activity of the proof constraint */
6454  )
6455 {
6456  SCIP_LPI* lpi;
6457 
6458  assert(set != NULL);
6459  assert(prob != NULL);
6460  assert(lp != NULL);
6461  assert(lp->flushed);
6462  assert(lp->solved);
6463  assert(curvarlbs != NULL);
6464  assert(curvarubs != NULL);
6465  assert(lbchginfoposs != NULL);
6466  assert(ubchginfoposs != NULL);
6467  assert(valid != NULL);
6468  assert(resolve != NULL);
6469 
6470  *valid = FALSE;
6471  *resolve = FALSE;
6472 
6473  SCIPsetDebugMsg(set, "undoing bound changes in LP exceeding cutoff: cutoff=%g\n", lp->cutoffbound);
6474 
6475  /* get LP solver interface */
6476  lpi = SCIPlpGetLPI(lp);
6477 
6478  /* check, if the dual row is still violated (using current bounds and ignoring local rows) */
6479  if( SCIPsetIsFeasGT(set, duallhs, *dualactivity) )
6480  {
6481  /* undo bound changes while keeping the infeasibility proof valid */
6482  SCIP_CALL( undoBdchgsProof(set, prob, currentdepth, dualcoefs, duallhs, dualactivity, curvarlbs, curvarubs, \
6483  lbchginfoposs, ubchginfoposs, oldlpbdchgs, relaxedlpbdchgs, resolve, lpi) );
6484 
6485  *valid = TRUE;
6486  }
6487 
6488  return SCIP_OKAY;
6489 }
6490 
6491 /** applies conflict analysis starting with given bound changes, that could not be undone during previous
6492  * infeasibility analysis
6493  */
6494 static
6496  SCIP_CONFLICT* conflict, /**< conflict analysis data */
6497  BMS_BLKMEM* blkmem, /**< block memory of transformed problem */
6498  SCIP_SET* set, /**< global SCIP settings */
6499  SCIP_STAT* stat, /**< problem statistics */
6500  SCIP_PROB* prob, /**< problem data */
6501  SCIP_TREE* tree, /**< branch and bound tree */
6502  SCIP_Bool diving, /**< are we in strong branching or diving mode? */
6503  int* lbchginfoposs, /**< positions of currently active lower bound change information in variables' arrays */
6504  int* ubchginfoposs, /**< positions of currently active upper bound change information in variables' arrays */
6505  int* nconss, /**< pointer to store the number of generated conflict constraints */
6506  int* nliterals, /**< pointer to store the number of literals in generated conflict constraints */
6507  int* nreconvconss, /**< pointer to store the number of generated reconvergence constraints */
6508  int* nreconvliterals /**< pointer to store the number of literals generated reconvergence constraints */
6509  )
6510 {
6511  SCIP_VAR** vars;
6512  SCIP_VAR* var;
6513  SCIP_CONFTYPE conftype;
6514  SCIP_Bool usescutoffbound;
6515  int nvars;
6516  int v;
6517  int nbdchgs;
6518  int maxsize;
6519 
6520  assert(prob != NULL);
6521  assert(lbchginfoposs != NULL);
6522  assert(ubchginfoposs != NULL);
6523  assert(nconss != NULL);
6524  assert(nliterals != NULL);
6525  assert(nreconvconss != NULL);
6526  assert(nreconvliterals != NULL);
6527 
6528  *nconss = 0;
6529  *nliterals = 0;
6530  *nreconvconss = 0;
6531  *nreconvliterals = 0;
6532 
6533  vars = prob->vars;
6534  nvars = prob->nvars;
6535  assert(nvars == 0 || vars != NULL);
6536 
6537  maxsize = 2*conflictCalcMaxsize(set, prob);
6538 
6539  /* initialize conflict data */
6540  conftype = conflict->conflictset->conflicttype;
6541  usescutoffbound = conflict->conflictset->usescutoffbound;
6542 
6543  SCIP_CALL( SCIPconflictInit(conflict, set, stat, prob, conftype, usescutoffbound) );
6544 
6545  conflict->conflictset->conflicttype = conftype;
6546  conflict->conflictset->usescutoffbound = usescutoffbound;
6547 
6548  /* add remaining bound changes to conflict queue */
6549  SCIPsetDebugMsg(set, "initial conflict set after undoing bound changes:\n");
6550 
6551  nbdchgs = 0;
6552  for( v = 0; v < nvars && nbdchgs < maxsize; ++v )
6553  {
6554  var = vars[v];
6555  assert(var != NULL);
6556  assert(var->nlbchginfos >= 0);
6557  assert(var->nubchginfos >= 0);
6558  assert(-1 <= lbchginfoposs[v] && lbchginfoposs[v] <= var->nlbchginfos);
6559  assert(-1 <= ubchginfoposs[v] && ubchginfoposs[v] <= var->nubchginfos);
6560 
6561  if( lbchginfoposs[v] == var->nlbchginfos || ubchginfoposs[v] == var->nubchginfos )
6562  {
6563  SCIP_BDCHGINFO* bdchginfo;
6564  SCIP_Real relaxedbd;
6565 
6566  /* the strong branching or diving bound stored in the column is responsible for the conflict:
6567  * it cannot be resolved and therefore has to be directly put into the conflict set
6568  */
6569  assert((lbchginfoposs[v] == var->nlbchginfos) != (ubchginfoposs[v] == var->nubchginfos)); /* only one can be tight in the dual! */
6570  assert(lbchginfoposs[v] < var->nlbchginfos || SCIPvarGetLbLP(var, set) > SCIPvarGetLbLocal(var));
6571  assert(ubchginfoposs[v] < var->nubchginfos || SCIPvarGetUbLP(var, set) < SCIPvarGetUbLocal(var));
6572 
6573  /* create an artificial bound change information for the diving/strong branching bound change;
6574  * they are freed in the SCIPconflictFlushConss() call
6575  */
6576  if( lbchginfoposs[v] == var->nlbchginfos )
6577  {
6578  SCIP_CALL( conflictCreateTmpBdchginfo(conflict, blkmem, set, var, SCIP_BOUNDTYPE_LOWER,
6579  SCIPvarGetLbLocal(var), SCIPvarGetLbLP(var, set), &bdchginfo) );
6580  relaxedbd = SCIPvarGetLbLP(var, set);
6581  }
6582  else
6583  {
6584  SCIP_CALL( conflictCreateTmpBdchginfo(conflict, blkmem, set, var, SCIP_BOUNDTYPE_UPPER,
6585  SCIPvarGetUbLocal(var), SCIPvarGetUbLP(var, set), &bdchginfo) );
6586  relaxedbd = SCIPvarGetUbLP(var, set);
6587  }
6588 
6589  /* put variable into the conflict set */
6590  SCIPsetDebugMsg(set, " force: <%s> %s %g [status: %d, type: %d, dive/strong]\n",
6591  SCIPvarGetName(var), lbchginfoposs[v] == var->nlbchginfos ? ">=" : "<=",
6592  lbchginfoposs[v] == var->nlbchginfos ? SCIPvarGetLbLP(var, set) : SCIPvarGetUbLP(var, set),
6593  SCIPvarGetStatus(var), SCIPvarGetType(var));
6594  SCIP_CALL( conflictAddConflictBound(conflict, blkmem, set, bdchginfo, relaxedbd) );
6595 
6596  /* each variable which is add to the conflict graph gets an increase in the VSIDS
6597  *
6598  * @note That is different to the VSIDS preseted in the literature
6599  */
6600  SCIP_CALL( incVSIDS(var, blkmem, set, stat, SCIPbdchginfoGetBoundtype(bdchginfo), relaxedbd, set->conf_conflictgraphweight) );
6601  nbdchgs++;
6602  }
6603  else
6604  {
6605  /* put remaining bound changes into conflict candidate queue */
6606  if( lbchginfoposs[v] >= 0 )
6607  {
6608  SCIP_CALL( conflictAddBound(conflict, blkmem, set, stat, var, SCIP_BOUNDTYPE_LOWER, \
6609  &var->lbchginfos[lbchginfoposs[v]], SCIPbdchginfoGetNewbound(&var->lbchginfos[lbchginfoposs[v]])) );
6610  nbdchgs++;
6611  }
6612  if( ubchginfoposs[v] >= 0 )
6613  {
6614  assert(!SCIPbdchginfoIsRedundant(&var->ubchginfos[ubchginfoposs[v]]));
6615  SCIP_CALL( conflictAddBound(conflict, blkmem, set, stat, var, SCIP_BOUNDTYPE_UPPER, \
6616  &var->ubchginfos[ubchginfoposs[v]], SCIPbdchginfoGetNewbound(&var->ubchginfos[ubchginfoposs[v]])) );
6617  nbdchgs++;
6618  }
6619  }
6620  }
6621 
6622  if( v == nvars )
6623  {
6624  /* analyze the conflict set, and create conflict constraints on success */
6625  SCIP_CALL( conflictAnalyze(conflict, blkmem, set, stat, prob, tree, diving, 0, FALSE, nconss, nliterals, \
6626  nreconvconss, nreconvliterals) );
6627  }
6628 
6629  return SCIP_OKAY;
6630 }
6631 
6632 /** adds a weighted LP row to an aggregation row */
6633 static
6635  SCIP_SET* set, /**< global SCIP settings */
6636  SCIP_ROW* row, /**< LP row */
6637  SCIP_Real weight, /**< weight for scaling */
6638  SCIP_AGGRROW* aggrrow /**< aggregation row */
6639  )
6640 {
6641  assert(set != NULL);
6642  assert(row != NULL);
6643  assert(weight != 0.0);
6644 
6645  /* add minimal value to dual row's left hand side: y_i < 0 -> lhs, y_i > 0 -> rhs */
6646  if( weight < 0.0 )
6647  {
6648  assert(!SCIPsetIsInfinity(set, -row->lhs));
6649  SCIP_CALL( SCIPaggrRowAddRow(set->scip, aggrrow, row, weight, -1) );
6650  }
6651  else
6652  {
6653  assert(!SCIPsetIsInfinity(set, row->rhs));
6654  SCIP_CALL( SCIPaggrRowAddRow(set->scip, aggrrow, row, weight, +1) );
6655  }
6656  SCIPsetDebugMsg(set, " -> add %s row <%s>[%g,%g](lp depth: %d): dual=%g -> dualrhs=%g\n",
6657  row->local ? "local" : "global",
6658  SCIProwGetName(row), row->lhs - row->constant, row->rhs - row->constant,
6659  row->lpdepth, weight, SCIPaggrRowGetRhs(aggrrow));
6660 
6661  return SCIP_OKAY;
6662 }
6663 
6664 /** checks validity of an LP row and a corresponding weight */
6665 static
6667  SCIP_SET* set, /**< global SCIP settings */
6668  SCIP_ROW* row, /**< LP row */
6669  SCIP_Real weight, /**< weight for scaling */
6670  SCIP_Bool* zerocontribution /**< pointer to store whether every row entry is zero within tolerances */
6671  )
6672 {
6673  SCIP_Bool valid = TRUE;
6674 
6675  *zerocontribution = TRUE;
6676 
6677  /* dual solution values of 0.0 are always valid */
6678  if( REALABS(weight) > QUAD_EPSILON )
6679  {
6680  *zerocontribution = FALSE;
6681 
6682  /* check dual feasibility */
6683  if( (SCIPsetIsInfinity(set, -row->lhs) && weight > 0.0) || (SCIPsetIsInfinity(set, row->rhs) && weight < 0.0) )
6684  {
6685  int i;
6686 
6687  /* ignore slight numerical violations if the contribution of every component of the row is close to zero */
6688  if( weight > 0.0 )
6689  *zerocontribution = SCIPsetIsDualfeasZero(set, row->rhs * weight);
6690  else
6691  *zerocontribution = SCIPsetIsDualfeasZero(set, row->lhs * weight);
6692 
6693  for( i = 0; i < row->len && *zerocontribution; i++ )
6694  {
6695  if( !SCIPsetIsDualfeasZero(set, weight * row->vals[i]) )
6696  *zerocontribution = FALSE;
6697  }
6698 
6699  if( !(*zerocontribution) )
6700  {
6701  SCIPsetDebugMsg(set, " -> invalid dual solution value %g for row <%s>: lhs=%g, rhs=%g\n",
6702  weight, SCIProwGetName(row), row->lhs, row->rhs);
6703 
6704  valid = FALSE;
6705  }
6706  }
6707  }
6708 
6709  return valid;
6710 }
6711 
6712 /** sort local rows by increasing depth and number of nonzeros as tie-breaker */
6713 static
6715  SCIP_SET* set, /**< global SCIP settings */
6716  SCIP_AGGRROW* aggrrow, /**< aggregation row */
6717  SCIP_ROW** rows, /**< array of local rows */
6718  int* rowinds, /**< array of row indices */
6719  int* rowdepth, /**< array of LP depths */
6720  int nrows /**< number of local rows */
6721  )
6722 {
6723  int* rownnz;
6724  int i;
6725 
6726  assert(aggrrow != NULL);
6727  assert(rows != NULL);
6728  assert(nrows > 0);
6729  assert(rowinds != NULL);
6730  assert(rowdepth != NULL);
6731 
6732  /* sort row indices by increasing depth */
6733  SCIPsortIntInt(rowdepth, rowinds, nrows);
6734  assert(rowdepth[0] <= rowdepth[nrows-1]);
6735 
6736  SCIP_CALL( SCIPsetAllocBufferArray(set, &rownnz, nrows) );
6737 
6738  /* get number of nonzero entries for every row */
6739  for( i = 0; i < nrows; i++ )
6740  {
6741  SCIP_ROW* row = rows[rowinds[i]];
6742  assert(row != NULL);
6743 
6744  rownnz[i] = row->len;
6745  }
6746 
6747  /* since SCIP has no stable sorting function we sort each bucket separately */
6748  for( i = 0; i < nrows; i++ )
6749  {
6750  int j = i;
6751  int d = rowdepth[i];
6752 
6753  /* search for the next row with a greater depth */
6754  while( j+1 < nrows && rowdepth[j+1] == d )
6755  j++;
6756 
6757  /* the bucket has size one */
6758  if( j == i )
6759  continue;
6760 
6761  assert(j-i+1 <= nrows);
6762 
6763  /* sort row indices by increasing number of nonzero elements */
6764  SCIPsortIntIntInt(&rownnz[i], &rowdepth[i], &rowinds[i], j-i+1);
6765  assert(rownnz[i] <= rownnz[j]);
6766 
6767  i = j;
6768  } /*lint --e{850} i is modified in the body of the for loop */
6769 
6770 #ifndef NDEBUG
6771  for( i = 0; i < nrows-1; i++ )
6772  assert(rowdepth[i] < rowdepth[i+1] || (rowdepth[i] == rowdepth[i+1] && rownnz[i] <= rownnz[i+1]));
6773 #endif
6774 
6775  SCIPsetFreeBufferArray(set, &rownnz);
6776 
6777  return SCIP_OKAY;
6778 }
6779 
6780 /** adds locally valid rows to the proof constraint */
6781 static
6783  SCIP_SET* set, /**< global SCIP settings */
6784  SCIP_PROB* transprob, /**< transformed problem */
6785  SCIP_LP* lp, /**< LP data */
6786  SCIP_AGGRROW* proofrow, /**< aggregated row representing the proof */
6787  SCIP_ROW** rows, /**< array if locally valid rows */
6788  SCIP_Real* dualsols, /**< dual solution vector */
6789  int* localrowinds, /**< array of row indecies */
6790  int* localrowdepth, /**< array of row depths */
6791  int nlocalrows, /**< number of local rows stored in rows array */
6792  SCIP_Real* proofact, /**< pointer to store the activity of the proof constraint */
6793  int* validdepth, /**< pointer to store the depth where the proof constraint is valid */
6794  SCIP_Real* curvarlbs, /**< current lower bounds of active problem variables */
6795  SCIP_Real* curvarubs, /**< current upper bounds of active problem variables */
6796  SCIP_Bool* valid /**< pointer store whether the proof constraint is valid */
6797  )
6798 {
6799  SCIP_Bool infdelta;
6800  int i;
6801 
6802  assert(set != NULL);
6803  assert(lp != NULL);
6804 
6805  *validdepth = 0;
6806 
6807  if( !set->conf_uselocalrows )
6808  return SCIP_OKAY;
6809 
6810  SCIPsetDebugMsg(set, "add local rows to dual proof:\n");
6811 
6812  /* check whether the proof is already valid, e.g., violated within the local bounds */
6813  *proofact = aggrRowGetMinActivity(set, transprob, proofrow, curvarlbs, curvarubs, &infdelta);
6814 
6815  /* we stop if the minimal activity is infinite but all variables have a finite activity delta (bad numerics) */
6816  if( !infdelta && SCIPsetIsInfinity(set, REALABS(*proofact)) )
6817  {
6818  *valid = FALSE;
6819  return SCIP_OKAY;
6820  }
6821 
6822  /* break if the proof is valid w.r.t local bounds
6823  * note: it can happen that the proof contains a variable with an infinite activity delta.
6824  * here, we don't break immediately because we might be able to fix it by adding local rows
6825  */
6826  if( !infdelta && SCIPsetIsGT(set, *proofact, SCIPaggrRowGetRhs(proofrow)) )
6827  {
6828  *valid = TRUE;
6829  return SCIP_OKAY;
6830  }
6831 
6832  /* sort local rows by depth */
6833  SCIP_CALL( sortLocalRows(set, proofrow, rows, localrowinds, localrowdepth, nlocalrows) );
6834 
6835  /* add successively local rows */
6836  for( i = 0; i < nlocalrows; ++i )
6837  {
6838  SCIP_ROW* row;
6839  int r;
6840 
6841  r = localrowinds[i];
6842  row = rows[r];
6843 
6844  assert(row != NULL);
6845  assert(row->len == 0 || row->cols != NULL);
6846  assert(row->len == 0 || row->vals != NULL);
6847  assert(row == lp->lpirows[r]);
6848  assert(row->local);
6849  assert(row->lpdepth == localrowdepth[i]);
6850 
6851  /* ignore dual solution values of 0.0 (in this case: y_i == 0) */
6852  if( REALABS(dualsols[r]) > 0.0 )
6853  {
6854 #ifndef NDEBUG
6855  SCIP_Bool zerocontribution;
6856 
6857  /* check dual feasibility */
6858  *valid = checkDualFeasibility(set, row, dualsols[r], &zerocontribution);
6859  assert(*valid);
6860  assert(!zerocontribution);
6861 #endif
6862 
6863  if( SCIPsetIsDualfeasZero(set, dualsols[r]) )
6864  continue;
6865 
6866  /* add row to dual proof */
6867  SCIP_CALL( addRowToAggrRow(set, row, -dualsols[r], proofrow) );
6868 
6869  /* update depth where the proof is valid */
6870  if( *validdepth < localrowdepth[i] )
6871  *validdepth = localrowdepth[i];
6872 
6873  /* get the new minimal activity */
6874  *proofact = aggrRowGetMinActivity(set, transprob, proofrow, curvarlbs, curvarubs, &infdelta);
6875 
6876  /* we stop if the minimal activity is infinite but all variables have a finite activity delta (bad numerics) */
6877  if( !infdelta && SCIPsetIsInfinity(set, REALABS(*proofact)) )
6878  {
6879  *valid = FALSE;
6880  goto TERMINATE;
6881  }
6882 
6883  /* break if the proof is valid w.r.t local bounds */
6884  if( !infdelta && SCIPsetIsGT(set, *proofact, SCIPaggrRowGetRhs(proofrow)) )
6885  {
6886  *valid = TRUE;
6887  break;
6888  }
6889  }
6890  }
6891 
6892  /* remove all nearly zero coefficients */
6893  SCIPaggrRowRemoveZeros(set->scip, proofrow, TRUE, valid);
6894 
6895  TERMINATE:
6896  if( !(*valid) )
6897  {
6898  SCIPsetDebugMsg(set, " -> proof is not valid: %g <= %g\n", *proofact, SCIPaggrRowGetRhs(proofrow));
6899  SCIPsetDebugMsg(set, " -> stop due to numerical troubles\n");
6900  }
6901  else
6902  {
6903  *proofact = aggrRowGetMinActivity(set, transprob, proofrow, curvarlbs, curvarubs, &infdelta);
6904 
6905  /* we stop if the minimal activity is infinite but all variables have a finite activity delta (bad numerics) */
6906  if( !infdelta && SCIPsetIsInfinity(set, REALABS(*proofact)) )
6907  {
6908  *valid = FALSE;
6909  SCIPsetDebugMsg(set, " -> proof is not valid: %g <= %g [infdelta: %d]\n", *proofact, SCIPaggrRowGetRhs(proofrow), infdelta);
6910  }
6911  else if( infdelta || SCIPsetIsLE(set, *proofact, SCIPaggrRowGetRhs(proofrow)) )
6912  {
6913  *valid = FALSE;
6914  SCIPsetDebugMsg(set, " -> proof is not valid: %g <= %g [infdelta: %d]\n", *proofact, SCIPaggrRowGetRhs(proofrow), infdelta);
6915  }
6916  }
6917 
6918  return SCIP_OKAY;
6919 }
6920 
6921 /** calculates a Farkas proof from the current dual LP solution */
6922 static
6924  SCIP_SET* set, /**< global SCIP settings */
6925  SCIP_PROB* prob, /**< transformed problem */
6926  SCIP_LP* lp, /**< LP data */
6927  SCIP_LPI* lpi, /**< LPI data */
6928  SCIP_TREE* tree, /**< tree data */
6929  SCIP_AGGRROW* farkasrow, /**< aggregated row representing the proof */
6930  SCIP_Real* farkasact, /**< maximal activity of the proof constraint */
6931  int* validdepth, /**< pointer to store the valid depth of the proof constraint */
6932  SCIP_Real* curvarlbs, /**< current lower bounds of active problem variables */
6933  SCIP_Real* curvarubs, /**< current upper bounds of active problem variables */
6934  SCIP_Bool* valid /**< pointer store whether the proof constraint is valid */
6935  )
6936 {
6937  SCIP_ROW** rows;
6938  SCIP_Real* dualfarkas;
6939  SCIP_ROW* row;
6940  int* localrowinds;
6941  int* localrowdepth;
6942  SCIP_Bool infdelta;
6943  int nlocalrows;
6944  int nrows;
6945  int r;
6946 
6947  assert(set != NULL);
6948  assert(prob != NULL);
6949  assert(lp != NULL);
6950  assert(lp->flushed);
6951  assert(lp->solved);
6952  assert(curvarlbs != NULL);
6953  assert(curvarubs != NULL);
6954  assert(valid != NULL);
6955 
6958 
6959  /* get LP rows and problem variables */
6960  rows = SCIPlpGetRows(lp);
6961  nrows = SCIPlpGetNRows(lp);
6962  assert(nrows == 0 || rows != NULL);
6963  assert(nrows == lp->nlpirows);
6964 
6965  /* it can happen that infeasibility is detetected within LP presolve. in that case, the LP solver may not be able to
6966  * to return the dual ray.
6967  */
6968  if( !SCIPlpiHasDualRay(lpi) )
6969  {
6970  *valid = FALSE;
6971  return SCIP_OKAY;
6972  }
6973 
6974  assert(farkasrow != NULL);
6975 
6976  /* allocate temporary memory */
6977  SCIP_CALL( SCIPsetAllocBufferArray(set, &dualfarkas, nrows) );
6978  BMSclearMemoryArray(dualfarkas, nrows);
6979 
6980  /* get dual Farkas values of rows */
6981  SCIP_CALL( SCIPlpiGetDualfarkas(lpi, dualfarkas) );
6982 
6983  localrowinds = NULL;
6984  localrowdepth = NULL;
6985  nlocalrows = 0;
6986 
6987  /* calculate the Farkas row */
6988  (*valid) = TRUE;
6989  (*validdepth) = 0;
6990 
6991  for( r = 0; r < nrows; ++r )
6992  {
6993  row = rows[r];
6994  assert(row != NULL);
6995  assert(row->len == 0 || row->cols != NULL);
6996  assert(row->len == 0 || row->vals != NULL);
6997  assert(row == lp->lpirows[r]);
6998 
6999  /* ignore dual ray values of 0.0 (in this case: y_i == z_i == 0) */
7000  if( REALABS(dualfarkas[r]) > 0.0 )
7001  {
7002  SCIP_Bool zerocontribution;
7003 
7004  /* check dual feasibility */
7005  *valid = checkDualFeasibility(set, row, dualfarkas[r], &zerocontribution);
7006 
7007  if( !(*valid) )
7008  goto TERMINATE;
7009 
7010  if( zerocontribution )
7011  continue;
7012 
7013  if( SCIPsetIsDualfeasZero(set, dualfarkas[r]) )
7014  continue;
7015 
7016  if( !row->local )
7017  {
7018  SCIP_CALL( addRowToAggrRow(set, row, -dualfarkas[r], farkasrow) );
7019 
7020  /* due to numerical reasons we want to stop */
7021  if( REALABS(SCIPaggrRowGetRhs(farkasrow)) > NUMSTOP )
7022  {
7023  (*valid) = FALSE;
7024  goto TERMINATE;
7025  }
7026  }
7027  else
7028  {
7029  int lpdepth = SCIProwGetLPDepth(row);
7030 
7031  if( nlocalrows == 0 && lpdepth < SCIPtreeGetFocusDepth(tree) )
7032  {
7033  SCIP_CALL( SCIPsetAllocBufferArray(set, &localrowinds, nrows-r) );
7034  SCIP_CALL( SCIPsetAllocBufferArray(set, &localrowdepth, nrows-r) );
7035  }
7036 
7037  if( lpdepth < SCIPtreeGetFocusDepth(tree) )
7038  {
7039  assert(localrowinds != NULL);
7040  assert(localrowdepth != NULL);
7041 
7042  localrowinds[nlocalrows] = r;
7043  localrowdepth[nlocalrows++] = lpdepth;
7044  }
7045  }
7046  }
7047  }
7048 
7049  /* remove all coefficients that are too close to zero */
7050  SCIPaggrRowRemoveZeros(set->scip, farkasrow, TRUE, valid);
7051 
7052  if( !(*valid) )
7053  goto TERMINATE;
7054 
7055  infdelta = FALSE;
7056 
7057  /* calculate the current Farkas activity, always using the best bound w.r.t. the Farkas coefficient */
7058  *farkasact = aggrRowGetMinActivity(set, prob, farkasrow, curvarlbs, curvarubs, &infdelta);
7059 
7060  SCIPsetDebugMsg(set, " -> farkasact=%g farkasrhs=%g [infdelta: %d], \n",
7061  (*farkasact), SCIPaggrRowGetRhs(farkasrow), infdelta);
7062 
7063  /* The constructed proof is not valid, this can happen due to numerical reasons,
7064  * e.g., we only consider rows r with !SCIPsetIsZero(set, dualfarkas[r]),
7065  * or because of local rows were ignored so far.
7066  * Due to the latter case, it might happen at least one variable contributes
7067  * with an infinite value to the activity (see: https://git.zib.de/integer/scip/issues/2743)
7068  */
7069  if( infdelta || SCIPsetIsFeasLE(set, *farkasact, SCIPaggrRowGetRhs(farkasrow)))
7070  {
7071  /* add contribution of local rows */
7072  if( nlocalrows > 0 && set->conf_uselocalrows > 0 )
7073  {
7074  SCIP_CALL( addLocalRows(set, prob, lp, farkasrow, rows, dualfarkas, localrowinds, localrowdepth,
7075  nlocalrows, farkasact, validdepth, curvarlbs, curvarubs, valid) );
7076  }
7077  else
7078  {
7079  (*valid) = FALSE;
7080  SCIPsetDebugMsg(set, " -> proof is not valid to due infinite activity delta\n",
7081  *farkasact, SCIPaggrRowGetRhs(farkasrow));
7082  }
7083  }
7084 
7085  TERMINATE:
7086 
7087  SCIPfreeBufferArrayNull(set->scip, &localrowdepth);
7088  SCIPfreeBufferArrayNull(set->scip, &localrowinds);
7089  SCIPsetFreeBufferArray(set, &dualfarkas);
7090 
7091  return SCIP_OKAY;
7092 }
7093 
7094 /** calculates a Farkas proof from the current dual LP solution */
7095 static
7097  SCIP_SET* set, /**< global SCIP settings */
7098  SCIP_PROB* transprob, /**< transformed problem */
7099  SCIP_LP* lp, /**< LP data */
7100  SCIP_LPI* lpi, /**< LPI data */
7101  SCIP_TREE* tree, /**< tree data */
7102  SCIP_AGGRROW* farkasrow, /**< aggregated row representing the proof */
7103  SCIP_Real* farkasact, /**< maximal activity of the proof constraint */
7104  int* validdepth, /**< pointer to store the valid depth of the proof constraint */
7105  SCIP_Real* curvarlbs, /**< current lower bounds of active problem variables */
7106  SCIP_Real* curvarubs, /**< current upper bounds of active problem variables */
7107  SCIP_Bool* valid /**< pointer store whether the proof constraint is valid */
7108  )
7109 {
7110  SCIP_RETCODE retcode;
7111  SCIP_ROW** rows;
7112  SCIP_ROW* row;
7113  SCIP_Real* primsols;
7114  SCIP_Real* dualsols;
7115  SCIP_Real* redcosts;
7116  int* localrowinds;
7117  int* localrowdepth;
7118  SCIP_Real maxabsdualsol;
7119  SCIP_Bool infdelta;
7120  int nlocalrows;
7121  int nrows;
7122  int ncols;
7123  int r;
7124 
7125  assert(set != NULL);
7126  assert(transprob != NULL);
7127  assert(lp != NULL);
7128  assert(lp->flushed);
7129  assert(lp->solved);
7130  assert(curvarlbs != NULL);
7131  assert(curvarubs != NULL);
7132  assert(valid != NULL);
7133 
7134  *validdepth = 0;
7135  *valid = TRUE;
7136 
7137  localrowinds = NULL;
7138  localrowdepth = NULL;
7139  nlocalrows = 0;
7140 
7141  /* get LP rows and problem variables */
7142  rows = SCIPlpGetRows(lp);
7143  nrows = SCIPlpGetNRows(lp);
7144  ncols = SCIPlpGetNCols(lp);
7145  assert(nrows == 0 || rows != NULL);
7146  assert(nrows == lp->nlpirows);
7147 
7148  /* get temporary memory */
7149  SCIP_CALL( SCIPsetAllocBufferArray(set, &primsols, ncols) );
7150  SCIP_CALL( SCIPsetAllocBufferArray(set, &dualsols, nrows) );
7151  SCIP_CALL( SCIPsetAllocBufferArray(set, &redcosts, ncols) );
7152 
7153  /* get solution from LPI */
7154  retcode = SCIPlpiGetSol(lpi, NULL, primsols, dualsols, NULL, redcosts);
7155  if( retcode == SCIP_LPERROR ) /* on an error in the LP solver, just abort the conflict analysis */
7156  {
7157  (*valid) = FALSE;
7158  goto TERMINATE;
7159  }
7160  SCIP_CALL( retcode );
7161 #ifdef SCIP_DEBUG
7162  {
7163  SCIP_Real objval;
7164  SCIP_CALL( SCIPlpiGetObjval(lpi, &objval) );
7165  SCIPsetDebugMsg(set, " -> LP objval: %g\n", objval);
7166  }
7167 #endif
7168 
7169  /* check whether the dual solution is numerically stable */
7170  maxabsdualsol = 0;
7171  for( r = 0; r < nrows; r++ )
7172  {
7173  SCIP_Real absdualsol = REALABS(dualsols[r]);
7174 
7175  if( absdualsol > maxabsdualsol )
7176  maxabsdualsol = absdualsol;
7177  }
7178 
7179  /* don't consider dual solution with maxabsdualsol > 1e+07, this would almost cancel out the objective constraint */
7180  if( maxabsdualsol > 1e+07 )
7181  {
7182  (*valid) = FALSE;
7183  goto TERMINATE;
7184  }
7185 
7186  /* clear the proof */
7187  SCIPaggrRowClear(farkasrow);
7188 
7189  /* Let y be the dual solution and r be the reduced cost vector. Let z be defined as
7190  * z_i := y_i if i is a global row,
7191  * z_i := 0 if i is a local row.
7192  * Define the set X := {x | lhs <= Ax <= rhs, lb <= x <= ub, c^Tx <= c*}, with c* being the current primal bound.
7193  * Then the following inequalities are valid for all x \in X:
7194  * - c* <= -c^Tx
7195  * <=> z^TAx - c* <= (z^TA - c^T) x
7196  * <=> z^TAx - c* <= (y^TA - c^T - (y-z)^TA) x
7197  * <=> z^TAx - c* <= (-r^T - (y-z)^TA) x (dual feasibility of (y,r): y^TA + r^T == c^T)
7198  * Because lhs <= Ax <= rhs and lb <= x <= ub, the inequality can be relaxed to give
7199  * min{z^Tq | lhs <= q <= rhs} - c* <= max{(-r^T - (y-z)^TA) x | lb <= x <= ub}, or X = {}.
7200  *
7201  * The resulting dual row is: z^T{lhs,rhs} - c* <= (-r^T - (y-z)^TA){lb,ub},
7202  * where lhs, rhs, lb, and ub are selected in order to maximize the feasibility of the row.
7203  */
7204 
7205  /* add the objective function to the aggregation row with current cutoff bound as right-hand side
7206  *
7207  * use a slightly tighter cutoff bound, because solutions with equal objective value should also be declared
7208  * infeasible
7209  */
7210  SCIP_CALL( SCIPaggrRowAddObjectiveFunction(set->scip, farkasrow, lp->cutoffbound - SCIPsetSumepsilon(set), 1.0) );
7211 
7212  /* dual row: z^T{lhs,rhs} - c* <= (-r^T - (y-z)^TA){lb,ub}
7213  * process rows: add z^T{lhs,rhs} to the dual row's left hand side, and -(y-z)^TA to the dual row's coefficients
7214  */
7215  for( r = 0; r < nrows; ++r )
7216  {
7217  row = rows[r];
7218  assert(row != NULL);
7219  assert(row->len == 0 || row->cols != NULL);
7220  assert(row->len == 0 || row->vals != NULL);
7221  assert(row == lp->lpirows[r]);
7222 
7223  /* ignore dual solution values of 0.0 (in this case: y_i == z_i == 0) */
7224  if( REALABS(dualsols[r]) > 0.0 )
7225  {
7226  SCIP_Bool zerocontribution;
7227 
7228  /* check dual feasibility */
7229  *valid = checkDualFeasibility(set, row, dualsols[r], &zerocontribution);
7230 
7231  if( !(*valid) )
7232  goto TERMINATE;
7233 
7234  if( zerocontribution )
7235  continue;
7236 
7237  if( SCIPsetIsDualfeasZero(set, dualsols[r]) )
7238  continue;
7239 
7240  /* skip local row */
7241  if( !row->local )
7242  {
7243  SCIP_CALL( addRowToAggrRow(set, row, -dualsols[r], farkasrow) );
7244 
7245  /* due to numerical reasons we want to stop */
7246  if( REALABS(SCIPaggrRowGetRhs(farkasrow)) > NUMSTOP )
7247  {
7248  (*valid) = FALSE;
7249  goto TERMINATE;
7250  }
7251  }
7252  else
7253  {
7254  int lpdepth = SCIProwGetLPDepth(row);
7255 
7256  if( nlocalrows == 0 && lpdepth < SCIPtreeGetFocusDepth(tree) )
7257  {
7258  SCIP_CALL( SCIPsetAllocBufferArray(set, &localrowinds, nrows-r) );
7259  SCIP_CALL( SCIPsetAllocBufferArray(set, &localrowdepth, nrows-r) );
7260  }
7261 
7262  if( lpdepth < SCIPtreeGetFocusDepth(tree) )
7263  {
7264  assert(localrowinds != NULL);
7265  assert(localrowdepth != NULL);
7266 
7267  localrowinds[nlocalrows] = r;
7268  localrowdepth[nlocalrows++] = lpdepth;
7269  }
7270  }
7271  }
7272  }
7273 
7274  /* remove all nearly zero coefficients */
7275  SCIPaggrRowRemoveZeros(set->scip, farkasrow, TRUE, valid);
7276 
7277  if( !(*valid) )
7278  goto TERMINATE;
7279 
7280  infdelta = FALSE;
7281 
7282  /* check validity of the proof */
7283  *farkasact = aggrRowGetMinActivity(set, transprob, farkasrow, curvarlbs, curvarubs, &infdelta);
7284 
7285  SCIPsetDebugMsg(set, " -> farkasact=%g farkasrhs=%g [infdelta: %d], \n",
7286  (*farkasact), SCIPaggrRowGetRhs(farkasrow), infdelta);
7287 
7288  /* The constructed proof is not valid, this can happen due to numerical reasons,
7289  * e.g., we only consider rows r with !SCIPsetIsZero(set, dualsol[r]),
7290  * or because of local rows were ignored so far.
7291  * Due to the latter case, it might happen at least one variable contributes
7292  * with an infinite value to the activity (see: https://git.zib.de/integer/scip/issues/2743)
7293  */
7294  if( infdelta || SCIPsetIsFeasLE(set, *farkasact, SCIPaggrRowGetRhs(farkasrow)))
7295  {
7296  /* add contribution of local rows */
7297  if( nlocalrows > 0 && set->conf_uselocalrows > 0 )
7298  {
7299  SCIP_CALL( addLocalRows(set, transprob, lp, farkasrow, rows, dualsols, localrowinds, localrowdepth,
7300  nlocalrows, farkasact, validdepth, curvarlbs, curvarubs, valid) );
7301  }
7302  else
7303  {
7304  (*valid) = FALSE;
7305  SCIPsetDebugMsg(set, " -> proof is not valid to due infinite activity delta\n",
7306  *farkasact, SCIPaggrRowGetRhs(farkasrow));
7307  }
7308  }
7309 
7310  TERMINATE:
7311 
7312  SCIPfreeBufferArrayNull(set->scip, &localrowdepth);
7313  SCIPfreeBufferArrayNull(set->scip, &localrowinds);
7314  SCIPsetFreeBufferArray(set, &redcosts);
7315  SCIPsetFreeBufferArray(set, &dualsols);
7316  SCIPsetFreeBufferArray(set, &primsols);
7317 
7318  return SCIP_OKAY;
7319 }
7320 
7321 #ifdef SCIP_DEBUG
7322 static
7324  SCIP_SET* set, /**< global SCIP settings */
7325  SCIP_Real minact, /**< min activity */
7326  SCIP_Real rhs, /**< right hand side */
7327  const char* infostr /**< additional info for this debug message, or NULL */
7328  )
7329 {
7330  SCIPsetDebugMsg(set, "-> %sminact=%.15g rhs=%.15g violation=%.15g\n",infostr != NULL ? infostr : "" , minact, rhs, minact - rhs);
7331 }
7332 #else
7333 #define debugPrintViolationInfo(...) /**/
7334 #endif
7335 
7336 /** apply coefficient tightening */
7337 static
7339  SCIP_SET* set, /**< global SCIP settings */
7340  SCIP_PROOFSET* proofset, /**< proof set */
7341  int* nchgcoefs, /**< pointer to store number of changed coefficients */
7342  SCIP_Bool* redundant /**< pointer to store whether the proof set is redundant */
7343  )
7344 {
7345 #ifdef SCIP_DEBUG
7346  SCIP_Real absmax = 0.0;
7347  SCIP_Real absmin = SCIPsetInfinity(set);
7348  int i;
7349 
7350  for( i = 0; i < proofset->nnz; i++ )
7351  {
7352  absmax = MAX(absmax, REALABS(proofset->vals[i]));
7353  absmin = MIN(absmin, REALABS(proofset->vals[i]));
7354  }
7355 #endif
7356 
7357  (*redundant) = SCIPcutsTightenCoefficients(set->scip, FALSE, proofset->vals, &proofset->rhs, proofset->inds, &proofset->nnz, nchgcoefs);
7358 
7359 #ifdef SCIP_DEBUG
7360  {
7361  SCIP_Real newabsmax = 0.0;
7362  SCIP_Real newabsmin = SCIPsetInfinity(set);
7363 
7364  for( i = 0; i < proofset->nnz; i++ )
7365  {
7366  newabsmax = MAX(newabsmax, REALABS(proofset->vals[i]));
7367  newabsmin = MIN(newabsmin, REALABS(proofset->vals[i]));
7368  }
7369 
7370  SCIPsetDebugMsg(set, "coefficient tightening: [%.15g,%.15g] -> [%.15g,%.15g] (nnz: %d, nchg: %d rhs: %.15g)\n",
7371  absmin, absmax, newabsmin, newabsmax, proofsetGetNVars(proofset), *nchgcoefs, proofsetGetRhs(proofset));
7372  printf("coefficient tightening: [%.15g,%.15g] -> [%.15g,%.15g] (nnz: %d, nchg: %d rhs: %.15g)\n",
7373  absmin, absmax, newabsmin, newabsmax, proofsetGetNVars(proofset), *nchgcoefs, proofsetGetRhs(proofset));
7374  }
7375 #endif
7376 }
7377 
7378 /** try to generate alternative proofs by applying subadditive functions */
7379 static
7381  SCIP_CONFLICT* conflict, /**< conflict analysis data */
7382  SCIP_SET* set, /**< global SCIP settings */
7383  SCIP_STAT* stat, /**< dynamic SCIP statistics */
7384  SCIP_PROB* transprob, /**< transformed problem */
7385  SCIP_TREE* tree, /**< tree data */
7386  BMS_BLKMEM* blkmem, /**< block memory */
7387  SCIP_AGGRROW* proofrow, /**< proof rows data */
7388  SCIP_Real* curvarlbs, /**< current lower bounds of active problem variables */
7389  SCIP_Real* curvarubs, /**< current upper bounds of active problem variables */
7390  SCIP_CONFTYPE conflicttype /**< type of the conflict */
7391  )
7392 {
7393  SCIP_VAR** vars;
7394  SCIP_SOL* refsol;
7395  SCIP_Real* cutcoefs;
7396  SCIP_Real cutefficacy;
7397  SCIP_Real cutrhs;
7398  SCIP_Real proofefficiacy;
7399  SCIP_Real efficiacynorm;
7400  SCIP_Bool islocal;
7401  SCIP_Bool cutsuccess;
7402  SCIP_Bool success;
7403  SCIP_Bool infdelta;
7404  int* cutinds;
7405  int* inds;
7406  int cutnnz;
7407  int nnz;
7408  int nvars;
7409  int i;
7410 
7411  vars = SCIPprobGetVars(transprob);
7412  nvars = SCIPprobGetNVars(transprob);
7413 
7414  inds = SCIPaggrRowGetInds(proofrow);
7415  nnz = SCIPaggrRowGetNNz(proofrow);
7416 
7417  proofefficiacy = aggrRowGetMinActivity(set, transprob, proofrow, curvarlbs, curvarubs, &infdelta);
7418 
7419  if( infdelta )
7420  return SCIP_OKAY;
7421 
7422  proofefficiacy -= SCIPaggrRowGetRhs(proofrow);
7423 
7424  efficiacynorm = SCIPaggrRowCalcEfficacyNorm(set->scip, proofrow);
7425  proofefficiacy /= MAX(1e-6, efficiacynorm);
7426 
7427  /* create reference solution */
7428  SCIP_CALL( SCIPcreateSol(set->scip, &refsol, NULL) );
7429 
7430  /* initialize with average solution */
7431  for( i = 0; i < nvars; i++ )
7432  {
7433  SCIP_CALL( SCIPsolSetVal(refsol, set, stat, tree, vars[i], SCIPvarGetAvgSol(vars[i])) );
7434  }
7435 
7436  /* set all variables that are part of the proof to its active local bound */
7437  for( i = 0; i < nnz; i++ )
7438  {
7439  SCIP_Real val = SCIPaggrRowGetProbvarValue(proofrow, inds[i]);
7440 
7441  if( val > 0.0 )
7442  {
7443  SCIP_CALL( SCIPsolSetVal(refsol, set, stat, tree, vars[inds[i]], curvarubs[inds[i]]) );
7444  }
7445  else
7446  {
7447  SCIP_CALL( SCIPsolSetVal(refsol, set, stat, tree, vars[inds[i]], curvarlbs[inds[i]]) );
7448  }
7449  }
7450 
7451  SCIP_CALL( SCIPsetAllocBufferArray(set, &cutcoefs, nvars) );
7452  SCIP_CALL( SCIPsetAllocBufferArray(set, &cutinds, nvars) );
7453 
7454  cutnnz = 0;
7455  cutefficacy = -SCIPsetInfinity(set);
7456 
7457  /* apply flow cover */
7458  SCIP_CALL( SCIPcalcFlowCover(set->scip, refsol, POSTPROCESS, BOUNDSWITCH, ALLOWLOCAL, proofrow, \
7459  cutcoefs, &cutrhs, cutinds, &cutnnz, &cutefficacy, NULL, &islocal, &cutsuccess) );
7460  success = cutsuccess;
7461 
7462  /* apply MIR */
7464  NULL, NULL, MINFRAC, MAXFRAC, proofrow, cutcoefs, &cutrhs, cutinds, &cutnnz, &cutefficacy, NULL, \
7465  &islocal, &cutsuccess) );
7466  success = (success || cutsuccess);
7467 
7468  /* replace the current proof */
7469  if( success && !islocal && SCIPsetIsPositive(set, cutefficacy) && cutefficacy * nnz > proofefficiacy * cutnnz )
7470  {
7471  SCIP_PROOFSET* alternativeproofset;
7472  SCIP_Bool redundant;
7473  int nchgcoefs;
7474 
7475  SCIP_CALL( proofsetCreate(&alternativeproofset, blkmem) );
7476  alternativeproofset->conflicttype = (conflicttype == SCIP_CONFTYPE_INFEASLP ? SCIP_CONFTYPE_ALTINFPROOF : SCIP_CONFTYPE_ALTBNDPROOF);
7477 
7478  SCIP_CALL( proofsetAddSparseData(alternativeproofset, blkmem, cutcoefs, cutinds, cutnnz, cutrhs) );
7479 
7480  /* apply coefficient tightening */
7481  tightenCoefficients(set, alternativeproofset, &nchgcoefs, &redundant);
7482 
7483  if( !redundant )
7484  {
7485  SCIP_CALL( conflictInsertProofset(conflict, set, alternativeproofset) );
7486  }
7487  else
7488  {
7489  proofsetFree(&alternativeproofset, blkmem);
7490  }
7491  } /*lint !e438*/
7492 
7493  SCIPsetFreeBufferArray(set, &cutinds);
7494  SCIPsetFreeBufferArray(set, &cutcoefs);
7495 
7496  SCIP_CALL( SCIPfreeSol(set->scip, &refsol) );
7497 
7498  return SCIP_OKAY;
7499 }
7500 
7501 /** tighten a given infeasibility proof a^Tx <= b with minact > b w.r.t. local bounds
7502  *
7503  * 1) Apply cut generating functions
7504  * - c-MIR
7505  * - Flow-cover
7506  * - TODO: implement other subadditive functions
7507  * 2) Remove continuous variables contributing with its global bound
7508  * - TODO: implement a variant of non-zero-cancellation
7509  */
7510 static
7512  SCIP_CONFLICT* conflict, /**< conflict analysis data */
7513  SCIP_SET* set, /**< global SCIP settings */
7514  SCIP_STAT* stat, /**< dynamic SCIP statistics */
7515  BMS_BLKMEM* blkmem, /**< block memory */
7516  SCIP_PROB* transprob, /**< transformed problem */
7517  SCIP_TREE* tree, /**< tree data */
7518  SCIP_AGGRROW* proofrow, /**< aggregated row representing the proof */
7519  int validdepth, /**< depth where the proof is valid */
7520  SCIP_Real* curvarlbs, /**< current lower bounds of active problem variables */
7521  SCIP_Real* curvarubs, /**< current upper bounds of active problem variables */
7522  SCIP_Bool initialproof /**< do we analyze the initial reason of infeasibility? */
7523  )
7524 {
7525  SCIP_VAR** vars;
7526  SCIP_Real* vals;
7527  int* inds;
7528  SCIP_PROOFSET* proofset;
7529  SCIP_Bool valid;
7530  SCIP_Bool redundant;
7531  int nnz;
7532  int nchgcoefs;
7533  int nbinvars;
7534  int ncontvars;
7535  int nintvars;
7536  int i;
7537 
7538  assert(conflict->proofset != NULL);
7539  assert(curvarlbs != NULL);
7540  assert(curvarubs != NULL);
7541 
7542  vars = SCIPprobGetVars(transprob);
7543  nbinvars = 0;
7544  nintvars = 0;
7545  ncontvars = 0;
7546 
7547  inds = SCIPaggrRowGetInds(proofrow);
7548  nnz = SCIPaggrRowGetNNz(proofrow);
7549 
7550  /* count number of binary, integer, and continuous variables */
7551  for( i = 0; i < nnz; i++ )
7552  {
7553  assert(SCIPvarGetProbindex(vars[inds[i]]) == inds[i]);
7554 
7555  if( SCIPvarIsBinary(vars[inds[i]]) )
7556  ++nbinvars;
7557  else if( SCIPvarIsIntegral(vars[inds[i]]) )
7558  ++nintvars;
7559  else
7560  ++ncontvars;
7561  }
7562 
7563  SCIPsetDebugMsg(set, "start dual proof tightening:\n");
7564  SCIPsetDebugMsg(set, "-> tighten dual proof: nvars=%d (bin=%d, int=%d, cont=%d)\n",
7565  nnz, nbinvars, nintvars, ncontvars);
7566  debugPrintViolationInfo(set, aggrRowGetMinActivity(set, transprob, proofrow, curvarlbs, curvarubs, NULL), SCIPaggrRowGetRhs(proofrow), NULL);
7567 
7568  /* try to find an alternative proof of local infeasibility that is stronger */
7569  if( set->conf_sepaaltproofs )
7570  {
7571  SCIP_CALL( separateAlternativeProofs(conflict, set, stat, transprob, tree, blkmem, proofrow, curvarlbs, curvarubs,
7572  conflict->conflictset->conflicttype) );
7573  }
7574 
7575  if( initialproof )
7576  proofset = conflict->proofset;
7577  else
7578  {
7579  SCIP_CALL( proofsetCreate(&proofset, blkmem) );
7580  }
7581 
7582  /* start with a proofset containing all variables with a non-zero coefficient in the dual proof */
7583  SCIP_CALL( proofsetAddAggrrow(proofset, set, blkmem, proofrow) );
7584  proofset->conflicttype = conflict->conflictset->conflicttype;
7585  proofset->validdepth = validdepth;
7586 
7587  /* get proof data */
7588  vals = proofsetGetVals(proofset);
7589  inds = proofsetGetInds(proofset);
7590  nnz = proofsetGetNVars(proofset);
7591 
7592 #ifndef NDEBUG
7593  for( i = 0; i < nnz; i++ )
7594  {
7595  int idx = inds[i];
7596  if( vals[i] > 0.0 )
7597  assert(!SCIPsetIsInfinity(set, -curvarlbs[idx]));
7598  if( vals[i] < 0.0 )
7599  assert(!SCIPsetIsInfinity(set, curvarubs[idx]));
7600  }
7601 #endif
7602 
7603  /* remove continuous variable contributing with their global bound
7604  *
7605  * todo: check whether we also want to do that for bound exceeding proofs, but then we cannot update the
7606  * conflict anymore
7607  */
7608  if( proofset->conflicttype == SCIP_CONFTYPE_INFEASLP )
7609  {
7610  /* remove all continuous variables that have equal global and local bounds (ub or lb depend on the sign)
7611  * from the proof
7612  */
7613 
7614  for( i = 0; i < nnz && nnz > 1; )
7615  {
7616  SCIP_Real val;
7617  int idx = inds[i];
7618 
7619  assert(vars[idx] != NULL);
7620 
7621  val = vals[i];
7622  assert(!SCIPsetIsZero(set, val));
7623 
7624  /* skip integral variables */
7625  if( SCIPvarGetType(vars[idx]) != SCIP_VARTYPE_CONTINUOUS && SCIPvarGetType(vars[idx]) != SCIP_VARTYPE_IMPLINT )
7626  {
7627  i++;
7628  continue;
7629  }
7630  else
7631  {
7632  SCIP_Real glbbd;
7633  SCIP_Real locbd;
7634 
7635  /* get appropriate global and local bounds */
7636  glbbd = (val < 0.0 ? SCIPvarGetUbGlobal(vars[idx]) : SCIPvarGetLbGlobal(vars[idx]));
7637  locbd = (val < 0.0 ? curvarubs[idx] : curvarlbs[idx]);
7638 
7639  if( !SCIPsetIsEQ(set, glbbd, locbd) )
7640  {
7641  i++;
7642  continue;
7643  }
7644 
7645  SCIPsetDebugMsg(set, "-> remove continuous variable <%s>: glb=[%g,%g], loc=[%g,%g], val=%g\n",
7646  SCIPvarGetName(vars[idx]), SCIPvarGetLbGlobal(vars[idx]), SCIPvarGetUbGlobal(vars[idx]),
7647  curvarlbs[idx], curvarubs[idx], val);
7648 
7649  proofsetCancelVarWithBound(proofset, set, vars[idx], i, &valid);
7650  assert(valid); /* this should be always fulfilled at this place */
7651 
7652  --nnz;
7653  }
7654  }
7655  }
7656 
7657  /* apply coefficient tightening to initial proof */
7658  tightenCoefficients(set, proofset, &nchgcoefs, &redundant);
7659 
7660  /* it can happen that the constraints is almost globally redundant w.r.t to the maximal activity,
7661  * e.g., due to numerics. in this case, we want to discard the proof
7662  */
7663  if( redundant )
7664  {
7665 #ifndef NDEBUG
7666  SCIP_Real eps = MIN(0.01, 10.0*set->num_feastol);
7667  assert(proofset->rhs - getMaxActivity(set, transprob, proofset->vals, proofset->inds, proofset->nnz, NULL, NULL) < eps);
7668 #endif
7669  if( initialproof )
7670  {
7671  proofsetClear(proofset);
7672  }
7673  else
7674  {
7675  proofsetFree(&proofset, blkmem);
7676  }
7677  }
7678  else
7679  {
7680  if( !initialproof )
7681  {
7682  SCIP_CALL( conflictInsertProofset(conflict, set, proofset) );
7683  }
7684 
7685  if( nchgcoefs > 0 )
7686  {
7687  if( proofset->conflicttype == SCIP_CONFTYPE_INFEASLP )
7689  else if( proofset->conflicttype == SCIP_CONFTYPE_BNDEXCEEDING )
7691  }
7692  }
7693 
7694  return SCIP_OKAY;
7695 }
7696 
7697 /** perform conflict analysis based on a dual unbounded ray
7698  *
7699  * given an aggregation of rows lhs <= a^Tx such that lhs > maxactivity. if the constraint has size one we add a
7700  * bound change instead of the constraint.
7701  */
7702 static
7704  SCIP_CONFLICT* conflict, /**< conflict analysis data */
7705  SCIP_SET* set, /**< global SCIP settings */
7706  SCIP_STAT* stat, /**< dynamic SCIP statistics */
7707  BMS_BLKMEM* blkmem, /**< block memory */
7708  SCIP_PROB* origprob, /**< original problem */
7709  SCIP_PROB* transprob, /**< transformed problem */
7710  SCIP_TREE* tree, /**< tree data */
7711  SCIP_REOPT* reopt, /**< reoptimization data */
7712  SCIP_LP* lp, /**< LP data */
7713  SCIP_AGGRROW* proofrow, /**< aggregated row representing the proof */
7714  int validdepth, /**< valid depth of the dual proof */
7715  SCIP_Real* curvarlbs, /**< current lower bounds of active problem variables */
7716  SCIP_Real* curvarubs, /**< current upper bounds of active problem variables */
7717  SCIP_Bool initialproof, /**< do we analyze the initial reason of infeasibility? */
7718  SCIP_Bool* globalinfeasible, /**< pointer to store whether global infeasibility could be proven */
7719  SCIP_Bool* success /**< pointer to store success result */
7720  )
7721 {
7722  SCIP_Real rhs;
7723  SCIP_Real minact;
7724  SCIP_Bool infdelta;
7725  int nnz;
7726 
7727  assert(set != NULL);
7728  assert(transprob != NULL);
7729  assert(validdepth >= 0);
7730  assert(validdepth == 0 || validdepth < SCIPtreeGetFocusDepth(tree));
7731 
7732  /* get sparse data */
7733  nnz = SCIPaggrRowGetNNz(proofrow);
7734  rhs = SCIPaggrRowGetRhs(proofrow);
7735 
7736  *globalinfeasible = FALSE;
7737  *success = FALSE;
7738 
7739  /* get minimal activity w.r.t. local bounds */
7740  minact = aggrRowGetMinActivity(set, transprob, proofrow, curvarlbs, curvarubs, &infdelta);
7741 
7742  if( infdelta )
7743  return SCIP_OKAY;
7744 
7745  /* only run is the proof proves local infeasibility */
7746  if( SCIPsetIsFeasLE(set, minact, rhs) )
7747  return SCIP_OKAY;
7748 
7749  /* if the farkas-proof is empty, the node and its sub tree can be cut off completely */
7750  if( nnz == 0 )
7751  {
7752  SCIPsetDebugMsg(set, " -> empty farkas-proof in depth %d cuts off sub tree at depth %d\n", SCIPtreeGetFocusDepth(tree), validdepth);
7753 
7754  SCIP_CALL( SCIPnodeCutoff(tree->path[validdepth], set, stat, tree, transprob, origprob, reopt, lp, blkmem) );
7755 
7756  *globalinfeasible = TRUE;
7757  *success = TRUE;
7758 
7759  ++conflict->ndualproofsinfsuccess;
7760 
7761  return SCIP_OKAY;
7762  }
7763 
7764  /* try to enforce the constraint based on a dual ray */
7765  SCIP_CALL( tightenDualproof(conflict, set, stat, blkmem, transprob, tree, proofrow, validdepth,
7766  curvarlbs, curvarubs, initialproof) );
7767 
7768  if( *globalinfeasible )
7769  {
7770  SCIPsetDebugMsg(set, "detect global: cutoff root node\n");
7771  SCIP_CALL( SCIPnodeCutoff(tree->path[0], set, stat, tree, transprob, origprob, reopt, lp, blkmem) );
7772  *success = TRUE;
7773 
7774  ++conflict->ndualproofsinfsuccess;
7775  }
7776 
7777  return SCIP_OKAY;
7778 }
7779 
7780 /** try to find a subset of changed bounds leading to an infeasible LP
7781  *
7782  * 1. call undoBdchgsDualfarkas() or undoBdchgsDualsol()
7783  * -> update lb/ubchginfoposs arrays
7784  * -> store additional changes in bdchg and curvarlbs/ubs arrays
7785  * -> apply additional changes to the LPI
7786  * 2. (optional) if additional bound changes were undone:
7787  * -> resolve LP
7788  * -> goto 1.
7789  * 3. redo all bound changes in the LPI to restore the LPI to its original state
7790  * 4. analyze conflict
7791  * -> put remaining changed bounds (see lb/ubchginfoposs arrays) into starting conflict set
7792  */
7793 static
7795  SCIP_CONFLICT* conflict, /**< conflict data */
7796  SCIP_SET* set, /**< global SCIP settings */
7797  SCIP_STAT* stat, /**< problem statistics */
7798  SCIP_PROB* origprob, /**< original problem */
7799  SCIP_PROB* transprob, /**< transformed problem */
7800  SCIP_TREE* tree, /**< branch and bound tree */
7801  SCIP_REOPT* reopt, /**< reoptimization data */
7802  SCIP_LP* lp, /**< LP data */
7803  SCIP_LPI* lpi, /**< LPI data */
7804  BMS_BLKMEM* blkmem, /**< block memory */
7805  SCIP_Real* proofcoefs, /**< coefficients in the proof constraint */
7806  SCIP_Real* prooflhs, /**< lhs of the proof constraint */
7807  SCIP_Real* proofactivity, /**< maximal activity of the proof constraint */
7808  SCIP_Real* curvarlbs, /**< current lower bounds of active problem variables */
7809  SCIP_Real* curvarubs, /**< current upper bounds of active problem variables */
7810  int* lbchginfoposs, /**< positions of currently active lower bound change information in variables' arrays */
7811  int* ubchginfoposs, /**< positions of currently active upper bound change information in variables' arrays */
7812  int* iterations, /**< pointer to store the total number of LP iterations used */
7813  SCIP_Bool marklpunsolved, /**< whether LP should be marked unsolved after analysis (needed for strong branching) */
7814  SCIP_Bool* dualproofsuccess, /**< pointer to store success result of dual proof analysis */
7815  SCIP_Bool* valid /**< pointer to store whether the result is still a valid proof */
7816  )
7817 {
7818  SCIP_LPBDCHGS* oldlpbdchgs;
7819  SCIP_LPBDCHGS* relaxedlpbdchgs;
7820  SCIP_Bool solvelp;
7821  SCIP_Bool resolve;
7822  int ncols;
7823 
7824  assert(set != NULL);
7825 
7826  /* get number of columns in the LP */
7827  ncols = SCIPlpGetNCols(lp);
7828 
7829  /* get temporary memory for remembering bound changes on LPI columns */
7830  SCIP_CALL( lpbdchgsCreate(&oldlpbdchgs, set, ncols) );
7831  SCIP_CALL( lpbdchgsCreate(&relaxedlpbdchgs, set, ncols) );
7832 
7833  /* undo as many bound changes as possible with the current LP solution */
7834  resolve = FALSE;
7835  if( (*valid) )
7836  {
7837  int currentdepth;
7838  currentdepth = SCIPtreeGetCurrentDepth(tree);
7839 
7840  if( SCIPlpiIsPrimalInfeasible(lpi) )
7841  {
7842  SCIP_CALL( undoBdchgsDualfarkas(set, transprob, lp, currentdepth, curvarlbs, curvarubs, lbchginfoposs, \
7843  ubchginfoposs, oldlpbdchgs, relaxedlpbdchgs, valid, &resolve, proofcoefs, *prooflhs, proofactivity) );
7844  }
7845  else
7846  {
7847  assert(SCIPlpiIsDualFeasible(lpi) || SCIPlpiIsObjlimExc(lpi));
7848  SCIP_CALL( undoBdchgsDualsol(set, transprob, lp, currentdepth, curvarlbs, curvarubs, lbchginfoposs, ubchginfoposs, \
7849  oldlpbdchgs, relaxedlpbdchgs, valid, &resolve, proofcoefs, *prooflhs, proofactivity) );
7850  }
7851  }
7852 
7853  /* check if we want to solve the LP */
7854  assert(SCIPprobAllColsInLP(transprob, set, lp));
7855  solvelp = (set->conf_maxlploops != 0 && set->conf_lpiterations != 0);
7856 
7857  if( (*valid) && resolve && solvelp )
7858  {
7859  SCIP_RETCODE retcode;
7860  SCIP_ROW** rows;
7861  int* sidechginds;
7862  SCIP_Real* sidechgoldlhss;
7863  SCIP_Real* sidechgoldrhss;
7864  SCIP_Real* sidechgnewlhss;
7865  SCIP_Real* sidechgnewrhss;
7866  SCIP_Real lpiinfinity;
7867  SCIP_Bool globalinfeasible;
7868  int maxlploops;
7869  int lpiterations;
7870  int sidechgssize;
7871  int nsidechgs;
7872  int nrows;
7873  int nloops;
7874  int r;
7875 
7876  /* get infinity value of LP solver */
7877  lpiinfinity = SCIPlpiInfinity(lpi);
7878 
7879  /* temporarily disable objective limit and install an iteration limit */
7880  maxlploops = (set->conf_maxlploops >= 0 ? set->conf_maxlploops : INT_MAX);
7881  lpiterations = (set->conf_lpiterations >= 0 ? set->conf_lpiterations : INT_MAX);
7882  SCIP_CALL( SCIPlpiSetRealpar(lpi, SCIP_LPPAR_OBJLIM, lpiinfinity) );
7883  SCIP_CALL( SCIPlpiSetIntpar(lpi, SCIP_LPPAR_LPITLIM, lpiterations) );
7884 
7885  /* get LP rows */
7886  rows = SCIPlpGetRows(lp);
7887  nrows = SCIPlpGetNRows(lp);
7888  assert(nrows == 0 || rows != NULL);
7889 
7890  /* get temporary memory for remembering side changes on LPI rows */
7891  SCIP_CALL( SCIPsetAllocBufferArray(set, &sidechginds, nrows) );
7892  SCIP_CALL( SCIPsetAllocBufferArray(set, &sidechgoldlhss, nrows) );
7893  SCIP_CALL( SCIPsetAllocBufferArray(set, &sidechgoldrhss, nrows) );
7894  SCIP_CALL( SCIPsetAllocBufferArray(set, &sidechgnewlhss, nrows) );
7895  SCIP_CALL( SCIPsetAllocBufferArray(set, &sidechgnewrhss, nrows) );
7896  sidechgssize = nrows;
7897  nsidechgs = 0;
7898 
7899  /* remove all local rows by setting their sides to infinity;
7900  * finite sides are only changed to near infinity, such that the row's sense in the LP solver
7901  * is not affected (e.g. CPLEX cannot handle free rows)
7902  */
7903  for( r = 0; r < nrows; ++r )
7904  {
7905  assert(SCIProwGetLPPos(rows[r]) == r);
7906 
7907  if( SCIProwIsLocal(rows[r]) )
7908  {
7909  SCIPsetDebugMsg(set, " -> removing local row <%s> [%g,%g]\n",
7910  SCIProwGetName(rows[r]), SCIProwGetLhs(rows[r]), SCIProwGetRhs(rows[r]));
7911  SCIP_CALL( addSideRemoval(set, rows[r], lpiinfinity, &sidechginds, &sidechgoldlhss, &sidechgoldrhss,
7912  &sidechgnewlhss, &sidechgnewrhss, &sidechgssize, &nsidechgs) );
7913  }
7914  }
7915 
7916  /* apply changes of local rows to the LP solver */
7917  if( nsidechgs > 0 )
7918  {
7919  SCIP_CALL( SCIPlpiChgSides(lpi, nsidechgs, sidechginds, sidechgnewlhss, sidechgnewrhss) );
7920  }
7921 
7922  /* undo as many additional bound changes as possible by resolving the LP */
7923  assert((*valid));
7924  assert(resolve);
7925  nloops = 0;
7926  globalinfeasible = FALSE;
7927  while( (*valid) && resolve && nloops < maxlploops )
7928  {
7929  int iter;
7930 
7931  assert(!globalinfeasible);
7932 
7933  nloops++;
7934  resolve = FALSE;
7935 
7936  SCIPsetDebugMsg(set, "infeasible LP conflict analysis loop %d (changed col bounds: %d)\n", nloops, relaxedlpbdchgs->nbdchgs);
7937 
7938  /* apply bound changes to the LP solver */
7939  assert(relaxedlpbdchgs->nbdchgs >= 0);
7940  if( relaxedlpbdchgs->nbdchgs > 0 )
7941  {
7942  SCIPsetDebugMsg(set, " -> applying %d bound changes to the LP solver\n", relaxedlpbdchgs->nbdchgs);
7943  SCIP_CALL( SCIPlpiChgBounds(lpi, relaxedlpbdchgs->nbdchgs, relaxedlpbdchgs->bdchginds, \
7944  relaxedlpbdchgs->bdchglbs, relaxedlpbdchgs->bdchgubs) );
7945 
7946  /* reset conflict LP bound change data structure */
7947  lpbdchgsReset(relaxedlpbdchgs, ncols);
7948  }
7949 
7950  /* start LP timer */
7951  SCIPclockStart(stat->conflictlptime, set);
7952 
7953  /* resolve LP */
7954  retcode = SCIPlpiSolveDual(lpi);
7955 
7956  /* stop LP timer */
7957  SCIPclockStop(stat->conflictlptime, set);
7958 
7959  /* check return code of LP solving call */
7960  if( retcode == SCIP_LPERROR )
7961  {
7962  (*valid) = FALSE;
7963  break;
7964  }
7965  SCIP_CALL( retcode );
7966 
7967  /* count number of LP iterations */
7968  SCIP_CALL( SCIPlpiGetIterations(lpi, &iter) );
7969  (*iterations) += iter;
7970  stat->nconflictlps++;
7971  stat->nconflictlpiterations += iter;
7972  SCIPsetDebugMsg(set, " -> resolved LP in %d iterations (total: %" SCIP_LONGINT_FORMAT ") (infeasible:%u)\n",
7974 
7975  /* evaluate result */
7976  if( SCIPlpiIsDualFeasible(lpi) || SCIPlpiIsObjlimExc(lpi) )
7977  {
7978  SCIP_Real objval;
7979 
7980  SCIP_CALL( SCIPlpiGetObjval(lpi, &objval) );
7981  (*valid) = (objval >= lp->lpiobjlim && !SCIPlpDivingObjChanged(lp));
7982  }
7983  else
7984  (*valid) = SCIPlpiIsPrimalInfeasible(lpi);
7985 
7986  if( (*valid) )
7987  {
7988  int currentdepth;
7989  currentdepth = SCIPtreeGetCurrentDepth(tree);
7990 
7991  /* undo additional bound changes */
7992  if( SCIPlpiIsPrimalInfeasible(lpi) )
7993  {
7994  SCIP_AGGRROW* farkasrow;
7995  int* inds;
7996  int validdepth;
7997  int nnz;
7998  int v;
7999 
8000 #ifndef NDEBUG
8001  SCIP_VAR** vars = SCIPprobGetVars(transprob);
8002 #endif
8003 
8004  SCIP_CALL( SCIPaggrRowCreate(set->scip, &farkasrow) );
8005 
8006  /* the original LP exceeds the current cutoff bound, thus, we have not constructed the Farkas proof */
8007  SCIP_CALL( getFarkasProof(set, transprob, lp, lpi, tree, farkasrow, proofactivity, &validdepth,
8008  curvarlbs, curvarubs, valid) );
8009 
8010  /* the constructed Farkas proof is not valid, we need to break here */
8011  if( !(*valid) )
8012  {
8013  SCIPaggrRowFree(set->scip, &farkasrow);
8014  break;
8015  }
8016 
8017  /* start dual proof analysis */
8018  if( set->conf_useinflp == 'd' || set->conf_useinflp == 'b' )
8019  {
8020  /* change the conflict type */
8021  SCIP_CONFTYPE oldconftype = conflict->conflictset->conflicttype;
8023 
8024  /* start dual proof analysis */
8025  SCIP_CALL( conflictAnalyzeDualProof(conflict, set, stat, blkmem, origprob, transprob, tree, reopt, lp, \
8026  farkasrow, validdepth, curvarlbs, curvarubs, FALSE, &globalinfeasible, dualproofsuccess) );
8027 
8028  conflict->conflictset->conflicttype = oldconftype;
8029  }
8030 
8031  /* todo: in theory, we could apply conflict graph analysis for locally valid proofs, too, but this needs to be implemented */
8032  if( globalinfeasible || validdepth > SCIPtreeGetEffectiveRootDepth(tree) )
8033  {
8034  SCIPaggrRowFree(set->scip, &farkasrow);
8035  goto TERMINATE;
8036  }
8037 
8038  BMSclearMemoryArray(proofcoefs, SCIPprobGetNVars(transprob));
8039  (*prooflhs) = -SCIPaggrRowGetRhs(farkasrow);
8040  (*proofactivity) = -(*proofactivity);
8041 
8042  inds = SCIPaggrRowGetInds(farkasrow);
8043  nnz = SCIPaggrRowGetNNz(farkasrow);
8044 
8045  for( v = 0; v < nnz; v++ )
8046  {
8047  int i = inds[v];
8048 
8049  assert(SCIPvarGetProbindex(vars[i]) == inds[v]);
8050 
8051  proofcoefs[i] = -SCIPaggrRowGetProbvarValue(farkasrow, i);
8052  }
8053 
8054  /* free aggregation rows */
8055  SCIPaggrRowFree(set->scip, &farkasrow);
8056 
8057  SCIP_CALL( undoBdchgsDualfarkas(set, transprob, lp, currentdepth, curvarlbs, curvarubs, lbchginfoposs, \
8058  ubchginfoposs, oldlpbdchgs, relaxedlpbdchgs, valid, &resolve, proofcoefs, (*prooflhs), proofactivity) );
8059  }
8060  else
8061  {
8062  SCIP_AGGRROW* proofrow;
8063  int* inds;
8064  int validdepth;
8065  int nnz;
8066  int v;
8067 
8068 #ifndef NDEBUG
8069  SCIP_VAR** vars = SCIPprobGetVars(transprob);
8070 #endif
8071 
8072  assert(SCIPlpiIsDualFeasible(lpi) || SCIPlpiIsObjlimExc(lpi));
8073 
8074  SCIP_CALL( SCIPaggrRowCreate(set->scip, &proofrow) );
8075 
8076  SCIP_CALL( getDualProof(set, transprob, lp, lpi, tree, proofrow, proofactivity, &validdepth,
8077  curvarlbs, curvarubs, valid) );
8078 
8079  /* the constructed dual proof is not valid, we need to break here */
8080  if( !(*valid) || validdepth > SCIPtreeGetEffectiveRootDepth(tree) )
8081  {
8082  SCIPaggrRowFree(set->scip, &proofrow);
8083  break;
8084  }
8085  /* in contrast to the infeasible case we don't want to analyze the (probably identical) proof again. */
8086 
8087  BMSclearMemoryArray(proofcoefs, SCIPprobGetNVars(transprob));
8088  (*prooflhs) = -SCIPaggrRowGetRhs(proofrow);
8089  (*proofactivity) = -(*proofactivity);
8090 
8091  inds = SCIPaggrRowGetInds(proofrow);
8092  nnz = SCIPaggrRowGetNNz(proofrow);
8093 
8094  for( v = 0; v < nnz; v++ )
8095  {
8096  int i = inds[v];
8097 
8098  assert(SCIPvarGetProbindex(vars[i]) == inds[v]);
8099 
8100  proofcoefs[i] = -SCIPaggrRowGetProbvarValue(proofrow, i);
8101  }
8102 
8103  /* free aggregation rows */
8104  SCIPaggrRowFree(set->scip, &proofrow);
8105 
8106  SCIP_CALL( undoBdchgsDualsol(set, transprob, lp, currentdepth, curvarlbs, curvarubs, lbchginfoposs, \
8107  ubchginfoposs, oldlpbdchgs, relaxedlpbdchgs, valid, &resolve, proofcoefs, *prooflhs, proofactivity) );
8108  }
8109  }
8110  assert(!resolve || (*valid));
8111  assert(!resolve || relaxedlpbdchgs->nbdchgs > 0);
8112  SCIPsetDebugMsg(set, " -> finished infeasible LP conflict analysis loop %d (iter: %d, nbdchgs: %d)\n",
8113  nloops, iter, relaxedlpbdchgs->nbdchgs);
8114  }
8115 
8116  SCIPsetDebugMsg(set, "finished undoing bound changes after %d loops (valid=%u, nbdchgs: %d)\n",
8117  nloops, (*valid), oldlpbdchgs->nbdchgs);
8118 
8119  TERMINATE:
8120  /* reset variables to local bounds */
8121  if( oldlpbdchgs->nbdchgs > 0 )
8122  {
8123  SCIP_CALL( SCIPlpiChgBounds(lpi, oldlpbdchgs->nbdchgs, oldlpbdchgs->bdchginds, oldlpbdchgs->bdchglbs, oldlpbdchgs->bdchgubs) );
8124  }
8125 
8126  /* reset changes of local rows */
8127  if( nsidechgs > 0 )
8128  {
8129  SCIP_CALL( SCIPlpiChgSides(lpi, nsidechgs, sidechginds, sidechgoldlhss, sidechgoldrhss) );
8130  }
8131 
8132  /* mark the LP unsolved */
8133  if( oldlpbdchgs->nbdchgs > 0 || nsidechgs > 0 )
8134  {
8135  /* The LPI data are out of sync with LP data. Thus, the LP should be marked
8136  * unsolved. However, for strong branching calls, the LP has to have status 'solved'; in
8137  * this case, marklpunsolved is FALSE and synchronization is performed later. */
8138  if ( marklpunsolved )
8139  {
8140  lp->solved = FALSE;
8141  lp->primalfeasible = FALSE;
8142  lp->primalchecked = FALSE;
8143  lp->dualfeasible = FALSE;
8144  lp->dualchecked = FALSE;
8145  lp->lpobjval = SCIP_INVALID;
8147  }
8148  }
8149 
8150  /* reinstall old objective and iteration limits in LP solver */
8153 
8154  /* free temporary memory */
8155  SCIPsetFreeBufferArray(set, &sidechgnewrhss);
8156  SCIPsetFreeBufferArray(set, &sidechgnewlhss);
8157  SCIPsetFreeBufferArray(set, &sidechgoldrhss);
8158  SCIPsetFreeBufferArray(set, &sidechgoldlhss);
8159  SCIPsetFreeBufferArray(set, &sidechginds);
8160  }
8161 
8162  /* free temporary memory */
8163  lpbdchgsFree(&relaxedlpbdchgs, set);
8164  lpbdchgsFree(&oldlpbdchgs, set);
8165 
8166  return SCIP_OKAY;
8167 }
8168 
8169 /** actually performs analysis of infeasible LP */
8170 static
8172  SCIP_CONFLICT* conflict, /**< conflict analysis data */
8173  SCIP_CONFLICTSTORE* conflictstore, /**< conflict store */
8174  BMS_BLKMEM* blkmem, /**< block memory of transformed problem */
8175  SCIP_SET* set, /**< global SCIP settings */
8176  SCIP_STAT* stat, /**< problem statistics */
8177  SCIP_PROB* transprob, /**< transformed problem */
8178  SCIP_PROB* origprob, /**< original problem */
8179  SCIP_TREE* tree, /**< branch and bound tree */
8180  SCIP_REOPT* reopt, /**< reoptimization data structure */
8181  SCIP_LP* lp, /**< LP data */
8182  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
8183  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
8184  SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
8185  SCIP_Bool diving, /**< are we in strong branching or diving mode? */
8186  SCIP_Bool* dualproofsuccess, /**< pointer to store success result of dual proof analysis */
8187  int* iterations, /**< pointer to store the total number of LP iterations used */
8188  int* nconss, /**< pointer to store the number of generated conflict constraints */
8189  int* nliterals, /**< pointer to store the number of literals in generated conflict constraints */
8190  int* nreconvconss, /**< pointer to store the number of generated reconvergence constraints */
8191  int* nreconvliterals, /**< pointer to store the number of literals generated reconvergence constraints */
8192  SCIP_Bool marklpunsolved /**< whether LP should be marked unsolved after analysis (needed for strong branching) */
8193  )
8194 {
8195  SCIP_VAR** vars;
8196  SCIP_AGGRROW* farkasrow;
8197  SCIP_LPI* lpi;
8198  SCIP_Bool valid;
8199  SCIP_Bool globalinfeasible;
8200  int* lbchginfoposs;
8201  int* ubchginfoposs;
8202  int validdepth;
8203  int nvars;
8204  int v;
8205  SCIP_Real* curvarlbs;
8206  SCIP_Real* curvarubs;
8207  SCIP_Real farkasactivity;
8208 
8209  assert(conflict != NULL);
8210  assert(conflict->nconflictsets == 0);
8211  assert(set != NULL);
8212  assert(SCIPprobAllColsInLP(transprob, set, lp)); /* LP conflict analysis is only valid, if all variables are known */
8213  assert(stat != NULL);
8214  assert(transprob != NULL);
8215  assert(lp != NULL);
8216  assert(lp->flushed);
8217  assert(lp->solved);
8218  assert(iterations != NULL);
8219  assert(nconss != NULL);
8220  assert(nliterals != NULL);
8221  assert(nreconvconss != NULL);
8222  assert(nreconvliterals != NULL);
8223 
8224  *iterations = 0;
8225  *nconss = 0;
8226  *nliterals = 0;
8227  *nreconvconss = 0;
8228  *nreconvliterals = 0;
8229 
8230  vars = transprob->vars;
8231  nvars = transprob->nvars;
8232 
8233  valid = TRUE;
8234  validdepth = 0;
8235 
8236  /* get LP solver interface */
8237  lpi = SCIPlpGetLPI(lp);
8240 
8241  if( !SCIPlpiIsPrimalInfeasible(lpi) )
8242  {
8243  SCIP_Real objval;
8244 
8245  assert(!SCIPlpDivingObjChanged(lp));
8246 
8247  /* make sure, a dual feasible solution exists, that exceeds the objective limit;
8248  * With FASTMIP setting, CPLEX does not apply the final pivot to reach the dual solution exceeding the objective
8249  * limit. Therefore, we have to either turn off FASTMIP and resolve the problem or continue solving it without
8250  * objective limit for at least one iteration. It seems that the strategy to continue with FASTMIP for one
8251  * additional simplex iteration yields better results.
8252  */
8253  SCIP_CALL( SCIPlpiGetObjval(lpi, &objval) );
8254  if( objval < lp->lpiobjlim )
8255  {
8256  SCIP_RETCODE retcode;
8257 
8258  /* temporarily disable objective limit and install an iteration limit */
8261 
8262  /* start LP timer */
8263  SCIPclockStart(stat->conflictlptime, set);
8264 
8265  /* resolve LP */
8266  retcode = SCIPlpiSolveDual(lpi);
8267 
8268  /* stop LP timer */
8269  SCIPclockStop(stat->conflictlptime, set);
8270 
8271  /* check return code of LP solving call */
8272  valid = (retcode != SCIP_LPERROR);
8273  if( valid )
8274  {
8275  int iter;
8276 
8277  SCIP_CALL( retcode );
8278 
8279  /* count number of LP iterations */
8280  SCIP_CALL( SCIPlpiGetIterations(lpi, &iter) );
8281  (*iterations) += iter;
8282  stat->nconflictlps++;
8283  stat->nconflictlpiterations += iter;
8284  SCIPsetDebugMsg(set, " -> resolved objlim exceeding LP in %d iterations (total: %" SCIP_LONGINT_FORMAT ") (infeasible:%u, objlim: %u, optimal:%u)\n",
8287  }
8288 
8289  /* reinstall old objective and iteration limits in LP solver */
8292 
8293  /* abort, if the LP produced an error */
8294  if( !valid )
8295  return SCIP_OKAY;
8296  }
8297  }
8299 
8300  if( !SCIPlpiIsPrimalInfeasible(lpi) )
8301  {
8302  SCIP_Real objval;
8303 
8304  assert(!SCIPlpDivingObjChanged(lp));
8305 
8306  SCIP_CALL( SCIPlpiGetObjval(lpi, &objval) );
8307  if( objval < lp->lpiobjlim )
8308  {
8309  SCIPsetDebugMsg(set, " -> LP does not exceed the cutoff bound: obj=%g, cutoff=%g\n", objval, lp->lpiobjlim);
8310  return SCIP_OKAY;
8311  }
8312  else
8313  {
8314  SCIPsetDebugMsg(set, " -> LP exceeds the cutoff bound: obj=%g, cutoff=%g\n", objval, lp->lpiobjlim);
8315  }
8316  }
8317 
8318  assert(valid);
8319 
8320  SCIP_CALL( SCIPaggrRowCreate(set->scip, &farkasrow) );
8321  SCIP_CALL( SCIPsetAllocBufferArray(set, &lbchginfoposs, transprob->nvars) );
8322  SCIP_CALL( SCIPsetAllocBufferArray(set, &ubchginfoposs, transprob->nvars) );
8323 
8324  farkasactivity = 0.0;
8325 
8326  /* get temporary memory for remembering variables' current bounds and corresponding bound change information
8327  * positions in variable's bound change information arrays
8328  */
8329  SCIP_CALL( SCIPsetAllocBufferArray(set, &curvarlbs, nvars) );
8330  SCIP_CALL( SCIPsetAllocBufferArray(set, &curvarubs, nvars) );
8331 
8332  /* get current bounds and current positions in lb/ubchginfos arrays of variables */
8333  valid = TRUE;
8334  for( v = 0; v < nvars && valid; ++v )
8335  {
8336  SCIP_VAR* var;
8337 
8338  var = vars[v];
8339 
8340  curvarlbs[v] = SCIPvarGetLbLP(var, set);
8341  curvarubs[v] = SCIPvarGetUbLP(var, set);
8342  lbchginfoposs[v] = var->nlbchginfos-1;
8343  ubchginfoposs[v] = var->nubchginfos-1;
8344  assert(diving || SCIPsetIsEQ(set, curvarlbs[v], SCIPvarGetLbLocal(var)));
8345  assert(diving || SCIPsetIsEQ(set, curvarubs[v], SCIPvarGetUbLocal(var)));
8346 
8347  /* check, if last bound changes were due to strong branching or diving */
8348  if( diving )
8349  {
8350  SCIP_Real lb;
8351  SCIP_Real ub;
8352 
8353  lb = SCIPvarGetLbLocal(var);
8354  ub = SCIPvarGetUbLocal(var);
8355  if( SCIPsetIsGT(set, curvarlbs[v], lb) )
8356  lbchginfoposs[v] = var->nlbchginfos;
8357  else if( SCIPsetIsLT(set, curvarlbs[v], lb) )
8358  {
8359  /* the bound in the diving LP was relaxed -> the LP is not a subproblem of the current node -> abort! */
8360  /**@todo we could still analyze such a conflict, but we would have to take care with our data structures */
8361  valid = FALSE;
8362  }
8363  if( SCIPsetIsLT(set, curvarubs[v], ub) )
8364  ubchginfoposs[v] = var->nubchginfos;
8365  else if( SCIPsetIsGT(set, curvarubs[v], ub) )
8366  {
8367  /* the bound in the diving LP was relaxed -> the LP is not a subproblem of the current node -> abort! */
8368  /**@todo we could still analyze such a conflict, but we would have to take care with our data structures */
8369  valid = FALSE;
8370  }
8371  }
8372  }
8373 
8374  if( !valid )
8375  goto TERMINATE;
8376 
8377  /* the LP is prooven to be infeasible */
8378  if( SCIPlpiIsPrimalInfeasible(lpi) )
8379  {
8380  SCIP_CALL( getFarkasProof(set, transprob, lp, lpi, tree, farkasrow, &farkasactivity, &validdepth,
8381  curvarlbs, curvarubs, &valid) );
8382  }
8383  /* the LP is dual feasible and/or exceeds the current incumbant solution */
8384  else
8385  {
8386  assert(SCIPlpiIsDualFeasible(lpi) || SCIPlpiIsObjlimExc(lpi));
8387  SCIP_CALL( getDualProof(set, transprob, lp, lpi, tree, farkasrow, &farkasactivity, &validdepth,
8388  curvarlbs, curvarubs, &valid) );
8389  }
8390 
8391  if( !valid || validdepth >= SCIPtreeGetCurrentDepth(tree) )
8392  goto TERMINATE;
8393 
8394  globalinfeasible = FALSE;
8395 
8396  /* start dual proof analysis */
8397  if( ((set->conf_useinflp == 'b' || set->conf_useinflp == 'd') && conflict->conflictset->conflicttype == SCIP_CONFTYPE_INFEASLP)
8398  || ((set->conf_useboundlp == 'b' || set->conf_useboundlp == 'd') && conflict->conflictset->conflicttype == SCIP_CONFTYPE_BNDEXCEEDING) )
8399  {
8400  /* start dual proof analysis */
8401  SCIP_CALL( conflictAnalyzeDualProof(conflict, set, stat, blkmem, origprob, transprob, tree, reopt, lp, farkasrow, \
8402  validdepth, curvarlbs, curvarubs, TRUE, &globalinfeasible, dualproofsuccess) );
8403  }
8404 
8405  assert(valid);
8406 
8407  /* todo: in theory, we could apply conflict graph analysis for locally valid proofs, too, but this needs to be implemented */
8408  if( !globalinfeasible && validdepth <= SCIPtreeGetEffectiveRootDepth(tree)
8409  && (((set->conf_useinflp == 'b' || set->conf_useinflp == 'c') && conflict->conflictset->conflicttype == SCIP_CONFTYPE_INFEASLP)
8410  || ((set->conf_useboundlp == 'b' || set->conf_useboundlp == 'c') && conflict->conflictset->conflicttype == SCIP_CONFTYPE_BNDEXCEEDING)) )
8411  {
8412  SCIP_Real* farkascoefs;
8413  SCIP_Real farkaslhs;
8414  int* inds;
8415  int nnz;
8416 
8417 #ifdef SCIP_DEBUG
8418  {
8419  SCIP_Real objlim;
8420  SCIPsetDebugMsg(set, "analyzing conflict on infeasible LP (infeasible: %u, objlimexc: %u, optimal:%u) in depth %d (diving: %u)\n",
8422 
8423  SCIP_CALL( SCIPlpiGetRealpar(lpi, SCIP_LPPAR_OBJLIM, &objlim) );
8424  SCIPsetDebugMsg(set, " -> objective limit in LP solver: %g (in LP: %g)\n", objlim, lp->lpiobjlim);
8425  }
8426 #endif
8427 
8428  SCIP_CALL( SCIPsetAllocBufferArray(set, &farkascoefs, SCIPprobGetNVars(transprob)) );
8429  BMSclearMemoryArray(farkascoefs, SCIPprobGetNVars(transprob));
8430 
8431  farkaslhs = -SCIPaggrRowGetRhs(farkasrow);
8432  farkasactivity = -farkasactivity;
8433 
8434  inds = SCIPaggrRowGetInds(farkasrow);
8435  nnz = SCIPaggrRowGetNNz(farkasrow);
8436 
8437  for( v = 0; v < nnz; v++ )
8438  {
8439  int i = inds[v];
8440 
8441  assert(SCIPvarGetProbindex(vars[i]) == inds[v]);
8442 
8443  farkascoefs[i] = -SCIPaggrRowGetProbvarValue(farkasrow, i);
8444  }
8445 
8446  SCIP_CALL( runBoundHeuristic(conflict, set, stat, origprob, transprob, tree, reopt, lp, lpi, blkmem, farkascoefs,
8447  &farkaslhs, &farkasactivity, curvarlbs, curvarubs, lbchginfoposs, ubchginfoposs, iterations, marklpunsolved,
8448  dualproofsuccess, &valid) );
8449 
8450  SCIPsetFreeBufferArray(set, &farkascoefs);
8451 
8452  if( !valid )
8453  goto FLUSHPROOFSETS;
8454 
8455  /* analyze the conflict starting with remaining bound changes */
8456  SCIP_CALL( conflictAnalyzeRemainingBdchgs(conflict, blkmem, set, stat, transprob, tree, diving, \
8457  lbchginfoposs, ubchginfoposs, nconss, nliterals, nreconvconss, nreconvliterals) );
8458 
8459  /* flush conflict set storage */
8460  SCIP_CALL( SCIPconflictFlushConss(conflict, blkmem, set, stat, transprob, origprob, tree, reopt, lp, branchcand, \
8461  eventqueue, cliquetable) );
8462  }
8463 
8464  FLUSHPROOFSETS:
8465  /* flush proof set */
8466  if( proofsetGetNVars(conflict->proofset) > 0 || conflict->nproofsets > 0 )
8467  {
8468  SCIP_CALL( conflictFlushProofset(conflict, conflictstore, blkmem, set, stat, transprob, origprob, tree, reopt, lp, \
8469  branchcand, eventqueue, cliquetable) );
8470  }
8471 
8472  TERMINATE:
8473  SCIPsetFreeBufferArray(set, &curvarubs);
8474  SCIPsetFreeBufferArray(set, &curvarlbs);
8475  SCIPsetFreeBufferArray(set, &ubchginfoposs);
8476  SCIPsetFreeBufferArray(set, &lbchginfoposs);
8477  SCIPaggrRowFree(set->scip, &farkasrow);
8478 
8479  return SCIP_OKAY;
8480 }
8481 
8482 /** analyzes an infeasible LP to find out the bound changes on variables that were responsible for the infeasibility;
8483  * on success, calls standard conflict analysis with the responsible variables as starting conflict set, thus creating
8484  * a conflict constraint out of the resulting conflict set;
8485  * updates statistics for infeasible LP conflict analysis
8486  */
8487 static
8489  SCIP_CONFLICT* conflict, /**< conflict analysis data */
8490  SCIP_CONFLICTSTORE* conflictstore, /**< conflict store */
8491  BMS_BLKMEM* blkmem, /**< block memory of transformed problem */
8492  SCIP_SET* set, /**< global SCIP settings */
8493  SCIP_STAT* stat, /**< problem statistics */
8494  SCIP_PROB* transprob, /**< transformed problem */
8495  SCIP_PROB* origprob, /**< original problem */
8496  SCIP_TREE* tree, /**< branch and bound tree */
8497  SCIP_REOPT* reopt, /**< reoptimization data structure */
8498  SCIP_LP* lp, /**< LP data */
8499  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
8500  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
8501  SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
8502  SCIP_Bool* success /**< pointer to store whether a conflict constraint was created, or NULL */
8503  )
8504 {
8505  SCIP_Bool dualraysuccess = FALSE;
8506  SCIP_Longint olddualproofsuccess;
8507  int iterations;
8508  int nconss;
8509  int nliterals;
8510  int nreconvconss;
8511  int nreconvliterals;
8512 
8513  assert(conflict != NULL);
8514  assert(set != NULL);
8515  assert(lp != NULL);
8516  assert(SCIPprobAllColsInLP(transprob, set, lp)); /* LP conflict analysis is only valid, if all variables are known */
8517 
8518  assert(success == NULL || *success == FALSE);
8519 
8520  /* check, if infeasible LP conflict analysis is enabled */
8521  if( !set->conf_enable || set->conf_useinflp == 'o' )
8522  return SCIP_OKAY;
8523 
8524  /* check, if there are any conflict handlers to use a conflict set */
8525  if( set->nconflicthdlrs == 0 )
8526  return SCIP_OKAY;
8527 
8528  SCIPsetDebugMsg(set, "analyzing conflict on infeasible LP in depth %d (solstat: %d, objchanged: %u)\n",
8530 
8531  /* start timing */
8532  SCIPclockStart(conflict->inflpanalyzetime, set);
8533  conflict->ninflpcalls++;
8534 
8536 
8537  olddualproofsuccess = conflict->ndualproofsinfsuccess;
8538 
8539  /* perform conflict analysis */
8540  SCIP_CALL( conflictAnalyzeLP(conflict, conflictstore, blkmem, set, stat, transprob, origprob, tree, reopt, lp, branchcand, eventqueue, \
8541  cliquetable, SCIPlpDiving(lp), &dualraysuccess, &iterations, &nconss, &nliterals, &nreconvconss, &nreconvliterals, TRUE) );
8542  conflict->ninflpsuccess += ((nconss > 0 || conflict->ndualproofsinfsuccess > olddualproofsuccess) ? 1 : 0);
8543  conflict->ninflpiterations += iterations;
8544  conflict->ninflpconfconss += nconss;
8545  conflict->ninflpconfliterals += nliterals;
8546  conflict->ninflpreconvconss += nreconvconss;
8547  conflict->ninflpreconvliterals += nreconvliterals;
8548  if( success != NULL )
8549  *success = (nconss > 0 || conflict->ndualproofsinfsuccess > olddualproofsuccess);
8550 
8551  /* stop timing */
8552  SCIPclockStop(conflict->inflpanalyzetime, set);
8553 
8554  return SCIP_OKAY;
8555 }
8556 
8557 /** analyzes a bound exceeding LP to find out the bound changes on variables that were responsible for exceeding the
8558  * primal bound;
8559  * on success, calls standard conflict analysis with the responsible variables as starting conflict set, thus creating
8560  * a conflict constraint out of the resulting conflict set;
8561  * updates statistics for bound exceeding LP conflict analysis
8562  */
8563 static
8565  SCIP_CONFLICT* conflict, /**< conflict analysis data */
8566  SCIP_CONFLICTSTORE* conflictstore, /**< conflict store */
8567  BMS_BLKMEM* blkmem, /**< block memory of transformed problem */
8568  SCIP_SET* set, /**< global SCIP settings */
8569  SCIP_STAT* stat, /**< problem statistics */
8570  SCIP_PROB* transprob, /**< transformed problem */
8571  SCIP_PROB* origprob, /**< original problem */
8572  SCIP_TREE* tree, /**< branch and bound tree */
8573  SCIP_REOPT* reopt, /**< reoptimization data structure */
8574  SCIP_LP* lp, /**< LP data */
8575  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
8576  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
8577  SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
8578  SCIP_Bool* success /**< pointer to store whether a conflict constraint was created, or NULL */
8579  )
8580 {
8581  SCIP_Bool dualraysuccess;
8582  SCIP_Longint oldnsuccess;
8583  int iterations;
8584  int nconss;
8585  int nliterals;
8586  int nreconvconss;
8587  int nreconvliterals;
8588 
8589  assert(conflict != NULL);
8590  assert(set != NULL);
8591  assert(lp != NULL);
8592  assert(!SCIPlpDivingObjChanged(lp));
8593  assert(SCIPprobAllColsInLP(transprob, set, lp)); /* LP conflict analysis is only valid, if all variables are known */
8594 
8595  assert(success == NULL || *success == FALSE);
8596 
8597  /* check, if bound exceeding LP conflict analysis is enabled */
8598  if( !set->conf_enable || set->conf_useboundlp == 'o')
8599  return SCIP_OKAY;
8600 
8601  /* check, if there are any conflict handlers to use a conflict set */
8602  if( set->nconflicthdlrs == 0 )
8603  return SCIP_OKAY;
8604 
8605  SCIPsetDebugMsg(set, "analyzing conflict on bound exceeding LP in depth %d (solstat: %d)\n",
8607 
8608  /* start timing */
8609  SCIPclockStart(conflict->boundlpanalyzetime, set);
8610  conflict->nboundlpcalls++;
8611 
8612  /* mark the conflict to depend on the cutoff bound */
8614  conflict->conflictset->usescutoffbound = TRUE;
8615 
8616  oldnsuccess = conflict->ndualproofsbndsuccess + conflict->ndualproofsinfsuccess;
8617 
8618  /* perform conflict analysis */
8619  SCIP_CALL( conflictAnalyzeLP(conflict, conflictstore, blkmem, set, stat, transprob, origprob, tree, reopt, lp, branchcand, eventqueue, \
8620  cliquetable, SCIPlpDiving(lp), &dualraysuccess, &iterations, &nconss, &nliterals, &nreconvconss, &nreconvliterals, TRUE) );
8621  conflict->nboundlpsuccess += ((nconss > 0 || conflict->ndualproofsbndsuccess + conflict->ndualproofsinfsuccess > oldnsuccess) ? 1 : 0);
8622  conflict->nboundlpiterations += iterations;
8623  conflict->nboundlpconfconss += nconss;
8624  conflict->nboundlpconfliterals += nliterals;
8625  conflict->nboundlpreconvconss += nreconvconss;
8626  conflict->nboundlpreconvliterals += nreconvliterals;
8627  if( success != NULL )
8628  *success = (nconss > 0 || conflict->ndualproofsbndsuccess + conflict->ndualproofsinfsuccess > oldnsuccess);
8629 
8630  /* stop timing */
8631  SCIPclockStop(conflict->boundlpanalyzetime, set);
8632 
8633  return SCIP_OKAY;
8634 }
8635 
8636 /** analyzes an infeasible or bound exceeding LP to find out the bound changes on variables that were responsible for the
8637  * infeasibility or for exceeding the primal bound;
8638  * on success, calls standard conflict analysis with the responsible variables as starting conflict set, thus creating
8639  * a conflict constraint out of the resulting conflict set;
8640  * updates statistics for infeasible or bound exceeding LP conflict analysis;
8641  * may only be called if SCIPprobAllColsInLP()
8642  */
8644  SCIP_CONFLICT* conflict, /**< conflict analysis data */
8645  SCIP_CONFLICTSTORE* conflictstore, /**< conflict store */
8646  BMS_BLKMEM* blkmem, /**< block memory of transformed problem */
8647  SCIP_SET* set, /**< global SCIP settings */
8648  SCIP_STAT* stat, /**< problem statistics */
8649  SCIP_PROB* transprob, /**< transformed problem */
8650  SCIP_PROB* origprob, /**< original problem */
8651  SCIP_TREE* tree, /**< branch and bound tree */
8652  SCIP_REOPT* reopt, /**< reoptimization data structure */
8653  SCIP_LP* lp, /**< LP data */
8654  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
8655  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
8656  SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
8657  SCIP_Bool* success /**< pointer to store whether a conflict constraint was created, or NULL */
8658  )
8659 {
8660  SCIP_LPSOLVALS storedsolvals;
8661  SCIP_COLSOLVALS* storedcolsolvals;
8662  SCIP_ROWSOLVALS* storedrowsolvals;
8663  int c;
8664  int r;
8665 
8666  if( success != NULL )
8667  *success = FALSE;
8668 
8669  /* check if the conflict analysis is applicable */
8670  if( !set->conf_enable || (set->conf_useinflp == 'o' && set->conf_useboundlp == 'o') )
8671  return SCIP_OKAY;
8672 
8673  /* in rare cases, it might happen that the solution stati of the LP and the LPI are out of sync; in particular this
8674  * happens when a new incumbent which cuts off the current node is found during the LP solving loop; in this case the
8675  * LP has status objlimit, but if diving has been used, the LPI only has the basis information, but is not solved
8676  *
8677  * @todo: alternatively, solve the LPI
8678  */
8679  if( !SCIPlpiWasSolved(SCIPlpGetLPI(lp)) )
8680  return SCIP_OKAY;
8681 
8682  /* LP conflict analysis is only valid, if all variables are known */
8683  assert( SCIPprobAllColsInLP(transprob, set, lp) );
8685  || (SCIPlpGetSolstat(lp) == SCIP_LPSOLSTAT_OPTIMAL && set->lp_disablecutoff == 1) );
8686 
8687  /* save status */
8688  storedsolvals.lpsolstat = lp->lpsolstat;
8689  storedsolvals.lpobjval = lp->lpobjval;
8690  storedsolvals.primalfeasible = lp->primalfeasible;
8691  storedsolvals.primalchecked = lp->primalchecked;
8692  storedsolvals.dualfeasible = lp->dualfeasible;
8693  storedsolvals.dualchecked = lp->dualchecked;
8694  storedsolvals.solisbasic = lp->solisbasic;
8695  storedsolvals.lpissolved = lp->solved;
8696 
8697  /* store solution values */
8698  SCIP_CALL( SCIPsetAllocBufferArray(set, &storedcolsolvals, lp->ncols) );
8699  SCIP_CALL( SCIPsetAllocBufferArray(set, &storedrowsolvals, lp->nrows) );
8700  for (c = 0; c < lp->ncols; ++c)
8701  {
8702  SCIP_COL* col;
8703 
8704  col = lp->cols[c];
8705  assert( col != NULL );
8706 
8707  storedcolsolvals[c].primsol = col->primsol;
8708  storedcolsolvals[c].redcost = col->redcost;
8709  storedcolsolvals[c].basisstatus = col->basisstatus; /*lint !e641 !e732*/
8710  }
8711  for (r = 0; r < lp->nrows; ++r)
8712  {
8713  SCIP_ROW* row;
8714 
8715  row = lp->rows[r];
8716  assert( row != NULL );
8717 
8718  if ( lp->lpsolstat == SCIP_LPSOLSTAT_INFEASIBLE )
8719  storedrowsolvals[r].dualsol = row->dualfarkas;
8720  else
8721  {
8722  assert( lp->lpsolstat == SCIP_LPSOLSTAT_OBJLIMIT ||
8723  (SCIPlpGetSolstat(lp) == SCIP_LPSOLSTAT_OPTIMAL && set->lp_disablecutoff == 1) );
8724  storedrowsolvals[r].dualsol = row->dualsol;
8725  }
8726  storedrowsolvals[r].activity = row->activity;
8727  storedrowsolvals[r].basisstatus = row->basisstatus; /*lint !e641 !e732*/
8728  }
8729 
8730  /* check, if the LP was infeasible or bound exceeding */
8732  {
8733  SCIP_CALL( conflictAnalyzeInfeasibleLP(conflict, conflictstore, blkmem, set, stat, transprob, origprob, tree, \
8734  reopt, lp, branchcand, eventqueue, cliquetable, success) );
8735  }
8736  else
8737  {
8738  SCIP_CALL( conflictAnalyzeBoundexceedingLP(conflict, conflictstore, blkmem, set, stat, transprob, origprob, tree, \
8739  reopt, lp, branchcand, eventqueue, cliquetable, success) );
8740  }
8741 
8742  /* possibly restore solution values */
8744  {
8745  /* restore status */
8746  lp->lpsolstat = storedsolvals.lpsolstat;
8747  lp->lpobjval = storedsolvals.lpobjval;
8748  lp->primalfeasible = storedsolvals.primalfeasible;
8749  lp->primalchecked = storedsolvals.primalchecked;
8750  lp->dualfeasible = storedsolvals.dualfeasible;
8751  lp->dualchecked = storedsolvals.dualchecked;
8752  lp->solisbasic = storedsolvals.solisbasic;
8753  lp->solved = storedsolvals.lpissolved;
8754 
8755  for (c = 0; c < lp->ncols; ++c)
8756  {
8757  SCIP_COL* col;
8758 
8759  col = lp->cols[c];
8760  assert( col != NULL );
8761  col->primsol = storedcolsolvals[c].primsol;
8762  col->redcost = storedcolsolvals[c].redcost;
8763  col->basisstatus = storedcolsolvals[c].basisstatus; /*lint !e641 !e732*/
8764  }
8765  for (r = 0; r < lp->nrows; ++r)
8766  {
8767  SCIP_ROW* row;
8768 
8769  row = lp->rows[r];
8770  assert( row != NULL );
8771 
8772  if ( lp->lpsolstat == SCIP_LPSOLSTAT_INFEASIBLE )
8773  row->dualfarkas = storedrowsolvals[r].dualsol;
8774  else
8775  {
8776  assert( lp->lpsolstat == SCIP_LPSOLSTAT_OBJLIMIT );
8777  row->dualsol = storedrowsolvals[r].dualsol;
8778  }
8779  row->activity = storedrowsolvals[r].activity;
8780  row->basisstatus = storedrowsolvals[r].basisstatus; /*lint !e641 !e732*/
8781  }
8782  }
8783  SCIPsetFreeBufferArray(set, &storedrowsolvals);
8784  SCIPsetFreeBufferArray(set, &storedcolsolvals);
8785 
8786  return SCIP_OKAY;
8787 }
8788 
8789 /** gets time in seconds used for analyzing infeasible LP conflicts */
8791  SCIP_CONFLICT* conflict /**< conflict analysis data */
8792  )
8793 {
8794  assert(conflict != NULL);
8795 
8796  return SCIPclockGetTime(conflict->inflpanalyzetime);
8797 }
8798 
8799 /** gets number of calls to infeasible LP conflict analysis */
8801  SCIP_CONFLICT* conflict /**< conflict analysis data */
8802  )
8803 {
8804  assert(conflict != NULL);
8805 
8806  return conflict->ninflpcalls;
8807 }
8808 
8809 /** gets number of calls to infeasible LP conflict analysis that yield at least one conflict constraint */
8811  SCIP_CONFLICT* conflict /**< conflict analysis data */
8812  )
8813 {
8814  assert(conflict != NULL);
8815 
8816  return conflict->ninflpsuccess;
8817 }
8818 
8819 /** gets number of conflict constraints detected in infeasible LP conflict analysis */
8821  SCIP_CONFLICT* conflict /**< conflict analysis data */
8822  )
8823 {
8824  assert(conflict != NULL);
8825 
8826  return conflict->ninflpconfconss;
8827 }
8828 
8829 /** gets total number of literals in conflict constraints created in infeasible LP conflict analysis */
8831  SCIP_CONFLICT* conflict /**< conflict analysis data */
8832  )
8833 {
8834  assert(conflict != NULL);
8835 
8836  return conflict->ninflpconfliterals;
8837 }
8838 
8839 /** gets number of reconvergence constraints detected in infeasible LP conflict analysis */
8841  SCIP_CONFLICT* conflict /**< conflict analysis data */
8842  )
8843 {
8844  assert(conflict != NULL);
8845 
8846  return conflict->ninflpreconvconss;
8847 }
8848 
8849 /** gets total number of literals in reconvergence constraints created in infeasible LP conflict analysis */
8851  SCIP_CONFLICT* conflict /**< conflict analysis data */
8852  )
8853 {
8854  assert(conflict != NULL);
8855 
8856  return conflict->ninflpreconvliterals;
8857 }
8858 
8859 /** gets number of LP iterations in infeasible LP conflict analysis */
8861  SCIP_CONFLICT* conflict /**< conflict analysis data */
8862  )
8863 {
8864  assert(conflict != NULL);
8865 
8866  return conflict->ninflpiterations;
8867 }
8868 
8869 /** gets time in seconds used for analyzing bound exceeding LP conflicts */
8871  SCIP_CONFLICT* conflict /**< conflict analysis data */
8872  )
8873 {
8874  assert(conflict != NULL);
8875 
8876  return SCIPclockGetTime(conflict->boundlpanalyzetime);
8877 }
8878 
8879 /** gets number of calls to bound exceeding LP conflict analysis */
8881  SCIP_CONFLICT* conflict /**< conflict analysis data */
8882  )
8883 {
8884  assert(conflict != NULL);
8885 
8886  return conflict->nboundlpcalls;
8887 }
8888 
8889 /** gets number of calls to bound exceeding LP conflict analysis that yield at least one conflict constraint */
8891  SCIP_CONFLICT* conflict /**< conflict analysis data */
8892  )
8893 {
8894  assert(conflict != NULL);
8895 
8896  return conflict->nboundlpsuccess;
8897 }
8898 
8899 /** gets number of conflict constraints detected in bound exceeding LP conflict analysis */
8901  SCIP_CONFLICT* conflict /**< conflict analysis data */
8902  )
8903 {
8904  assert(conflict != NULL);
8905 
8906  return conflict->nboundlpconfconss;
8907 }
8908 
8909 /** gets total number of literals in conflict constraints created in bound exceeding LP conflict analysis */
8911  SCIP_CONFLICT* conflict /**< conflict analysis data */
8912  )
8913 {
8914  assert(conflict != NULL);
8915 
8916  return conflict->nboundlpconfliterals;
8917 }
8918 
8919 /** gets number of reconvergence constraints detected in bound exceeding LP conflict analysis */
8921  SCIP_CONFLICT* conflict /**< conflict analysis data */
8922  )
8923 {
8924  assert(conflict != NULL);
8925 
8926  return conflict->nboundlpreconvconss;
8927 }
8928 
8929 /** gets total number of literals in reconvergence constraints created in bound exceeding LP conflict analysis */
8931  SCIP_CONFLICT* conflict /**< conflict analysis data */
8932  )
8933 {
8934  assert(conflict != NULL);
8935 
8936  return conflict->nboundlpreconvliterals;
8937 }
8938 
8939 /** gets number of LP iterations in bound exceeding LP conflict analysis */
8941  SCIP_CONFLICT* conflict /**< conflict analysis data */
8942  )
8943 {
8944  assert(conflict != NULL);
8945 
8946  return conflict->nboundlpiterations;
8947 }
8948 
8949 
8950 
8951 
8952 /*
8953  * infeasible strong branching conflict analysis
8954  */
8955 
8956 /** analyses infeasible strong branching sub problems for conflicts */
8958  SCIP_CONFLICT* conflict, /**< conflict analysis data */
8959  SCIP_CONFLICTSTORE* conflictstore, /**< conflict store */
8960  BMS_BLKMEM* blkmem, /**< block memory buffers */
8961  SCIP_SET* set, /**< global SCIP settings */
8962  SCIP_STAT* stat, /**< dynamic problem statistics */
8963  SCIP_PROB* transprob, /**< transformed problem */
8964  SCIP_PROB* origprob, /**< original problem */
8965  SCIP_TREE* tree, /**< branch and bound tree */
8966  SCIP_REOPT* reopt, /**< reoptimization data structure */
8967  SCIP_LP* lp, /**< LP data */
8968  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
8969  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
8970  SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
8971  SCIP_COL* col, /**< LP column with at least one infeasible strong branching subproblem */
8972  SCIP_Bool* downconflict, /**< pointer to store whether a conflict constraint was created for an
8973  * infeasible downwards branch, or NULL */
8974  SCIP_Bool* upconflict /**< pointer to store whether a conflict constraint was created for an
8975  * infeasible upwards branch, or NULL */
8976  )
8977 {
8978  int* cstat;
8979  int* rstat;
8980  SCIP_RETCODE retcode;
8981  SCIP_Bool resolve;
8982  SCIP_Real oldlb;
8983  SCIP_Real oldub;
8984  SCIP_Real newlb;
8985  SCIP_Real newub;
8986  SCIP_Bool dualraysuccess;
8987  int iter;
8988  int nconss;
8989  int nliterals;
8990  int nreconvconss;
8991  int nreconvliterals;
8992 
8993  assert(stat != NULL);
8994  assert(lp != NULL);
8995  assert(lp->flushed);
8996  assert(lp->solved);
8997  assert(SCIPprobAllColsInLP(transprob, set, lp)); /* LP conflict analysis is only valid, if all variables are known */
8998  assert(col != NULL);
8999  assert((col->sbdownvalid && SCIPsetIsGE(set, col->sbdown, lp->cutoffbound)
9000  && SCIPsetFeasCeil(set, col->primsol-1.0) >= col->lb - 0.5)
9001  || (col->sbupvalid && SCIPsetIsGE(set, col->sbup, lp->cutoffbound)
9002  && SCIPsetFeasFloor(set, col->primsol+1.0) <= col->ub + 0.5));
9003  assert(SCIPtreeGetCurrentDepth(tree) > 0);
9004 
9005  if( downconflict != NULL )
9006  *downconflict = FALSE;
9007  if( upconflict != NULL )
9008  *upconflict = FALSE;
9009 
9010  /* check, if infeasible LP conflict analysis is enabled */
9011  if( !set->conf_enable || !set->conf_usesb )
9012  return SCIP_OKAY;
9013 
9014  /* check, if there are any conflict handlers to use a conflict set */
9015  if( set->nconflicthdlrs == 0 )
9016  return SCIP_OKAY;
9017 
9018  /* inform the LPI that strong branch is (temporarily) finished */
9020 
9021  /* start timing */
9022  SCIPclockStart(conflict->sbanalyzetime, set);
9023 
9024  /* get temporary memory for storing current LP basis */
9025  SCIP_CALL( SCIPsetAllocBufferArray(set, &cstat, lp->nlpicols) );
9026  SCIP_CALL( SCIPsetAllocBufferArray(set, &rstat, lp->nlpirows) );
9027 
9028  /* get current LP basis */
9029  SCIP_CALL( SCIPlpiGetBase(lp->lpi, cstat, rstat) );
9030 
9031  /* remember old bounds */
9032  oldlb = col->lb;
9033  oldub = col->ub;
9034 
9035  resolve = FALSE;
9036 
9037  /* is down branch infeasible? */
9038  if( col->sbdownvalid && SCIPsetIsGE(set, col->sbdown, lp->cutoffbound) )
9039  {
9040  newub = SCIPsetFeasCeil(set, col->primsol-1.0);
9041  if( newub >= col->lb - 0.5 )
9042  {
9043  SCIPsetDebugMsg(set, "analyzing conflict on infeasible downwards strongbranch for variable <%s>[%g,%g] in depth %d\n",
9045  SCIPtreeGetCurrentDepth(tree));
9046 
9048  conflict->nsbcalls++;
9049 
9050  /* change the upper bound */
9051  col->ub = newub;
9052  SCIP_CALL( SCIPlpiChgBounds(lp->lpi, 1, &col->lpipos, &col->lb, &col->ub) );
9053 
9054  /* start LP timer */
9055  SCIPclockStart(stat->conflictlptime, set);
9056 
9057  /* resolve the LP */
9058  retcode = SCIPlpiSolveDual(lp->lpi);
9059 
9060  /* stop LP timer */
9061  SCIPclockStop(stat->conflictlptime, set);
9062 
9063  /* check return code of LP solving call */
9064  if( retcode != SCIP_LPERROR )
9065  {
9066  SCIP_CALL( retcode );
9067 
9068  /* count number of LP iterations */
9069  SCIP_CALL( SCIPlpiGetIterations(lp->lpi, &iter) );
9070  stat->nconflictlps++;
9071  stat->nconflictlpiterations += iter;
9072  conflict->nsbiterations += iter;
9073  SCIPsetDebugMsg(set, " -> resolved downwards strong branching LP in %d iterations\n", iter);
9074 
9075  /* perform conflict analysis on infeasible LP; last parameter guarantees status 'solved' on return */
9076  SCIP_CALL( conflictAnalyzeLP(conflict, conflictstore, blkmem, set, stat, transprob, origprob, tree, reopt, \
9077  lp, branchcand, eventqueue, cliquetable, TRUE, &dualraysuccess, &iter, &nconss, &nliterals, \
9078  &nreconvconss, &nreconvliterals, FALSE) );
9079  conflict->nsbsuccess += ((nconss > 0 || dualraysuccess) ? 1 : 0);
9080  conflict->nsbiterations += iter;
9081  conflict->nsbconfconss += nconss;
9082  conflict->nsbconfliterals += nliterals;
9083  conflict->nsbreconvconss += nreconvconss;
9084  conflict->nsbreconvliterals += nreconvliterals;
9085  if( downconflict != NULL )
9086  *downconflict = (nconss > 0);
9087  }
9088 
9089  /* reset the upper bound */
9090  col->ub = oldub;
9091  SCIP_CALL( SCIPlpiChgBounds(lp->lpi, 1, &col->lpipos, &col->lb, &col->ub) );
9092 
9093  /* reset LP basis */
9094  SCIP_CALL( SCIPlpiSetBase(lp->lpi, cstat, rstat) );
9095 
9096  /* mark the LP to be resolved at the end */
9097  resolve = TRUE;
9098  }
9099  }
9100 
9101  /* is up branch infeasible? */
9102  if( col->sbupvalid && SCIPsetIsGE(set, col->sbup, lp->cutoffbound) )
9103  {
9104  newlb = SCIPsetFeasFloor(set, col->primsol+1.0);
9105  if( newlb <= col->ub + 0.5 )
9106  {
9107  SCIPsetDebugMsg(set, "analyzing conflict on infeasible upwards strongbranch for variable <%s>[%g,%g] in depth %d\n",
9109  SCIPtreeGetCurrentDepth(tree));
9110 
9112  conflict->nsbcalls++;
9113 
9114  /* change the lower bound */
9115  col->lb = newlb;
9116  SCIP_CALL( SCIPlpiChgBounds(lp->lpi, 1, &col->lpipos, &col->lb, &col->ub) );
9117 
9118  /* start LP timer */
9119  SCIPclockStart(stat->conflictlptime, set);
9120 
9121  /* resolve the LP */
9122  retcode = SCIPlpiSolveDual(lp->lpi);
9123 
9124  /* stop LP timer */
9125  SCIPclockStop(stat->conflictlptime, set);
9126 
9127  /* check return code of LP solving call */
9128  if( retcode != SCIP_LPERROR )
9129  {
9130  SCIP_CALL( retcode );
9131 
9132  /* count number of LP iterations */
9133  SCIP_CALL( SCIPlpiGetIterations(lp->lpi, &iter) );
9134  stat->nconflictlps++;
9135  stat->nconflictlpiterations += iter;
9136  conflict->nsbiterations += iter;
9137  SCIPsetDebugMsg(set, " -> resolved upwards strong branching LP in %d iterations\n", iter);
9138 
9139  /* perform conflict analysis on infeasible LP; last parameter guarantees status 'solved' on return */
9140  SCIP_CALL( conflictAnalyzeLP(conflict, conflictstore, blkmem, set, stat, transprob, origprob, tree, reopt, \
9141  lp, branchcand, eventqueue, cliquetable, TRUE, &dualraysuccess, &iter, &nconss, &nliterals, \
9142  &nreconvconss, &nreconvliterals, FALSE) );
9143  conflict->nsbsuccess += ((nconss > 0 || dualraysuccess) ? 1 : 0);
9144  conflict->nsbiterations += iter;
9145  conflict->nsbconfconss += nconss;
9146  conflict->nsbconfliterals += nliterals;
9147  conflict->nsbreconvconss += nreconvconss;
9148  conflict->nsbreconvliterals += nreconvliterals;
9149  if( upconflict != NULL )
9150  *upconflict = (nconss > 0);
9151  }
9152 
9153  /* reset the lower bound */
9154  col->lb = oldlb;
9155  SCIP_CALL( SCIPlpiChgBounds(lp->lpi, 1, &col->lpipos, &col->lb, &col->ub) );
9156 
9157  /* reset LP basis */
9158  SCIP_CALL( SCIPlpiSetBase(lp->lpi, cstat, rstat) );
9159 
9160  /* mark the LP to be resolved at the end */
9161  resolve = TRUE;
9162  }
9163  }
9164 
9165  /* free temporary memory for storing current LP basis */
9166  SCIPsetFreeBufferArray(set, &rstat);
9167  SCIPsetFreeBufferArray(set, &cstat);
9168 
9169  assert(lp->flushed);
9170 
9171  /* resolve LP if something has changed in order to synchronize LPI and LP */
9172  if ( resolve )
9173  {
9174  /* start LP timer */
9175  SCIPclockStart(stat->conflictlptime, set);
9176 
9177  /* resolve the LP */
9178  SCIP_CALL( SCIPlpiSolveDual(lp->lpi) );
9179 
9180  /* stop LP timer */
9181  SCIPclockStop(stat->conflictlptime, set);
9182  }
9183 
9184  /* stop timing */
9185  SCIPclockStop(conflict->sbanalyzetime, set);
9186 
9187  /* inform the LPI that strong branch starts (again) */
9189 
9190  return SCIP_OKAY;
9191 }
9192 
9193 /** gets time in seconds used for analyzing infeasible strong branching conflicts */
9195  SCIP_CONFLICT* conflict /**< conflict analysis data */
9196  )
9197 {
9198  assert(conflict != NULL);
9199 
9200  return SCIPclockGetTime(conflict->sbanalyzetime);
9201 }
9202 
9203 /** gets number of successful calls to dual proof analysis derived from infeasible LPs */
9205  SCIP_CONFLICT* conflict /**< conflict analysis data */
9206  )
9207 {
9208  assert(conflict != NULL);
9209 
9210  return conflict->ndualproofsinfsuccess;
9211 }
9212 
9213 /** gets number of globally valid dual proof constraints derived from infeasible LPs */
9215  SCIP_CONFLICT* conflict /**< conflict analysis data */
9216  )
9217 {
9218  assert(conflict != NULL);
9219 
9220  return conflict->ndualproofsinfglobal;
9221 }
9222 
9223 /** gets number of locally valid dual proof constraints derived from infeasible LPs */
9225  SCIP_CONFLICT* conflict /**< conflict analysis data */
9226  )
9227 {
9228  assert(conflict != NULL);
9229 
9230  return conflict->ndualproofsinflocal;
9231 }
9232 
9233 /** gets average length of dual proof constraints derived from infeasible LPs */
9235  SCIP_CONFLICT* conflict /**< conflict analysis data */
9236  )
9237 {
9238  assert(conflict != NULL);
9239 
9240  return conflict->dualproofsinfnnonzeros;
9241 }
9242 
9243 /** gets number of successfully analyzed dual proofs derived from bound exceeding LPs */
9245  SCIP_CONFLICT* conflict /**< conflict analysis data */
9246  )
9247 {
9248  assert(conflict != NULL);
9249 
9250  return conflict->ndualproofsbndsuccess;
9251 }
9252 
9253 /** gets number of globally applied dual proofs derived from bound exceeding LPs */
9255  SCIP_CONFLICT* conflict /**< conflict analysis data */
9256  )
9257 {
9258  assert(conflict != NULL);
9259 
9260  return conflict->ndualproofsbndglobal;
9261 }
9262 
9263 /** gets number of locally applied dual proofs derived from bound exceeding LPs */
9265  SCIP_CONFLICT* conflict /**< conflict analysis data */
9266  )
9267 {
9268  assert(conflict != NULL);
9269 
9270  return conflict->ndualproofsbndlocal;
9271 }
9272 
9273 /** gets average length of dual proofs derived from bound exceeding LPs */
9275  SCIP_CONFLICT* conflict /**< conflict analysis data */
9276  )
9277 {
9278  assert(conflict != NULL);
9279 
9280  return conflict->dualproofsbndnnonzeros;
9281 }
9282 
9283 /** gets number of calls to infeasible strong branching conflict analysis */
9285  SCIP_CONFLICT* conflict /**< conflict analysis data */
9286  )
9287 {
9288  assert(conflict != NULL);
9289 
9290  return conflict->nsbcalls;
9291 }
9292 
9293 /** gets number of calls to infeasible strong branching conflict analysis that yield at least one conflict constraint */
9295  SCIP_CONFLICT* conflict /**< conflict analysis data */
9296  )
9297 {
9298  assert(conflict != NULL);
9299 
9300  return conflict->nsbsuccess;
9301 }
9302 
9303 /** gets number of conflict constraints detected in infeasible strong branching conflict analysis */
9305  SCIP_CONFLICT* conflict /**< conflict analysis data */
9306  )
9307 {
9308  assert(conflict != NULL);
9309 
9310  return conflict->nsbconfconss;
9311 }
9312 
9313 /** gets total number of literals in conflict constraints created in infeasible strong branching conflict analysis */
9315  SCIP_CONFLICT* conflict /**< conflict analysis data */
9316  )
9317 {
9318  assert(conflict != NULL);
9319 
9320  return conflict->nsbconfliterals;
9321 }
9322 
9323 /** gets number of reconvergence constraints detected in infeasible strong branching conflict analysis */
9325  SCIP_CONFLICT* conflict /**< conflict analysis data */
9326  )
9327 {
9328  assert(conflict != NULL);
9329 
9330  return conflict->nsbreconvconss;
9331 }
9332 
9333 /** gets total number of literals in reconvergence constraints created in infeasible strong branching conflict analysis */
9335  SCIP_CONFLICT* conflict /**< conflict analysis data */
9336  )
9337 {
9338  assert(conflict != NULL);
9339 
9340  return conflict->nsbreconvliterals;
9341 }
9342 
9343 /** gets number of LP iterations in infeasible strong branching conflict analysis */
9345  SCIP_CONFLICT* conflict /**< conflict analysis data */
9346  )
9347 {
9348  assert(conflict != NULL);
9349 
9350  return conflict->nsbiterations;
9351 }
9352 
9353 
9354 
9355 
9356 /*
9357  * pseudo solution conflict analysis
9358  */
9359 
9360 /** analyzes a pseudo solution with objective value exceeding the current cutoff to find out the bound changes on
9361  * variables that were responsible for the objective value degradation;
9362  * on success, calls standard conflict analysis with the responsible variables as starting conflict set, thus creating
9363  * a conflict constraint out of the resulting conflict set;
9364  * updates statistics for pseudo solution conflict analysis
9365  */
9367  SCIP_CONFLICT* conflict, /**< conflict analysis data */
9368  BMS_BLKMEM* blkmem, /**< block memory of transformed problem */
9369  SCIP_SET* set, /**< global SCIP settings */
9370  SCIP_STAT* stat, /**< problem statistics */
9371  SCIP_PROB* transprob, /**< transformed problem */
9372  SCIP_PROB* origprob, /**< original problem */
9373  SCIP_TREE* tree, /**< branch and bound tree */
9374  SCIP_REOPT* reopt, /**< reoptimization data structure */
9375  SCIP_LP* lp, /**< LP data */
9376  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
9377  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
9378  SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
9379  SCIP_Bool* success /**< pointer to store whether a conflict constraint was created, or NULL */
9380  )
9381 {
9382  SCIP_VAR** vars;
9383  SCIP_VAR* var;
9384  SCIP_Real* curvarlbs;
9385  SCIP_Real* curvarubs;
9386  int* lbchginfoposs;
9387  int* ubchginfoposs;
9388  SCIP_Real* pseudocoefs;
9389  SCIP_Real pseudolhs;
9390  SCIP_Real pseudoact;
9391  int nvars;
9392  int v;
9393 
9394  assert(conflict != NULL);
9395  assert(conflict->nconflictsets == 0);
9396  assert(set != NULL);
9397  assert(stat != NULL);
9398  assert(transprob != NULL);
9399  assert(lp != NULL);
9400  assert(!SCIPsetIsInfinity(set, -SCIPlpGetPseudoObjval(lp, set, transprob)));
9401  assert(!SCIPsetIsInfinity(set, lp->cutoffbound));
9402 
9403  if( success != NULL )
9404  *success = FALSE;
9405 
9406  /* check, if pseudo solution conflict analysis is enabled */
9407  if( !set->conf_enable || !set->conf_usepseudo )
9408  return SCIP_OKAY;
9409 
9410  /* check, if there are any conflict handlers to use a conflict set */
9411  if( set->nconflicthdlrs == 0 )
9412  return SCIP_OKAY;
9413 
9414  SCIPsetDebugMsg(set, "analyzing pseudo solution (obj: %g) that exceeds objective limit (%g)\n",
9415  SCIPlpGetPseudoObjval(lp, set, transprob), lp->cutoffbound);
9416 
9418  conflict->conflictset->usescutoffbound = TRUE;
9419 
9420  /* start timing */
9421  SCIPclockStart(conflict->pseudoanalyzetime, set);
9422  conflict->npseudocalls++;
9423 
9424  vars = transprob->vars;
9425  nvars = transprob->nvars;
9426  assert(nvars == 0 || vars != NULL);
9427 
9428  /* The current primal bound c* gives an upper bound for the current pseudo objective value:
9429  * min{c^T x | lb <= x <= ub} <= c*.
9430  * We have to transform this row into a >= inequality in order to use methods above:
9431  * -c* <= max{-c^T x | lb <= x <= ub}.
9432  * In the local subproblem, this row is violated. We want to undo bound changes while still keeping the
9433  * row violated.
9434  */
9435 
9436  /* get temporary memory for remembering variables' current bounds and corresponding bound change information
9437  * positions in variable's bound change information arrays
9438  */
9439  SCIP_CALL( SCIPsetAllocBufferArray(set, &curvarlbs, nvars) );
9440  SCIP_CALL( SCIPsetAllocBufferArray(set, &curvarubs, nvars) );
9441  SCIP_CALL( SCIPsetAllocBufferArray(set, &lbchginfoposs, nvars) );
9442  SCIP_CALL( SCIPsetAllocBufferArray(set, &ubchginfoposs, nvars) );
9443 
9444  /* get temporary memory for infeasibility proof coefficients */
9445  SCIP_CALL( SCIPsetAllocBufferArray(set, &pseudocoefs, nvars) );
9446 
9447  /* use a slightly tighter cutoff bound, because solutions with equal objective value should also be declared
9448  * infeasible
9449  */
9450  pseudolhs = -(lp->cutoffbound - SCIPsetSumepsilon(set));
9451 
9452  /* store the objective values as infeasibility proof coefficients, and recalculate the pseudo activity */
9453  pseudoact = 0.0;
9454  for( v = 0; v < nvars; ++v )
9455  {
9456  var = vars[v];
9457  pseudocoefs[v] = -SCIPvarGetObj(var);
9458  curvarlbs[v] = SCIPvarGetLbLocal(var);
9459  curvarubs[v] = SCIPvarGetUbLocal(var);
9460  lbchginfoposs[v] = var->nlbchginfos-1;
9461  ubchginfoposs[v] = var->nubchginfos-1;
9462 
9463  if( SCIPsetIsZero(set, pseudocoefs[v]) )
9464  {
9465  pseudocoefs[v] = 0.0;
9466  continue;
9467  }
9468 
9469  if( pseudocoefs[v] > 0.0 )
9470  pseudoact += pseudocoefs[v] * curvarubs[v];
9471  else
9472  pseudoact += pseudocoefs[v] * curvarlbs[v];
9473  }
9474  assert(SCIPsetIsFeasEQ(set, pseudoact, -SCIPlpGetPseudoObjval(lp, set, transprob)));
9475  SCIPsetDebugMsg(set, " -> recalculated pseudo infeasibility proof: %g <= %g\n", pseudolhs, pseudoact);
9476 
9477  /* check, if the pseudo row is still violated (after recalculation of pseudo activity) */
9478  if( SCIPsetIsFeasGT(set, pseudolhs, pseudoact) )
9479  {
9480  int nconss;
9481  int nliterals;
9482  int nreconvconss;
9483  int nreconvliterals;
9484 
9485  /* undo bound changes without destroying the infeasibility proof */
9486  SCIP_CALL( undoBdchgsProof(set, transprob, SCIPtreeGetCurrentDepth(tree), pseudocoefs, pseudolhs, &pseudoact,
9487  curvarlbs, curvarubs, lbchginfoposs, ubchginfoposs, NULL, NULL, NULL, lp->lpi) );
9488 
9489  /* analyze conflict on remaining bound changes */
9490  SCIP_CALL( conflictAnalyzeRemainingBdchgs(conflict, blkmem, set, stat, transprob, tree, FALSE, \
9491  lbchginfoposs, ubchginfoposs, &nconss, &nliterals, &nreconvconss, &nreconvliterals) );
9492  conflict->npseudosuccess += (nconss > 0 ? 1 : 0);
9493  conflict->npseudoconfconss += nconss;
9494  conflict->npseudoconfliterals += nliterals;
9495  conflict->npseudoreconvconss += nreconvconss;
9496  conflict->npseudoreconvliterals += nreconvliterals;
9497  if( success != NULL )
9498  *success = (nconss > 0);
9499  }
9500 
9501  /* free temporary memory */
9502  SCIPsetFreeBufferArray(set, &pseudocoefs);
9503  SCIPsetFreeBufferArray(set, &ubchginfoposs);
9504  SCIPsetFreeBufferArray(set, &lbchginfoposs);
9505  SCIPsetFreeBufferArray(set, &curvarubs);
9506  SCIPsetFreeBufferArray(set, &curvarlbs);
9507 
9508  /* flush conflict set storage */
9509  SCIP_CALL( SCIPconflictFlushConss(conflict, blkmem, set, stat, transprob, origprob, tree, reopt, lp, branchcand, eventqueue, cliquetable) );
9510 
9511  /* stop timing */
9512  SCIPclockStop(conflict->pseudoanalyzetime, set);
9513 
9514  return SCIP_OKAY;
9515 }
9516 
9517 /** gets time in seconds used for analyzing pseudo solution conflicts */
9519  SCIP_CONFLICT* conflict /**< conflict analysis data */
9520  )
9521 {
9522  assert(conflict != NULL);
9523 
9524  return SCIPclockGetTime(conflict->pseudoanalyzetime);
9525 }
9526 
9527 /** gets number of calls to pseudo solution conflict analysis */
9529  SCIP_CONFLICT* conflict /**< conflict analysis data */
9530  )
9531 {
9532  assert(conflict != NULL);
9533 
9534  return conflict->npseudocalls;
9535 }
9536 
9537 /** gets number of calls to pseudo solution conflict analysis that yield at least one conflict constraint */
9539  SCIP_CONFLICT* conflict /**< conflict analysis data */
9540  )
9541 {
9542  assert(conflict != NULL);
9543 
9544  return conflict->npseudosuccess;
9545 }
9546 
9547 /** gets number of conflict constraints detected in pseudo solution conflict analysis */
9549  SCIP_CONFLICT* conflict /**< conflict analysis data */
9550  )
9551 {
9552  assert(conflict != NULL);
9553 
9554  return conflict->npseudoconfconss;
9555 }
9556 
9557 /** gets total number of literals in conflict constraints created in pseudo solution conflict analysis */
9559  SCIP_CONFLICT* conflict /**< conflict analysis data */
9560  )
9561 {
9562  assert(conflict != NULL);
9563 
9564  return conflict->npseudoconfliterals;
9565 }
9566 
9567 /** gets number of reconvergence constraints detected in pseudo solution conflict analysis */
9569  SCIP_CONFLICT* conflict /**< conflict analysis data */
9570  )
9571 {
9572  assert(conflict != NULL);
9573 
9574  return conflict->npseudoreconvconss;
9575 }
9576 
9577 /** gets total number of literals in reconvergence constraints created in pseudo solution conflict analysis */
9579  SCIP_CONFLICT* conflict /**< conflict analysis data */
9580  )
9581 {
9582  assert(conflict != NULL);
9583 
9584  return conflict->npseudoreconvliterals;
9585 }
9586 
9587 
9588 /** enables or disables all clocks of \p conflict, depending on the value of the flag */
9590  SCIP_CONFLICT* conflict, /**< the conflict analysis data for which all clocks should be enabled or disabled */
9591  SCIP_Bool enable /**< should the clocks of the conflict analysis data be enabled? */
9592  )
9593 {
9594  assert(conflict != NULL);
9595 
9596  SCIPclockEnableOrDisable(conflict->boundlpanalyzetime, enable);
9597  SCIPclockEnableOrDisable(conflict->dIBclock, enable);
9598  SCIPclockEnableOrDisable(conflict->inflpanalyzetime, enable);
9599  SCIPclockEnableOrDisable(conflict->propanalyzetime, enable);
9600  SCIPclockEnableOrDisable(conflict->pseudoanalyzetime, enable);
9601  SCIPclockEnableOrDisable(conflict->sbanalyzetime, enable);
9602 }
9603 
enum SCIP_Result SCIP_RESULT
Definition: type_result.h:52
void SCIPconflictEnableOrDisableClocks(SCIP_CONFLICT *conflict, SCIP_Bool enable)
Definition: conflict.c:9589
SCIP_Longint SCIPconflictGetNStrongbranchSuccess(SCIP_CONFLICT *conflict)
Definition: conflict.c:9294
SCIP_EXPORT SCIP_RETCODE SCIPlpiSetIntpar(SCIP_LPI *lpi, SCIP_LPPARAM type, int ival)
Definition: lpi_clp.cpp:3678
static SCIP_Bool bdchginfoIsResolvable(SCIP_BDCHGINFO *bdchginfo)
Definition: conflict.c:3819
SCIP_Bool solisbasic
Definition: struct_lp.h:362
#define ALLOWLOCAL
Definition: conflict.c:166
static SCIP_RETCODE conflictInitProofset(SCIP_CONFLICT *conflict, BMS_BLKMEM *blkmem)
Definition: conflict.c:958
enum SCIP_BoundType SCIP_BOUNDTYPE
Definition: type_lp.h:50
static SCIP_RETCODE undoBdchgsDualsol(SCIP_SET *set, SCIP_PROB *prob, SCIP_LP *lp, int currentdepth, SCIP_Real *curvarlbs, SCIP_Real *curvarubs, int *lbchginfoposs, int *ubchginfoposs, SCIP_LPBDCHGS *oldlpbdchgs, SCIP_LPBDCHGS *relaxedlpbdchgs, SCIP_Bool *valid, SCIP_Bool *resolve, SCIP_Real *dualcoefs, SCIP_Real duallhs, SCIP_Real *dualactivity)
Definition: conflict.c:6438
SCIP_CLOCK * propanalyzetime
void * SCIPpqueueRemove(SCIP_PQUEUE *pqueue)
Definition: misc.c:1433
SCIP_Bool lpissolved
Definition: struct_lp.h:116
SCIP_Real SCIPbdchginfoGetRelaxedBound(SCIP_BDCHGINFO *bdchginfo)
Definition: var.c:18383
static SCIP_RETCODE addSideRemoval(SCIP_SET *set, SCIP_ROW *row, SCIP_Real lpiinfinity, int **sidechginds, SCIP_Real **sidechgoldlhss, SCIP_Real **sidechgoldrhss, SCIP_Real **sidechgnewlhss, SCIP_Real **sidechgnewrhss, int *sidechgssize, int *nsidechgs)
Definition: conflict.c:5808
void SCIPconflicthdlrSetInit(SCIP_CONFLICTHDLR *conflicthdlr, SCIP_DECL_CONFLICTINIT((*conflictinit)))
Definition: conflict.c:719
SCIP_Real sbup
Definition: struct_lp.h:145
SCIP_Longint ninflpconfliterals
SCIP_Longint SCIPconflictGetNLocalChgBds(SCIP_CONFLICT *conflict)
Definition: conflict.c:3781
SCIP_RETCODE SCIPcreateConsLinear(SCIP *scip, SCIP_CONS **cons, const char *name, int nvars, SCIP_VAR **vars, SCIP_Real *vals, SCIP_Real lhs, SCIP_Real rhs, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool modifiable, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode)
SCIP_RETCODE SCIPfreeSol(SCIP *scip, SCIP_SOL **sol)
Definition: scip_sol.c:977
void SCIPgmlWriteEdge(FILE *file, unsigned int source, unsigned int target, const char *label, const char *color)
Definition: misc.c:584
SCIP_Bool primalchecked
Definition: struct_lp.h:112
SCIP_Bool SCIProwIsLocal(SCIP_ROW *row)
Definition: lp.c:17250
SCIP_Bool SCIPsetIsInfinity(SCIP_SET *set, SCIP_Real val)
Definition: set.c:5980
SCIP_EXPORT void SCIPsortedvecInsertIntPtrReal(int *intarray, void **ptrarray, SCIP_Real *realarray, int keyval, void *field1val, SCIP_Real field2val, int *len, int *pos)
SCIP_RETCODE SCIPconflictAnalyzeLP(SCIP_CONFLICT *conflict, SCIP_CONFLICTSTORE *conflictstore, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, SCIP_CLIQUETABLE *cliquetable, SCIP_Bool *success)
Definition: conflict.c:8643
static SCIP_RETCODE addLocalRows(SCIP_SET *set, SCIP_PROB *transprob, SCIP_LP *lp, SCIP_AGGRROW *proofrow, SCIP_ROW **rows, SCIP_Real *dualsols, int *localrowinds, int *localrowdepth, int nlocalrows, SCIP_Real *proofact, int *validdepth, SCIP_Real *curvarlbs, SCIP_Real *curvarubs, SCIP_Bool *valid)
Definition: conflict.c:6782
SCIP_EXPORT SCIP_Real SCIPlpiInfinity(SCIP_LPI *lpi)
Definition: lpi_clp.cpp:3893
#define BMSfreeBlockMemoryArrayNull(mem, ptr, num)
Definition: memory.h:459
#define NUMSTOP
Definition: conflict.c:6376
unsigned int repropagate
SCIP_Longint ninflpreconvconss
SCIP_Longint SCIPconflictGetNPropConflictConss(SCIP_CONFLICT *conflict)
Definition: conflict.c:5721
SCIP_Real SCIPaggrRowCalcEfficacyNorm(SCIP *scip, SCIP_AGGRROW *aggrrow)
Definition: cuts.c:2009
void SCIPpqueueFree(SCIP_PQUEUE **pqueue)
Definition: misc.c:1262
#define MINFRAC
Definition: conflict.c:167
static SCIP_RETCODE doConflicthdlrCreate(SCIP_CONFLICTHDLR **conflicthdlr, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, BMS_BLKMEM *blkmem, const char *name, const char *desc, int priority, SCIP_DECL_CONFLICTCOPY((*conflictcopy)), SCIP_DECL_CONFLICTFREE((*conflictfree)), SCIP_DECL_CONFLICTINIT((*conflictinit)), SCIP_DECL_CONFLICTEXIT((*conflictexit)), SCIP_DECL_CONFLICTINITSOL((*conflictinitsol)), SCIP_DECL_CONFLICTEXITSOL((*conflictexitsol)), SCIP_DECL_CONFLICTEXEC((*conflictexec)), SCIP_CONFLICTHDLRDATA *conflicthdlrdata)
Definition: conflict.c:400
SCIP_Bool SCIPsetIsLE(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6038
static int conflictCalcMaxsize(SCIP_SET *set, SCIP_PROB *prob)
Definition: conflict.c:2074
internal methods for storing primal CIP solutions
void SCIPhistoryIncVSIDS(SCIP_HISTORY *history, SCIP_BRANCHDIR dir, SCIP_Real weight)
Definition: history.c:494
SCIP_RETCODE SCIPconflictAddBound(SCIP_CONFLICT *conflict, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_VAR *var, SCIP_BOUNDTYPE boundtype, SCIP_BDCHGIDX *bdchgidx)
Definition: conflict.c:4371
SCIP_RETCODE SCIPvarIncVSIDS(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_BRANCHDIR dir, SCIP_Real value, SCIP_Real weight)
Definition: var.c:14811
SCIP_Real SCIPgetLhsLinear(SCIP *scip, SCIP_CONS *cons)
SCIP_Bool SCIPlpDiving(SCIP_LP *lp)
Definition: lp.c:17669
int nubchginfos
Definition: struct_var.h:263
#define BMSfreeMemoryArrayNull(ptr)
Definition: memory.h:140
SCIP_Longint ndualproofsinfsuccess
SCIP_Real SCIPgetVarLbAtIndex(SCIP *scip, SCIP_VAR *var, SCIP_BDCHGIDX *bdchgidx, SCIP_Bool after)
Definition: scip_var.c:1996
public methods for branch and bound tree
internal methods for branch and bound tree
SCIP_BDCHGIDX bdchgidx
Definition: struct_var.h:112
static SCIP_BDCHGINFO * conflictRemoveCand(SCIP_CONFLICT *conflict)
Definition: conflict.c:4689
void * SCIPpqueueFirst(SCIP_PQUEUE *pqueue)
Definition: misc.c:1453
SCIP_Real conflictlb
Definition: struct_var.h:213
static SCIP_Bool isBoundchgUseless(SCIP_SET *set, SCIP_BDCHGINFO *bdchginfo)
Definition: conflict.c:4214
SCIP_Longint SCIPconflictGetNPropSuccess(SCIP_CONFLICT *conflict)
Definition: conflict.c:5711
SCIP_EXPORT SCIP_Bool SCIPvarIsInLP(SCIP_VAR *var)
Definition: var.c:17387
void SCIPconflicthdlrSetExit(SCIP_CONFLICTHDLR *conflicthdlr, SCIP_DECL_CONFLICTEXIT((*conflictexit)))
Definition: conflict.c:730
SCIP_PQUEUE * bdchgqueue
SCIP_EXPORT SCIP_RETCODE SCIPlpiGetDualfarkas(SCIP_LPI *lpi, SCIP_Real *dualfarkas)
Definition: lpi_clp.cpp:2843
SCIP_Bool primalfeasible
Definition: struct_lp.h:358
SCIP_Longint dualproofsinfnnonzeros
SCIP_EXPORT int SCIPvarGetNLocksUpType(SCIP_VAR *var, SCIP_LOCKTYPE locktype)
Definition: var.c:3250
public methods for memory management
SCIP_RETCODE SCIPshrinkDisjunctiveVarSet(SCIP *scip, SCIP_VAR **vars, SCIP_Real *bounds, SCIP_Bool *boundtypes, SCIP_Bool *redundants, int nvars, int *nredvars, int *nglobalred, SCIP_Bool *setredundant, SCIP_Bool *glbinfeas, SCIP_Bool fullshortening)
Definition: presolve.c:986
SCIP_Longint nsbcalls
static SCIP_Real calcBdchgScore(SCIP_Real prooflhs, SCIP_Real proofact, SCIP_Real proofactdelta, SCIP_Real proofcoef, int depth, int currentdepth, SCIP_VAR *var, SCIP_SET *set)
Definition: conflict.c:1402
#define SCIPsetAllocBuffer(set, ptr)
Definition: set.h:1683
int nlpicols
Definition: struct_lp.h:307
SCIP_Bool SCIPsetIsFeasEQ(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6378
void SCIPconflicthdlrSetInitsol(SCIP_CONFLICTHDLR *conflicthdlr, SCIP_DECL_CONFLICTINITSOL((*conflictinitsol)))
Definition: conflict.c:741
SCIP_Longint SCIPconflictGetNBoundexceedingLPConflictConss(SCIP_CONFLICT *conflict)
Definition: conflict.c:8900
SCIP_PARAMDATA * SCIPparamGetData(SCIP_PARAM *param)
Definition: paramset.c:670
SCIP_Longint SCIPconflictGetNAppliedGlobalConss(SCIP_CONFLICT *conflict)
Definition: conflict.c:3761
SCIP_EXPORT void SCIPsortIntPtrReal(int *intarray, void **ptrarray, SCIP_Real *realarray, int len)
SCIP_Longint SCIPconflictGetNBoundexceedingLPIterations(SCIP_CONFLICT *conflict)
Definition: conflict.c:8940
SCIP_CLOCK * conflictlptime
Definition: struct_stat.h:159
#define SCIP_MAXSTRLEN
Definition: def.h:273
SCIP_EXPORT SCIP_RETCODE SCIPlpiGetBase(SCIP_LPI *lpi, int *cstat, int *rstat)
Definition: lpi_clp.cpp:2953
public methods for conflict handler plugins and conflict analysis
static void lpbdchgsReset(SCIP_LPBDCHGS *lpbdchgs, int ncols)
Definition: conflict.c:877
static SCIP_RETCODE conflictCreateTmpBdchginfo(SCIP_CONFLICT *conflict, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_VAR *var, SCIP_BOUNDTYPE boundtype, SCIP_Real oldbound, SCIP_Real newbound, SCIP_BDCHGINFO **bdchginfo)
Definition: conflict.c:1228
SCIP_Longint SCIPconflictGetNPseudoReconvergenceLiterals(SCIP_CONFLICT *conflict)
Definition: conflict.c:9578
internal methods for clocks and timing issues
SCIP_Longint SCIPconflictGetNGlobalChgBds(SCIP_CONFLICT *conflict)
Definition: conflict.c:3751
int lpdepth
Definition: struct_lp.h:232
SCIP_BOUNDCHG * boundchgs
Definition: struct_var.h:125
SCIP_Bool SCIPsetIsPositive(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6103
SCIP_Longint nappliedlocliterals
static long bound
SCIP_CLOCK * inflpanalyzetime
SCIP_Real * bdchgubs
struct SCIP_ParamData SCIP_PARAMDATA
Definition: type_paramset.h:77
SCIP_Longint SCIPconflictGetNPseudoConflictLiterals(SCIP_CONFLICT *conflict)
Definition: conflict.c:9558
#define SCIPsetAllocCleanBufferArray(set, ptr, num)
Definition: set.h:1696
SCIP_EXPORT SCIP_Bool SCIPbdchginfoIsRedundant(SCIP_BDCHGINFO *bdchginfo)
Definition: var.c:18392
SCIP_RETCODE SCIPbdchginfoCreate(SCIP_BDCHGINFO **bdchginfo, BMS_BLKMEM *blkmem, SCIP_VAR *var, SCIP_BOUNDTYPE boundtype, SCIP_Real oldbound, SCIP_Real newbound)
Definition: var.c:16126
void SCIPconflicthdlrSetCopy(SCIP_CONFLICTHDLR *conflicthdlr, SCIP_DECL_CONFLICTCOPY((*conflictcopy)))
Definition: conflict.c:697
#define SCIP_CALL_FINALLY(x, y)
Definition: def.h:406
SCIP_Longint SCIPconflictGetNInfeasibleLPSuccess(SCIP_CONFLICT *conflict)
Definition: conflict.c:8810
static SCIP_RETCODE undoBdchgsProof(SCIP_SET *set, SCIP_PROB *prob, int currentdepth, SCIP_Real *proofcoefs, SCIP_Real prooflhs, SCIP_Real *proofact, SCIP_Real *curvarlbs, SCIP_Real *curvarubs, int *lbchginfoposs, int *ubchginfoposs, SCIP_LPBDCHGS *oldlpbdchgs, SCIP_LPBDCHGS *relaxedlpbdchgs, SCIP_Bool *resolve, SCIP_LPI *lpi)
Definition: conflict.c:6163
SCIP_Longint nappliedglbliterals
int SCIPconsGetValidDepth(SCIP_CONS *cons)
Definition: cons.c:8172
SCIP_Longint SCIPconflictGetNPropCalls(SCIP_CONFLICT *conflict)
Definition: conflict.c:5701
SCIP_Longint npseudoreconvliterals
SCIP_RETCODE SCIPaddCoefLinear(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_Real val)
static SCIP_Real getMinActivity(SCIP_SET *set, SCIP_PROB *transprob, SCIP_Real *coefs, int *inds, int nnz, SCIP_Real *curvarlbs, SCIP_Real *curvarubs)
Definition: conflict.c:2728
SCIP_EXPORT SCIP_BDCHGINFO * SCIPvarGetBdchgInfoUb(SCIP_VAR *var, int pos)
Definition: var.c:18082
static void proofsetCancelVarWithBound(SCIP_PROOFSET *proofset, SCIP_SET *set, SCIP_VAR *var, int pos, SCIP_Bool *valid)
Definition: conflict.c:1160
SCIP_EXPORT SCIP_Longint SCIPnodeGetNumber(SCIP_NODE *node)
Definition: tree.c:7420
int SCIPcolGetNNonz(SCIP_COL *col)
Definition: lp.c:16975
static SCIP_RETCODE lpbdchgsCreate(SCIP_LPBDCHGS **lpbdchgs, SCIP_SET *set, int ncols)
Definition: conflict.c:855
SCIP_Longint SCIPconflictGetNStrongbranchIterations(SCIP_CONFLICT *conflict)
Definition: conflict.c:9344
static SCIP_RETCODE conflictsetCalcInsertDepth(SCIP_CONFLICTSET *conflictset, SCIP_SET *set, SCIP_TREE *tree)
Definition: conflict.c:1802
interface methods for specific LP solvers
SCIP_Longint npropconfliterals
SCIP_Real SCIPsetInfinity(SCIP_SET *set)
Definition: set.c:5845
static SCIP_RETCODE conflictAddConflictBound(SCIP_CONFLICT *conflict, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_BDCHGINFO *bdchginfo, SCIP_Real relaxedbd)
Definition: conflict.c:4171
int SCIPprobGetNVars(SCIP_PROB *prob)
Definition: prob.c:2318
SCIP_BDCHGINFO * ubchginfos
Definition: struct_var.h:243
void SCIPconsMarkConflict(SCIP_CONS *cons)
Definition: cons.c:6995
SCIP_COL ** cols
Definition: struct_lp.h:291
int startnconss
Definition: struct_prob.h:76
int nlpirows
Definition: struct_lp.h:310
SCIP_Longint nappliedglbconss
SCIP_Real SCIPvarGetLbLP(SCIP_VAR *var, SCIP_SET *set)
Definition: var.c:12698
SCIP_RETCODE SCIPvarScaleVSIDS(SCIP_VAR *var, SCIP_Real scalar)
Definition: var.c:14897
unsigned int nboundchgs
Definition: struct_var.h:123
SCIP_Longint SCIPconflictGetNDualproofsInfGlobal(SCIP_CONFLICT *conflict)
Definition: conflict.c:9214
SCIP_Real SCIProwGetConstant(SCIP_ROW *row)
Definition: lp.c:17107
datastructures for conflict analysis
SCIP_Longint npseudoreconvconss
SCIP_EXPORT SCIP_Bool SCIPvarIsBinary(SCIP_VAR *var)
Definition: var.c:17192
SCIP_EXPORT void SCIPsortedvecDelPosIntPtrReal(int *intarray, void **ptrarray, SCIP_Real *realarray, int pos, int *len)
void SCIPclockStop(SCIP_CLOCK *clck, SCIP_SET *set)
Definition: clock.c:351
SCIP_EXPORT SCIP_Bool SCIPlpiIsInfinity(SCIP_LPI *lpi, SCIP_Real val)
Definition: lpi_clp.cpp:3905
SCIP_Longint SCIPconflictGetNInfeasibleLPReconvergenceConss(SCIP_CONFLICT *conflict)
Definition: conflict.c:8840
SCIP_Longint SCIPconflictGetNInfeasibleLPReconvergenceLiterals(SCIP_CONFLICT *conflict)
Definition: conflict.c:8850
#define FALSE
Definition: def.h:73
static void skipRedundantBdchginfos(SCIP_VAR *var, int *lbchginfopos, int *ubchginfopos)
Definition: conflict.c:6131
methods for the aggregation rows
static SCIP_BDCHGINFO * conflictFirstCand(SCIP_CONFLICT *conflict)
Definition: conflict.c:4733
SCIP_RETCODE SCIPconflictAnalyze(SCIP_CONFLICT *conflict, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_TREE *tree, int validdepth, SCIP_Bool *success)
Definition: conflict.c:5623
SCIP_EXPORT SCIP_Real SCIPvarGetObj(SCIP_VAR *var)
Definition: var.c:17510
SCIP_Longint nlocchgbds
SCIP_EXPORT SCIP_Bool SCIPlpiIsPrimalInfeasible(SCIP_LPI *lpi)
Definition: lpi_clp.cpp:2488
SCIP_Bool solved
Definition: struct_lp.h:357
void SCIPclockStart(SCIP_CLOCK *clck, SCIP_SET *set)
Definition: clock.c:281
SCIP_EXPORT int SCIPnodeGetDepth(SCIP_NODE *node)
Definition: tree.c:7430
SCIP_RETCODE SCIPconflicthdlrExec(SCIP_CONFLICTHDLR *conflicthdlr, SCIP_SET *set, SCIP_NODE *node, SCIP_NODE *validnode, SCIP_BDCHGINFO **bdchginfos, SCIP_Real *relaxedbds, int nbdchginfos, SCIP_CONFTYPE conftype, SCIP_Bool usescutoffbound, SCIP_Bool resolved, SCIP_RESULT *result)
Definition: conflict.c:629
SCIP_Bool dualchecked
Definition: struct_lp.h:361
static SCIP_RETCODE undoBdchgsDualfarkas(SCIP_SET *set, SCIP_PROB *prob, SCIP_LP *lp, int currentdepth, SCIP_Real *curvarlbs, SCIP_Real *curvarubs, int *lbchginfoposs, int *ubchginfoposs, SCIP_LPBDCHGS *oldlpbdchgs, SCIP_LPBDCHGS *relaxedlpbdchgs, SCIP_Bool *valid, SCIP_Bool *resolve, SCIP_Real *farkascoefs, SCIP_Real farkaslhs, SCIP_Real *farkasactivity)
Definition: conflict.c:6380
SCIP_Bool SCIPsetIsZero(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6092
SCIP_EXPORT SCIP_VARTYPE SCIPvarGetType(SCIP_VAR *var)
Definition: var.c:17177
#define TRUE
Definition: def.h:72
#define SCIPdebug(x)
Definition: pub_message.h:84
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:54
SCIP_Longint SCIPconflictGetNPropConflictLiterals(SCIP_CONFLICT *conflict)
Definition: conflict.c:5731
SCIP_Real * relaxedbds
SCIP_EXPORT SCIP_RETCODE SCIPlpiStartStrongbranch(SCIP_LPI *lpi)
Definition: lpi_clp.cpp:1992
unsigned int basisstatus
Definition: struct_lp.h:240
static SCIP_RETCODE propagateLongProof(SCIP_CONFLICT *conflict, SCIP_SET *set, SCIP_STAT *stat, SCIP_REOPT *reopt, SCIP_TREE *tree, BMS_BLKMEM *blkmem, SCIP_PROB *origprob, SCIP_PROB *transprob, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, SCIP_CLIQUETABLE *cliquetable, SCIP_Real *coefs, int *inds, int nnz, SCIP_Real rhs, SCIP_CONFTYPE conflicttype, int validdepth)
Definition: conflict.c:2859
int SCIPpqueueNElems(SCIP_PQUEUE *pqueue)
Definition: misc.c:1467
int nlbchginfos
Definition: struct_var.h:261
void SCIPconflicthdlrSetPriority(SCIP_CONFLICTHDLR *conflicthdlr, SCIP_SET *set, int priority)
Definition: conflict.c:793
SCIP_Real dualsol
Definition: struct_lp.h:98
SCIP_Real redcost
Definition: struct_lp.h:140
#define SCIPsetAllocBufferArray(set, ptr, num)
Definition: set.h:1685
int SCIPtreeGetCurrentDepth(SCIP_TREE *tree)
Definition: tree.c:8380
void SCIPaggrRowFree(SCIP *scip, SCIP_AGGRROW **aggrrow)
Definition: cuts.c:1616
SCIP_Longint npropcalls
unsigned int sbdownvalid
Definition: struct_lp.h:179
SCIP_RETCODE SCIPconflicthdlrExitsol(SCIP_CONFLICTHDLR *conflicthdlr, SCIP_SET *set)
Definition: conflict.c:605
int SCIPsetCalcMemGrowSize(SCIP_SET *set, int num)
Definition: set.c:5573
unsigned int basisstatus
Definition: struct_lp.h:170
SCIP_Longint nglbchgbds
SCIP_Real * bdchglbs
SCIP_EXPORT SCIP_Bool SCIPvarIsActive(SCIP_VAR *var)
Definition: var.c:17335
public methods for problem variables
SCIP_EXPORT SCIP_Bool SCIPlpiIsObjlimExc(SCIP_LPI *lpi)
Definition: lpi_clp.cpp:2676
SCIP_Longint npropsuccess
SCIP_Real dualfarkas
Definition: struct_lp.h:206
#define EPSGE(x, y, eps)
Definition: def.h:192
static void conflictsetClear(SCIP_CONFLICTSET *conflictset)
Definition: conflict.c:1268
SCIP_ROW ** SCIPlpGetRows(SCIP_LP *lp)
Definition: lp.c:17434
SCIP_Bool diving
Definition: struct_lp.h:370
#define SCIPdebugMessage
Definition: pub_message.h:87
SCIP_RETCODE SCIPconflictFree(SCIP_CONFLICT **conflict, BMS_BLKMEM *blkmem)
Definition: conflict.c:3965
SCIP_Longint SCIPconflictGetNAppliedLiterals(SCIP_CONFLICT *conflict)
Definition: conflict.c:3741
SCIP_Real SCIPlpGetPseudoObjval(SCIP_LP *lp, SCIP_SET *set, SCIP_PROB *prob)
Definition: lp.c:13246
static SCIP_RETCODE conflictAddBound(SCIP_CONFLICT *conflict, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_VAR *var, SCIP_BOUNDTYPE boundtype, SCIP_BDCHGINFO *bdchginfo, SCIP_Real relaxedbd)
Definition: conflict.c:4315
SCIP_RETCODE SCIPconflicthdlrCreate(SCIP_CONFLICTHDLR **conflicthdlr, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, BMS_BLKMEM *blkmem, const char *name, const char *desc, int priority, SCIP_DECL_CONFLICTCOPY((*conflictcopy)), SCIP_DECL_CONFLICTFREE((*conflictfree)), SCIP_DECL_CONFLICTINIT((*conflictinit)), SCIP_DECL_CONFLICTEXIT((*conflictexit)), SCIP_DECL_CONFLICTINITSOL((*conflictinitsol)), SCIP_DECL_CONFLICTEXITSOL((*conflictexitsol)), SCIP_DECL_CONFLICTEXEC((*conflictexec)), SCIP_CONFLICTHDLRDATA *conflicthdlrdata)
Definition: conflict.c:454
SCIP_EXPORT SCIP_VARSTATUS SCIPvarGetStatus(SCIP_VAR *var)
Definition: var.c:17131
void SCIPaggrRowRemoveZeros(SCIP *scip, SCIP_AGGRROW *aggrrow, SCIP_Bool useglbbounds, SCIP_Bool *valid)
Definition: cuts.c:2320
int SCIProwGetLPPos(SCIP_ROW *row)
Definition: lp.c:17350
int SCIPbdchgidxGetPos(SCIP_BDCHGIDX *bdchgidx)
Definition: var.c:18194
static SCIP_RETCODE conflictQueueBound(SCIP_CONFLICT *conflict, SCIP_SET *set, SCIP_BDCHGINFO *bdchginfo, SCIP_Real relaxedbd)
Definition: conflict.c:4234
SCIP_Bool SCIPsetIsNegative(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6114
void SCIPconflicthdlrSetExitsol(SCIP_CONFLICTHDLR *conflicthdlr, SCIP_DECL_CONFLICTEXITSOL((*conflictexitsol)))
Definition: conflict.c:752
static SCIP_RETCODE conflictInsertProofset(SCIP_CONFLICT *conflict, SCIP_SET *set, SCIP_PROOFSET *proofset)
Definition: conflict.c:1960
methods for creating output for visualization tools (VBC, BAK)
void SCIPclockEnableOrDisable(SCIP_CLOCK *clck, SCIP_Bool enable)
Definition: clock.c:251
#define QUAD_ASSIGN(a, constant)
Definition: dbldblarith.h:42
SCIP_Real SCIPconflictGetGlobalApplTime(SCIP_CONFLICT *conflict)
Definition: conflict.c:5681
#define SCIPsetFreeBufferArray(set, ptr)
Definition: set.h:1692
unsigned int basisstatus
Definition: struct_lp.h:100
#define BMSfreeMemory(ptr)
Definition: memory.h:137
SCIP_Longint SCIPconflictGetNDualproofsInfNonzeros(SCIP_CONFLICT *conflict)
Definition: conflict.c:9234
void SCIPvarAdjustLb(SCIP_VAR *var, SCIP_SET *set, SCIP_Real *lb)
Definition: var.c:6321
public methods for SCIP variables
static SCIP_RETCODE conflictFlushProofset(SCIP_CONFLICT *conflict, SCIP_CONFLICTSTORE *conflictstore, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, SCIP_CLIQUETABLE *cliquetable)
Definition: conflict.c:3242
SCIP_Longint SCIPconflictGetNStrongbranchReconvergenceLiterals(SCIP_CONFLICT *conflict)
Definition: conflict.c:9334
SCIP_Longint SCIPconflictGetNDualproofsBndSuccess(SCIP_CONFLICT *conflict)
Definition: conflict.c:9244
SCIP_Real SCIPconflictGetPseudoTime(SCIP_CONFLICT *conflict)
Definition: conflict.c:9518
#define SCIP_DECL_CONFLICTEXIT(x)
SCIP_Longint nappliedlocconss
SCIP_Longint SCIPconflictGetNInfeasibleLPConflictLiterals(SCIP_CONFLICT *conflict)
Definition: conflict.c:8830
SCIP_Longint SCIPconflictGetNPropReconvergenceConss(SCIP_CONFLICT *conflict)
Definition: conflict.c:5741
SCIP_LPSOLSTAT SCIPlpGetSolstat(SCIP_LP *lp)
Definition: lp.c:13047
SCIP_VISUAL * visual
Definition: struct_stat.h:172
int conflictlbcount
Definition: struct_var.h:264
SCIP_EXPORT void SCIPsortIntIntInt(int *intarray1, int *intarray2, int *intarray3, int len)
internal methods for LP management
SCIP_RETCODE SCIPaggrRowCreate(SCIP *scip, SCIP_AGGRROW **aggrrow)
Definition: cuts.c:1584
void SCIPpqueueClear(SCIP_PQUEUE *pqueue)
Definition: misc.c:1273
static void proofsetClear(SCIP_PROOFSET *proofset)
Definition: conflict.c:923
SCIP_Longint npseudosuccess
Definition: heur_padm.c:125
SCIP_Real SCIPconflictGetVarUb(SCIP_CONFLICT *conflict, SCIP_VAR *var)
Definition: conflict.c:4673
SCIP_Longint SCIPconflictGetNDualproofsInfSuccess(SCIP_CONFLICT *conflict)
Definition: conflict.c:9204
#define QUAD_TO_DBL(x)
Definition: dbldblarith.h:40
SCIP_Bool primalchecked
Definition: struct_lp.h:359
real eps
internal methods for branching and inference history
int * SCIPaggrRowGetInds(SCIP_AGGRROW *aggrrow)
Definition: cuts.c:2390
static char varGetChar(SCIP_VAR *var)
Definition: conflict.c:910
SCIP_Real SCIPconflictGetStrongbranchTime(SCIP_CONFLICT *conflict)
Definition: conflict.c:9194
SCIP_Longint SCIPconflictGetNAppliedLocalLiterals(SCIP_CONFLICT *conflict)
Definition: conflict.c:3801
SCIP_Bool strongbranching
Definition: struct_lp.h:367
void SCIPgmlWriteOpening(FILE *file, SCIP_Bool directed)
Definition: misc.c:672
SCIP_Longint SCIPconflictGetNPseudoConflictConss(SCIP_CONFLICT *conflict)
Definition: conflict.c:9548
SCIP_Longint ninflpiterations
#define POSTPROCESS
Definition: conflict.c:164
SCIP_Bool dualfeasible
Definition: struct_lp.h:113
SCIP_EXPORT SCIP_Real * SCIPvarGetMultaggrScalars(SCIP_VAR *var)
Definition: var.c:17454
void SCIPgmlWriteArc(FILE *file, unsigned int source, unsigned int target, const char *label, const char *color)
Definition: misc.c:628
SCIP_RETCODE SCIPcreateSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
Definition: scip_sol.c:320
int SCIPconflictstoreGetNDualInfProofs(SCIP_CONFLICTSTORE *conflictstore)
int SCIPlpGetNCols(SCIP_LP *lp)
Definition: lp.c:17424
SCIP_Real SCIPvarGetUbLP(SCIP_VAR *var, SCIP_SET *set)
Definition: var.c:12768
static SCIP_RETCODE conflictEnsureProofsetsMem(SCIP_CONFLICT *conflict, SCIP_SET *set, int num)
Definition: conflict.c:1911
SCIP_Bool SCIPsetIsGE(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6074
SCIP_HISTORY * glbhistorycrun
Definition: struct_stat.h:170
internal methods for propagators
SCIP_Longint npropreconvliterals
static SCIP_RETCODE getDualProof(SCIP_SET *set, SCIP_PROB *transprob, SCIP_LP *lp, SCIP_LPI *lpi, SCIP_TREE *tree, SCIP_AGGRROW *farkasrow, SCIP_Real *farkasact, int *validdepth, SCIP_Real *curvarlbs, SCIP_Real *curvarubs, SCIP_Bool *valid)
Definition: conflict.c:7096
static SCIP_Bool conflictsetIsRedundant(SCIP_CONFLICTSET *conflictset1, SCIP_CONFLICTSET *conflictset2)
Definition: conflict.c:1849
int SCIPtreeGetFocusDepth(SCIP_TREE *tree)
Definition: tree.c:8305
#define SCIPdebugCheckConflict(blkmem, set, node, bdchginfos, relaxedbds, nliterals)
Definition: debug.h:253
void SCIPhistoryScaleVSIDS(SCIP_HISTORY *history, SCIP_Real scalar)
Definition: history.c:508
SCIP_Longint ndualproofsinflocal
SCIP_Longint npropconfconss
SCIP_Longint nboundlpcalls
SCIP_Real * vals
Definition: struct_lp.h:220
enum SCIP_BranchDir SCIP_BRANCHDIR
Definition: type_history.h:39
SCIP_EXPORT SCIP_VAR * SCIPbdchginfoGetInferVar(SCIP_BDCHGINFO *bdchginfo)
Definition: var.c:18324
SCIP_Real conflictrelaxedub
Definition: struct_var.h:216
SCIP_Real avgnnz
Definition: struct_stat.h:117
SCIP_EXPORT SCIP_Bool SCIPvarIsRelaxationOnly(SCIP_VAR *var)
Definition: var.c:17299
SCIP_RETCODE SCIPnodeCutoff(SCIP_NODE *node, SCIP_SET *set, SCIP_STAT *stat, SCIP_TREE *tree, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_REOPT *reopt, SCIP_LP *lp, BMS_BLKMEM *blkmem)
Definition: tree.c:1176
SCIP_RETCODE SCIPconflictAnalyzePseudo(SCIP_CONFLICT *conflict, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, SCIP_CLIQUETABLE *cliquetable, SCIP_Bool *success)
Definition: conflict.c:9366
void SCIPconflicthdlrSetFree(SCIP_CONFLICTHDLR *conflicthdlr, SCIP_DECL_CONFLICTFREE((*conflictfree)))
Definition: conflict.c:708
SCIP_EXPORT SCIP_BOUNDCHGTYPE SCIPbdchginfoGetChgtype(SCIP_BDCHGINFO *bdchginfo)
Definition: var.c:18274
SCIP_Bool SCIPsetIsLT(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6020
const char * SCIPconflicthdlrGetDesc(SCIP_CONFLICTHDLR *conflicthdlr)
Definition: conflict.c:773
#define BOUNDSWITCH
Definition: conflict.c:163
static SCIP_Real aggrRowGetMinActivity(SCIP_SET *set, SCIP_PROB *transprob, SCIP_AGGRROW *aggrrow, SCIP_Real *curvarlbs, SCIP_Real *curvarubs, SCIP_Bool *infdelta)
Definition: conflict.c:2659
SCIP_BOUNDTYPE SCIPboundtypeOpposite(SCIP_BOUNDTYPE boundtype)
Definition: lp.c:17052
SCIP_CLOCK * setuptime
SCIP_RETCODE SCIPconflicthdlrExit(SCIP_CONFLICTHDLR *conflicthdlr, SCIP_SET *set)
Definition: conflict.c:550
SCIP_CLOCK * pseudoanalyzetime
public methods for handling parameter settings
SCIP_RETCODE SCIPconflicthdlrInitsol(SCIP_CONFLICTHDLR *conflicthdlr, SCIP_SET *set)
Definition: conflict.c:581
public methods for managing constraints
SCIP_DOMCHG * domchg
Definition: struct_tree.h:150
static void proofsetFree(SCIP_PROOFSET **proofset, BMS_BLKMEM *blkmem)
Definition: conflict.c:973
int lpiitlim
Definition: struct_lp.h:335
SCIP_Real lb
Definition: struct_lp.h:129
SCIP_Real dualsol
Definition: struct_lp.h:204
SCIP_Real conflictrelaxedlb
Definition: struct_var.h:215
static SCIP_RETCODE detectImpliedBounds(SCIP_SET *set, SCIP_PROB *prob, SCIP_CONFLICTSET *conflictset, int *nbdchgs, int *nredvars, SCIP_Bool *redundant)
Definition: conflict.c:2242
SCIP_Real SCIPconflicthdlrGetSetupTime(SCIP_CONFLICTHDLR *conflicthdlr)
Definition: conflict.c:829
static SCIP_RETCODE addCand(SCIP_SET *set, int currentdepth, SCIP_VAR *var, int lbchginfopos, int ubchginfopos, SCIP_Real proofcoef, SCIP_Real prooflhs, SCIP_Real proofact, SCIP_VAR ***cands, SCIP_Real **candscores, SCIP_Real **newbounds, SCIP_Real **proofactdeltas, int *candssize, int *ncands, int firstcand)
Definition: conflict.c:5995
#define SCIP_DECL_CONFLICTINITSOL(x)
SCIP_CLOCK * boundlpanalyzetime
#define BMSduplicateBlockMemoryArray(mem, ptr, source, num)
Definition: memory.h:453
SCIP_Longint SCIPconflictGetNInfeasibleLPConflictConss(SCIP_CONFLICT *conflict)
Definition: conflict.c:8820
SCIP_Real sbdown
Definition: struct_lp.h:144
SCIP_Longint ninflpreconvliterals
SCIP_EXPORT const char * SCIPvarGetName(SCIP_VAR *var)
Definition: var.c:17012
#define SCIP_DECL_CONFLICTEXEC(x)
SCIP_BDCHGINFO ** tmpbdchginfos
SCIP_CLOCK * conflicttime
SCIP_EXPORT SCIP_Bool SCIPvarIsIntegral(SCIP_VAR *var)
Definition: var.c:17203
static SCIP_RETCODE separateAlternativeProofs(SCIP_CONFLICT *conflict, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *transprob, SCIP_TREE *tree, BMS_BLKMEM *blkmem, SCIP_AGGRROW *proofrow, SCIP_Real *curvarlbs, SCIP_Real *curvarubs, SCIP_CONFTYPE conflicttype)
Definition: conflict.c:7380
SCIP_EXPORT SCIP_Bool SCIPbdchginfoIsTighter(SCIP_BDCHGINFO *bdchginfo1, SCIP_BDCHGINFO *bdchginfo2)
Definition: var.c:18417
void SCIPhistoryIncNActiveConflicts(SCIP_HISTORY *history, SCIP_BRANCHDIR dir, SCIP_Real length)
Definition: history.c:533
internal methods for storing and manipulating the main problem
#define SCIPerrorMessage
Definition: pub_message.h:55
#define SCIPdebugPrintf
Definition: pub_message.h:90
#define QUAD_EPSILON
Definition: dbldblarith.h:33
SCIP_EXPORT SCIP_RETCODE SCIPlpiEndStrongbranch(SCIP_LPI *lpi)
Definition: lpi_clp.cpp:2004
int SCIPconflicthdlrGetPriority(SCIP_CONFLICTHDLR *conflicthdlr)
Definition: conflict.c:783
static SCIP_RETCODE conflictsetAddBounds(SCIP_CONFLICT *conflict, SCIP_CONFLICTSET *conflictset, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_BDCHGINFO **bdchginfos, int nbdchginfos)
Definition: conflict.c:1592
static SCIP_RETCODE conflictsetEnsureBdchginfosMem(SCIP_CONFLICTSET *conflictset, BMS_BLKMEM *blkmem, SCIP_SET *set, int num)
Definition: conflict.c:1358
SCIP_RETCODE SCIPconflictstoreAddDualraycons(SCIP_CONFLICTSTORE *conflictstore, SCIP_CONS *dualproof, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *transprob, SCIP_REOPT *reopt, SCIP_Bool hasrelaxvar)
SCIP_Longint SCIPconflictGetNBoundexceedingLPReconvergenceConss(SCIP_CONFLICT *conflict)
Definition: conflict.c:8920
void SCIPconflicthdlrSetData(SCIP_CONFLICTHDLR *conflicthdlr, SCIP_CONFLICTHDLRDATA *conflicthdlrdata)
Definition: conflict.c:686
SCIP_Bool SCIPconflicthdlrIsInitialized(SCIP_CONFLICTHDLR *conflicthdlr)
Definition: conflict.c:807
SCIP_Bool dualchecked
Definition: struct_lp.h:114
SCIP_COL ** cols
Definition: struct_lp.h:218
void SCIPclockReset(SCIP_CLOCK *clck)
Definition: clock.c:200
SCIP_Real SCIPaggrRowGetRhs(SCIP_AGGRROW *aggrrow)
Definition: cuts.c:2430
SCIP_Longint ndualproofsbndglobal
SCIP_Longint nconflictlpiterations
Definition: struct_stat.h:70
static SCIP_Bool conflictMarkBoundCheckPresence(SCIP_CONFLICT *conflict, SCIP_SET *set, SCIP_BDCHGINFO *bdchginfo, SCIP_Real relaxedbd)
Definition: conflict.c:4082
SCIP_EXPORT int SCIPbdchginfoGetDepth(SCIP_BDCHGINFO *bdchginfo)
Definition: var.c:18294
SCIP_EXPORT SCIP_RETCODE SCIPlpiSetBase(SCIP_LPI *lpi, const int *cstat, const int *rstat)
Definition: lpi_clp.cpp:3053
static SCIP_RETCODE runBoundHeuristic(SCIP_CONFLICT *conflict, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *origprob, SCIP_PROB *transprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_LPI *lpi, BMS_BLKMEM *blkmem, SCIP_Real *proofcoefs, SCIP_Real *prooflhs, SCIP_Real *proofactivity, SCIP_Real *curvarlbs, SCIP_Real *curvarubs, int *lbchginfoposs, int *ubchginfoposs, int *iterations, SCIP_Bool marklpunsolved, SCIP_Bool *dualproofsuccess, SCIP_Bool *valid)
Definition: conflict.c:7794
SCIP_CONFLICTHDLRDATA * conflicthdlrdata
static SCIP_RETCODE createAndAddProofcons(SCIP_CONFLICT *conflict, SCIP_CONFLICTSTORE *conflictstore, SCIP_PROOFSET *proofset, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *origprob, SCIP_PROB *transprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, SCIP_CLIQUETABLE *cliquetable, BMS_BLKMEM *blkmem)
Definition: conflict.c:2963
SCIP_NODE ** path
Definition: struct_tree.h:179
SCIP_Longint SCIPconflictGetNPseudoReconvergenceConss(SCIP_CONFLICT *conflict)
Definition: conflict.c:9568
SCIP_ROW ** lpirows
Definition: struct_lp.h:288
#define SCIPfreeBufferArrayNull(scip, ptr)
Definition: scip_mem.h:124
unsigned int sbupvalid
Definition: struct_lp.h:181
SCIP_Longint ndualproofsbndlocal
SCIP_RETCODE SCIPsolSetVal(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_TREE *tree, SCIP_VAR *var, SCIP_Real val)
Definition: sol.c:1068
SCIP_Longint SCIPconflictGetNAppliedLocalConss(SCIP_CONFLICT *conflict)
Definition: conflict.c:3791
const char * SCIPpropGetName(SCIP_PROP *prop)
Definition: prop.c:932
#define QUAD(x)
Definition: dbldblarith.h:38
SCIP_Real lhs
Definition: struct_lp.h:195
SCIP_EXPORT SCIP_RETCODE SCIPlpiGetObjval(SCIP_LPI *lpi, SCIP_Real *objval)
Definition: lpi_clp.cpp:2752
SCIP_Real SCIPgetRhsLinear(SCIP *scip, SCIP_CONS *cons)
static SCIP_RETCODE conflictEnsureConflictsetsMem(SCIP_CONFLICT *conflict, SCIP_SET *set, int num)
Definition: conflict.c:1935
static SCIP_RETCODE convertToActiveVar(SCIP_VAR **var, SCIP_SET *set, SCIP_BOUNDTYPE *boundtype, SCIP_Real *bound)
Definition: conflict.c:4280
SCIP_Longint npropreconvconss
unsigned int pos
Definition: struct_var.h:113
static SCIP_Real conflictsetCalcScore(SCIP_CONFLICTSET *conflictset, SCIP_SET *set)
Definition: conflict.c:1388
SCIP_PROOFSET * proofset
SCIP_Real SCIPconflictGetBoundexceedingLPTime(SCIP_CONFLICT *conflict)
Definition: conflict.c:8870
static SCIP_RETCODE conflictsetCreate(SCIP_CONFLICTSET **conflictset, BMS_BLKMEM *blkmem)
Definition: conflict.c:1286
SCIP_Real SCIPclockGetTime(SCIP_CLOCK *clck)
Definition: clock.c:429
SCIP_Real SCIPsetFeasCeil(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6556
#define SCIPsetReallocBufferArray(set, ptr, num)
Definition: set.h:1689
SCIP_Real cutoffbound
Definition: struct_lp.h:274
#define NULL
Definition: lpi_spx1.cpp:155
SCIP_PROOFSET ** proofsets
static SCIP_RETCODE proofsetCreate(SCIP_PROOFSET **proofset, BMS_BLKMEM *blkmem)
Definition: conflict.c:937
SCIP_Longint SCIPconflictGetNStrongbranchReconvergenceConss(SCIP_CONFLICT *conflict)
Definition: conflict.c:9324
data structures for branch and bound tree
SCIP_HISTORY * glbhistory
Definition: struct_stat.h:169
#define REALABS(x)
Definition: def.h:187
SCIP_Longint SCIPconflictGetNDualproofsBndNonzeros(SCIP_CONFLICT *conflict)
Definition: conflict.c:9274
void SCIPaggrRowClear(SCIP_AGGRROW *aggrrow)
Definition: cuts.c:1984
SCIP_Longint ninflpcalls
SCIP_Longint nconflictlps
Definition: struct_stat.h:201
SCIP_RETCODE SCIPconflicthdlrFree(SCIP_CONFLICTHDLR **conflicthdlr, SCIP_SET *set)
Definition: conflict.c:485
SCIP_Longint SCIPconflictGetNStrongbranchConflictLiterals(SCIP_CONFLICT *conflict)
Definition: conflict.c:9314
struct SCIP_ConflicthdlrData SCIP_CONFLICTHDLRDATA
Definition: type_conflict.h:40
internal methods for global SCIP settings
internal methods for storing conflicts
#define SCIP_CALL(x)
Definition: def.h:364
SCIP_Longint SCIPconflictGetNDualproofsBndLocal(SCIP_CONFLICT *conflict)
Definition: conflict.c:9264
SCIP_EXPORT int SCIPvarGetNVubs(SCIP_VAR *var)
Definition: var.c:17896
SCIP_EXPORT void SCIPsortLongPtrRealRealBool(SCIP_Longint *longarray, void **ptrarray, SCIP_Real *realarray, SCIP_Real *realarray2, SCIP_Bool *boolarray, int len)
SCIP_Real activity
Definition: struct_lp.h:99
static SCIP_Real * proofsetGetVals(SCIP_PROOFSET *proofset)
Definition: conflict.c:1024
SCIP_EXPORT SCIP_RETCODE SCIPlpiChgSides(SCIP_LPI *lpi, int nrows, const int *ind, const SCIP_Real *lhs, const SCIP_Real *rhs)
Definition: lpi_clp.cpp:1158
SCIP_Bool SCIPsetIsFeasGE(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6466
int SCIPlpGetNRows(SCIP_LP *lp)
Definition: lp.c:17444
SCIP_VAR * h
Definition: circlepacking.c:59
#define SCIP_DECL_CONFLICTCOPY(x)
Definition: type_conflict.h:77
SCIP_Bool SCIPcutsTightenCoefficients(SCIP *scip, SCIP_Bool cutislocal, SCIP_Real *cutcoefs, SCIP_Real *cutrhs, int *cutinds, int *cutnnz, int *nchgcoefs)
Definition: cuts.c:1383
SCIP_Longint SCIPconflictGetNPseudoSuccess(SCIP_CONFLICT *conflict)
Definition: conflict.c:9538
SCIP_EXPORT SCIP_PROP * SCIPbdchginfoGetInferProp(SCIP_BDCHGINFO *bdchginfo)
Definition: var.c:18348
SCIP_RETCODE SCIPsetAddIntParam(SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, BMS_BLKMEM *blkmem, const char *name, const char *desc, int *valueptr, SCIP_Bool isadvanced, int defaultvalue, int minvalue, int maxvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
Definition: set.c:2949
SCIP_Bool SCIPsetIsEQ(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6002
SCIP_Real vsidsweight
Definition: struct_stat.h:120
SCIP_EXPORT SCIP_Bool SCIPlpiIsDualFeasible(SCIP_LPI *lpi)
Definition: lpi_clp.cpp:2595
SCIP_LPI * SCIPlpGetLPI(SCIP_LP *lp)
Definition: lp.c:17596
static SCIP_RETCODE conflictsetAddBound(SCIP_CONFLICTSET *conflictset, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_BDCHGINFO *bdchginfo, SCIP_Real relaxedbd)
Definition: conflict.c:1522
SCIP_LPI * lpi
Definition: struct_lp.h:286
#define SCIPquadprecProdDD(r, a, b)
Definition: dbldblarith.h:49
SCIP_Longint SCIPconflictGetNInfeasibleLPCalls(SCIP_CONFLICT *conflict)
Definition: conflict.c:8800
static SCIP_RETCODE conflictAddConflictset(SCIP_CONFLICT *conflict, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_TREE *tree, int validdepth, SCIP_Bool diving, SCIP_Bool repropagate, SCIP_Bool *success, int *nliterals)
Definition: conflict.c:4787
static SCIP_CONFTYPE proofsetGetConftype(SCIP_PROOFSET *proofset)
Definition: conflict.c:1057
SCIP_EXPORT SCIP_RETCODE SCIPlpiChgBounds(SCIP_LPI *lpi, int ncols, const int *ind, const SCIP_Real *lb, const SCIP_Real *ub)
Definition: lpi_clp.cpp:1075
SCIP_CLOCK * sbanalyzetime
SCIP_Longint dualproofsbndnnonzeros
SCIP_Bool SCIPsetIsFeasLE(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6422
#define BMSduplicateMemoryArray(ptr, source, num)
Definition: memory.h:135
public methods for constraint handler plugins and constraints
static SCIP_RETCODE conflictAnalyzeRemainingBdchgs(SCIP_CONFLICT *conflict, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_TREE *tree, SCIP_Bool diving, int *lbchginfoposs, int *ubchginfoposs, int *nconss, int *nliterals, int *nreconvconss, int *nreconvliterals)
Definition: conflict.c:6495
SCIP_RETCODE SCIPclockCreate(SCIP_CLOCK **clck, SCIP_CLOCKTYPE clocktype)
Definition: clock.c:161
methods commonly used for presolving
SCIP_Longint nboundlpsuccess
SCIP_RETCODE SCIPconflicthdlrInit(SCIP_CONFLICTHDLR *conflicthdlr, SCIP_SET *set)
Definition: conflict.c:513
void SCIPvarAdjustBd(SCIP_VAR *var, SCIP_SET *set, SCIP_BOUNDTYPE boundtype, SCIP_Real *bd)
Definition: var.c:6355
static SCIP_RETCODE conflictAnalyzeBoundexceedingLP(SCIP_CONFLICT *conflict, SCIP_CONFLICTSTORE *conflictstore, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, SCIP_CLIQUETABLE *cliquetable, SCIP_Bool *success)
Definition: conflict.c:8564
SCIP_CONFLICTSET * conflictset
SCIP_DECL_SORTPTRCOMP(SCIPconflicthdlrComp)
Definition: conflict.c:353
SCIP_EXPORT SCIP_COL * SCIPvarGetCol(SCIP_VAR *var)
Definition: var.c:17376
#define BMSfreeBlockMemory(mem, ptr)
Definition: memory.h:456
SCIP_Longint nboundlpreconvconss
internal methods for problem variables
SCIP_Bool SCIPsetIsIntegral(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6125
public data structures and miscellaneous methods
static SCIP_RETCODE conflictAnalyzeDualProof(SCIP_CONFLICT *conflict, SCIP_SET *set, SCIP_STAT *stat, BMS_BLKMEM *blkmem, SCIP_PROB *origprob, SCIP_PROB *transprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_AGGRROW *proofrow, int validdepth, SCIP_Real *curvarlbs, SCIP_Real *curvarubs, SCIP_Bool initialproof, SCIP_Bool *globalinfeasible, SCIP_Bool *success)
Definition: conflict.c:7703
void SCIPnodePropagateAgain(SCIP_NODE *node, SCIP_SET *set, SCIP_STAT *stat, SCIP_TREE *tree)
Definition: tree.c:1236
static SCIP_RETCODE sortLocalRows(SCIP_SET *set, SCIP_AGGRROW *aggrrow, SCIP_ROW **rows, int *rowinds, int *rowdepth, int nrows)
Definition: conflict.c:6714
int SCIPtreeGetEffectiveRootDepth(SCIP_TREE *tree)
Definition: tree.c:8419
#define SCIP_Bool
Definition: def.h:70
#define SCIPsetFreeBuffer(set, ptr)
Definition: set.h:1690
SCIP_Real redcost
Definition: struct_lp.h:87
SCIP_Real SCIPsetSumepsilon(SCIP_SET *set)
Definition: set.c:5877
SCIP_Real * vals
#define BMSallocBlockMemoryArray(mem, ptr, num)
Definition: memory.h:445
SCIP_EXPORT SCIP_Bool SCIPbdchginfoHasInferenceReason(SCIP_BDCHGINFO *bdchginfo)
Definition: var.c:18403
SCIP_EXPORT SCIP_Bool SCIPbdchgidxIsEarlierNonNull(SCIP_BDCHGIDX *bdchgidx1, SCIP_BDCHGIDX *bdchgidx2)
Definition: var.c:18204
SCIP_RETCODE SCIPpropResolvePropagation(SCIP_PROP *prop, SCIP_SET *set, SCIP_VAR *infervar, int inferinfo, SCIP_BOUNDTYPE inferboundtype, SCIP_BDCHGIDX *bdchgidx, SCIP_Real relaxedbd, SCIP_RESULT *result)
Definition: prop.c:728
SCIP_EXPORT void SCIPsortIntInt(int *intarray1, int *intarray2, int len)
int ncontvars
Definition: struct_prob.h:65
static SCIP_RETCODE getFarkasProof(SCIP_SET *set, SCIP_PROB *prob, SCIP_LP *lp, SCIP_LPI *lpi, SCIP_TREE *tree, SCIP_AGGRROW *farkasrow, SCIP_Real *farkasact, int *validdepth, SCIP_Real *curvarlbs, SCIP_Real *curvarubs, SCIP_Bool *valid)
Definition: conflict.c:6923
unsigned int depth
Definition: struct_tree.h:151
static const char * paramname[]
Definition: lpi_msk.c:4958
SCIP_Bool SCIPconflictApplicable(SCIP_SET *set)
Definition: conflict.c:3859
SCIP_RETCODE SCIPconsRelease(SCIP_CONS **cons, BMS_BLKMEM *blkmem, SCIP_SET *set)
Definition: cons.c:6207
SCIP_EXPORT SCIP_Real SCIPvarGetUbGlobal(SCIP_VAR *var)
Definition: var.c:17672
static SCIP_RETCODE proofsetAddAggrrow(SCIP_PROOFSET *proofset, SCIP_SET *set, BMS_BLKMEM *blkmem, SCIP_AGGRROW *aggrrow)
Definition: conflict.c:1119
void SCIPclockFree(SCIP_CLOCK **clck)
Definition: clock.c:176
int SCIProwGetLPDepth(SCIP_ROW *row)
Definition: lp.c:17361
SCIP_Bool SCIPlpDivingObjChanged(SCIP_LP *lp)
Definition: lp.c:17679
SCIP_Longint ndualproofsinfglobal
SCIP_RETCODE SCIPconflictAnalyzeStrongbranch(SCIP_CONFLICT *conflict, SCIP_CONFLICTSTORE *conflictstore, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, SCIP_CLIQUETABLE *cliquetable, SCIP_COL *col, SCIP_Bool *downconflict, SCIP_Bool *upconflict)
Definition: conflict.c:8957
SCIP_EXPORT SCIP_RETCODE SCIPlpiSetRealpar(SCIP_LPI *lpi, SCIP_LPPARAM type, SCIP_Real dval)
Definition: lpi_clp.cpp:3819
#define MAX(x, y)
Definition: tclique_def.h:83
unsigned int basisstatus
Definition: struct_lp.h:88
SCIP_EXPORT int SCIPbdchginfoGetInferInfo(SCIP_BDCHGINFO *bdchginfo)
Definition: var.c:18359
SCIP_Real SCIProwGetLhs(SCIP_ROW *row)
Definition: lp.c:17141
#define SCIPdebugCheckConflictFrontier(blkmem, set, node, bdchginfo, bdchginfos, relaxedbds, nliterals, bdchgqueue, forcedbdchgqueue)
Definition: debug.h:254
SCIP_RETCODE SCIPcutGenerationHeuristicCMIR(SCIP *scip, SCIP_SOL *sol, SCIP_Bool postprocess, SCIP_Real boundswitch, SCIP_Bool usevbds, SCIP_Bool allowlocal, int maxtestdelta, int *boundsfortrans, SCIP_BOUNDTYPE *boundtypesfortrans, SCIP_Real minfrac, SCIP_Real maxfrac, SCIP_AGGRROW *aggrrow, SCIP_Real *cutcoefs, SCIP_Real *cutrhs, int *cutinds, int *cutnnz, SCIP_Real *cutefficacy, int *cutrank, SCIP_Bool *cutislocal, SCIP_Bool *success)
Definition: cuts.c:4281
SCIP_Real SCIPconflictstoreGetAvgNnzDualBndProofs(SCIP_CONFLICTSTORE *conflictstore)
public methods for LP management
SCIP_CONFTYPE conflicttype
static SCIP_RETCODE incVSIDS(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_BOUNDTYPE boundtype, SCIP_Real value, SCIP_Real weight)
Definition: conflict.c:2092
#define SCIPsetDebugMsg
Definition: set.h:1721
void SCIPgmlWriteClosing(FILE *file)
Definition: misc.c:688
SCIP_Real conflictub
Definition: struct_var.h:214
SCIP_PQUEUE * forcedbdchgqueue
SCIP_Real oldbound
Definition: struct_var.h:108
SCIP_Bool SCIPprobAllColsInLP(SCIP_PROB *prob, SCIP_SET *set, SCIP_LP *lp)
Definition: prob.c:2275
SCIP_Longint SCIPconflictGetNStrongbranchConflictConss(SCIP_CONFLICT *conflict)
Definition: conflict.c:9304
static void conflictsetCalcConflictDepth(SCIP_CONFLICTSET *conflictset)
Definition: conflict.c:1758
SCIP_EXPORT SCIP_Bool SCIPbdchgidxIsEarlier(SCIP_BDCHGIDX *bdchgidx1, SCIP_BDCHGIDX *bdchgidx2)
Definition: var.c:18224
static SCIP_DECL_PARAMCHGD(paramChgdConflicthdlrPriority)
Definition: conflict.c:366
#define EPSLE(x, y, eps)
Definition: def.h:190
SCIP_EXPORT SCIP_BOUNDTYPE SCIPbdchginfoGetBoundtype(SCIP_BDCHGINFO *bdchginfo)
Definition: var.c:18284
SCIP_EXPORT SCIP_BOUNDTYPE SCIPbdchginfoGetInferBoundtype(SCIP_BDCHGINFO *bdchginfo)
Definition: var.c:18371
static SCIP_RETCODE tightenSingleVar(SCIP_CONFLICT *conflict, SCIP_SET *set, SCIP_STAT *stat, SCIP_TREE *tree, BMS_BLKMEM *blkmem, SCIP_PROB *origprob, SCIP_PROB *transprob, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, SCIP_CLIQUETABLE *cliquetable, SCIP_VAR *var, SCIP_Real val, SCIP_Real rhs, SCIP_CONFTYPE prooftype, int validdepth)
Definition: conflict.c:2509
#define SCIPquadprecProdQD(r, a, b)
Definition: dbldblarith.h:54
static SCIP_RETCODE updateStatistics(SCIP_CONFLICT *conflict, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_CONFLICTSET *conflictset, int insertdepth)
Definition: conflict.c:2123
#define BMScopyMemoryArray(ptr, source, num)
Definition: memory.h:126
const char * SCIPconflicthdlrGetName(SCIP_CONFLICTHDLR *conflicthdlr)
Definition: conflict.c:763
int SCIPconflictGetNConflicts(SCIP_CONFLICT *conflict)
Definition: conflict.c:3721
SCIP_Longint SCIPconflictGetNBoundexceedingLPCalls(SCIP_CONFLICT *conflict)
Definition: conflict.c:8880
Constraint handler for linear constraints in their most general form, .
#define MAXFRAC
Definition: conflict.c:168
datastructures for problem statistics
SCIP_Longint nboundlpreconvliterals
SCIP_Real ub
Definition: struct_lp.h:130
SCIP_Longint nsbconfconss
#define BMSclearMemory(ptr)
Definition: memory.h:121
SCIP_Bool SCIPsetIsFeasLT(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6400
SCIP_Longint nsbconfliterals
SCIP_Longint SCIPconflictGetNBoundexceedingLPReconvergenceLiterals(SCIP_CONFLICT *conflict)
Definition: conflict.c:8930
SCIP_RETCODE SCIPvarIncNActiveConflicts(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_BRANCHDIR dir, SCIP_Real value, SCIP_Real length)
Definition: var.c:14947
SCIP_ROW ** rows
Definition: struct_lp.h:293
SCIP_EXPORT SCIP_Real SCIPvarGetLbLocal(SCIP_VAR *var)
Definition: var.c:17718
SCIP_Longint nboundlpiterations
#define SCIPquadprecSumQQ(r, a, b)
Definition: dbldblarith.h:58
#define debugPrintViolationInfo(...)
Definition: conflict.c:7333
SCIP_Real SCIPconflicthdlrGetTime(SCIP_CONFLICTHDLR *conflicthdlr)
Definition: conflict.c:839
SCIP_VAR * SCIPcolGetVar(SCIP_COL *col)
Definition: lp.c:16901
SCIP_Bool SCIPprobIsTransformed(SCIP_PROB *prob)
Definition: prob.c:2253
SCIP_Real SCIPgetVarUbAtIndex(SCIP *scip, SCIP_VAR *var, SCIP_BDCHGIDX *bdchgidx, SCIP_Bool after)
Definition: scip_var.c:2132
int conflictubcount
Definition: struct_var.h:265
SCIP_EXPORT int SCIPbdchginfoGetPos(SCIP_BDCHGINFO *bdchginfo)
Definition: var.c:18304
SCIP_Longint npseudoconfliterals
SCIP_Longint ninflpconfconss
SCIP_EXPORT int SCIPvarGetNLocksDownType(SCIP_VAR *var, SCIP_LOCKTYPE locktype)
Definition: var.c:3193
#define SCIP_REAL_MAX
Definition: def.h:164
static SCIP_RETCODE conflictsetCopy(SCIP_CONFLICTSET **targetconflictset, BMS_BLKMEM *blkmem, SCIP_CONFLICTSET *sourceconflictset, int nadditionalelems)
Definition: conflict.c:1306
int SCIPparamGetInt(SCIP_PARAM *param)
Definition: paramset.c:725
SCIP_Real rhs
Definition: struct_lp.h:196
SCIP_Longint SCIPconflictGetNPseudoCalls(SCIP_CONFLICT *conflict)
Definition: conflict.c:9528
SCIP_Real constant
Definition: struct_lp.h:194
static void lpbdchgsFree(SCIP_LPBDCHGS **lpbdchgs, SCIP_SET *set)
Definition: conflict.c:890
SCIP_Bool SCIPconsIsGlobal(SCIP_CONS *cons)
Definition: cons.c:8318
datastructures for storing and manipulating the main problem
SCIP_RETCODE SCIPconflictstoreAddDualsolcons(SCIP_CONFLICTSTORE *conflictstore, SCIP_CONS *dualproof, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *transprob, SCIP_REOPT *reopt, SCIP_Real scale, SCIP_Bool updateside, SCIP_Bool hasrelaxvar)
SCIP_Real * r
Definition: circlepacking.c:50
#define SCIP_REAL_MIN
Definition: def.h:165
SCIP_EXPORT SCIP_Real SCIPvarGetUbLocal(SCIP_VAR *var)
Definition: var.c:17728
methods for sorting joint arrays of various types
SCIP_Real SCIPsetFeasFloor(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6545
SCIP_EXPORT SCIP_Bool SCIPlpiHasDualRay(SCIP_LPI *lpi)
Definition: lpi_clp.cpp:2542
SCIP_CONFTYPE conflicttype
static SCIP_RETCODE ensureSidechgsSize(SCIP_SET *set, int **sidechginds, SCIP_Real **sidechgoldlhss, SCIP_Real **sidechgoldrhss, SCIP_Real **sidechgnewlhss, SCIP_Real **sidechgnewrhss, int *sidechgssize, int num)
Definition: conflict.c:5769
SCIP_DOMCHGBOUND domchgbound
Definition: struct_var.h:153
SCIP_Real SCIPconflictGetInfeasibleLPTime(SCIP_CONFLICT *conflict)
Definition: conflict.c:8790
SCIP_RETCODE SCIPconflictCreate(SCIP_CONFLICT **conflict, BMS_BLKMEM *blkmem, SCIP_SET *set)
Definition: conflict.c:3875
SCIP_EXPORT SCIP_VAR * SCIPbdchginfoGetVar(SCIP_BDCHGINFO *bdchginfo)
Definition: var.c:18264
SCIP_RETCODE SCIPsetConflicthdlrPriority(SCIP *scip, SCIP_CONFLICTHDLR *conflicthdlr, int priority)
SCIP_EXPORT SCIP_RETCODE SCIPlpiGetSol(SCIP_LPI *lpi, SCIP_Real *objval, SCIP_Real *primsol, SCIP_Real *dualsol, SCIP_Real *activity, SCIP_Real *redcost)
Definition: lpi_clp.cpp:2774
void SCIPvisualFoundConflict(SCIP_VISUAL *visual, SCIP_STAT *stat, SCIP_NODE *node)
Definition: visual.c:603
SCIP_RETCODE SCIPpqueueCreate(SCIP_PQUEUE **pqueue, int initsize, SCIP_Real sizefac, SCIP_DECL_SORTPTRCOMP((*ptrcomp)), SCIP_DECL_PQUEUEELEMCHGPOS((*elemchgpos)))
Definition: misc.c:1235
SCIP_EXPORT SCIP_CONS * SCIPbdchginfoGetInferCons(SCIP_BDCHGINFO *bdchginfo)
Definition: var.c:18336
SCIP_Longint SCIPconflictGetNBoundexceedingLPSuccess(SCIP_CONFLICT *conflict)
Definition: conflict.c:8890
SCIP_RETCODE SCIPaggrRowAddObjectiveFunction(SCIP *scip, SCIP_AGGRROW *aggrrow, SCIP_Real rhs, SCIP_Real scale)
Definition: cuts.c:1863
SCIP_RETCODE SCIPaggrRowAddRow(SCIP *scip, SCIP_AGGRROW *aggrrow, SCIP_ROW *row, SCIP_Real weight, int sidetype)
Definition: cuts.c:1719
SCIP_LPSOLSTAT lpsolstat
Definition: struct_lp.h:109
unsigned int boundtype
Definition: struct_var.h:115
public methods for solutions
SCIP_Longint lastconflictnode
Definition: struct_stat.h:103
internal methods for conflict analysis
#define SCIPsetFreeCleanBufferArray(set, ptr)
Definition: set.h:1699
static SCIP_RETCODE conflictAddConflictCons(SCIP_CONFLICT *conflict, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, SCIP_CLIQUETABLE *cliquetable, SCIP_CONFLICTSET *conflictset, int insertdepth, SCIP_Bool *success)
Definition: conflict.c:3361
void ** SCIPpqueueElems(SCIP_PQUEUE *pqueue)
Definition: misc.c:1478
static const SCIP_Real scalars[]
Definition: lp.c:5731
SCIP_Longint nsbsuccess
int lpipos
Definition: struct_lp.h:164
SCIP_EXPORT SCIP_Bool SCIPlpiIsOptimal(SCIP_LPI *lpi)
Definition: lpi_clp.cpp:2609
static int * proofsetGetInds(SCIP_PROOFSET *proofset)
Definition: conflict.c:1013
void SCIPsetSortConflicthdlrs(SCIP_SET *set)
Definition: set.c:4014
SCIP_RETCODE SCIPnodeAddBoundchg(SCIP_NODE *node, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, SCIP_CLIQUETABLE *cliquetable, SCIP_VAR *var, SCIP_Real newbound, SCIP_BOUNDTYPE boundtype, SCIP_Bool probingchange)
Definition: tree.c:2075
static SCIP_RETCODE conflictAnalyzeInfeasibleLP(SCIP_CONFLICT *conflict, SCIP_CONFLICTSTORE *conflictstore, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, SCIP_CLIQUETABLE *cliquetable, SCIP_Bool *success)
Definition: conflict.c:8488
unsigned int redundant
Definition: struct_var.h:117
public methods for conflict analysis handlers
SCIP_RETCODE SCIPcalcFlowCover(SCIP *scip, SCIP_SOL *sol, SCIP_Bool postprocess, SCIP_Real boundswitch, SCIP_Bool allowlocal, SCIP_AGGRROW *aggrrow, SCIP_Real *cutcoefs, SCIP_Real *cutrhs, int *cutinds, int *cutnnz, SCIP_Real *cutefficacy, int *cutrank, SCIP_Bool *cutislocal, SCIP_Bool *success)
Definition: cuts.c:7480
static SCIP_RETCODE ensureCandsSize(SCIP_SET *set, SCIP_VAR ***cands, SCIP_Real **candscores, SCIP_Real **newbounds, SCIP_Real **proofactdeltas, int *candssize, int num)
Definition: conflict.c:5958
SCIP_Longint nsbreconvliterals
SCIP_EXPORT SCIP_Real SCIPvarGetLbGlobal(SCIP_VAR *var)
Definition: var.c:17662
static void conflictsetFree(SCIP_CONFLICTSET **conflictset, BMS_BLKMEM *blkmem)
Definition: conflict.c:1342
SCIP_Longint nboundlpconfliterals
SCIP_Bool flushed
Definition: struct_lp.h:356
SCIP_EXPORT int SCIPvarGetMultaggrNVars(SCIP_VAR *var)
Definition: var.c:17430
int nrows
Definition: struct_lp.h:324
static SCIP_RETCODE conflictInsertConflictset(SCIP_CONFLICT *conflict, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_CONFLICTSET **conflictset)
Definition: conflict.c:1980
SCIP_VAR * var
Definition: struct_var.h:110
public methods for message output
SCIP_RETCODE SCIPconflictInit(SCIP_CONFLICT *conflict, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_CONFTYPE conftype, SCIP_Bool usescutoffbound)
Definition: conflict.c:4013
data structures for LP management
#define USEVBDS
Definition: conflict.c:165
SCIP_Real * conflictsetscores
SCIP_EXPORT SCIP_BDCHGINFO * SCIPvarGetBdchgInfoLb(SCIP_VAR *var, int pos)
Definition: var.c:18062
int SCIPsnprintf(char *t, int len, const char *s,...)
Definition: misc.c:10590
SCIP_RETCODE SCIPconflictAddRelaxedBound(SCIP_CONFLICT *conflict, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_VAR *var, SCIP_BOUNDTYPE boundtype, SCIP_BDCHGIDX *bdchgidx, SCIP_Real relaxedbd)
Definition: conflict.c:4432
SCIP_Bool SCIPsetIsGT(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6056
datastructures for problem variables
const char * SCIPconsGetName(SCIP_CONS *cons)
Definition: cons.c:8089
static SCIP_RETCODE addBdchg(SCIP_SET *set, SCIP_VAR *var, SCIP_Real newlb, SCIP_Real newub, SCIP_LPBDCHGS *oldlpbdchgs, SCIP_LPBDCHGS *relaxedlpbdchgs, SCIP_LPI *lpi)
Definition: conflict.c:5877
SCIP_Real lpobjval
Definition: struct_lp.h:261
SCIP_Real primsol
Definition: struct_lp.h:86
#define SCIP_Real
Definition: def.h:163
static SCIP_RETCODE addRowToAggrRow(SCIP_SET *set, SCIP_ROW *row, SCIP_Real weight, SCIP_AGGRROW *aggrrow)
Definition: conflict.c:6634
SCIP_Bool solisbasic
Definition: struct_lp.h:115
SCIP_VAR ** vars
Definition: struct_prob.h:55
enum SCIP_ConflictType SCIP_CONFTYPE
Definition: type_conflict.h:56
SCIP_Longint npseudocalls
SCIP_Real lpiobjlim
Definition: struct_lp.h:276
SCIP_CONSHDLR * SCIPconsGetHdlr(SCIP_CONS *cons)
Definition: cons.c:8109
SCIP_Longint SCIPconflictGetNStrongbranchCalls(SCIP_CONFLICT *conflict)
Definition: conflict.c:9284
SCIP_Longint SCIPconflictGetNInfeasibleLPIterations(SCIP_CONFLICT *conflict)
Definition: conflict.c:8860
SCIP_Real SCIPconflictGetVarLb(SCIP_CONFLICT *conflict, SCIP_VAR *var)
Definition: conflict.c:4656
SCIP_EXPORT SCIP_Bool SCIPlpiWasSolved(SCIP_LPI *lpi)
Definition: lpi_clp.cpp:2372
#define SCIPsetDebugMsgPrint
Definition: set.h:1722
const char * SCIProwGetName(SCIP_ROW *row)
Definition: lp.c:17200
SCIP_RETCODE SCIPconflictFlushConss(SCIP_CONFLICT *conflict, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, SCIP_CLIQUETABLE *cliquetable)
Definition: conflict.c:3512
SCIP_VAR ** SCIPprobGetVars(SCIP_PROB *prob)
Definition: prob.c:2363
SCIP_RETCODE SCIPconflictIsVarUsed(SCIP_CONFLICT *conflict, SCIP_VAR *var, SCIP_SET *set, SCIP_BOUNDTYPE boundtype, SCIP_BDCHGIDX *bdchgidx, SCIP_Bool *used)
Definition: conflict.c:4596
#define BMSallocMemory(ptr)
Definition: memory.h:111
#define SCIP_INVALID
Definition: def.h:183
#define BMSreallocMemoryArray(ptr, num)
Definition: memory.h:119
SCIP_CLOCK * dIBclock
#define SCIP_DECL_CONFLICTINIT(x)
Definition: type_conflict.h:93
internal methods for constraints and constraint handlers
static SCIP_Bool checkRedundancy(SCIP_SET *set, SCIP_CONFLICTSET *conflictset)
Definition: conflict.c:2177
SCIP_EXPORT SCIP_BDCHGINFO * SCIPvarGetBdchgInfo(SCIP_VAR *var, SCIP_BOUNDTYPE boundtype, SCIP_BDCHGIDX *bdchgidx, SCIP_Bool after)
Definition: var.c:16282
#define SCIPquadprecSumDD(r, a, b)
Definition: dbldblarith.h:51
SCIP_Real primsol
Definition: struct_lp.h:139
SCIP_Longint nsbiterations
SCIP_Longint SCIPconflictGetNAppliedGlobalLiterals(SCIP_CONFLICT *conflict)
Definition: conflict.c:3771
SCIP_Longint nboundlpconfconss
static SCIP_RETCODE conflictAnalyze(SCIP_CONFLICT *conflict, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_TREE *tree, SCIP_Bool diving, int validdepth, SCIP_Bool mustresolve, int *nconss, int *nliterals, int *nreconvconss, int *nreconvliterals)
Definition: conflict.c:5336
int SCIPconflictstoreGetNDualBndProofs(SCIP_CONFLICTSTORE *conflictstore)
SCIP_RETCODE SCIPnodeAddCons(SCIP_NODE *node, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_TREE *tree, SCIP_CONS *cons)
Definition: tree.c:1596
#define SCIP_Longint
Definition: def.h:148
SCIP_Bool SCIPsetIsDualfeasZero(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6699
const char * SCIPconshdlrGetName(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4179
void SCIPconflicthdlrEnableOrDisableClocks(SCIP_CONFLICTHDLR *conflicthdlr, SCIP_Bool enable)
Definition: conflict.c:817
SCIP_Bool SCIPsetIsFeasGT(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6444
SCIP_Longint npseudoconfconss
SCIP_Real SCIPconflictstoreGetAvgNnzDualInfProofs(SCIP_CONFLICTSTORE *conflictstore)
SCIP_Bool dualfeasible
Definition: struct_lp.h:360
SCIP_Real SCIPgetVarBdAtIndex(SCIP *scip, SCIP_VAR *var, SCIP_BOUNDTYPE boundtype, SCIP_BDCHGIDX *bdchgidx, SCIP_Bool after)
Definition: scip_var.c:2268
SCIP_EXPORT SCIP_RETCODE SCIPlpiSolveDual(SCIP_LPI *lpi)
Definition: lpi_clp.cpp:1871
static void conflictFreeTmpBdchginfos(SCIP_CONFLICT *conflict, BMS_BLKMEM *blkmem)
Definition: conflict.c:1252
SCIP_EXPORT int SCIPvarGetProbindex(SCIP_VAR *var)
Definition: var.c:17355
SCIP_EXPORT SCIP_RETCODE SCIPlpiGetIterations(SCIP_LPI *lpi, int *iterations)
Definition: lpi_clp.cpp:2907
enum SCIP_Vartype SCIP_VARTYPE
Definition: type_var.h:60
SCIP_Longint SCIPconflictGetNAppliedConss(SCIP_CONFLICT *conflict)
Definition: conflict.c:3731
SCIP_RETCODE SCIPupgradeConsLinear(SCIP *scip, SCIP_CONS *cons, SCIP_CONS **upgdcons)
static INLINE SCIP_Real SCIPaggrRowGetProbvarValue(SCIP_AGGRROW *aggrrow, int probindex)
Definition: cuts.h:240
SCIP_Real newbound
Definition: struct_var.h:109
SCIP_Longint SCIPconflictGetNBoundexceedingLPConflictLiterals(SCIP_CONFLICT *conflict)
Definition: conflict.c:8910
SCIP_RETCODE SCIPprobAddCons(SCIP_PROB *prob, SCIP_SET *set, SCIP_STAT *stat, SCIP_CONS *cons)
Definition: prob.c:1277
void SCIPbdchginfoFree(SCIP_BDCHGINFO **bdchginfo, BMS_BLKMEM *blkmem)
Definition: var.c:16156
SCIP_BDCHGINFO ** bdchginfos
void SCIPvarAdjustUb(SCIP_VAR *var, SCIP_SET *set, SCIP_Real *ub)
Definition: var.c:6338
#define BMSallocBlockMemory(mem, ptr)
Definition: memory.h:443
static int proofsetGetNVars(SCIP_PROOFSET *proofset)
Definition: conflict.c:1046
SCIP_Real SCIProwGetRhs(SCIP_ROW *row)
Definition: lp.c:17151
SCIP_Longint SCIPconflictGetNPropReconvergenceLiterals(SCIP_CONFLICT *conflict)
Definition: conflict.c:5751
static SCIP_RETCODE conflictAnalyzeLP(SCIP_CONFLICT *conflict, SCIP_CONFLICTSTORE *conflictstore, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, SCIP_CLIQUETABLE *cliquetable, SCIP_Bool diving, SCIP_Bool *dualproofsuccess, int *iterations, int *nconss, int *nliterals, int *nreconvconss, int *nreconvliterals, SCIP_Bool marklpunsolved)
Definition: conflict.c:8171
SCIP_EXPORT SCIP_RETCODE SCIPlpiGetRealpar(SCIP_LPI *lpi, SCIP_LPPARAM type, SCIP_Real *dval)
Definition: lpi_clp.cpp:3782
unsigned int usescutoffbound
static SCIP_Real getMaxActivity(SCIP_SET *set, SCIP_PROB *transprob, SCIP_Real *coefs, int *inds, int nnz, SCIP_Real *curvarlbs, SCIP_Real *curvarubs)
Definition: conflict.c:2794
static void tightenCoefficients(SCIP_SET *set, SCIP_PROOFSET *proofset, int *nchgcoefs, SCIP_Bool *redundant)
Definition: conflict.c:7338
SCIP_CONFLICTSET ** conflictsets
#define BMSclearMemoryArray(ptr, num)
Definition: memory.h:122
SCIP_Real SCIPconflictGetPropTime(SCIP_CONFLICT *conflict)
Definition: conflict.c:5691
SCIP_Longint nnodes
Definition: struct_stat.h:73
void SCIPinfoMessage(SCIP *scip, FILE *file, const char *formatstr,...)
Definition: scip_message.c:199
struct BMS_BlkMem BMS_BLKMEM
Definition: memory.h:429
SCIP_EXPORT int SCIPvarGetNCliques(SCIP_VAR *var, SCIP_Bool varfixing)
Definition: var.c:18014
SCIP_RETCODE SCIPvarGetProbvarSum(SCIP_VAR **var, SCIP_SET *set, SCIP_Real *scalar, SCIP_Real *constant)
Definition: var.c:12413
SCIP_Longint SCIPconflictGetNDualproofsInfLocal(SCIP_CONFLICT *conflict)
Definition: conflict.c:9224
#define SCIP_DECL_CONFLICTFREE(x)
Definition: type_conflict.h:85
SCIP_NODE * root
Definition: struct_tree.h:177
SCIP_RETCODE SCIPreleaseCons(SCIP *scip, SCIP_CONS **cons)
Definition: scip_cons.c:1110
static SCIP_RETCODE conflictResolveBound(SCIP_CONFLICT *conflict, SCIP_SET *set, SCIP_BDCHGINFO *bdchginfo, SCIP_Real relaxedbd, int validdepth, SCIP_Bool *resolved)
Definition: conflict.c:4886
void SCIPgmlWriteNode(FILE *file, unsigned int id, const char *label, const char *nodetype, const char *fillcolor, const char *bordercolor)
Definition: misc.c:486
SCIP_RETCODE SCIPconflicthdlrCopyInclude(SCIP_CONFLICTHDLR *conflicthdlr, SCIP_SET *set)
Definition: conflict.c:380
static SCIP_RETCODE conflictEnsureTmpbdchginfosMem(SCIP_CONFLICT *conflict, SCIP_SET *set, int num)
Definition: conflict.c:1204
SCIP_Bool primalfeasible
Definition: struct_lp.h:111
static SCIP_RETCODE conflictCreateReconvergenceConss(SCIP_CONFLICT *conflict, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_TREE *tree, SCIP_Bool diving, int validdepth, SCIP_BDCHGINFO *firstuip, int *nreconvconss, int *nreconvliterals)
Definition: conflict.c:5099
SCIP_Longint ndualproofsbndsuccess
#define SCIP_ALLOC(x)
Definition: def.h:375
#define SCIPABORT()
Definition: def.h:336
SCIP_LPSOLSTAT lpsolstat
Definition: struct_lp.h:343
SCIP_Longint SCIPconflictGetNDualproofsBndGlobal(SCIP_CONFLICT *conflict)
Definition: conflict.c:9254
const char * SCIPprobGetName(SCIP_PROB *prob)
Definition: prob.c:2309
int ncols
Definition: struct_lp.h:318
datastructures for global SCIP settings
static void conflictClear(SCIP_CONFLICT *conflict)
Definition: conflict.c:4001
static SCIP_Bool bdchginfoIsInvalid(SCIP_CONFLICT *conflict, SCIP_BDCHGINFO *bdchginfo)
Definition: conflict.c:1479
SCIP_Real lpobjval
Definition: struct_lp.h:110
SCIP_Longint nsbreconvconss
#define BMSreallocBlockMemoryArray(mem, ptr, oldnum, newnum)
Definition: memory.h:449
SCIP_EXPORT SCIP_Real SCIPvarGetAvgSol(SCIP_VAR *var)
Definition: var.c:13824
SCIP_EXPORT SCIP_Real SCIPbdchginfoGetOldbound(SCIP_BDCHGINFO *bdchginfo)
Definition: var.c:18244
SCIP_CONFLICTHDLRDATA * SCIPconflicthdlrGetData(SCIP_CONFLICTHDLR *conflicthdlr)
Definition: conflict.c:676
unsigned int local
Definition: struct_lp.h:249
static SCIP_Bool checkDualFeasibility(SCIP_SET *set, SCIP_ROW *row, SCIP_Real weight, SCIP_Bool *zerocontribution)
Definition: conflict.c:6666
SCIP_EXPORT SCIP_VAR ** SCIPvarGetMultaggrVars(SCIP_VAR *var)
Definition: var.c:17442
SCIP_EXPORT SCIP_BDCHGIDX * SCIPbdchginfoGetIdx(SCIP_BDCHGINFO *bdchginfo)
Definition: var.c:18314
SCIP_EXPORT SCIP_Real SCIPbdchginfoGetNewbound(SCIP_BDCHGINFO *bdchginfo)
Definition: var.c:18254
SCIP_Real activity
Definition: struct_lp.h:205
SCIP_Bool * usedcols
int len
Definition: struct_lp.h:226
int SCIPaggrRowGetNNz(SCIP_AGGRROW *aggrrow)
Definition: cuts.c:2400
SCIP_EXPORT int SCIPvarGetNVlbs(SCIP_VAR *var)
Definition: var.c:17854
static SCIP_RETCODE proofsetAddSparseData(SCIP_PROOFSET *proofset, BMS_BLKMEM *blkmem, SCIP_Real *vals, int *inds, int nnz, SCIP_Real rhs)
Definition: conflict.c:1068
SCIP_EXPORT int SCIPvarGetIndex(SCIP_VAR *var)
Definition: var.c:17345
int SCIPcolGetLPPos(SCIP_COL *col)
Definition: lp.c:16942
SCIP_BDCHGINFO * lbchginfos
Definition: struct_var.h:242
public methods for propagators
SCIP_Longint ninflpsuccess
#define SCIP_DECL_CONFLICTEXITSOL(x)
SCIP_RETCODE SCIPconsResolvePropagation(SCIP_CONS *cons, SCIP_SET *set, SCIP_VAR *infervar, int inferinfo, SCIP_BOUNDTYPE inferboundtype, SCIP_BDCHGIDX *bdchgidx, SCIP_Real relaxedbd, SCIP_RESULT *result)
Definition: cons.c:7193
SCIP_RETCODE SCIPpqueueInsert(SCIP_PQUEUE *pqueue, void *elem)
Definition: misc.c:1334
static SCIP_RETCODE tightenDualproof(SCIP_CONFLICT *conflict, SCIP_SET *set, SCIP_STAT *stat, BMS_BLKMEM *blkmem, SCIP_PROB *transprob, SCIP_TREE *tree, SCIP_AGGRROW *proofrow, int validdepth, SCIP_Real *curvarlbs, SCIP_Real *curvarubs, SCIP_Bool initialproof)
Definition: conflict.c:7511
static SCIP_Real proofsetGetRhs(SCIP_PROOFSET *proofset)
Definition: conflict.c:1035