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-2023 Zuse Institute Berlin (ZIB) */
7 /* */
8 /* Licensed under the Apache License, Version 2.0 (the "License"); */
9 /* you may not use this file except in compliance with the License. */
10 /* You may obtain a copy of the License at */
11 /* */
12 /* http://www.apache.org/licenses/LICENSE-2.0 */
13 /* */
14 /* Unless required by applicable law or agreed to in writing, software */
15 /* distributed under the License is distributed on an "AS IS" BASIS, */
16 /* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
17 /* See the License for the specific language governing permissions and */
18 /* limitations under the License. */
19 /* */
20 /* You should have received a copy of the Apache-2.0 license */
21 /* along with SCIP; see the file LICENSE. If not visit scipopt.org. */
22 /* */
23 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
24 /**@file conflict.c
25  * @ingroup OTHER_CFILES
26  * @brief methods and datastructures for conflict analysis
27  * @author Tobias Achterberg
28  * @author Timo Berthold
29  * @author Stefan Heinz
30  * @author Marc Pfetsch
31  * @author Michael Winkler
32  * @author Jakob Witzig
33  *
34  * This file implements a conflict analysis method like the one used in modern
35  * SAT solvers like zchaff. The algorithm works as follows:
36  *
37  * Given is a set of bound changes that are not allowed being applied simultaneously, because they
38  * render the current node infeasible (e.g. because a single constraint is infeasible in the these
39  * bounds, or because the LP relaxation is infeasible). The goal is to deduce a clause on variables
40  * -- a conflict clause -- representing the "reason" for this conflict, i.e., the branching decisions
41  * or the deductions (applied e.g. in domain propagation) that lead to the conflict. This clause can
42  * then be added to the constraint set to help cutting off similar parts of the branch and bound
43  * tree, that would lead to the same conflict. A conflict clause can also be generated, if the
44  * conflict was detected by a locally valid constraint. In this case, the resulting conflict clause
45  * is also locally valid in the same depth as the conflict detecting constraint. If all involved
46  * variables are binary, a linear (set covering) constraint can be generated, otherwise a bound
47  * disjunction constraint is generated. Details are given in
48  *
49  * Tobias Achterberg, Conflict Analysis in Mixed Integer Programming@n
50  * Discrete Optimization, 4, 4-20 (2007)
51  *
52  * See also @ref CONF. Here is an outline of the algorithm:
53  *
54  * -# Put all the given bound changes to a priority queue, which is ordered,
55  * such that the bound change that was applied last due to branching or deduction
56  * is at the top of the queue. The variables in the queue are always active
57  * problem variables. Because binary variables are preferred over general integer
58  * variables, integer variables are put on the priority queue prior to the binary
59  * variables. Create an empty conflict set.
60  * -# Remove the top bound change b from the priority queue.
61  * -# Perform the following case distinction:
62  * -# If the remaining queue is non-empty, and bound change b' (the one that is now
63  * on the top of the queue) was applied at the same depth level as b, and if
64  * b was a deduction with known inference reason, and if the inference constraint's
65  * valid depth is smaller or equal to the conflict detecting constraint's valid
66  * depth:
67  * - Resolve bound change b by asking the constraint that inferred the
68  * bound change to put all the bound changes on the priority queue, that
69  * lead to the deduction of b.
70  * Note that these bound changes have at most the same inference depth
71  * level as b, and were deduced earlier than b.
72  * -# Otherwise, the bound change b was a branching decision or a deduction with
73  * missing inference reason, or the inference constraint's validity is more local
74  * than the one of the conflict detecting constraint.
75  * - If a the bound changed corresponds to a binary variable, add it or its
76  * negation to the conflict set, depending on which of them is currently fixed to
77  * FALSE (i.e., the conflict set consists of literals that cannot be FALSE
78  * altogether at the same time).
79  * - Otherwise put the bound change into the conflict set.
80  * Note that if the bound change was a branching, all deduced bound changes
81  * remaining in the priority queue have smaller inference depth level than b,
82  * since deductions are always applied after the branching decisions. However,
83  * there is the possibility, that b was a deduction, where the inference
84  * reason was not given or the inference constraint was too local.
85  * With this lack of information, we must treat the deduced bound change like
86  * a branching, and there may exist other deduced bound changes of the same
87  * inference depth level in the priority queue.
88  * -# If priority queue is non-empty, goto step 2.
89  * -# The conflict set represents the conflict clause saying that at least one
90  * of the conflict variables must take a different value. The conflict set is then passed
91  * to the conflict handlers, that may create a corresponding constraint (e.g. a logicor
92  * constraint or bound disjunction constraint) out of these conflict variables and
93  * add it to the problem.
94  *
95  * If all deduced bound changes come with (global) inference information, depending on
96  * the conflict analyzing strategy, the resulting conflict set has the following property:
97  * - 1-FirstUIP: In the depth level where the conflict was found, at most one variable
98  * assigned at that level is member of the conflict set. This conflict variable is the
99  * first unique implication point of its depth level (FUIP).
100  * - All-FirstUIP: For each depth level, at most one variable assigned at that level is
101  * member of the conflict set. This conflict variable is the first unique implication
102  * point of its depth level (FUIP).
103  *
104  * The user has to do the following to get the conflict analysis running in its
105  * current implementation:
106  * - A constraint handler or propagator supporting the conflict analysis must implement
107  * the CONSRESPROP/PROPRESPROP call, that processes a bound change inference b and puts all
108  * the reason bounds leading to the application of b with calls to
109  * SCIPaddConflictBound() on the conflict queue (algorithm step 3.(a)).
110  * - If the current bounds lead to a deduction of a bound change (e.g. in domain
111  * propagation), a constraint handler should call SCIPinferVarLbCons() or
112  * SCIPinferVarUbCons(), thus providing the constraint that inferred the bound change.
113  * A propagator should call SCIPinferVarLbProp() or SCIPinferVarUbProp() instead,
114  * thus providing a pointer to itself.
115  * - If (in the current bounds) an infeasibility is detected, the constraint handler or
116  * propagator should
117  * 1. call SCIPinitConflictAnalysis() to initialize the conflict queue,
118  * 2. call SCIPaddConflictBound() for each bound that lead to the conflict,
119  * 3. call SCIPanalyzeConflictCons() or SCIPanalyzeConflict() to analyze the conflict
120  * and add an appropriate conflict constraint.
121  */
122 
123 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
124 
125 #include "lpi/lpi.h"
126 #include "scip/clock.h"
127 #include "scip/conflict.h"
128 #include "scip/conflictstore.h"
129 #include "scip/cons.h"
130 #include "scip/cons_linear.h"
131 #include "scip/cuts.h"
132 #include "scip/history.h"
133 #include "scip/lp.h"
134 #include "scip/presolve.h"
135 #include "scip/prob.h"
136 #include "scip/prop.h"
137 #include "scip/pub_conflict.h"
138 #include "scip/pub_cons.h"
139 #include "scip/pub_lp.h"
140 #include "scip/pub_message.h"
141 #include "scip/pub_misc.h"
142 #include "scip/pub_misc_sort.h"
143 #include "scip/pub_paramset.h"
144 #include "scip/pub_prop.h"
145 #include "scip/pub_tree.h"
146 #include "scip/pub_var.h"
147 #include "scip/scip_conflict.h"
148 #include "scip/scip_cons.h"
149 #include "scip/scip_mem.h"
150 #include "scip/scip_sol.h"
151 #include "scip/scip_var.h"
152 #include "scip/set.h"
153 #include "scip/sol.h"
154 #include "scip/struct_conflict.h"
155 #include "scip/struct_lp.h"
156 #include "scip/struct_prob.h"
157 #include "scip/struct_set.h"
158 #include "scip/struct_stat.h"
159 #include "scip/struct_tree.h"
160 #include "scip/struct_var.h"
161 #include "scip/tree.h"
162 #include "scip/var.h"
163 #include "scip/visual.h"
164 #include <string.h>
165 #if defined(_WIN32) || defined(_WIN64)
166 #else
167 #include <strings.h> /*lint --e{766}*/
168 #endif
169 
170 
171 
172 #define BOUNDSWITCH 0.51 /**< threshold for bound switching - see cuts.c */
173 #define POSTPROCESS FALSE /**< apply postprocessing to the cut - see cuts.c */
174 #define USEVBDS FALSE /**< use variable bounds - see cuts.c */
175 #define ALLOWLOCAL FALSE /**< allow to generate local cuts - see cuts. */
176 #define MINFRAC 0.05 /**< minimal fractionality of floor(rhs) - see cuts.c */
177 #define MAXFRAC 0.999 /**< maximal fractionality of floor(rhs) - see cuts.c */
178 
179 /*#define SCIP_CONFGRAPH*/
180 
181 
182 #ifdef SCIP_CONFGRAPH
183 /*
184  * Output of Conflict Graph
185  */
186 
187 #include <stdio.h>
188 
189 static FILE* confgraphfile = NULL; /**< output file for current conflict graph */
190 static SCIP_BDCHGINFO* confgraphcurrentbdchginfo = NULL; /**< currently resolved bound change */
191 static int confgraphnconflictsets = 0; /**< number of conflict sets marked in the graph */
192 
193 /** writes a node section to the conflict graph file */
194 static
195 void confgraphWriteNode(
196  void* idptr, /**< id of the node */
197  const char* label, /**< label of the node */
198  const char* nodetype, /**< type of the node */
199  const char* fillcolor, /**< color of the node's interior */
200  const char* bordercolor /**< color of the node's border */
201  )
202 {
203  assert(confgraphfile != NULL);
204 
205  SCIPgmlWriteNode(confgraphfile, (unsigned int)(size_t)idptr, label, nodetype, fillcolor, bordercolor);
206 }
207 
208 /** writes an edge section to the conflict graph file */
209 static
210 void confgraphWriteEdge(
211  void* source, /**< source node of the edge */
212  void* target, /**< target node of the edge */
213  const char* color /**< color of the edge */
214  )
215 {
216  assert(confgraphfile != NULL);
217 
218 #ifndef SCIP_CONFGRAPH_EDGE
219  SCIPgmlWriteArc(confgraphfile, (unsigned int)(size_t)source, (unsigned int)(size_t)target, NULL, color);
220 #else
221  SCIPgmlWriteEdge(confgraphfile, (unsigned int)(size_t)source, (unsigned int)(size_t)target, NULL, color);
222 #endif
223 }
224 
225 /** creates a file to output the current conflict graph into; adds the conflict vertex to the graph */
226 static
227 SCIP_RETCODE confgraphCreate(
228  SCIP_SET* set, /**< global SCIP settings */
229  SCIP_CONFLICT* conflict /**< conflict analysis data */
230  )
231 {
232  char fname[SCIP_MAXSTRLEN];
233 
234  assert(conflict != NULL);
235  assert(confgraphfile == NULL);
236 
237  (void) SCIPsnprintf(fname, SCIP_MAXSTRLEN, "conf%p%d.gml", conflict, conflict->count);
238  SCIPinfoMessage(set->scip, NULL, "storing conflict graph in file <%s>\n", fname);
239 
240  confgraphfile = fopen(fname, "w");
241 
242  if( confgraphfile == NULL )
243  {
244  SCIPerrorMessage("cannot open graph file <%s>\n", fname);
245  SCIPABORT(); /*lint !e527*/
246  return SCIP_WRITEERROR;
247  }
248 
249  SCIPgmlWriteOpening(confgraphfile, TRUE);
250 
251  confgraphWriteNode(NULL, "conflict", "ellipse", "#ff0000", "#000000");
252 
253  confgraphcurrentbdchginfo = NULL;
254 
255  return SCIP_OKAY;
256 }
257 
258 /** closes conflict graph file */
259 static
260 void confgraphFree(
261  void
262  )
263 {
264  if( confgraphfile != NULL )
265  {
266  SCIPgmlWriteClosing(confgraphfile);
267 
268  fclose(confgraphfile);
269 
270  confgraphfile = NULL;
271  confgraphnconflictsets = 0;
272  }
273 }
274 
275 /** adds a bound change node to the conflict graph and links it to the currently resolved bound change */
276 static
277 void confgraphAddBdchg(
278  SCIP_BDCHGINFO* bdchginfo /**< bound change to add to the conflict graph */
279  )
280 {
281  const char* colors[] = {
282  "#8888ff", /* blue for constraint resolving */
283  "#ffff00", /* yellow for propagator resolving */
284  "#55ff55" /* green branching decision */
285  };
286  char label[SCIP_MAXSTRLEN];
287  char depth[SCIP_MAXSTRLEN];
288  int col;
289 
290  switch( SCIPbdchginfoGetChgtype(bdchginfo) )
291  {
293  col = 2;
294  break;
296  col = 0;
297  break;
299  col = (SCIPbdchginfoGetInferProp(bdchginfo) == NULL ? 1 : 0);
300  break;
301  default:
302  SCIPerrorMessage("invalid bound change type\n");
303  col = 0;
304  SCIPABORT();
305  break;
306  }
307 
308  if( SCIPbdchginfoGetDepth(bdchginfo) == INT_MAX )
309  (void) SCIPsnprintf(depth, SCIP_MAXSTRLEN, "dive");
310  else
311  (void) SCIPsnprintf(depth, SCIP_MAXSTRLEN, "%d", SCIPbdchginfoGetDepth(bdchginfo));
312  (void) SCIPsnprintf(label, SCIP_MAXSTRLEN, "%s %s %g\n[%s:%d]", SCIPvarGetName(SCIPbdchginfoGetVar(bdchginfo)),
313  SCIPbdchginfoGetBoundtype(bdchginfo) == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=",
314  SCIPbdchginfoGetNewbound(bdchginfo), depth, SCIPbdchginfoGetPos(bdchginfo));
315  confgraphWriteNode(bdchginfo, label, "ellipse", colors[col], "#000000");
316  confgraphWriteEdge(bdchginfo, confgraphcurrentbdchginfo, "#000000");
317 }
318 
319 /** links the already existing bound change node to the currently resolved bound change */
320 static
321 void confgraphLinkBdchg(
322  SCIP_BDCHGINFO* bdchginfo /**< bound change to add to the conflict graph */
323  )
324 {
325  confgraphWriteEdge(bdchginfo, confgraphcurrentbdchginfo, "#000000");
326 }
327 
328 /** marks the given bound change to be the currently resolved bound change */
329 static
330 void confgraphSetCurrentBdchg(
331  SCIP_BDCHGINFO* bdchginfo /**< bound change to add to the conflict graph */
332  )
333 {
334  confgraphcurrentbdchginfo = bdchginfo;
335 }
336 
337 /** marks given conflict set in the conflict graph */
338 static
339 void confgraphMarkConflictset(
340  SCIP_CONFLICTSET* conflictset /**< conflict set */
341  )
342 {
343  char label[SCIP_MAXSTRLEN];
344  int i;
345 
346  assert(conflictset != NULL);
347 
348  confgraphnconflictsets++;
349  (void) SCIPsnprintf(label, SCIP_MAXSTRLEN, "conf %d (%d)", confgraphnconflictsets, conflictset->validdepth);
350  confgraphWriteNode((void*)(size_t)confgraphnconflictsets, label, "rectangle", "#ff00ff", "#000000");
351  for( i = 0; i < conflictset->nbdchginfos; ++i )
352  confgraphWriteEdge((void*)(size_t)confgraphnconflictsets, conflictset->bdchginfos[i], "#ff00ff");
353 }
354 
355 #endif
356 
357 /*
358  * Conflict Handler
359  */
360 
361 /** compares two conflict handlers w. r. to their priority */
362 SCIP_DECL_SORTPTRCOMP(SCIPconflicthdlrComp)
363 { /*lint --e{715}*/
364  return ((SCIP_CONFLICTHDLR*)elem2)->priority - ((SCIP_CONFLICTHDLR*)elem1)->priority;
365 }
366 
367 /** comparison method for sorting conflict handler w.r.t. to their name */
368 SCIP_DECL_SORTPTRCOMP(SCIPconflicthdlrCompName)
369 {
371 }
372 
373 /** method to call, when the priority of a conflict handler was changed */
374 static
375 SCIP_DECL_PARAMCHGD(paramChgdConflicthdlrPriority)
376 { /*lint --e{715}*/
377  SCIP_PARAMDATA* paramdata;
378 
379  paramdata = SCIPparamGetData(param);
380  assert(paramdata != NULL);
381 
382  /* use SCIPsetConflicthdlrPriority() to mark the conflicthdlrs unsorted */
383  SCIP_CALL( SCIPsetConflicthdlrPriority(scip, (SCIP_CONFLICTHDLR*)paramdata, SCIPparamGetInt(param)) ); /*lint !e740*/
384 
385  return SCIP_OKAY;
386 }
387 
388 /** copies the given conflict handler to a new scip */
390  SCIP_CONFLICTHDLR* conflicthdlr, /**< conflict handler */
391  SCIP_SET* set /**< SCIP_SET of SCIP to copy to */
392  )
393 {
394  assert(conflicthdlr != NULL);
395  assert(set != NULL);
396  assert(set->scip != NULL);
397 
398  if( conflicthdlr->conflictcopy != NULL )
399  {
400  SCIPsetDebugMsg(set, "including conflict handler %s in subscip %p\n", SCIPconflicthdlrGetName(conflicthdlr), (void*)set->scip);
401  SCIP_CALL( conflicthdlr->conflictcopy(set->scip, conflicthdlr) );
402  }
403 
404  return SCIP_OKAY;
405 }
406 
407 /** internal method for creating a conflict handler */
408 static
410  SCIP_CONFLICTHDLR** conflicthdlr, /**< pointer to conflict handler data structure */
411  SCIP_SET* set, /**< global SCIP settings */
412  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
413  BMS_BLKMEM* blkmem, /**< block memory for parameter settings */
414  const char* name, /**< name of conflict handler */
415  const char* desc, /**< description of conflict handler */
416  int priority, /**< priority of the conflict handler */
417  SCIP_DECL_CONFLICTCOPY((*conflictcopy)), /**< copy method of conflict handler or NULL if you don't want to copy your plugin into sub-SCIPs */
418  SCIP_DECL_CONFLICTFREE((*conflictfree)), /**< destructor of conflict handler */
419  SCIP_DECL_CONFLICTINIT((*conflictinit)), /**< initialize conflict handler */
420  SCIP_DECL_CONFLICTEXIT((*conflictexit)), /**< deinitialize conflict handler */
421  SCIP_DECL_CONFLICTINITSOL((*conflictinitsol)),/**< solving process initialization method of conflict handler */
422  SCIP_DECL_CONFLICTEXITSOL((*conflictexitsol)),/**< solving process deinitialization method of conflict handler */
423  SCIP_DECL_CONFLICTEXEC((*conflictexec)), /**< conflict processing method of conflict handler */
424  SCIP_CONFLICTHDLRDATA* conflicthdlrdata /**< conflict handler data */
425  )
426 {
428  char paramdesc[SCIP_MAXSTRLEN];
429 
430  assert(conflicthdlr != NULL);
431  assert(name != NULL);
432  assert(desc != NULL);
433 
434  SCIP_ALLOC( BMSallocMemory(conflicthdlr) );
435  BMSclearMemory(*conflicthdlr);
436 
437  SCIP_ALLOC( BMSduplicateMemoryArray(&(*conflicthdlr)->name, name, strlen(name)+1) );
438  SCIP_ALLOC( BMSduplicateMemoryArray(&(*conflicthdlr)->desc, desc, strlen(desc)+1) );
439  (*conflicthdlr)->priority = priority;
440  (*conflicthdlr)->conflictcopy = conflictcopy;
441  (*conflicthdlr)->conflictfree = conflictfree;
442  (*conflicthdlr)->conflictinit = conflictinit;
443  (*conflicthdlr)->conflictexit = conflictexit;
444  (*conflicthdlr)->conflictinitsol = conflictinitsol;
445  (*conflicthdlr)->conflictexitsol = conflictexitsol;
446  (*conflicthdlr)->conflictexec = conflictexec;
447  (*conflicthdlr)->conflicthdlrdata = conflicthdlrdata;
448  (*conflicthdlr)->initialized = FALSE;
449 
450  SCIP_CALL( SCIPclockCreate(&(*conflicthdlr)->setuptime, SCIP_CLOCKTYPE_DEFAULT) );
451  SCIP_CALL( SCIPclockCreate(&(*conflicthdlr)->conflicttime, SCIP_CLOCKTYPE_DEFAULT) );
452 
453  /* add parameters */
454  (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "conflict/%s/priority", name);
455  (void) SCIPsnprintf(paramdesc, SCIP_MAXSTRLEN, "priority of conflict handler <%s>", name);
456  SCIP_CALL( SCIPsetAddIntParam(set, messagehdlr, blkmem, paramname, paramdesc, &(*conflicthdlr)->priority, TRUE, \
457  priority, INT_MIN, INT_MAX, paramChgdConflicthdlrPriority, (SCIP_PARAMDATA*)(*conflicthdlr)) ); /*lint !e740*/
458 
459  return SCIP_OKAY;
460 }
461 
462 /** creates a conflict handler */
464  SCIP_CONFLICTHDLR** conflicthdlr, /**< pointer to conflict handler data structure */
465  SCIP_SET* set, /**< global SCIP settings */
466  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
467  BMS_BLKMEM* blkmem, /**< block memory for parameter settings */
468  const char* name, /**< name of conflict handler */
469  const char* desc, /**< description of conflict handler */
470  int priority, /**< priority of the conflict handler */
471  SCIP_DECL_CONFLICTCOPY((*conflictcopy)), /**< copy method of conflict handler or NULL if you don't want to
472  * copy your plugin into sub-SCIPs */
473  SCIP_DECL_CONFLICTFREE((*conflictfree)), /**< destructor of conflict handler */
474  SCIP_DECL_CONFLICTINIT((*conflictinit)), /**< initialize conflict handler */
475  SCIP_DECL_CONFLICTEXIT((*conflictexit)), /**< deinitialize conflict handler */
476  SCIP_DECL_CONFLICTINITSOL((*conflictinitsol)),/**< solving process initialization method of conflict handler */
477  SCIP_DECL_CONFLICTEXITSOL((*conflictexitsol)),/**< solving process deinitialization method of conflict handler */
478  SCIP_DECL_CONFLICTEXEC((*conflictexec)), /**< conflict processing method of conflict handler */
479  SCIP_CONFLICTHDLRDATA* conflicthdlrdata /**< conflict handler data */
480  )
481 {
482  assert(conflicthdlr != NULL);
483  assert(name != NULL);
484  assert(desc != NULL);
485 
486  SCIP_CALL_FINALLY( doConflicthdlrCreate(conflicthdlr, set, messagehdlr, blkmem, name, desc, priority,
487  conflictcopy, conflictfree, conflictinit, conflictexit, conflictinitsol, conflictexitsol, conflictexec,
488  conflicthdlrdata), (void) SCIPconflicthdlrFree(conflicthdlr, set) );
489 
490  return SCIP_OKAY;
491 }
492 
493 /** calls destructor and frees memory of conflict handler */
495  SCIP_CONFLICTHDLR** conflicthdlr, /**< pointer to conflict handler data structure */
496  SCIP_SET* set /**< global SCIP settings */
497  )
498 {
499  assert(conflicthdlr != NULL);
500  if( *conflicthdlr == NULL )
501  return SCIP_OKAY;
502  assert(!(*conflicthdlr)->initialized);
503  assert(set != NULL);
504 
505  /* call destructor of conflict handler */
506  if( (*conflicthdlr)->conflictfree != NULL )
507  {
508  SCIP_CALL( (*conflicthdlr)->conflictfree(set->scip, *conflicthdlr) );
509  }
510 
511  SCIPclockFree(&(*conflicthdlr)->conflicttime);
512  SCIPclockFree(&(*conflicthdlr)->setuptime);
513 
514  BMSfreeMemoryArrayNull(&(*conflicthdlr)->name);
515  BMSfreeMemoryArrayNull(&(*conflicthdlr)->desc);
516  BMSfreeMemory(conflicthdlr);
517 
518  return SCIP_OKAY;
519 }
520 
521 /** calls initialization method of conflict handler */
523  SCIP_CONFLICTHDLR* conflicthdlr, /**< conflict handler */
524  SCIP_SET* set /**< global SCIP settings */
525  )
526 {
527  assert(conflicthdlr != NULL);
528  assert(set != NULL);
529 
530  if( conflicthdlr->initialized )
531  {
532  SCIPerrorMessage("conflict handler <%s> already initialized\n", conflicthdlr->name);
533  return SCIP_INVALIDCALL;
534  }
535 
536  if( set->misc_resetstat )
537  {
538  SCIPclockReset(conflicthdlr->setuptime);
539  SCIPclockReset(conflicthdlr->conflicttime);
540  }
541 
542  /* call initialization method of conflict handler */
543  if( conflicthdlr->conflictinit != NULL )
544  {
545  /* start timing */
546  SCIPclockStart(conflicthdlr->setuptime, set);
547 
548  SCIP_CALL( conflicthdlr->conflictinit(set->scip, conflicthdlr) );
549 
550  /* stop timing */
551  SCIPclockStop(conflicthdlr->setuptime, set);
552  }
553  conflicthdlr->initialized = TRUE;
554 
555  return SCIP_OKAY;
556 }
557 
558 /** calls exit method of conflict handler */
560  SCIP_CONFLICTHDLR* conflicthdlr, /**< conflict handler */
561  SCIP_SET* set /**< global SCIP settings */
562  )
563 {
564  assert(conflicthdlr != NULL);
565  assert(set != NULL);
566 
567  if( !conflicthdlr->initialized )
568  {
569  SCIPerrorMessage("conflict handler <%s> not initialized\n", conflicthdlr->name);
570  return SCIP_INVALIDCALL;
571  }
572 
573  /* call deinitialization method of conflict handler */
574  if( conflicthdlr->conflictexit != NULL )
575  {
576  /* start timing */
577  SCIPclockStart(conflicthdlr->setuptime, set);
578 
579  SCIP_CALL( conflicthdlr->conflictexit(set->scip, conflicthdlr) );
580 
581  /* stop timing */
582  SCIPclockStop(conflicthdlr->setuptime, set);
583  }
584  conflicthdlr->initialized = FALSE;
585 
586  return SCIP_OKAY;
587 }
588 
589 /** informs conflict handler that the branch and bound process is being started */
591  SCIP_CONFLICTHDLR* conflicthdlr, /**< conflict handler */
592  SCIP_SET* set /**< global SCIP settings */
593  )
594 {
595  assert(conflicthdlr != NULL);
596  assert(set != NULL);
597 
598  /* call solving process initialization method of conflict handler */
599  if( conflicthdlr->conflictinitsol != NULL )
600  {
601  /* start timing */
602  SCIPclockStart(conflicthdlr->setuptime, set);
603 
604  SCIP_CALL( conflicthdlr->conflictinitsol(set->scip, conflicthdlr) );
605 
606  /* stop timing */
607  SCIPclockStop(conflicthdlr->setuptime, set);
608  }
609 
610  return SCIP_OKAY;
611 }
612 
613 /** informs conflict handler that the branch and bound process data is being freed */
615  SCIP_CONFLICTHDLR* conflicthdlr, /**< conflict handler */
616  SCIP_SET* set /**< global SCIP settings */
617  )
618 {
619  assert(conflicthdlr != NULL);
620  assert(set != NULL);
621 
622  /* call solving process deinitialization method of conflict handler */
623  if( conflicthdlr->conflictexitsol != NULL )
624  {
625  /* start timing */
626  SCIPclockStart(conflicthdlr->setuptime, set);
627 
628  SCIP_CALL( conflicthdlr->conflictexitsol(set->scip, conflicthdlr) );
629 
630  /* stop timing */
631  SCIPclockStop(conflicthdlr->setuptime, set);
632  }
633 
634  return SCIP_OKAY;
635 }
636 
637 /** calls execution method of conflict handler */
639  SCIP_CONFLICTHDLR* conflicthdlr, /**< conflict handler */
640  SCIP_SET* set, /**< global SCIP settings */
641  SCIP_NODE* node, /**< node to add conflict constraint to */
642  SCIP_NODE* validnode, /**< node at which the constraint is valid */
643  SCIP_BDCHGINFO** bdchginfos, /**< bound change resembling the conflict set */
644  SCIP_Real* relaxedbds, /**< array with relaxed bounds which are efficient to create a valid conflict */
645  int nbdchginfos, /**< number of bound changes in the conflict set */
646  SCIP_CONFTYPE conftype, /**< type of the conflict */
647  SCIP_Bool usescutoffbound, /**< depends the conflict on the cutoff bound? */
648  SCIP_Bool resolved, /**< was the conflict set already used to create a constraint? */
649  SCIP_RESULT* result /**< pointer to store the result of the callback method */
650  )
651 {
652  assert(conflicthdlr != NULL);
653  assert(set != NULL);
654  assert(bdchginfos != NULL || nbdchginfos == 0);
655  assert(result != NULL);
656 
657  /* call solution start method of conflict handler */
658  *result = SCIP_DIDNOTRUN;
659  if( conflicthdlr->conflictexec != NULL )
660  {
661  /* start timing */
662  SCIPclockStart(conflicthdlr->conflicttime, set);
663 
664  SCIP_CALL( conflicthdlr->conflictexec(set->scip, conflicthdlr, node, validnode, bdchginfos, relaxedbds, nbdchginfos,
665  conftype, usescutoffbound, set->conf_separate, (SCIPnodeGetDepth(validnode) > 0), set->conf_dynamic,
666  set->conf_removable, resolved, result) );
667 
668  /* stop timing */
669  SCIPclockStop(conflicthdlr->conflicttime, set);
670 
671  if( *result != SCIP_CONSADDED
672  && *result != SCIP_DIDNOTFIND
673  && *result != SCIP_DIDNOTRUN )
674  {
675  SCIPerrorMessage("execution method of conflict handler <%s> returned invalid result <%d>\n",
676  conflicthdlr->name, *result);
677  return SCIP_INVALIDRESULT;
678  }
679  }
680 
681  return SCIP_OKAY;
682 }
683 
684 /** gets user data of conflict handler */
686  SCIP_CONFLICTHDLR* conflicthdlr /**< conflict handler */
687  )
688 {
689  assert(conflicthdlr != NULL);
690 
691  return conflicthdlr->conflicthdlrdata;
692 }
693 
694 /** sets user data of conflict handler; user has to free old data in advance! */
696  SCIP_CONFLICTHDLR* conflicthdlr, /**< conflict handler */
697  SCIP_CONFLICTHDLRDATA* conflicthdlrdata /**< new conflict handler user data */
698  )
699 {
700  assert(conflicthdlr != NULL);
701 
702  conflicthdlr->conflicthdlrdata = conflicthdlrdata;
703 }
704 
705 /** set copy method of conflict handler */
707  SCIP_CONFLICTHDLR* conflicthdlr, /**< conflict handler */
708  SCIP_DECL_CONFLICTCOPY((*conflictcopy)) /**< copy method of the conflict handler */
709  )
710 {
711  assert(conflicthdlr != NULL);
712 
713  conflicthdlr->conflictcopy = conflictcopy;
714 }
715 
716 /** set destructor of conflict handler */
718  SCIP_CONFLICTHDLR* conflicthdlr, /**< conflict handler */
719  SCIP_DECL_CONFLICTFREE((*conflictfree)) /**< destructor of conflict handler */
720  )
721 {
722  assert(conflicthdlr != NULL);
723 
724  conflicthdlr->conflictfree = conflictfree;
725 }
726 
727 /** set initialization method of conflict handler */
729  SCIP_CONFLICTHDLR* conflicthdlr, /**< conflict handler */
730  SCIP_DECL_CONFLICTINIT((*conflictinit)) /**< initialization method conflict handler */
731  )
732 {
733  assert(conflicthdlr != NULL);
734 
735  conflicthdlr->conflictinit = conflictinit;
736 }
737 
738 /** set deinitialization method of conflict handler */
740  SCIP_CONFLICTHDLR* conflicthdlr, /**< conflict handler */
741  SCIP_DECL_CONFLICTEXIT((*conflictexit)) /**< deinitialization method conflict handler */
742  )
743 {
744  assert(conflicthdlr != NULL);
745 
746  conflicthdlr->conflictexit = conflictexit;
747 }
748 
749 /** set solving process initialization method of conflict handler */
751  SCIP_CONFLICTHDLR* conflicthdlr, /**< conflict handler */
752  SCIP_DECL_CONFLICTINITSOL((*conflictinitsol))/**< solving process initialization method of conflict handler */
753  )
754 {
755  assert(conflicthdlr != NULL);
756 
757  conflicthdlr->conflictinitsol = conflictinitsol;
758 }
759 
760 /** set solving process deinitialization method of conflict handler */
762  SCIP_CONFLICTHDLR* conflicthdlr, /**< conflict handler */
763  SCIP_DECL_CONFLICTEXITSOL((*conflictexitsol))/**< solving process deinitialization method of conflict handler */
764  )
765 {
766  assert(conflicthdlr != NULL);
767 
768  conflicthdlr->conflictexitsol = conflictexitsol;
769 }
770 
771 /** gets name of conflict handler */
773  SCIP_CONFLICTHDLR* conflicthdlr /**< conflict handler */
774  )
775 {
776  assert(conflicthdlr != NULL);
777 
778  return conflicthdlr->name;
779 }
780 
781 /** gets description of conflict handler */
783  SCIP_CONFLICTHDLR* conflicthdlr /**< conflict handler */
784  )
785 {
786  assert(conflicthdlr != NULL);
787 
788  return conflicthdlr->desc;
789 }
790 
791 /** gets priority of conflict handler */
793  SCIP_CONFLICTHDLR* conflicthdlr /**< conflict handler */
794  )
795 {
796  assert(conflicthdlr != NULL);
797 
798  return conflicthdlr->priority;
799 }
800 
801 /** sets priority of conflict handler */
803  SCIP_CONFLICTHDLR* conflicthdlr, /**< conflict handler */
804  SCIP_SET* set, /**< global SCIP settings */
805  int priority /**< new priority of the conflict handler */
806  )
807 {
808  assert(conflicthdlr != NULL);
809  assert(set != NULL);
810 
811  conflicthdlr->priority = priority;
812  set->conflicthdlrssorted = FALSE;
813 }
814 
815 /** is conflict handler initialized? */
817  SCIP_CONFLICTHDLR* conflicthdlr /**< conflict handler */
818  )
819 {
820  assert(conflicthdlr != NULL);
821 
822  return conflicthdlr->initialized;
823 }
824 
825 /** enables or disables all clocks of \p conflicthdlr, depending on the value of the flag */
827  SCIP_CONFLICTHDLR* conflicthdlr, /**< the conflict handler for which all clocks should be enabled or disabled */
828  SCIP_Bool enable /**< should the clocks of the conflict handler be enabled? */
829  )
830 {
831  assert(conflicthdlr != NULL);
832 
833  SCIPclockEnableOrDisable(conflicthdlr->setuptime, enable);
834  SCIPclockEnableOrDisable(conflicthdlr->conflicttime, enable);
835 }
836 
837 /** gets time in seconds used in this conflict handler for setting up for next stages */
839  SCIP_CONFLICTHDLR* conflicthdlr /**< conflict handler */
840  )
841 {
842  assert(conflicthdlr != NULL);
843 
844  return SCIPclockGetTime(conflicthdlr->setuptime);
845 }
846 
847 /** gets time in seconds used in this conflict handler */
849  SCIP_CONFLICTHDLR* conflicthdlr /**< conflict handler */
850  )
851 {
852  assert(conflicthdlr != NULL);
853 
854  return SCIPclockGetTime(conflicthdlr->conflicttime);
855 }
856 
857 /*
858  * Conflict LP Bound Changes
859  */
860 
861 
862 /** create conflict LP bound change data structure */
863 static
865  SCIP_LPBDCHGS** lpbdchgs, /**< pointer to store the conflict LP bound change data structure */
866  SCIP_SET* set, /**< global SCIP settings */
867  int ncols /**< number of columns */
868  )
869 {
870  SCIP_CALL( SCIPsetAllocBuffer(set, lpbdchgs) );
871 
872  SCIP_CALL( SCIPsetAllocBufferArray(set, &(*lpbdchgs)->bdchginds, ncols) );
873  SCIP_CALL( SCIPsetAllocBufferArray(set, &(*lpbdchgs)->bdchglbs, ncols) );
874  SCIP_CALL( SCIPsetAllocBufferArray(set, &(*lpbdchgs)->bdchgubs, ncols) );
875  SCIP_CALL( SCIPsetAllocBufferArray(set, &(*lpbdchgs)->bdchgcolinds, ncols) );
876  SCIP_CALL( SCIPsetAllocBufferArray(set, &(*lpbdchgs)->usedcols, ncols) );
877  BMSclearMemoryArray((*lpbdchgs)->usedcols, ncols);
878 
879  (*lpbdchgs)->nbdchgs = 0;
880 
881  return SCIP_OKAY;
882 }
883 
884 /** reset conflict LP bound change data structure */
885 static
887  SCIP_LPBDCHGS* lpbdchgs, /**< conflict LP bound change data structure */
888  int ncols /**< number of columns */
889  )
890 {
891  assert(lpbdchgs != NULL);
892 
893  BMSclearMemoryArray(lpbdchgs->usedcols, ncols);
894  lpbdchgs->nbdchgs = 0;
895 }
896 
897 /** free conflict LP bound change data structure */
898 static
900  SCIP_LPBDCHGS** lpbdchgs, /**< pointer to store the conflict LP bound change data structure */
901  SCIP_SET* set /**< global SCIP settings */
902  )
903 {
904  SCIPsetFreeBufferArray(set, &(*lpbdchgs)->usedcols);
905  SCIPsetFreeBufferArray(set, &(*lpbdchgs)->bdchgcolinds);
906  SCIPsetFreeBufferArray(set, &(*lpbdchgs)->bdchgubs);
907  SCIPsetFreeBufferArray(set, &(*lpbdchgs)->bdchglbs);
908  SCIPsetFreeBufferArray(set, &(*lpbdchgs)->bdchginds);
909 
910  SCIPsetFreeBuffer(set, lpbdchgs);
911 }
912 
913 /*
914  * Proof Sets
915  */
916 
917 /** return the char associated with the type of the variable */
918 static
920  SCIP_VAR* var /**< variable */
921  )
922 {
923  SCIP_VARTYPE vartype = SCIPvarGetType(var);
924 
925  return (!SCIPvarIsIntegral(var) ? 'C' :
926  (vartype == SCIP_VARTYPE_BINARY ? 'B' :
927  (vartype == SCIP_VARTYPE_INTEGER ? 'I' : 'M')));
928 }
929 
930 /** resets the data structure of a proofset */
931 static
933  SCIP_PROOFSET* proofset /**< proof set */
934  )
935 {
936  assert(proofset != NULL);
937 
938  proofset->nnz = 0;
939  proofset->rhs = 0.0;
940  proofset->validdepth = 0;
942 }
943 
944 /** creates a proofset */
945 static
947  SCIP_PROOFSET** proofset, /**< proof set */
948  BMS_BLKMEM* blkmem /**< block memory of transformed problem */
949  )
950 {
951  assert(proofset != NULL);
952 
953  SCIP_ALLOC( BMSallocBlockMemory(blkmem, proofset) );
954  (*proofset)->vals = NULL;
955  (*proofset)->inds = NULL;
956  (*proofset)->rhs = 0.0;
957  (*proofset)->nnz = 0;
958  (*proofset)->size = 0;
959  (*proofset)->validdepth = 0;
960  (*proofset)->conflicttype = SCIP_CONFTYPE_UNKNOWN;
961 
962  return SCIP_OKAY;
963 }
964 
965 /** creates and clears the proofset */
966 static
968  SCIP_CONFLICT* conflict, /**< conflict analysis data */
969  BMS_BLKMEM* blkmem /**< block memory of transformed problem */
970  )
971 {
972  assert(conflict != NULL);
973  assert(blkmem != NULL);
974 
975  SCIP_CALL( proofsetCreate(&conflict->proofset, blkmem) );
976 
977  return SCIP_OKAY;
978 }
979 
980 /** frees a proofset */
981 static
983  SCIP_PROOFSET** proofset, /**< proof set */
984  BMS_BLKMEM* blkmem /**< block memory */
985  )
986 {
987  assert(proofset != NULL);
988  assert(*proofset != NULL);
989  assert(blkmem != NULL);
990 
991  BMSfreeBlockMemoryArrayNull(blkmem, &(*proofset)->vals, (*proofset)->size);
992  BMSfreeBlockMemoryArrayNull(blkmem, &(*proofset)->inds, (*proofset)->size);
993  BMSfreeBlockMemory(blkmem, proofset);
994  (*proofset) = NULL;
995 }
996 
997 #ifdef SCIP_DEBUG
998 static
999 void proofsetPrint(
1000  SCIP_PROOFSET* proofset,
1001  SCIP_SET* set,
1002  SCIP_PROB* transprob
1003  )
1004 {
1005  SCIP_VAR** vars;
1006  int i;
1007 
1008  assert(proofset != NULL);
1009 
1010  vars = SCIPprobGetVars(transprob);
1011  assert(vars != NULL);
1012 
1013  printf("proofset: ");
1014  for( i = 0; i < proofset->nnz; i++ )
1015  printf("%+.15g <%s> ", proofset->vals[i], SCIPvarGetName(vars[proofset->inds[i]]));
1016  printf(" <= %.15g\n", proofset->rhs);
1017 }
1018 #endif
1019 
1020 /** return the indices of variables in the proofset */
1021 static
1023  SCIP_PROOFSET* proofset /**< proof set */
1024  )
1025 {
1026  assert(proofset != NULL);
1027 
1028  return proofset->inds;
1029 }
1030 
1031 /** return coefficient of variable in the proofset with given probindex */
1032 static
1034  SCIP_PROOFSET* proofset /**< proof set */
1035  )
1036 {
1037  assert(proofset != NULL);
1038 
1039  return proofset->vals;
1040 }
1041 
1042 /** return the right-hand side if a proofset */
1043 static
1045  SCIP_PROOFSET* proofset /**< proof set */
1046  )
1047 {
1048  assert(proofset != NULL);
1049 
1050  return proofset->rhs;
1051 }
1052 
1053 /** returns the number of variables in the proofset */
1054 static
1056  SCIP_PROOFSET* proofset /**< proof set */
1057  )
1058 {
1059  assert(proofset != NULL);
1060 
1061  return proofset->nnz;
1062 }
1063 
1064 /** returns the number of variables in the proofset */
1065 static
1067  SCIP_PROOFSET* proofset /**< proof set */
1068  )
1069 {
1070  assert(proofset != NULL);
1071 
1072  return proofset->conflicttype;
1073 }
1074 
1075 /** adds given data as aggregation row to the proofset */
1076 static
1078  SCIP_PROOFSET* proofset, /**< proof set */
1079  BMS_BLKMEM* blkmem, /**< block memory */
1080  SCIP_Real* vals, /**< variable coefficients */
1081  int* inds, /**< variable array */
1082  int nnz, /**< size of variable and coefficient array */
1083  SCIP_Real rhs /**< right-hand side of the aggregation row */
1084  )
1085 {
1086  assert(proofset != NULL);
1087  assert(blkmem != NULL);
1088 
1089  if( proofset->size == 0 )
1090  {
1091  assert(proofset->vals == NULL);
1092  assert(proofset->inds == NULL);
1093 
1094  SCIP_ALLOC( BMSduplicateBlockMemoryArray(blkmem, &proofset->vals, vals, nnz) );
1095  SCIP_ALLOC( BMSduplicateBlockMemoryArray(blkmem, &proofset->inds, inds, nnz) );
1096 
1097  proofset->size = nnz;
1098  }
1099  else
1100  {
1101  int i;
1102 
1103  assert(proofset->vals != NULL);
1104  assert(proofset->inds != NULL);
1105 
1106  if( proofset->size < nnz )
1107  {
1108  SCIP_ALLOC( BMSreallocBlockMemoryArray(blkmem, &proofset->vals, proofset->size, nnz) );
1109  SCIP_ALLOC( BMSreallocBlockMemoryArray(blkmem, &proofset->inds, proofset->size, nnz) );
1110  proofset->size = nnz;
1111  }
1112 
1113  for( i = 0; i < nnz; i++ )
1114  {
1115  proofset->vals[i] = vals[i];
1116  proofset->inds[i] = inds[i];
1117  }
1118  }
1119 
1120  proofset->rhs = rhs;
1121  proofset->nnz = nnz;
1122 
1123  return SCIP_OKAY;
1124 }
1125 
1126 /** adds an aggregation row to the proofset */
1127 static
1129  SCIP_PROOFSET* proofset, /**< proof set */
1130  SCIP_SET* set, /**< global SCIP settings */
1131  BMS_BLKMEM* blkmem, /**< block memory */
1132  SCIP_AGGRROW* aggrrow /**< aggregation row to add */
1133  )
1134 {
1135  SCIP_Real* vals;
1136  int* inds;
1137  int nnz;
1138  int i;
1139 
1140  assert(proofset != NULL);
1141  assert(set != NULL);
1142 
1143  inds = SCIPaggrRowGetInds(aggrrow);
1144  assert(inds != NULL);
1145 
1146  nnz = SCIPaggrRowGetNNz(aggrrow);
1147  assert(nnz > 0);
1148 
1149  SCIP_CALL( SCIPsetAllocBufferArray(set, &vals, nnz) );
1150 
1151  for( i = 0; i < nnz; i++ )
1152  {
1153  vals[i] = SCIPaggrRowGetProbvarValue(aggrrow, inds[i]);
1154  }
1155 
1156  SCIP_CALL( proofsetAddSparseData(proofset, blkmem, vals, inds, nnz, SCIPaggrRowGetRhs(aggrrow)) );
1157 
1158  SCIPsetFreeBufferArray(set, &vals);
1159 
1160  return SCIP_OKAY;
1161 }
1162 
1163 /** Removes a given variable @p var from position @p pos from the proofset and updates the right-hand side according
1164  * to sign of the coefficient, i.e., rhs -= coef * bound, where bound = lb if coef >= 0 and bound = ub, otherwise.
1165  *
1166  * @note: The list of non-zero indices and coefficients will be updated by swapping the last non-zero index to @p pos.
1167  */
1168 static
1170  SCIP_PROOFSET* proofset,
1171  SCIP_SET* set,
1172  SCIP_VAR* var,
1173  int pos,
1174  SCIP_Bool* valid
1175  )
1176 {
1177  assert(proofset != NULL);
1178  assert(var != NULL);
1179  assert(pos >= 0 && pos < proofset->nnz);
1180  assert(valid != NULL);
1181 
1182  *valid = TRUE;
1183 
1184  /* cancel with lower bound */
1185  if( proofset->vals[pos] > 0.0 )
1186  {
1187  proofset->rhs -= proofset->vals[pos] * SCIPvarGetLbGlobal(var);
1188  }
1189  /* cancel with upper bound */
1190  else
1191  {
1192  assert(proofset->vals[pos] < 0.0);
1193  proofset->rhs -= proofset->vals[pos] * SCIPvarGetUbGlobal(var);
1194  }
1195 
1196  --proofset->nnz;
1197 
1198  proofset->vals[pos] = proofset->vals[proofset->nnz];
1199  proofset->inds[pos] = proofset->inds[proofset->nnz];
1200  proofset->vals[proofset->nnz] = 0.0;
1201  proofset->inds[proofset->nnz] = 0;
1202 
1203  if( SCIPsetIsInfinity(set, proofset->rhs) )
1204  *valid = FALSE;
1205 }
1206 
1207 /*
1208  * Conflict Sets
1209  */
1210 
1211 /** resizes the array of the temporary bound change informations to be able to store at least num bound change entries */
1212 static
1214  SCIP_CONFLICT* conflict, /**< conflict analysis data */
1215  SCIP_SET* set, /**< global SCIP settings */
1216  int num /**< minimal number of slots in arrays */
1217  )
1218 {
1219  assert(conflict != NULL);
1220  assert(set != NULL);
1221 
1222  if( num > conflict->tmpbdchginfossize )
1223  {
1224  int newsize;
1225 
1226  newsize = SCIPsetCalcMemGrowSize(set, num);
1227  SCIP_ALLOC( BMSreallocMemoryArray(&conflict->tmpbdchginfos, newsize) );
1228  conflict->tmpbdchginfossize = newsize;
1229  }
1230  assert(num <= conflict->tmpbdchginfossize);
1231 
1232  return SCIP_OKAY;
1233 }
1234 
1235 /** creates a temporary bound change information object that is destroyed after the conflict sets are flushed */
1236 static
1238  SCIP_CONFLICT* conflict, /**< conflict analysis data */
1239  BMS_BLKMEM* blkmem, /**< block memory */
1240  SCIP_SET* set, /**< global SCIP settings */
1241  SCIP_VAR* var, /**< active variable that changed the bounds */
1242  SCIP_BOUNDTYPE boundtype, /**< type of bound for var: lower or upper bound */
1243  SCIP_Real oldbound, /**< old value for bound */
1244  SCIP_Real newbound, /**< new value for bound */
1245  SCIP_BDCHGINFO** bdchginfo /**< pointer to store bound change information */
1246  )
1247 {
1248  assert(conflict != NULL);
1249 
1250  SCIP_CALL( conflictEnsureTmpbdchginfosMem(conflict, set, conflict->ntmpbdchginfos+1) );
1251  SCIP_CALL( SCIPbdchginfoCreate(&conflict->tmpbdchginfos[conflict->ntmpbdchginfos], blkmem,
1252  var, boundtype, oldbound, newbound) );
1253  *bdchginfo = conflict->tmpbdchginfos[conflict->ntmpbdchginfos];
1254  conflict->ntmpbdchginfos++;
1255 
1256  return SCIP_OKAY;
1257 }
1258 
1259 /** frees all temporarily created bound change information data */
1260 static
1262  SCIP_CONFLICT* conflict, /**< conflict analysis data */
1263  BMS_BLKMEM* blkmem /**< block memory */
1264  )
1265 {
1266  int i;
1267 
1268  assert(conflict != NULL);
1269 
1270  for( i = 0; i < conflict->ntmpbdchginfos; ++i )
1271  SCIPbdchginfoFree(&conflict->tmpbdchginfos[i], blkmem);
1272  conflict->ntmpbdchginfos = 0;
1273 }
1274 
1275 /** clears the given conflict set */
1276 static
1278  SCIP_CONFLICTSET* conflictset /**< conflict set */
1279  )
1280 {
1281  assert(conflictset != NULL);
1282 
1283  conflictset->nbdchginfos = 0;
1284  conflictset->validdepth = 0;
1285  conflictset->insertdepth = 0;
1286  conflictset->conflictdepth = 0;
1287  conflictset->repropdepth = 0;
1288  conflictset->repropagate = TRUE;
1289  conflictset->usescutoffbound = FALSE;
1290  conflictset->hasrelaxonlyvar = FALSE;
1291  conflictset->conflicttype = SCIP_CONFTYPE_UNKNOWN;
1292 }
1293 
1294 /** creates an empty conflict set */
1295 static
1297  SCIP_CONFLICTSET** conflictset, /**< pointer to store the conflict set */
1298  BMS_BLKMEM* blkmem /**< block memory of transformed problem */
1299  )
1300 {
1301  assert(conflictset != NULL);
1302 
1303  SCIP_ALLOC( BMSallocBlockMemory(blkmem, conflictset) );
1304  (*conflictset)->bdchginfos = NULL;
1305  (*conflictset)->relaxedbds = NULL;
1306  (*conflictset)->sortvals = NULL;
1307  (*conflictset)->bdchginfossize = 0;
1308 
1309  conflictsetClear(*conflictset);
1310 
1311  return SCIP_OKAY;
1312 }
1313 
1314 /** creates a copy of the given conflict set, allocating an additional amount of memory */
1315 static
1317  SCIP_CONFLICTSET** targetconflictset, /**< pointer to store the conflict set */
1318  BMS_BLKMEM* blkmem, /**< block memory of transformed problem */
1319  SCIP_CONFLICTSET* sourceconflictset, /**< source conflict set */
1320  int nadditionalelems /**< number of additional elements to allocate memory for */
1321  )
1322 {
1323  int targetsize;
1324 
1325  assert(targetconflictset != NULL);
1326  assert(sourceconflictset != NULL);
1327 
1328  targetsize = sourceconflictset->nbdchginfos + nadditionalelems;
1329  SCIP_ALLOC( BMSallocBlockMemory(blkmem, targetconflictset) );
1330  SCIP_ALLOC( BMSallocBlockMemoryArray(blkmem, &(*targetconflictset)->bdchginfos, targetsize) );
1331  SCIP_ALLOC( BMSallocBlockMemoryArray(blkmem, &(*targetconflictset)->relaxedbds, targetsize) );
1332  SCIP_ALLOC( BMSallocBlockMemoryArray(blkmem, &(*targetconflictset)->sortvals, targetsize) );
1333  (*targetconflictset)->bdchginfossize = targetsize;
1334 
1335  BMScopyMemoryArray((*targetconflictset)->bdchginfos, sourceconflictset->bdchginfos, sourceconflictset->nbdchginfos);
1336  BMScopyMemoryArray((*targetconflictset)->relaxedbds, sourceconflictset->relaxedbds, sourceconflictset->nbdchginfos);
1337  BMScopyMemoryArray((*targetconflictset)->sortvals, sourceconflictset->sortvals, sourceconflictset->nbdchginfos);
1338 
1339  (*targetconflictset)->nbdchginfos = sourceconflictset->nbdchginfos;
1340  (*targetconflictset)->validdepth = sourceconflictset->validdepth;
1341  (*targetconflictset)->insertdepth = sourceconflictset->insertdepth;
1342  (*targetconflictset)->conflictdepth = sourceconflictset->conflictdepth;
1343  (*targetconflictset)->repropdepth = sourceconflictset->repropdepth;
1344  (*targetconflictset)->usescutoffbound = sourceconflictset->usescutoffbound;
1345  (*targetconflictset)->hasrelaxonlyvar = sourceconflictset->hasrelaxonlyvar;
1346  (*targetconflictset)->conflicttype = sourceconflictset->conflicttype;
1347 
1348  return SCIP_OKAY;
1349 }
1350 
1351 /** frees a conflict set */
1352 static
1354  SCIP_CONFLICTSET** conflictset, /**< pointer to the conflict set */
1355  BMS_BLKMEM* blkmem /**< block memory of transformed problem */
1356  )
1357 {
1358  assert(conflictset != NULL);
1359  assert(*conflictset != NULL);
1360 
1361  BMSfreeBlockMemoryArrayNull(blkmem, &(*conflictset)->bdchginfos, (*conflictset)->bdchginfossize);
1362  BMSfreeBlockMemoryArrayNull(blkmem, &(*conflictset)->relaxedbds, (*conflictset)->bdchginfossize);
1363  BMSfreeBlockMemoryArrayNull(blkmem, &(*conflictset)->sortvals, (*conflictset)->bdchginfossize);
1364  BMSfreeBlockMemory(blkmem, conflictset);
1365 }
1366 
1367 /** resizes the arrays of the conflict set to be able to store at least num bound change entries */
1368 static
1370  SCIP_CONFLICTSET* conflictset, /**< conflict set */
1371  BMS_BLKMEM* blkmem, /**< block memory of transformed problem */
1372  SCIP_SET* set, /**< global SCIP settings */
1373  int num /**< minimal number of slots in arrays */
1374  )
1375 {
1376  assert(conflictset != NULL);
1377  assert(set != NULL);
1378 
1379  if( num > conflictset->bdchginfossize )
1380  {
1381  int newsize;
1382 
1383  newsize = SCIPsetCalcMemGrowSize(set, num);
1384  SCIP_ALLOC( BMSreallocBlockMemoryArray(blkmem, &conflictset->bdchginfos, conflictset->bdchginfossize, newsize) );
1385  SCIP_ALLOC( BMSreallocBlockMemoryArray(blkmem, &conflictset->relaxedbds, conflictset->bdchginfossize, newsize) );
1386  SCIP_ALLOC( BMSreallocBlockMemoryArray(blkmem, &conflictset->sortvals, conflictset->bdchginfossize, newsize) );
1387  conflictset->bdchginfossize = newsize;
1388  }
1389  assert(num <= conflictset->bdchginfossize);
1390 
1391  return SCIP_OKAY;
1392 }
1393 
1394 /** calculates the score of the conflict set
1395  *
1396  * the score is weighted sum of number of bound changes, repropagation depth, and valid depth
1397  */
1398 static
1400  SCIP_CONFLICTSET* conflictset, /**< conflict set */
1401  SCIP_SET* set /**< global SCIP settings */
1402  )
1403 {
1404  assert(conflictset != NULL);
1405 
1406  return -(set->conf_weightsize * conflictset->nbdchginfos
1407  + set->conf_weightrepropdepth * conflictset->repropdepth
1408  + set->conf_weightvaliddepth * conflictset->validdepth);
1409 }
1410 
1411 /** calculates the score of a bound change within a conflict */
1412 static
1414  SCIP_Real prooflhs, /**< lhs of proof constraint */
1415  SCIP_Real proofact, /**< activity of the proof constraint */
1416  SCIP_Real proofactdelta, /**< activity change */
1417  SCIP_Real proofcoef, /**< coefficient in proof constraint */
1418  int depth, /**< bound change depth */
1419  int currentdepth, /**< current depth */
1420  SCIP_VAR* var, /**< variable corresponding to bound change */
1421  SCIP_SET* set /**< global SCIP settings */
1422  )
1423 {
1424  SCIP_COL* col;
1425  SCIP_Real score;
1426 
1427  score = set->conf_proofscorefac * (1.0 - proofactdelta/(prooflhs - proofact));
1428  score = MAX(score, 0.0);
1429  score += set->conf_depthscorefac * (SCIP_Real)(depth+1)/(SCIP_Real)(currentdepth+1);
1430 
1432  col = SCIPvarGetCol(var);
1433  else
1434  col = NULL;
1435 
1436  if( proofcoef > 0.0 )
1437  {
1438  if( col != NULL && SCIPcolGetNNonz(col) > 0 )
1439  score += set->conf_uplockscorefac
1441  else
1442  score += set->conf_uplockscorefac * SCIPvarGetNLocksUpType(var, SCIP_LOCKTYPE_MODEL);
1443  }
1444  else
1445  {
1446  if( col != NULL && SCIPcolGetNNonz(col) > 0 )
1447  score += set->conf_downlockscorefac
1449  else
1450  score += set->conf_downlockscorefac * SCIPvarGetNLocksDownType(var, SCIP_LOCKTYPE_MODEL);
1451  }
1452 
1453  return score;
1454 }
1455 
1456 /** check if the bound change info (which is the potential next candidate which is queued) is valid for the current
1457  * conflict analysis; a bound change info can get invalid if after this one was added to the queue, a weaker bound
1458  * change was added to the queue (due the bound widening idea) which immediately makes this bound change redundant; due
1459  * to the priority we did not removed that bound change info since that cost O(log(n)); hence we have to skip/ignore it
1460  * now
1461  *
1462  * The following situations can occur before for example the bound change info (x >= 3) is potentially popped from the
1463  * queue.
1464  *
1465  * Postcondition: the reason why (x >= 3) was queued is that at this time point no lower bound of x was involved yet in
1466  * the current conflict or the lower bound which was involved until then was stronger, e.g., (x >= 2).
1467  *
1468  * 1) during the time until (x >= 3) gets potentially popped no weaker lower bound was added to the queue, in that case
1469  * the conflictlbcount is valid and conflictlb is 3; that is (var->conflictlbcount == conflict->count &&
1470  * var->conflictlb == 3)
1471  *
1472  * 2) a weaker bound change info gets queued (e.g., x >= 4); this bound change is popped before (x >= 3) since it has
1473  * higher priority (which is the time stamp of the bound change info and (x >= 4) has to be done after (x >= 3)
1474  * during propagation or branching)
1475  *
1476  * a) if (x >= 4) is popped and added to the conflict set the conflictlbcount is still valid and conflictlb is at
1477  * most 4; that is (var->conflictlbcount == conflict->count && var->conflictlb >= 4); it follows that any bound
1478  * change info which is stronger than (x >= 4) gets ignored (for example x >= 2)
1479  *
1480  * b) if (x >= 4) is popped and resolved without introducing a new lower bound on x until (x >= 3) is a potentially
1481  * candidate the conflictlbcount indicates that bound change is currently not present; that is
1482  * (var->conflictlbcount != conflict->count)
1483  *
1484  * 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
1485  * pooped, the conflictlbcount indicates that bound change is currently present; that is (var->conflictlbcount ==
1486  * conflict->count); however the (x >= 3) only has be explained if conflictlb matches that one; that is
1487  * (var->conflictlb == bdchginfo->newbound); otherwise it redundant/invalid.
1488  */
1489 static
1491  SCIP_CONFLICT* conflict, /**< conflict analysis data */
1492  SCIP_BDCHGINFO* bdchginfo /**< bound change information */
1493  )
1494 {
1495  SCIP_VAR* var;
1496 
1497  assert(bdchginfo != NULL);
1498 
1499  var = SCIPbdchginfoGetVar(bdchginfo);
1500  assert(var != NULL);
1501 
1502  /* the bound change info of a binary (domained) variable can never be invalid since the concepts of relaxed bounds
1503  * and bound widening do not make sense for these type of variables
1504  */
1505  if( SCIPvarIsBinary(var) )
1506  return FALSE;
1507 
1508  /* check if the bdchginfo is invaild since a tight/weaker bound change was already explained */
1510  {
1511  if( var->conflictlbcount != conflict->count || var->conflictlb != SCIPbdchginfoGetNewbound(bdchginfo) ) /*lint !e777*/
1512  {
1513  assert(!SCIPvarIsBinary(var));
1514  return TRUE;
1515  }
1516  }
1517  else
1518  {
1519  assert(SCIPbdchginfoGetBoundtype(bdchginfo) == SCIP_BOUNDTYPE_UPPER);
1520 
1521  if( var->conflictubcount != conflict->count || var->conflictub != SCIPbdchginfoGetNewbound(bdchginfo) ) /*lint !e777*/
1522  {
1523  assert(!SCIPvarIsBinary(var));
1524  return TRUE;
1525  }
1526  }
1527 
1528  return FALSE;
1529 }
1530 
1531 /** adds a bound change to a conflict set */
1532 static
1534  SCIP_CONFLICTSET* conflictset, /**< conflict set */
1535  BMS_BLKMEM* blkmem, /**< block memory of transformed problem */
1536  SCIP_SET* set, /**< global SCIP settings */
1537  SCIP_BDCHGINFO* bdchginfo, /**< bound change to add to the conflict set */
1538  SCIP_Real relaxedbd /**< relaxed bound */
1539  )
1540 {
1541  SCIP_BDCHGINFO** bdchginfos;
1542  SCIP_Real* relaxedbds;
1543  int* sortvals;
1544  SCIP_VAR* var;
1545  SCIP_BOUNDTYPE boundtype;
1546  int idx;
1547  int sortval;
1548  int pos;
1549 
1550  assert(conflictset != NULL);
1551  assert(bdchginfo != NULL);
1552 
1553  /* allocate memory for additional element */
1554  SCIP_CALL( conflictsetEnsureBdchginfosMem(conflictset, blkmem, set, conflictset->nbdchginfos+1) );
1555 
1556  /* insert the new bound change in the arrays sorted by increasing variable index and by bound type */
1557  bdchginfos = conflictset->bdchginfos;
1558  relaxedbds = conflictset->relaxedbds;
1559  sortvals = conflictset->sortvals;
1560  var = SCIPbdchginfoGetVar(bdchginfo);
1561  boundtype = SCIPbdchginfoGetBoundtype(bdchginfo);
1562  idx = SCIPvarGetIndex(var);
1563  assert(idx < INT_MAX/2);
1564  assert((int)boundtype == 0 || (int)boundtype == 1);
1565  sortval = 2*idx + (int)boundtype; /* first sorting criteria: variable index, second criteria: boundtype */
1566 
1567  /* insert new element into the sorted arrays; if an element exits with the same value insert the new element afterwards
1568  *
1569  * @todo check if it better (faster) to first search for the position O(log n) and compare the sort values and if
1570  * they are equal just replace the element and if not run the insert method O(n)
1571  */
1572 
1573  SCIPsortedvecInsertIntPtrReal(sortvals, (void**)bdchginfos, relaxedbds, sortval, (void*)bdchginfo, relaxedbd, &conflictset->nbdchginfos, &pos);
1574  assert(pos == conflictset->nbdchginfos - 1 || sortval < sortvals[pos+1]);
1575 
1576  /* merge multiple bound changes */
1577  if( pos > 0 && sortval == sortvals[pos-1] )
1578  {
1579  /* this is a multiple bound change */
1580  if( SCIPbdchginfoIsTighter(bdchginfo, bdchginfos[pos-1]) )
1581  {
1582  /* remove the "old" bound change since the "new" one in tighter */
1583  SCIPsortedvecDelPosIntPtrReal(sortvals, (void**)bdchginfos, relaxedbds, pos-1, &conflictset->nbdchginfos);
1584  }
1585  else if( SCIPbdchginfoIsTighter(bdchginfos[pos-1], bdchginfo) )
1586  {
1587  /* remove the "new" bound change since the "old" one is tighter */
1588  SCIPsortedvecDelPosIntPtrReal(sortvals, (void**)bdchginfos, relaxedbds, pos, &conflictset->nbdchginfos);
1589  }
1590  else
1591  {
1592  /* both bound change are equivalent; hence, keep the worse relaxed bound and remove one of them */
1593  relaxedbds[pos-1] = boundtype == SCIP_BOUNDTYPE_LOWER ? MAX(relaxedbds[pos-1], relaxedbd) : MIN(relaxedbds[pos-1], relaxedbd);
1594  SCIPsortedvecDelPosIntPtrReal(sortvals, (void**)bdchginfos, relaxedbds, pos, &conflictset->nbdchginfos);
1595  }
1596  }
1597 
1598  if( SCIPvarIsRelaxationOnly(var) )
1599  conflictset->hasrelaxonlyvar = TRUE;
1600 
1601  return SCIP_OKAY;
1602 }
1603 
1604 /** adds given bound changes to a conflict set */
1605 static
1607  SCIP_CONFLICT* conflict, /**< conflict analysis data */
1608  SCIP_CONFLICTSET* conflictset, /**< conflict set */
1609  BMS_BLKMEM* blkmem, /**< block memory of transformed problem */
1610  SCIP_SET* set, /**< global SCIP settings */
1611  SCIP_BDCHGINFO** bdchginfos, /**< bound changes to add to the conflict set */
1612  int nbdchginfos /**< number of bound changes to add */
1613  )
1614 {
1615  SCIP_BDCHGINFO** confbdchginfos;
1616  SCIP_BDCHGINFO* bdchginfo;
1617  SCIP_Real* confrelaxedbds;
1618  int* confsortvals;
1619  int confnbdchginfos;
1620  int idx;
1621  int sortval;
1622  int i;
1623  SCIP_BOUNDTYPE boundtype;
1624 
1625  assert(conflict != NULL);
1626  assert(conflictset != NULL);
1627  assert(blkmem != NULL);
1628  assert(set != NULL);
1629  assert(bdchginfos != NULL || nbdchginfos == 0);
1630 
1631  /* nothing to add */
1632  if( nbdchginfos == 0 )
1633  return SCIP_OKAY;
1634 
1635  assert(bdchginfos != NULL);
1636 
1637  /* only one element to add, use the single insertion method */
1638  if( nbdchginfos == 1 )
1639  {
1640  bdchginfo = bdchginfos[0];
1641  assert(bdchginfo != NULL);
1642 
1643  if( !bdchginfoIsInvalid(conflict, bdchginfo) )
1644  {
1645  SCIP_CALL( conflictsetAddBound(conflictset, blkmem, set, bdchginfo, SCIPbdchginfoGetRelaxedBound(bdchginfo)) );
1646  }
1647  else
1648  {
1649  SCIPsetDebugMsg(set, "-> bound change info [%d:<%s> %s %g] is invaild -> ignore it\n", SCIPbdchginfoGetDepth(bdchginfo),
1650  SCIPvarGetName(SCIPbdchginfoGetVar(bdchginfo)),
1651  SCIPbdchginfoGetBoundtype(bdchginfo) == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=",
1652  SCIPbdchginfoGetNewbound(bdchginfo));
1653  }
1654 
1655  return SCIP_OKAY;
1656  }
1657 
1658  confnbdchginfos = conflictset->nbdchginfos;
1659 
1660  /* allocate memory for additional element */
1661  SCIP_CALL( conflictsetEnsureBdchginfosMem(conflictset, blkmem, set, confnbdchginfos + nbdchginfos) );
1662 
1663  confbdchginfos = conflictset->bdchginfos;
1664  confrelaxedbds = conflictset->relaxedbds;
1665  confsortvals = conflictset->sortvals;
1666 
1667  assert(SCIP_BOUNDTYPE_LOWER == FALSE); /*lint !e641 !e506*/
1668  assert(SCIP_BOUNDTYPE_UPPER == TRUE); /*lint !e641 !e506*/
1669 
1670  for( i = 0; i < nbdchginfos; ++i )
1671  {
1672  bdchginfo = bdchginfos[i];
1673  assert(bdchginfo != NULL);
1674 
1675  /* add only valid bound change infos */
1676  if( !bdchginfoIsInvalid(conflict, bdchginfo) )
1677  {
1678  /* calculate sorting value */
1679  boundtype = SCIPbdchginfoGetBoundtype(bdchginfo);
1680  assert(SCIPbdchginfoGetVar(bdchginfo) != NULL);
1681 
1682  idx = SCIPvarGetIndex(SCIPbdchginfoGetVar(bdchginfo));
1683  assert(idx < INT_MAX/2);
1684 
1685  assert((int)boundtype == 0 || (int)boundtype == 1);
1686  sortval = 2*idx + (int)boundtype; /* first sorting criteria: variable index, second criteria: boundtype */
1687 
1688  /* add new element */
1689  confbdchginfos[confnbdchginfos] = bdchginfo;
1690  confrelaxedbds[confnbdchginfos] = SCIPbdchginfoGetRelaxedBound(bdchginfo);
1691  confsortvals[confnbdchginfos] = sortval;
1692  ++confnbdchginfos;
1693 
1695  conflictset->hasrelaxonlyvar = TRUE;
1696  }
1697  else
1698  {
1699  SCIPsetDebugMsg(set, "-> bound change info [%d:<%s> %s %g] is invaild -> ignore it\n", SCIPbdchginfoGetDepth(bdchginfo),
1700  SCIPvarGetName(SCIPbdchginfoGetVar(bdchginfo)),
1701  SCIPbdchginfoGetBoundtype(bdchginfo) == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=",
1702  SCIPbdchginfoGetNewbound(bdchginfo));
1703  }
1704  }
1705  assert(confnbdchginfos <= conflictset->nbdchginfos + nbdchginfos);
1706 
1707  /* sort and merge the new conflict set */
1708  if( confnbdchginfos > conflictset->nbdchginfos )
1709  {
1710  int k = 0;
1711 
1712  /* sort array */
1713  SCIPsortIntPtrReal(confsortvals, (void**)confbdchginfos, confrelaxedbds, confnbdchginfos);
1714 
1715  i = 1;
1716  /* merge multiple bound changes */
1717  while( i < confnbdchginfos )
1718  {
1719  assert(i > k);
1720 
1721  /* is this a multiple bound change */
1722  if( confsortvals[k] == confsortvals[i] )
1723  {
1724  if( SCIPbdchginfoIsTighter(confbdchginfos[k], confbdchginfos[i]) )
1725  ++i;
1726  else if( SCIPbdchginfoIsTighter(confbdchginfos[i], confbdchginfos[k]) )
1727  {
1728  /* replace worse bound change info by tighter bound change info */
1729  confbdchginfos[k] = confbdchginfos[i];
1730  confrelaxedbds[k] = confrelaxedbds[i];
1731  confsortvals[k] = confsortvals[i];
1732  ++i;
1733  }
1734  else
1735  {
1736  assert(confsortvals[k] == confsortvals[i]);
1737 
1738  /* both bound change are equivalent; hence, keep the worse relaxed bound and remove one of them */
1739  confrelaxedbds[k] = (confsortvals[k] % 2 == 0) ? MAX(confrelaxedbds[k], confrelaxedbds[i]) : MIN(confrelaxedbds[k], confrelaxedbds[i]);
1740  ++i;
1741  }
1742  }
1743  else
1744  {
1745  /* all bound change infos must be valid */
1746  assert(!bdchginfoIsInvalid(conflict, confbdchginfos[k]));
1747 
1748  ++k;
1749  /* move next comparison element to the correct position */
1750  if( k != i )
1751  {
1752  confbdchginfos[k] = confbdchginfos[i];
1753  confrelaxedbds[k] = confrelaxedbds[i];
1754  confsortvals[k] = confsortvals[i];
1755  }
1756  ++i;
1757  }
1758  }
1759  /* last bound change infos must also be valid */
1760  assert(!bdchginfoIsInvalid(conflict, confbdchginfos[k]));
1761  /* the number of bound change infos cannot be decreased, it would mean that the conflict set was not merged
1762  * before
1763  */
1764  assert(conflictset->nbdchginfos <= k + 1 );
1765  assert(k + 1 <= confnbdchginfos);
1766 
1767  conflictset->nbdchginfos = k + 1;
1768  }
1769 
1770  return SCIP_OKAY;
1771 }
1772 
1773 /** calculates the conflict and the repropagation depths of the conflict set */
1774 static
1776  SCIP_CONFLICTSET* conflictset /**< conflict set */
1777  )
1778 {
1779  int maxdepth[2];
1780  int i;
1781 
1782  assert(conflictset != NULL);
1783  assert(conflictset->validdepth <= conflictset->insertdepth);
1784 
1785  /* get the depth of the last and last but one bound change */
1786  maxdepth[0] = conflictset->validdepth;
1787  maxdepth[1] = conflictset->validdepth;
1788  for( i = 0; i < conflictset->nbdchginfos; ++i )
1789  {
1790  int depth;
1791 
1792  depth = SCIPbdchginfoGetDepth(conflictset->bdchginfos[i]);
1793  assert(depth >= 0);
1794  if( depth > maxdepth[0] )
1795  {
1796  maxdepth[1] = maxdepth[0];
1797  maxdepth[0] = depth;
1798  }
1799  else if( depth > maxdepth[1] )
1800  maxdepth[1] = depth;
1801  }
1802  assert(maxdepth[0] >= maxdepth[1]);
1803 
1804  conflictset->conflictdepth = maxdepth[0];
1805  conflictset->repropdepth = maxdepth[1];
1806 }
1807 
1808 /** identifies the depth, at which the conflict set should be added:
1809  * - if the branching rule operates on variables only, and if all branching variables up to a certain
1810  * depth level are member of the conflict, the conflict constraint can only be violated in the subtree
1811  * of the node at that depth, because in all other nodes, at least one of these branching variables
1812  * violates its conflicting bound, such that the conflict constraint is feasible
1813  * - if there is at least one branching variable in a node, we assume, that this branching was performed
1814  * on variables, and that the siblings of this node are disjunct w.r.t. the branching variables' fixings
1815  * - we have to add the conflict set at least in the valid depth of the initial conflict set,
1816  * so we start searching at the first branching after this depth level, i.e. validdepth+1
1817  */
1818 static
1820  SCIP_CONFLICTSET* conflictset, /**< conflict set */
1821  SCIP_SET* set, /**< global SCIP settings */
1822  SCIP_TREE* tree /**< branch and bound tree */
1823  )
1824 {
1825  SCIP_Bool* branchingincluded;
1826  int currentdepth;
1827  int i;
1828 
1829  assert(conflictset != NULL);
1830  assert(set != NULL);
1831  assert(tree != NULL);
1832 
1833  /* the conflict set must not be inserted prior to its valid depth */
1834  conflictset->insertdepth = conflictset->validdepth;
1835  assert(conflictset->insertdepth >= 0);
1836 
1837  currentdepth = SCIPtreeGetCurrentDepth(tree);
1838  assert(currentdepth == tree->pathlen-1);
1839 
1840  /* mark the levels for which a branching variable is included in the conflict set */
1841  SCIP_CALL( SCIPsetAllocBufferArray(set, &branchingincluded, currentdepth+2) );
1842  BMSclearMemoryArray(branchingincluded, currentdepth+2);
1843  for( i = 0; i < conflictset->nbdchginfos; ++i )
1844  {
1845  int depth;
1846 
1847  depth = SCIPbdchginfoGetDepth(conflictset->bdchginfos[i]);
1848  depth = MIN(depth, currentdepth+1); /* put diving/probing/strong branching changes in this depth level */
1849  branchingincluded[depth] = TRUE;
1850  }
1851 
1852  /* skip additional depth levels where branching on the conflict variables was applied */
1853  while( conflictset->insertdepth < currentdepth && branchingincluded[conflictset->insertdepth+1] )
1854  conflictset->insertdepth++;
1855 
1856  /* free temporary memory */
1857  SCIPsetFreeBufferArray(set, &branchingincluded);
1858 
1859  assert(conflictset->validdepth <= conflictset->insertdepth && conflictset->insertdepth <= currentdepth);
1860 
1861  return SCIP_OKAY;
1862 }
1863 
1864 /** checks whether the first conflict set is redundant to the second one */
1865 static
1867  SCIP_CONFLICTSET* conflictset1, /**< first conflict conflict set */
1868  SCIP_CONFLICTSET* conflictset2 /**< second conflict conflict set */
1869  )
1870 {
1871  int i1;
1872  int i2;
1873 
1874  assert(conflictset1 != NULL);
1875  assert(conflictset2 != NULL);
1876 
1877  /* if conflictset1 has smaller validdepth, it is definitely not redundant to conflictset2 */
1878  if( conflictset1->validdepth < conflictset2->validdepth )
1879  return FALSE;
1880 
1881  /* check, if all bound changes in conflictset2 are also present at least as tight in conflictset1;
1882  * we can stop immediately, if more bound changes are remaining in conflictset2 than in conflictset1
1883  */
1884  for( i1 = 0, i2 = 0; i2 < conflictset2->nbdchginfos && conflictset1->nbdchginfos - i1 >= conflictset2->nbdchginfos - i2;
1885  ++i1, ++i2 )
1886  {
1887  int sortval;
1888 
1889  assert(i2 == 0 || conflictset2->sortvals[i2-1] < conflictset2->sortvals[i2]);
1890 
1891  sortval = conflictset2->sortvals[i2];
1892  for( ; i1 < conflictset1->nbdchginfos && conflictset1->sortvals[i1] < sortval; ++i1 ) /*lint !e445*/
1893  {
1894  /* while scanning conflictset1, check consistency */
1895  assert(i1 == 0 || conflictset1->sortvals[i1-1] < conflictset1->sortvals[i1]);
1896  }
1897  if( i1 >= conflictset1->nbdchginfos || conflictset1->sortvals[i1] > sortval
1898  || SCIPbdchginfoIsTighter(conflictset2->bdchginfos[i2], conflictset1->bdchginfos[i1]) )
1899  return FALSE;
1900  }
1901 
1902  return (i2 == conflictset2->nbdchginfos);
1903 }
1904 
1905 #ifdef SCIP_DEBUG
1906 /** prints a conflict set to the screen */
1907 static
1908 void conflictsetPrint(
1909  SCIP_CONFLICTSET* conflictset /**< conflict set */
1910  )
1911 {
1912  int i;
1913 
1914  assert(conflictset != NULL);
1915  for( i = 0; i < conflictset->nbdchginfos; ++i )
1916  {
1917  SCIPdebugPrintf(" [%d:<%s> %s %g(%g)]", SCIPbdchginfoGetDepth(conflictset->bdchginfos[i]),
1918  SCIPvarGetName(SCIPbdchginfoGetVar(conflictset->bdchginfos[i])),
1919  SCIPbdchginfoGetBoundtype(conflictset->bdchginfos[i]) == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=",
1920  SCIPbdchginfoGetNewbound(conflictset->bdchginfos[i]), conflictset->relaxedbds[i]);
1921  }
1922  SCIPdebugPrintf("\n");
1923 }
1924 #endif
1925 
1926 /** resizes proofsets array to be able to store at least num entries */
1927 static
1929  SCIP_CONFLICT* conflict, /**< conflict analysis data */
1930  SCIP_SET* set, /**< global SCIP settings */
1931  int num /**< minimal number of slots in array */
1932  )
1933 {
1934  assert(conflict != NULL);
1935  assert(set != NULL);
1936 
1937  if( num > conflict->proofsetssize )
1938  {
1939  int newsize;
1940 
1941  newsize = SCIPsetCalcMemGrowSize(set, num);
1942  SCIP_ALLOC( BMSreallocMemoryArray(&conflict->proofsets, newsize) );
1943  conflict->proofsetssize = newsize;
1944  }
1945  assert(num <= conflict->proofsetssize);
1946 
1947  return SCIP_OKAY;
1948 }
1949 
1950 /** resizes conflictsets array to be able to store at least num entries */
1951 static
1953  SCIP_CONFLICT* conflict, /**< conflict analysis data */
1954  SCIP_SET* set, /**< global SCIP settings */
1955  int num /**< minimal number of slots in array */
1956  )
1957 {
1958  assert(conflict != NULL);
1959  assert(set != NULL);
1960 
1961  if( num > conflict->conflictsetssize )
1962  {
1963  int newsize;
1964 
1965  newsize = SCIPsetCalcMemGrowSize(set, num);
1966  SCIP_ALLOC( BMSreallocMemoryArray(&conflict->conflictsets, newsize) );
1967  SCIP_ALLOC( BMSreallocMemoryArray(&conflict->conflictsetscores, newsize) );
1968  conflict->conflictsetssize = newsize;
1969  }
1970  assert(num <= conflict->conflictsetssize);
1971 
1972  return SCIP_OKAY;
1973 }
1974 
1975 /** add a proofset to the list of all proofsets */
1976 static
1978  SCIP_CONFLICT* conflict, /**< conflict analysis data */
1979  SCIP_SET* set, /**< global SCIP settings */
1980  SCIP_PROOFSET* proofset /**< proof set to add */
1981  )
1982 {
1983  assert(conflict != NULL);
1984  assert(proofset != NULL);
1985 
1986  /* insert proofset into the sorted proofsets array */
1987  SCIP_CALL( conflictEnsureProofsetsMem(conflict, set, conflict->nproofsets + 1) );
1988 
1989  conflict->proofsets[conflict->nproofsets] = proofset;
1990  ++conflict->nproofsets;
1991 
1992  return SCIP_OKAY;
1993 }
1994 
1995 /** inserts conflict set into sorted conflictsets array and deletes the conflict set pointer */
1996 static
1998  SCIP_CONFLICT* conflict, /**< conflict analysis data */
1999  BMS_BLKMEM* blkmem, /**< block memory of transformed problem */
2000  SCIP_SET* set, /**< global SCIP settings */
2001  SCIP_CONFLICTSET** conflictset /**< pointer to conflict set to insert */
2002  )
2003 {
2004  SCIP_Real score;
2005  int pos;
2006  int i;
2007  int j;
2008 
2009  assert(conflict != NULL);
2010  assert(set != NULL);
2011  assert(conflictset != NULL);
2012  assert(*conflictset != NULL);
2013  assert((*conflictset)->validdepth <= (*conflictset)->insertdepth);
2014  assert(set->conf_allowlocal || (*conflictset)->validdepth == 0);
2015 
2016  /* calculate conflict and repropagation depth */
2017  conflictsetCalcConflictDepth(*conflictset);
2018 
2019  /* if we apply repropagations, the conflict set should be inserted at most at its repropdepth */
2020  if( set->conf_repropagate )
2021  (*conflictset)->insertdepth = MIN((*conflictset)->insertdepth, (*conflictset)->repropdepth);
2022  else
2023  (*conflictset)->repropdepth = INT_MAX;
2024  assert((*conflictset)->insertdepth <= (*conflictset)->repropdepth);
2025 
2026  SCIPsetDebugMsg(set, "inserting conflict set (valid: %d, insert: %d, conf: %d, reprop: %d):\n",
2027  (*conflictset)->validdepth, (*conflictset)->insertdepth, (*conflictset)->conflictdepth, (*conflictset)->repropdepth);
2028  SCIPdebug(conflictsetPrint(*conflictset));
2029 
2030  /* get the score of the conflict set */
2031  score = conflictsetCalcScore(*conflictset, set);
2032 
2033  /* check, if conflict set is redundant to a better conflict set */
2034  for( pos = 0; pos < conflict->nconflictsets && score < conflict->conflictsetscores[pos]; ++pos )
2035  {
2036  /* check if conflict set is redundant with respect to conflictsets[pos] */
2037  if( conflictsetIsRedundant(*conflictset, conflict->conflictsets[pos]) )
2038  {
2039  SCIPsetDebugMsg(set, " -> conflict set is redundant to: ");
2040  SCIPdebug(conflictsetPrint(conflict->conflictsets[pos]));
2041  conflictsetFree(conflictset, blkmem);
2042  return SCIP_OKAY;
2043  }
2044 
2045  /**@todo like in sepastore.c: calculate overlap between conflictsets -> large overlap reduces score */
2046  }
2047 
2048  /* insert conflictset into the sorted conflictsets array */
2049  SCIP_CALL( conflictEnsureConflictsetsMem(conflict, set, conflict->nconflictsets + 1) );
2050  for( i = conflict->nconflictsets; i > pos; --i )
2051  {
2052  assert(score >= conflict->conflictsetscores[i-1]);
2053  conflict->conflictsets[i] = conflict->conflictsets[i-1];
2054  conflict->conflictsetscores[i] = conflict->conflictsetscores[i-1];
2055  }
2056  conflict->conflictsets[pos] = *conflictset;
2057  conflict->conflictsetscores[pos] = score;
2058  conflict->nconflictsets++;
2059 
2060  /* remove worse conflictsets that are redundant to the new conflictset */
2061  for( i = pos+1, j = pos+1; i < conflict->nconflictsets; ++i )
2062  {
2063  if( conflictsetIsRedundant(conflict->conflictsets[i], *conflictset) )
2064  {
2065  SCIPsetDebugMsg(set, " -> conflict set dominates: ");
2066  SCIPdebug(conflictsetPrint(conflict->conflictsets[i]));
2067  conflictsetFree(&conflict->conflictsets[i], blkmem);
2068  }
2069  else
2070  {
2071  assert(j <= i);
2072  conflict->conflictsets[j] = conflict->conflictsets[i];
2073  conflict->conflictsetscores[j] = conflict->conflictsetscores[i];
2074  j++;
2075  }
2076  }
2077  assert(j <= conflict->nconflictsets);
2078  conflict->nconflictsets = j;
2079 
2080 #ifdef SCIP_CONFGRAPH
2081  confgraphMarkConflictset(*conflictset);
2082 #endif
2083 
2084  *conflictset = NULL; /* ownership of pointer is now in the conflictsets array */
2085 
2086  return SCIP_OKAY;
2087 }
2088 
2089 /** calculates the maximal size of conflict sets to be used */
2090 static
2092  SCIP_SET* set, /**< global SCIP settings */
2093  SCIP_PROB* prob /**< problem data */
2094  )
2095 {
2096  int maxsize;
2097 
2098  assert(set != NULL);
2099  assert(prob != NULL);
2100 
2101  maxsize = (int)(set->conf_maxvarsfac * (prob->nvars - prob->ncontvars));
2102  maxsize = MAX(maxsize, set->conf_minmaxvars);
2103 
2104  return maxsize;
2105 }
2106 
2107 /** increases the conflict score of the variable in the given direction */
2108 static
2110  SCIP_VAR* var, /**< problem variable */
2111  BMS_BLKMEM* blkmem, /**< block memory */
2112  SCIP_SET* set, /**< global SCIP settings */
2113  SCIP_STAT* stat, /**< dynamic problem statistics */
2114  SCIP_BOUNDTYPE boundtype, /**< type of bound for which the score should be increased */
2115  SCIP_Real value, /**< value of the bound */
2116  SCIP_Real weight /**< weight of this VSIDS updates */
2117  )
2118 {
2119  SCIP_BRANCHDIR branchdir;
2120 
2121  assert(var != NULL);
2122  assert(stat != NULL);
2123 
2124  /* weight the VSIDS by the given weight */
2125  weight *= stat->vsidsweight;
2126 
2127  if( SCIPsetIsZero(set, weight) )
2128  return SCIP_OKAY;
2129 
2130  branchdir = (boundtype == SCIP_BOUNDTYPE_LOWER ? SCIP_BRANCHDIR_UPWARDS : SCIP_BRANCHDIR_DOWNWARDS); /*lint !e641*/
2131  SCIP_CALL( SCIPvarIncVSIDS(var, blkmem, set, stat, branchdir, value, weight) );
2132  SCIPhistoryIncVSIDS(stat->glbhistory, branchdir, weight);
2133  SCIPhistoryIncVSIDS(stat->glbhistorycrun, branchdir, weight);
2134 
2135  return SCIP_OKAY;
2136 }
2137 
2138 /** update conflict statistics */
2139 static
2141  SCIP_CONFLICT* conflict, /**< conflict analysis data */
2142  BMS_BLKMEM* blkmem, /**< block memory */
2143  SCIP_SET* set, /**< global SCIP settings */
2144  SCIP_STAT* stat, /**< dynamic problem statistics */
2145  SCIP_CONFLICTSET* conflictset, /**< conflict set to add to the tree */
2146  int insertdepth /**< depth level at which the conflict set should be added */
2147  )
2148 {
2149  if( insertdepth > 0 )
2150  {
2151  conflict->nappliedlocconss++;
2152  conflict->nappliedlocliterals += conflictset->nbdchginfos;
2153  }
2154  else
2155  {
2156  int i;
2157  int conflictlength;
2158  conflictlength = conflictset->nbdchginfos;
2159 
2160  for( i = 0; i < conflictlength; i++ )
2161  {
2162  SCIP_VAR* var;
2163  SCIP_BRANCHDIR branchdir;
2164  SCIP_BOUNDTYPE boundtype;
2165  SCIP_Real bound;
2166 
2167  assert(stat != NULL);
2168 
2169  var = conflictset->bdchginfos[i]->var;
2170  boundtype = SCIPbdchginfoGetBoundtype(conflictset->bdchginfos[i]);
2171  bound = conflictset->relaxedbds[i];
2172 
2173  branchdir = (boundtype == SCIP_BOUNDTYPE_LOWER ? SCIP_BRANCHDIR_UPWARDS : SCIP_BRANCHDIR_DOWNWARDS); /*lint !e641*/
2174 
2175  SCIP_CALL( SCIPvarIncNActiveConflicts(var, blkmem, set, stat, branchdir, bound, (SCIP_Real)conflictlength) );
2176  SCIPhistoryIncNActiveConflicts(stat->glbhistory, branchdir, (SCIP_Real)conflictlength);
2177  SCIPhistoryIncNActiveConflicts(stat->glbhistorycrun, branchdir, (SCIP_Real)conflictlength);
2178 
2179  /* each variable which is part of the conflict gets an increase in the VSIDS */
2180  SCIP_CALL( incVSIDS(var, blkmem, set, stat, boundtype, bound, set->conf_conflictweight) );
2181  }
2182  conflict->nappliedglbconss++;
2183  conflict->nappliedglbliterals += conflictset->nbdchginfos;
2184  }
2185 
2186  return SCIP_OKAY;
2187 }
2188 
2189 
2190 /** check conflict set for redundancy, other conflicts in the same conflict analysis could have led to global reductions
2191  * an made this conflict set redundant
2192  */
2193 static
2195  SCIP_SET* set, /**< global SCIP settings */
2196  SCIP_CONFLICTSET* conflictset /**< conflict set */
2197  )
2198 {
2199  SCIP_BDCHGINFO** bdchginfos;
2200  SCIP_VAR* var;
2201  SCIP_Real* relaxedbds;
2202  SCIP_Real bound;
2203  int v;
2204 
2205  assert(set != NULL);
2206  assert(conflictset != NULL);
2207 
2208  bdchginfos = conflictset->bdchginfos;
2209  relaxedbds = conflictset->relaxedbds;
2210  assert(bdchginfos != NULL);
2211  assert(relaxedbds != NULL);
2212 
2213  /* check all boundtypes and bounds for redundancy */
2214  for( v = conflictset->nbdchginfos - 1; v >= 0; --v )
2215  {
2216  var = SCIPbdchginfoGetVar(bdchginfos[v]);
2217  assert(var != NULL);
2218  assert(SCIPvarGetProbindex(var) >= 0);
2219 
2220  /* check if the relaxed bound is really a relaxed bound */
2221  assert(SCIPbdchginfoGetBoundtype(bdchginfos[v]) == SCIP_BOUNDTYPE_LOWER || SCIPsetIsGE(set, relaxedbds[v], SCIPbdchginfoGetNewbound(bdchginfos[v])));
2222  assert(SCIPbdchginfoGetBoundtype(bdchginfos[v]) == SCIP_BOUNDTYPE_UPPER || SCIPsetIsLE(set, relaxedbds[v], SCIPbdchginfoGetNewbound(bdchginfos[v])));
2223 
2224  bound = relaxedbds[v];
2225 
2226  if( SCIPbdchginfoGetBoundtype(bdchginfos[v]) == SCIP_BOUNDTYPE_UPPER )
2227  {
2229  {
2230  assert(SCIPsetIsIntegral(set, bound));
2231  bound += 1.0;
2232  }
2233 
2234  /* check if the bound is already fulfilled globally */
2235  if( SCIPsetIsFeasGE(set, SCIPvarGetLbGlobal(var), bound) )
2236  return TRUE;
2237  }
2238  else
2239  {
2240  assert(SCIPbdchginfoGetBoundtype(bdchginfos[v]) == SCIP_BOUNDTYPE_LOWER);
2241 
2243  {
2244  assert(SCIPsetIsIntegral(set, bound));
2245  bound -= 1.0;
2246  }
2247 
2248  /* check if the bound is already fulfilled globally */
2249  if( SCIPsetIsFeasLE(set, SCIPvarGetUbGlobal(var), bound) )
2250  return TRUE;
2251  }
2252  }
2253 
2254  return FALSE;
2255 }
2256 
2257 /** find global fixings which can be derived from the new conflict set */
2258 static
2260  SCIP_SET* set, /**< global SCIP settings */
2261  SCIP_PROB* prob, /**< transformed problem after presolve */
2262  SCIP_STAT* stat, /**< dynamic SCIP statistics */
2263  SCIP_TREE* tree, /**< tree data */
2264  BMS_BLKMEM* blkmem, /**< block memory */
2265  SCIP_PROB* origprob, /**< original problem */
2266  SCIP_REOPT* reopt, /**< reoptimization data */
2267  SCIP_LP* lp, /**< LP data */
2268  SCIP_CONFLICTSET* conflictset, /**< conflict set to add to the tree */
2269  int* nbdchgs, /**< number of global deducted bound changes due to the conflict set */
2270  int* nredvars, /**< number of redundant and removed variables from conflict set */
2271  SCIP_Bool* redundant /**< did we found a global reduction on a conflict set variable, which makes this conflict redundant */
2272  )
2273 {
2274  SCIP_BDCHGINFO** bdchginfos;
2275  SCIP_Real* relaxedbds;
2276  SCIP_VAR* var;
2277  SCIP_Bool* boundtypes;
2278  SCIP_Real* bounds;
2279  SCIP_Longint* nbinimpls;
2280  int* sortvals;
2281  SCIP_Real bound;
2282  SCIP_Bool isupper;
2283  int ntrivialredvars;
2284  int nbdchginfos;
2285  int nzeroimpls;
2286  int v;
2287 
2288  assert(set != NULL);
2289  assert(prob != NULL);
2290  assert(SCIPprobIsTransformed(prob));
2291  assert(conflictset != NULL);
2292  assert(nbdchgs != NULL);
2293  assert(nredvars != NULL);
2294  /* only check conflict sets with more than one variable */
2295  assert(conflictset->nbdchginfos > 1);
2296 
2297  *nbdchgs = 0;
2298  *nredvars = 0;
2299 
2300  /* due to other conflict in the same conflict analysis, this conflict set might have become redundant */
2301  *redundant = checkRedundancy(set, conflictset);
2302 
2303  if( *redundant )
2304  return SCIP_OKAY;
2305 
2306  bdchginfos = conflictset->bdchginfos;
2307  relaxedbds = conflictset->relaxedbds;
2308  nbdchginfos = conflictset->nbdchginfos;
2309  sortvals = conflictset->sortvals;
2310 
2311  assert(bdchginfos != NULL);
2312  assert(relaxedbds != NULL);
2313  assert(sortvals != NULL);
2314 
2315  /* check if the boolean representation of boundtypes matches the 'standard' definition */
2316  assert(SCIP_BOUNDTYPE_LOWER == FALSE); /*lint !e641 !e506*/
2317  assert(SCIP_BOUNDTYPE_UPPER == TRUE); /*lint !e641 !e506*/
2318 
2319  ntrivialredvars = 0;
2320 
2321  /* due to multiple conflict sets for one conflict, it can happen, that we already have redundant information in the
2322  * conflict set
2323  */
2324  for( v = nbdchginfos - 1; v >= 0; --v )
2325  {
2326  var = SCIPbdchginfoGetVar(bdchginfos[v]);
2327  bound = relaxedbds[v];
2328  isupper = (SCIP_Bool) SCIPboundtypeOpposite(SCIPbdchginfoGetBoundtype(bdchginfos[v]));
2329 
2330  /* for integral variable we can increase/decrease the conflicting bound */
2331  if( SCIPvarIsIntegral(var) )
2332  bound += (isupper ? -1.0 : +1.0);
2333 
2334  /* if conflict variable cannot fulfill the conflict we can remove it */
2335  if( (isupper && SCIPsetIsFeasLT(set, bound, SCIPvarGetLbGlobal(var))) ||
2336  (!isupper && SCIPsetIsFeasGT(set, bound, SCIPvarGetUbGlobal(var))) )
2337  {
2338  SCIPsetDebugMsg(set, "remove redundant variable <%s> from conflict set\n", SCIPvarGetName(var));
2339 
2340  bdchginfos[v] = bdchginfos[nbdchginfos - 1];
2341  relaxedbds[v] = relaxedbds[nbdchginfos - 1];
2342  sortvals[v] = sortvals[nbdchginfos - 1];
2343 
2344  --nbdchginfos;
2345  ++ntrivialredvars;
2346  }
2347  }
2348  assert(ntrivialredvars + nbdchginfos == conflictset->nbdchginfos);
2349 
2350  SCIPsetDebugMsg(set, "trivially removed %d redundant of %d variables from conflictset (%p)\n", ntrivialredvars, conflictset->nbdchginfos, (void*)conflictset);
2351  conflictset->nbdchginfos = nbdchginfos;
2352 
2353  /* all variables where removed, the conflict cannot be fulfilled, i.e., we have an infeasibility proof */
2354  if( conflictset->nbdchginfos == 0 )
2355  return SCIP_OKAY;
2356 
2357  /* do not check to big or trivial conflicts */
2358  if( conflictset->nbdchginfos > set->conf_maxvarsdetectimpliedbounds || conflictset->nbdchginfos == 1 )
2359  {
2360  *nredvars = ntrivialredvars;
2361  return SCIP_OKAY;
2362  }
2363 
2364  /* create array of boundtypes, and bound values in conflict set */
2365  SCIP_CALL( SCIPsetAllocBufferArray(set, &boundtypes, nbdchginfos) );
2366  SCIP_CALL( SCIPsetAllocBufferArray(set, &bounds, nbdchginfos) );
2367  /* memory for the estimates for binary implications used for sorting */
2368  SCIP_CALL( SCIPsetAllocBufferArray(set, &nbinimpls, nbdchginfos) );
2369 
2370  nzeroimpls = 0;
2371 
2372  /* collect estimates and initialize variables, boundtypes, and bounds array */
2373  for( v = 0; v < nbdchginfos; ++v )
2374  {
2375  var = SCIPbdchginfoGetVar(bdchginfos[v]);
2376  boundtypes[v] = (SCIP_Bool) SCIPboundtypeOpposite(SCIPbdchginfoGetBoundtype(bdchginfos[v]));
2377  bounds[v] = relaxedbds[v];
2378 
2379  assert(SCIPvarGetProbindex(var) >= 0);
2380 
2381  /* check if the relaxed bound is really a relaxed bound */
2382  assert(SCIPbdchginfoGetBoundtype(bdchginfos[v]) == SCIP_BOUNDTYPE_LOWER || SCIPsetIsGE(set, relaxedbds[v], SCIPbdchginfoGetNewbound(bdchginfos[v])));
2383  assert(SCIPbdchginfoGetBoundtype(bdchginfos[v]) == SCIP_BOUNDTYPE_UPPER || SCIPsetIsLE(set, relaxedbds[v], SCIPbdchginfoGetNewbound(bdchginfos[v])));
2384 
2385  /* for continuous variables, we can only use the relaxed version of the bounds negation: !(x <= u) -> x >= u */
2386  if( SCIPvarIsBinary(var) )
2387  {
2388  if( !boundtypes[v] )
2389  {
2390  assert(SCIPsetIsZero(set, bounds[v]));
2391  bounds[v] = 1.0;
2392  nbinimpls[v] = (SCIP_Longint)SCIPvarGetNCliques(var, TRUE) * 2;
2393  }
2394  else
2395  {
2396  assert(SCIPsetIsEQ(set, bounds[v], 1.0));
2397  bounds[v] = 0.0;
2398  nbinimpls[v] = (SCIP_Longint)SCIPvarGetNCliques(var, FALSE) * 2;
2399  }
2400  }
2401  else if( SCIPvarIsIntegral(var) )
2402  {
2403  assert(SCIPsetIsIntegral(set, bounds[v]));
2404 
2405  bounds[v] += ((!boundtypes[v]) ? +1.0 : -1.0);
2406  nbinimpls[v] = (boundtypes[v] ? SCIPvarGetNVlbs(var) : SCIPvarGetNVubs(var));
2407  }
2408  else if( ((!boundtypes[v]) && SCIPsetIsFeasEQ(set, SCIPvarGetLbGlobal(var), bounds[v]))
2409  || ((boundtypes[v]) && SCIPsetIsFeasEQ(set, SCIPvarGetUbGlobal(var), bounds[v])) )
2410  {
2411  /* the literal is satisfied in global bounds (may happen due to weak "negation" of continuous variables)
2412  * -> discard the conflict constraint
2413  */
2414  break;
2415  }
2416  else
2417  {
2418  nbinimpls[v] = (boundtypes[v] ? SCIPvarGetNVlbs(var) : SCIPvarGetNVubs(var));
2419  }
2420 
2421  if( nbinimpls[v] == 0 )
2422  ++nzeroimpls;
2423  }
2424 
2425  /* starting to derive global bound changes */
2426  if( v == nbdchginfos && ((!set->conf_fullshortenconflict && nzeroimpls < 2) || (set->conf_fullshortenconflict && nzeroimpls < nbdchginfos)) )
2427  {
2428  SCIP_VAR** vars;
2429  SCIP_Bool* redundants;
2430  SCIP_Bool glbinfeas;
2431 
2432  /* sort variables in increasing order of binary implications to gain speed later on */
2433  SCIPsortLongPtrRealRealBool(nbinimpls, (void**)bdchginfos, relaxedbds, bounds, boundtypes, v);
2434 
2435  SCIPsetDebugMsg(set, "checking for global reductions and redundant conflict variables(in %s) on conflict:\n", SCIPprobGetName(prob));
2436  SCIPsetDebugMsg(set, "[");
2437  for( v = 0; v < nbdchginfos; ++v )
2438  {
2439  SCIPsetDebugMsgPrint(set, "%s %s %g", SCIPvarGetName(SCIPbdchginfoGetVar(bdchginfos[v])), (!boundtypes[v]) ? ">=" : "<=", bounds[v]);
2440  if( v < nbdchginfos - 1 )
2441  SCIPsetDebugMsgPrint(set, ", ");
2442  }
2443  SCIPsetDebugMsgPrint(set, "]\n");
2444 
2445  SCIP_CALL( SCIPsetAllocBufferArray(set, &vars, v) );
2446  SCIP_CALL( SCIPsetAllocCleanBufferArray(set, &redundants, v) );
2447 
2448  /* initialize conflict variable data */
2449  for( v = 0; v < nbdchginfos; ++v )
2450  vars[v] = SCIPbdchginfoGetVar(bdchginfos[v]);
2451 
2452  SCIP_CALL( SCIPshrinkDisjunctiveVarSet(set->scip, vars, bounds, boundtypes, redundants, nbdchginfos, nredvars, \
2453  nbdchgs, redundant, &glbinfeas, set->conf_fullshortenconflict) );
2454 
2455  if( glbinfeas )
2456  {
2457  SCIPsetDebugMsg(set, "conflict set (%p) led to global infeasibility\n", (void*) conflictset);
2458 
2459  SCIP_CALL( SCIPnodeCutoff(SCIPtreeGetRootNode(tree), set, stat, tree, prob, origprob, reopt, lp, blkmem) );
2460 
2461  /* clear the memory array before freeing it */
2462  BMSclearMemoryArray(redundants, nbdchginfos);
2463  goto TERMINATE;
2464  }
2465 
2466 #ifdef SCIP_DEBUG
2467  if( *nbdchgs > 0 )
2468  {
2469  SCIPsetDebugMsg(set, "conflict set (%p) led to %d global bound reductions\n", (void*) conflictset, *nbdchgs);
2470  }
2471 #endif
2472 
2473  /* remove as redundant marked variables */
2474  if( *redundant )
2475  {
2476  SCIPsetDebugMsg(set, "conflict set (%p) is redundant because at least one global reduction, fulfills the conflict constraint\n", (void*)conflictset);
2477 
2478  /* clear the memory array before freeing it */
2479  BMSclearMemoryArray(redundants, nbdchginfos);
2480  }
2481  else if( *nredvars > 0 )
2482  {
2483  assert(bdchginfos == conflictset->bdchginfos);
2484  assert(relaxedbds == conflictset->relaxedbds);
2485  assert(sortvals == conflictset->sortvals);
2486 
2487  for( v = nbdchginfos - 1; v >= 0; --v )
2488  {
2489  /* if conflict variable was marked to be redundant remove it */
2490  if( redundants[v] )
2491  {
2492  SCIPsetDebugMsg(set, "remove redundant variable <%s> from conflict set\n", SCIPvarGetName(SCIPbdchginfoGetVar(bdchginfos[v])));
2493 
2494  bdchginfos[v] = bdchginfos[nbdchginfos - 1];
2495  relaxedbds[v] = relaxedbds[nbdchginfos - 1];
2496  sortvals[v] = sortvals[nbdchginfos - 1];
2497 
2498  /* reset redundants[v] to 0 */
2499  redundants[v] = 0;
2500 
2501  --nbdchginfos;
2502  }
2503  }
2504  assert((*nredvars) + nbdchginfos == conflictset->nbdchginfos);
2505 
2506  SCIPsetDebugMsg(set, "removed %d redundant of %d variables from conflictset (%p)\n", (*nredvars), conflictset->nbdchginfos, (void*)conflictset);
2507  conflictset->nbdchginfos = nbdchginfos;
2508  }
2509  else
2510  {
2511  /* clear the memory array before freeing it */
2512  BMSclearMemoryArray(redundants, nbdchginfos);
2513  }
2514 
2515  TERMINATE:
2516  SCIPsetFreeCleanBufferArray(set, &redundants);
2517  SCIPsetFreeBufferArray(set, &vars);
2518  }
2519 
2520  /* free temporary memory */
2521  SCIPsetFreeBufferArray(set, &nbinimpls);
2522  SCIPsetFreeBufferArray(set, &bounds);
2523  SCIPsetFreeBufferArray(set, &boundtypes);
2524 
2525  *nredvars += ntrivialredvars;
2526 
2527  return SCIP_OKAY;
2528 }
2529 
2530 /** tighten the bound of a singleton variable in a constraint
2531  *
2532  * if the bound is contradicting with a global bound we cannot tighten the bound directly.
2533  * in this case we need to create and add a constraint of size one such that propagating this constraint will
2534  * enforce the infeasibility.
2535  */
2536 static
2538  SCIP_CONFLICT* conflict, /**< conflict analysis data */
2539  SCIP_SET* set, /**< global SCIP settings */
2540  SCIP_STAT* stat, /**< dynamic SCIP statistics */
2541  SCIP_TREE* tree, /**< tree data */
2542  BMS_BLKMEM* blkmem, /**< block memory */
2543  SCIP_PROB* origprob, /**< original problem */
2544  SCIP_PROB* transprob, /**< transformed problem */
2545  SCIP_REOPT* reopt, /**< reoptimization data */
2546  SCIP_LP* lp, /**< LP data */
2547  SCIP_BRANCHCAND* branchcand, /**< branching candidates */
2548  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
2549  SCIP_CLIQUETABLE* cliquetable, /**< clique table */
2550  SCIP_VAR* var, /**< problem variable */
2551  SCIP_Real val, /**< coefficient of the variable */
2552  SCIP_Real rhs, /**< rhs of the constraint */
2553  SCIP_CONFTYPE prooftype, /**< type of the proof */
2554  int validdepth /**< depth where the bound change is valid */
2555  )
2556 {
2557  SCIP_Real newbound;
2558  SCIP_Bool applyglobal;
2559  SCIP_BOUNDTYPE boundtype;
2560 
2561  assert(tree != NULL);
2562  assert(validdepth >= 0);
2563 
2564  applyglobal = (validdepth <= SCIPtreeGetEffectiveRootDepth(tree));
2565 
2566  /* if variable and coefficient are integral the rhs can be rounded down */
2567  if( SCIPvarIsIntegral(var) && SCIPsetIsIntegral(set, val) )
2568  newbound = SCIPsetFeasFloor(set, rhs)/val;
2569  else
2570  newbound = rhs/val;
2571 
2572  boundtype = (val > 0.0 ? SCIP_BOUNDTYPE_UPPER : SCIP_BOUNDTYPE_LOWER);
2573  SCIPvarAdjustBd(var, set, boundtype, &newbound);
2574 
2575  /* skip numerical unstable bound changes */
2576  if( applyglobal
2577  && ((boundtype == SCIP_BOUNDTYPE_LOWER && SCIPsetIsLE(set, newbound, SCIPvarGetLbGlobal(var)))
2578  || (boundtype == SCIP_BOUNDTYPE_UPPER && SCIPsetIsGE(set, newbound, SCIPvarGetUbGlobal(var)))) )
2579  {
2580  return SCIP_OKAY;
2581  }
2582 
2583  /* the new bound contradicts a global bound, we can cutoff the root node immediately */
2584  if( applyglobal
2585  && ((boundtype == SCIP_BOUNDTYPE_LOWER && SCIPsetIsGT(set, newbound, SCIPvarGetUbGlobal(var)))
2586  || (boundtype == SCIP_BOUNDTYPE_UPPER && SCIPsetIsLT(set, newbound, SCIPvarGetLbGlobal(var)))) )
2587  {
2588  SCIPsetDebugMsg(set, "detected global infeasibility at var <%s>: locdom=[%g,%g] glbdom=[%g,%g] new %s bound=%g\n",
2589  SCIPvarGetName(var), SCIPvarGetLbLocal(var),
2591  (boundtype == SCIP_BOUNDTYPE_LOWER ? "lower" : "upper"), newbound);
2592  SCIP_CALL( SCIPnodeCutoff(tree->path[0], set, stat, tree, transprob, origprob, reopt, lp, blkmem) );
2593  }
2594  else
2595  {
2596  if( lp->strongbranching || !applyglobal )
2597  {
2598  SCIP_CONS* cons;
2599  SCIP_Real conslhs;
2600  SCIP_Real consrhs;
2601  char name[SCIP_MAXSTRLEN];
2602 
2603  SCIPsetDebugMsg(set, "add constraint <%s>[%c] %s %g to node #%lld in depth %d\n",
2604  SCIPvarGetName(var), varGetChar(var), boundtype == SCIP_BOUNDTYPE_UPPER ? "<=" : ">=", newbound,
2605  SCIPnodeGetNumber(tree->path[validdepth]), validdepth);
2606 
2607  (void)SCIPsnprintf(name, SCIP_MAXSTRLEN, "pc_fix_%s", SCIPvarGetName(var));
2608 
2609  if( boundtype == SCIP_BOUNDTYPE_UPPER )
2610  {
2611  conslhs = -SCIPsetInfinity(set);
2612  consrhs = newbound;
2613  }
2614  else
2615  {
2616  conslhs = newbound;
2617  consrhs = SCIPsetInfinity(set);
2618  }
2619 
2620  SCIP_CALL( SCIPcreateConsLinear(set->scip, &cons, name, 0, NULL, NULL, conslhs, consrhs,
2622 
2623  SCIP_CALL( SCIPaddCoefLinear(set->scip, cons, var, 1.0) );
2624 
2625  if( applyglobal )
2626  {
2627  SCIP_CALL( SCIPprobAddCons(transprob, set, stat, cons) );
2628  }
2629  else
2630  {
2631  SCIP_CALL( SCIPnodeAddCons(tree->path[validdepth], blkmem, set, stat, tree, cons) );
2632  }
2633 
2634  SCIP_CALL( SCIPconsRelease(&cons, blkmem, set) );
2635  }
2636  else
2637  {
2638  assert(applyglobal);
2639 
2640  SCIPsetDebugMsg(set, "change global %s bound of <%s>[%c]: %g -> %g\n",
2641  (boundtype == SCIP_BOUNDTYPE_LOWER ? "lower" : "upper"),
2642  SCIPvarGetName(var), varGetChar(var),
2643  (boundtype == SCIP_BOUNDTYPE_LOWER ? SCIPvarGetLbGlobal(var) : SCIPvarGetUbGlobal(var)),
2644  newbound);
2645 
2646  SCIP_CALL( SCIPnodeAddBoundchg(tree->path[0], blkmem, set, stat, transprob, origprob, tree, reopt, lp, branchcand, \
2647  eventqueue, cliquetable, var, newbound, boundtype, FALSE) );
2648 
2649  /* mark the node in the validdepth to be propagated again */
2650  SCIPnodePropagateAgain(tree->path[0], set, stat, tree);
2651  }
2652  }
2653 
2654  if( applyglobal )
2655  ++conflict->nglbchgbds;
2656  else
2657  ++conflict->nlocchgbds;
2658 
2659  if( prooftype == SCIP_CONFTYPE_INFEASLP || prooftype == SCIP_CONFTYPE_ALTINFPROOF )
2660  {
2661  ++conflict->dualproofsinfnnonzeros; /* we count a global bound reduction as size 1 */
2662  ++conflict->ndualproofsinfsuccess;
2663  ++conflict->ninflpsuccess;
2664 
2665  if( applyglobal )
2666  ++conflict->ndualproofsinfglobal;
2667  else
2668  ++conflict->ndualproofsinflocal;
2669  }
2670  else
2671  {
2672  ++conflict->dualproofsbndnnonzeros; /* we count a global bound reduction as size 1 */
2673  ++conflict->ndualproofsbndsuccess;
2674  ++conflict->nboundlpsuccess;
2675 
2676  if( applyglobal )
2677  ++conflict->ndualproofsbndglobal;
2678  else
2679  ++conflict->ndualproofsbndlocal;
2680  }
2681 
2682  return SCIP_OKAY;
2683 }
2684 
2685 /** calculates the minimal activity of a given aggregation row */
2686 static
2688  SCIP_SET* set, /**< global SCIP settings */
2689  SCIP_PROB* transprob, /**< transformed problem data */
2690  SCIP_AGGRROW* aggrrow, /**< aggregation row */
2691  SCIP_Real* curvarlbs, /**< current lower bounds of active problem variables (or NULL for global bounds) */
2692  SCIP_Real* curvarubs, /**< current upper bounds of active problem variables (or NULL for global bounds) */
2693  SCIP_Bool* infdelta /**< pointer to store whether at least one variable contributes with an infinite value */
2694  )
2695 {
2696  SCIP_VAR** vars;
2697  SCIP_Real QUAD(minact);
2698  int* inds;
2699  int nnz;
2700  int i;
2701 
2702  vars = SCIPprobGetVars(transprob);
2703  assert(vars != NULL);
2704 
2705  nnz = SCIPaggrRowGetNNz(aggrrow);
2706  inds = SCIPaggrRowGetInds(aggrrow);
2707 
2708  QUAD_ASSIGN(minact, 0.0);
2709 
2710  if( infdelta != NULL )
2711  *infdelta = FALSE;
2712 
2713  for( i = 0; i < nnz; i++ )
2714  {
2715  SCIP_Real val;
2716  SCIP_Real QUAD(delta);
2717  int v = inds[i];
2718 
2719  assert(SCIPvarGetProbindex(vars[v]) == v);
2720 
2721  val = SCIPaggrRowGetProbvarValue(aggrrow, v);
2722 
2723  if( val > 0.0 )
2724  {
2725  SCIP_Real bnd = (curvarlbs == NULL ? SCIPvarGetLbGlobal(vars[v]) : curvarlbs[v]);
2726  if( infdelta != NULL && SCIPsetIsInfinity(set, -bnd) )
2727  {
2728  *infdelta = TRUE;
2729  goto TERMINATE;
2730  }
2731  SCIPquadprecProdDD(delta, val, bnd);
2732  }
2733  else
2734  {
2735  SCIP_Real bnd = (curvarubs == NULL ? SCIPvarGetUbGlobal(vars[v]) : curvarubs[v]);
2736  if( infdelta != NULL && SCIPsetIsInfinity(set, bnd) )
2737  {
2738  *infdelta = TRUE;
2739  goto TERMINATE;
2740  }
2741  SCIPquadprecProdDD(delta, val, bnd);
2742  }
2743 
2744  /* update minimal activity */
2745  SCIPquadprecSumQQ(minact, minact, delta);
2746 
2747  if( infdelta != NULL && SCIPsetIsInfinity(set, REALABS(QUAD_TO_DBL(delta))) )
2748  {
2749  *infdelta = TRUE;
2750  goto TERMINATE;
2751  }
2752  }
2753 
2754  TERMINATE:
2755  /* check whether the minimal activity is infinite */
2756  if( SCIPsetIsInfinity(set, QUAD_TO_DBL(minact)) )
2757  return SCIPsetInfinity(set);
2758  if( SCIPsetIsInfinity(set, -QUAD_TO_DBL(minact)) )
2759  return -SCIPsetInfinity(set);
2760 
2761  return QUAD_TO_DBL(minact);
2762 }
2763 
2764 /** calculates the minimal activity of a given set of bounds and coefficients */
2765 static
2767  SCIP_SET* set, /**< global SCIP settings */
2768  SCIP_PROB* transprob, /**< transformed problem data */
2769  SCIP_Real* coefs, /**< coefficients in sparse representation */
2770  int* inds, /**< non-zero indices */
2771  int nnz, /**< number of non-zero indices */
2772  SCIP_Real* curvarlbs, /**< current lower bounds of active problem variables (or NULL for global bounds) */
2773  SCIP_Real* curvarubs /**< current upper bounds of active problem variables (or NULL for global bounds) */
2774  )
2775 {
2776  SCIP_VAR** vars;
2777  SCIP_Real QUAD(minact);
2778  int i;
2779 
2780  assert(coefs != NULL);
2781  assert(inds != NULL);
2782 
2783  vars = SCIPprobGetVars(transprob);
2784  assert(vars != NULL);
2785 
2786  QUAD_ASSIGN(minact, 0.0);
2787 
2788  for( i = 0; i < nnz; i++ )
2789  {
2790  SCIP_Real val;
2791  SCIP_Real QUAD(delta);
2792  int v = inds[i];
2793 
2794  assert(SCIPvarGetProbindex(vars[v]) == v);
2795 
2796  val = coefs[i];
2797 
2798  if( val > 0.0 )
2799  {
2800  SCIP_Real bnd;
2801 
2802  assert(curvarlbs == NULL || !SCIPsetIsInfinity(set, -curvarlbs[v]));
2803 
2804  bnd = (curvarlbs == NULL ? SCIPvarGetLbGlobal(vars[v]) : curvarlbs[v]);
2805  SCIPquadprecProdDD(delta, val, bnd);
2806  }
2807  else
2808  {
2809  SCIP_Real bnd;
2810 
2811  assert(curvarubs == NULL || !SCIPsetIsInfinity(set, curvarubs[v]));
2812 
2813  bnd = (curvarubs == NULL ? SCIPvarGetUbGlobal(vars[v]) : curvarubs[v]);
2814  SCIPquadprecProdDD(delta, val, bnd);
2815  }
2816 
2817  /* update minimal activity */
2818  SCIPquadprecSumQQ(minact, minact, delta);
2819  }
2820 
2821  /* check whether the minmal activity is infinite */
2822  if( SCIPsetIsInfinity(set, QUAD_TO_DBL(minact)) )
2823  return SCIPsetInfinity(set);
2824  if( SCIPsetIsInfinity(set, -QUAD_TO_DBL(minact)) )
2825  return -SCIPsetInfinity(set);
2826 
2827  return QUAD_TO_DBL(minact);
2828 }
2829 
2830 /** calculates the minimal activity of a given set of bounds and coefficients */
2831 static
2833  SCIP_SET* set, /**< global SCIP settings */
2834  SCIP_PROB* transprob, /**< transformed problem data */
2835  SCIP_Real* coefs, /**< coefficients in sparse representation */
2836  int* inds, /**< non-zero indices */
2837  int nnz, /**< number of non-zero indices */
2838  SCIP_Real* curvarlbs, /**< current lower bounds of active problem variables (or NULL for global bounds) */
2839  SCIP_Real* curvarubs /**< current upper bounds of active problem variables (or NULL for global bounds) */
2840  )
2841 {
2842  SCIP_VAR** vars;
2843  SCIP_Real QUAD(maxact);
2844  int i;
2845 
2846  assert(coefs != NULL);
2847  assert(inds != NULL);
2848 
2849  vars = SCIPprobGetVars(transprob);
2850  assert(vars != NULL);
2851 
2852  QUAD_ASSIGN(maxact, 0.0);
2853 
2854  for( i = 0; i < nnz; i++ )
2855  {
2856  SCIP_Real val;
2857  SCIP_Real QUAD(delta);
2858  int v = inds[i];
2859 
2860  assert(SCIPvarGetProbindex(vars[v]) == v);
2861 
2862  val = coefs[i];
2863 
2864  if( val < 0.0 )
2865  {
2866  SCIP_Real bnd;
2867 
2868  assert(curvarlbs == NULL || !SCIPsetIsInfinity(set, -curvarlbs[v]));
2869 
2870  bnd = (curvarlbs == NULL ? SCIPvarGetLbGlobal(vars[v]) : curvarlbs[v]);
2871  SCIPquadprecProdDD(delta, val, bnd);
2872  }
2873  else
2874  {
2875  SCIP_Real bnd;
2876 
2877  assert(curvarubs == NULL || !SCIPsetIsInfinity(set, curvarubs[v]));
2878 
2879  bnd = (curvarubs == NULL ? SCIPvarGetUbGlobal(vars[v]) : curvarubs[v]);
2880  SCIPquadprecProdDD(delta, val, bnd);
2881  }
2882 
2883  /* update maximal activity */
2884  SCIPquadprecSumQQ(maxact, maxact, delta);
2885  }
2886 
2887  /* check whether the maximal activity got infinite */
2888  if( SCIPsetIsInfinity(set, QUAD_TO_DBL(maxact)) )
2889  return SCIPsetInfinity(set);
2890  if( SCIPsetIsInfinity(set, -QUAD_TO_DBL(maxact)) )
2891  return -SCIPsetInfinity(set);
2892 
2893  return QUAD_TO_DBL(maxact);
2894 }
2895 
2896 static
2898  SCIP_CONFLICT* conflict, /**< conflict analysis data */
2899  SCIP_SET* set, /**< global SCIP settings */
2900  SCIP_STAT* stat, /**< dynamic SCIP statistics */
2901  SCIP_REOPT* reopt, /**< reoptimization data */
2902  SCIP_TREE* tree, /**< tree data */
2903  BMS_BLKMEM* blkmem, /**< block memory */
2904  SCIP_PROB* origprob, /**< original problem */
2905  SCIP_PROB* transprob, /**< transformed problem */
2906  SCIP_LP* lp, /**< LP data */
2907  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
2908  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
2909  SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
2910  SCIP_Real* coefs, /**< coefficients in sparse representation */
2911  int* inds, /**< non-zero indices */
2912  int nnz, /**< number of non-zero indices */
2913  SCIP_Real rhs, /**< right-hand side */
2914  SCIP_CONFTYPE conflicttype, /**< type of the conflict */
2915  int validdepth /**< depth where the proof is valid */
2916  )
2917 {
2918  SCIP_VAR** vars;
2919  SCIP_Real minact;
2920  int i;
2921 
2922  assert(coefs != NULL);
2923  assert(inds != NULL);
2924  assert(nnz >= 0);
2925 
2926  vars = SCIPprobGetVars(transprob);
2927  minact = getMinActivity(set, transprob, coefs, inds, nnz, NULL, NULL);
2928 
2929  /* we cannot find global tightenings */
2930  if( SCIPsetIsInfinity(set, -minact) )
2931  return SCIP_OKAY;
2932 
2933  for( i = 0; i < nnz; i++ )
2934  {
2935  SCIP_VAR* var;
2936  SCIP_Real val;
2937  SCIP_Real resminact;
2938  SCIP_Real lb;
2939  SCIP_Real ub;
2940  int pos;
2941 
2942  pos = inds[i];
2943  val = coefs[i];
2944  var = vars[pos];
2945  lb = SCIPvarGetLbGlobal(var);
2946  ub = SCIPvarGetUbGlobal(var);
2947 
2948  assert(!SCIPsetIsZero(set, val));
2949 
2950  resminact = minact;
2951 
2952  /* we got a potential new upper bound */
2953  if( val > 0.0 )
2954  {
2955  SCIP_Real newub;
2956 
2957  resminact -= (val * lb);
2958  newub = (rhs - resminact)/val;
2959 
2960  if( SCIPsetIsInfinity(set, newub) )
2961  continue;
2962 
2963  /* we cannot tighten the upper bound */
2964  if( SCIPsetIsGE(set, newub, ub) )
2965  continue;
2966 
2967  SCIP_CALL( tightenSingleVar(conflict, set, stat, tree, blkmem, origprob, transprob, reopt, lp, branchcand, \
2968  eventqueue, cliquetable, var, val, rhs-resminact, conflicttype, validdepth) );
2969  }
2970  /* we got a potential new lower bound */
2971  else
2972  {
2973  SCIP_Real newlb;
2974 
2975  resminact -= (val * ub);
2976  newlb = (rhs - resminact)/val;
2977 
2978  if( SCIPsetIsInfinity(set, -newlb) )
2979  continue;
2980 
2981  /* we cannot tighten the lower bound */
2982  if( SCIPsetIsLE(set, newlb, lb) )
2983  continue;
2984 
2985  SCIP_CALL( tightenSingleVar(conflict, set, stat, tree, blkmem, origprob, transprob, reopt, lp, branchcand, \
2986  eventqueue, cliquetable, var, val, rhs-resminact, conflicttype, validdepth) );
2987  }
2988 
2989  /* the minimal activity should stay unchanged because we tightened the bound that doesn't contribute to the
2990  * minimal activity
2991  */
2992  assert(SCIPsetIsEQ(set, minact, getMinActivity(set, transprob, coefs, inds, nnz, NULL, NULL)));
2993  }
2994 
2995  return SCIP_OKAY;
2996 }
2997 
2998 
2999 /** creates a proof constraint and tries to add it to the storage */
3000 static
3002  SCIP_CONFLICT* conflict, /**< conflict analysis data */
3003  SCIP_CONFLICTSTORE* conflictstore, /**< conflict pool data */
3004  SCIP_PROOFSET* proofset, /**< proof set */
3005  SCIP_SET* set, /**< global SCIP settings */
3006  SCIP_STAT* stat, /**< dynamic SCIP statistics */
3007  SCIP_PROB* origprob, /**< original problem */
3008  SCIP_PROB* transprob, /**< transformed problem */
3009  SCIP_TREE* tree, /**< tree data */
3010  SCIP_REOPT* reopt, /**< reoptimization data */
3011  SCIP_LP* lp, /**< LP data */
3012  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
3013  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
3014  SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
3015  BMS_BLKMEM* blkmem /**< block memory */
3016  )
3017 {
3018  SCIP_CONS* cons;
3019  SCIP_CONS* upgdcons;
3020  SCIP_VAR** vars;
3021  SCIP_Real* coefs;
3022  int* inds;
3023  SCIP_Real rhs;
3024  SCIP_Real fillin;
3025  SCIP_Real globalminactivity;
3026  SCIP_Bool applyglobal;
3027  SCIP_Bool toolong;
3028  SCIP_Bool contonly;
3029  SCIP_Bool hasrelaxvar;
3030  SCIP_CONFTYPE conflicttype;
3031  char name[SCIP_MAXSTRLEN];
3032  int nnz;
3033  int i;
3034 
3035  assert(conflict != NULL);
3036  assert(conflictstore != NULL);
3037  assert(proofset != NULL);
3038  assert(proofset->validdepth == 0 || proofset->validdepth < SCIPtreeGetFocusDepth(tree));
3039 
3040  nnz = proofsetGetNVars(proofset);
3041 
3042  if( nnz == 0 )
3043  return SCIP_OKAY;
3044 
3045  vars = SCIPprobGetVars(transprob);
3046 
3047  rhs = proofsetGetRhs(proofset);
3048  assert(!SCIPsetIsInfinity(set, rhs));
3049 
3050  coefs = proofsetGetVals(proofset);
3051  assert(coefs != NULL);
3052 
3053  inds = proofsetGetInds(proofset);
3054  assert(inds != NULL);
3055 
3056  conflicttype = proofsetGetConftype(proofset);
3057 
3058  applyglobal = (proofset->validdepth <= SCIPtreeGetEffectiveRootDepth(tree));
3059 
3060  if( applyglobal )
3061  {
3062  SCIP_Real globalmaxactivity = getMaxActivity(set, transprob, coefs, inds, nnz, NULL, NULL);
3063 
3064  /* check whether the alternative proof is redundant */
3065  if( SCIPsetIsLE(set, globalmaxactivity, rhs) )
3066  return SCIP_OKAY;
3067 
3068  /* check whether the constraint proves global infeasibility */
3069  globalminactivity = getMinActivity(set, transprob, coefs, inds, nnz, NULL, NULL);
3070  if( SCIPsetIsGT(set, globalminactivity, rhs) )
3071  {
3072  SCIPsetDebugMsg(set, "detect global infeasibility: minactivity=%g, rhs=%g\n", globalminactivity, rhs);
3073 
3074  SCIP_CALL( SCIPnodeCutoff(tree->path[proofset->validdepth], set, stat, tree, transprob, origprob, reopt, lp, blkmem) );
3075 
3076  goto UPDATESTATISTICS;
3077  }
3078  }
3079 
3080  if( set->conf_minmaxvars >= nnz )
3081  toolong = FALSE;
3082  else
3083  {
3084  SCIP_Real maxnnz;
3085 
3086  if( transprob->startnconss < 100 )
3087  maxnnz = 0.85 * transprob->nvars;
3088  else
3089  maxnnz = (SCIP_Real)transprob->nvars;
3090 
3091  fillin = nnz;
3092  if( conflicttype == SCIP_CONFTYPE_INFEASLP || conflicttype == SCIP_CONFTYPE_ALTINFPROOF )
3093  {
3094  fillin += SCIPconflictstoreGetNDualInfProofs(conflictstore) * SCIPconflictstoreGetAvgNnzDualInfProofs(conflictstore);
3095  fillin /= (SCIPconflictstoreGetNDualInfProofs(conflictstore) + 1.0);
3096  toolong = (fillin > MIN(2.0 * stat->avgnnz, maxnnz));
3097  }
3098  else
3099  {
3100  assert(conflicttype == SCIP_CONFTYPE_BNDEXCEEDING || conflicttype == SCIP_CONFTYPE_ALTBNDPROOF);
3101 
3102  fillin += SCIPconflictstoreGetNDualBndProofs(conflictstore) * SCIPconflictstoreGetAvgNnzDualBndProofs(conflictstore);
3103  fillin /= (SCIPconflictstoreGetNDualBndProofs(conflictstore) + 1.0);
3104  toolong = (fillin > MIN(1.5 * stat->avgnnz, maxnnz));
3105  }
3106 
3107  toolong = (toolong && (nnz > set->conf_maxvarsfac * transprob->nvars));
3108  }
3109 
3110  /* don't store global dual proofs that are too long / have too many non-zeros */
3111  if( toolong )
3112  {
3113  if( applyglobal )
3114  {
3115  SCIP_CALL( propagateLongProof(conflict, set, stat, reopt, tree, blkmem, origprob, transprob, lp, branchcand,
3116  eventqueue, cliquetable, coefs, inds, nnz, rhs, conflicttype, proofset->validdepth) );
3117  }
3118  return SCIP_OKAY;
3119  }
3120 
3121  /* check if conflict contains variables that are invalid after a restart to label it appropriately */
3122  hasrelaxvar = FALSE;
3123  contonly = TRUE;
3124  for( i = 0; i < nnz && (!hasrelaxvar || contonly); ++i )
3125  {
3126  hasrelaxvar |= SCIPvarIsRelaxationOnly(vars[inds[i]]);
3127 
3128  if( SCIPvarIsIntegral(vars[inds[i]]) )
3129  contonly = FALSE;
3130  }
3131 
3132  if( !applyglobal && contonly )
3133  return SCIP_OKAY;
3134 
3135  if( conflicttype == SCIP_CONFTYPE_INFEASLP || conflicttype == SCIP_CONFTYPE_ALTINFPROOF )
3136  (void)SCIPsnprintf(name, SCIP_MAXSTRLEN, "dualproof_inf_%" SCIP_LONGINT_FORMAT, conflict->ndualproofsinfsuccess);
3137  else if( conflicttype == SCIP_CONFTYPE_BNDEXCEEDING || conflicttype == SCIP_CONFTYPE_ALTBNDPROOF )
3138  (void)SCIPsnprintf(name, SCIP_MAXSTRLEN, "dualproof_bnd_%" SCIP_LONGINT_FORMAT, conflict->ndualproofsbndsuccess);
3139  else
3140  return SCIP_INVALIDCALL;
3141 
3142  SCIP_CALL( SCIPcreateConsLinear(set->scip, &cons, name, 0, NULL, NULL, -SCIPsetInfinity(set), rhs,
3143  FALSE, FALSE, FALSE, FALSE, TRUE, !applyglobal,
3144  FALSE, TRUE, TRUE, FALSE) );
3145 
3146  for( i = 0; i < nnz; i++ )
3147  {
3148  int v = inds[i];
3149  SCIP_CALL( SCIPaddCoefLinear(set->scip, cons, vars[v], coefs[i]) );
3150  }
3151 
3152  /* do not upgrade linear constraints of size 1 */
3153  if( nnz > 1 )
3154  {
3155  upgdcons = NULL;
3156  /* try to automatically convert a linear constraint into a more specific and more specialized constraint */
3157  SCIP_CALL( SCIPupgradeConsLinear(set->scip, cons, &upgdcons) );
3158  if( upgdcons != NULL )
3159  {
3160  SCIP_CALL( SCIPreleaseCons(set->scip, &cons) );
3161  cons = upgdcons;
3162 
3163  if( conflicttype == SCIP_CONFTYPE_INFEASLP )
3164  conflicttype = SCIP_CONFTYPE_ALTINFPROOF;
3165  else if( conflicttype == SCIP_CONFTYPE_BNDEXCEEDING )
3166  conflicttype = SCIP_CONFTYPE_ALTBNDPROOF;
3167  }
3168  }
3169 
3170  /* mark constraint to be a conflict */
3171  SCIPconsMarkConflict(cons);
3172 
3173  /* add constraint to storage */
3174  if( conflicttype == SCIP_CONFTYPE_INFEASLP || conflicttype == SCIP_CONFTYPE_ALTINFPROOF )
3175  {
3176  /* add dual proof to storage */
3177  SCIP_CALL( SCIPconflictstoreAddDualraycons(conflictstore, cons, blkmem, set, stat, transprob, reopt, hasrelaxvar) );
3178  }
3179  else
3180  {
3181  SCIP_Real scale = 1.0;
3182  SCIP_Bool updateside = FALSE;
3183 
3184  /* In some cases the constraint could not be updated to a more special type. However, it is possible that
3185  * constraint got scaled. Therefore, we need to be very careful when updating the lhs/rhs after the incumbent
3186  * solution has improved.
3187  */
3188  if( conflicttype == SCIP_CONFTYPE_BNDEXCEEDING )
3189  {
3190  SCIP_Real side;
3191 
3192 #ifndef NDEBUG
3193  SCIP_CONSHDLR* conshdlr = SCIPconsGetHdlr(cons);
3194 
3195  assert(conshdlr != NULL);
3196  assert(strcmp(SCIPconshdlrGetName(conshdlr), "linear") == 0);
3197 #endif
3198  side = SCIPgetLhsLinear(set->scip, cons);
3199 
3200  if( !SCIPsetIsInfinity(set, -side) )
3201  {
3202  if( SCIPsetIsZero(set, side) )
3203  {
3204  scale = -1.0;
3205  }
3206  else
3207  {
3208  scale = proofsetGetRhs(proofset) / side;
3209  assert(SCIPsetIsNegative(set, scale));
3210  }
3211  }
3212  else
3213  {
3214  side = SCIPgetRhsLinear(set->scip, cons);
3215  assert(!SCIPsetIsInfinity(set, side));
3216 
3217  if( SCIPsetIsZero(set, side) )
3218  {
3219  scale = 1.0;
3220  }
3221  else
3222  {
3223  scale = proofsetGetRhs(proofset) / side;
3224  assert(SCIPsetIsPositive(set, scale));
3225  }
3226  }
3227  updateside = TRUE;
3228  }
3229 
3230  /* add dual proof to storage */
3231  SCIP_CALL( SCIPconflictstoreAddDualsolcons(conflictstore, cons, blkmem, set, stat, transprob, reopt, scale, updateside, hasrelaxvar) );
3232  }
3233 
3234  if( applyglobal ) /*lint !e774*/
3235  {
3236  /* add the constraint to the global problem */
3237  SCIP_CALL( SCIPprobAddCons(transprob, set, stat, cons) );
3238  }
3239  else
3240  {
3241  SCIP_CALL( SCIPnodeAddCons(tree->path[proofset->validdepth], blkmem, set, stat, tree, cons) );
3242  }
3243 
3244  SCIPsetDebugMsg(set, "added proof-constraint to node %p (#%lld) in depth %d (nproofconss %d)\n",
3245  (void*)tree->path[proofset->validdepth], SCIPnodeGetNumber(tree->path[proofset->validdepth]),
3246  proofset->validdepth,
3247  (conflicttype == SCIP_CONFTYPE_INFEASLP || conflicttype == SCIP_CONFTYPE_ALTINFPROOF)
3249 
3250  /* release the constraint */
3251  SCIP_CALL( SCIPreleaseCons(set->scip, &cons) );
3252 
3253  UPDATESTATISTICS:
3254  /* update statistics */
3255  if( conflicttype == SCIP_CONFTYPE_INFEASLP || conflicttype == SCIP_CONFTYPE_ALTINFPROOF )
3256  {
3257  conflict->dualproofsinfnnonzeros += nnz;
3258  if( applyglobal ) /*lint !e774*/
3259  ++conflict->ndualproofsinfglobal;
3260  else
3261  ++conflict->ndualproofsinflocal;
3262  ++conflict->ndualproofsinfsuccess;
3263  }
3264  else
3265  {
3266  assert(conflicttype == SCIP_CONFTYPE_BNDEXCEEDING || conflicttype == SCIP_CONFTYPE_ALTBNDPROOF);
3267  conflict->dualproofsbndnnonzeros += nnz;
3268  if( applyglobal ) /*lint !e774*/
3269  ++conflict->ndualproofsbndglobal;
3270  else
3271  ++conflict->ndualproofsbndlocal;
3272 
3273  ++conflict->ndualproofsbndsuccess;
3274  }
3275  return SCIP_OKAY;
3276 }
3277 
3278 /* create proof constraints out of proof sets */
3279 static
3281  SCIP_CONFLICT* conflict, /**< conflict analysis data */
3282  SCIP_CONFLICTSTORE* conflictstore, /**< conflict store */
3283  BMS_BLKMEM* blkmem, /**< block memory */
3284  SCIP_SET* set, /**< global SCIP settings */
3285  SCIP_STAT* stat, /**< dynamic problem statistics */
3286  SCIP_PROB* transprob, /**< transformed problem after presolve */
3287  SCIP_PROB* origprob, /**< original problem */
3288  SCIP_TREE* tree, /**< branch and bound tree */
3289  SCIP_REOPT* reopt, /**< reoptimization data structure */
3290  SCIP_LP* lp, /**< current LP data */
3291  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
3292  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
3293  SCIP_CLIQUETABLE* cliquetable /**< clique table data structure */
3294  )
3295 {
3296  assert(conflict != NULL);
3297 
3299  {
3300  /* only one variable has a coefficient different to zero, we add this bound change instead of a constraint */
3301  if( proofsetGetNVars(conflict->proofset) == 1 )
3302  {
3303  SCIP_VAR** vars;
3304  SCIP_Real* coefs;
3305  int* inds;
3306  SCIP_Real rhs;
3307 
3308  vars = SCIPprobGetVars(transprob);
3309 
3310  coefs = proofsetGetVals(conflict->proofset);
3311  inds = proofsetGetInds(conflict->proofset);
3312  rhs = proofsetGetRhs(conflict->proofset);
3313 
3314  SCIP_CALL( tightenSingleVar(conflict, set, stat, tree, blkmem, origprob, transprob, reopt, lp, \
3315  branchcand, eventqueue, cliquetable, vars[inds[0]], coefs[0], rhs, conflict->proofset->conflicttype,
3316  conflict->proofset->validdepth) );
3317  }
3318  else
3319  {
3320  SCIP_Bool skipinitialproof = FALSE;
3321 
3322  /* prefer an infeasibility proof
3323  *
3324  * todo: check whether this is really what we want
3325  */
3326  if( set->conf_prefinfproof && proofsetGetConftype(conflict->proofset) == SCIP_CONFTYPE_BNDEXCEEDING )
3327  {
3328  int i;
3329 
3330  for( i = 0; i < conflict->nproofsets; i++ )
3331  {
3333  {
3334  skipinitialproof = TRUE;
3335  break;
3336  }
3337  }
3338  }
3339 
3340  if( !skipinitialproof )
3341  {
3342  /* create and add the original proof */
3343  SCIP_CALL( createAndAddProofcons(conflict, conflictstore, conflict->proofset, set, stat, origprob, transprob, \
3344  tree, reopt, lp, branchcand, eventqueue, cliquetable, blkmem) );
3345  }
3346  }
3347 
3348  /* clear the proof set anyway */
3349  proofsetClear(conflict->proofset);
3350  }
3351 
3352  if( conflict->nproofsets > 0 )
3353  {
3354  int i;
3355 
3356  for( i = 0; i < conflict->nproofsets; i++ )
3357  {
3358  assert(conflict->proofsets[i] != NULL);
3359  assert(proofsetGetConftype(conflict->proofsets[i]) != SCIP_CONFTYPE_UNKNOWN);
3360 
3361  /* only one variable has a coefficient different to zero, we add this bound change instead of a constraint */
3362  if( proofsetGetNVars(conflict->proofsets[i]) == 1 )
3363  {
3364  SCIP_VAR** vars;
3365  SCIP_Real* coefs;
3366  int* inds;
3367  SCIP_Real rhs;
3368 
3369  vars = SCIPprobGetVars(transprob);
3370 
3371  coefs = proofsetGetVals(conflict->proofsets[i]);
3372  inds = proofsetGetInds(conflict->proofsets[i]);
3373  rhs = proofsetGetRhs(conflict->proofsets[i]);
3374 
3375  SCIP_CALL( tightenSingleVar(conflict, set, stat, tree, blkmem, origprob, transprob, reopt, lp,
3376  branchcand, eventqueue, cliquetable, vars[inds[0]], coefs[0], rhs,
3377  conflict->proofsets[i]->conflicttype, conflict->proofsets[i]->validdepth) );
3378  }
3379  else
3380  {
3381  /* create and add proof constraint */
3382  SCIP_CALL( createAndAddProofcons(conflict, conflictstore, conflict->proofsets[i], set, stat, origprob, \
3383  transprob, tree, reopt, lp, branchcand, eventqueue, cliquetable, blkmem) );
3384  }
3385  }
3386 
3387  /* free all proofsets */
3388  for( i = 0; i < conflict->nproofsets; i++ )
3389  proofsetFree(&conflict->proofsets[i], blkmem);
3390 
3391  conflict->nproofsets = 0;
3392  }
3393 
3394  return SCIP_OKAY;
3395 }
3396 
3397 /** adds the given conflict set as conflict constraint to the problem */
3398 static
3400  SCIP_CONFLICT* conflict, /**< conflict analysis data */
3401  BMS_BLKMEM* blkmem, /**< block memory */
3402  SCIP_SET* set, /**< global SCIP settings */
3403  SCIP_STAT* stat, /**< dynamic problem statistics */
3404  SCIP_PROB* transprob, /**< transformed problem after presolve */
3405  SCIP_PROB* origprob, /**< original problem */
3406  SCIP_TREE* tree, /**< branch and bound tree */
3407  SCIP_REOPT* reopt, /**< reoptimization data structure */
3408  SCIP_LP* lp, /**< current LP data */
3409  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
3410  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
3411  SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
3412  SCIP_CONFLICTSET* conflictset, /**< conflict set to add to the tree */
3413  int insertdepth, /**< depth level at which the conflict set should be added */
3414  SCIP_Bool* success /**< pointer to store whether the addition was successful */
3415  )
3416 {
3417  SCIP_Bool redundant;
3418  int h;
3419 
3420  assert(conflict != NULL);
3421  assert(tree != NULL);
3422  assert(tree->path != NULL);
3423  assert(conflictset != NULL);
3424  assert(conflictset->validdepth <= insertdepth);
3425  assert(success != NULL);
3426 
3427  *success = FALSE;
3428  redundant = FALSE;
3429 
3430  /* try to derive global bound changes and shorten the conflictset by using implication and clique and variable bound
3431  * information
3432  */
3433  if( conflictset->nbdchginfos > 1 && insertdepth == 0 && !lp->strongbranching )
3434  {
3435  int nbdchgs;
3436  int nredvars;
3437 #ifdef SCIP_DEBUG
3438  int oldnbdchginfos = conflictset->nbdchginfos;
3439 #endif
3440  assert(conflictset->validdepth == 0);
3441 
3442  /* check conflict set on debugging solution */
3443  SCIP_CALL( SCIPdebugCheckConflict(blkmem, set, tree->root, conflictset->bdchginfos, conflictset->relaxedbds, conflictset->nbdchginfos) );
3444 
3445  SCIPclockStart(conflict->dIBclock, set);
3446 
3447  /* find global bound changes which can be derived from the new conflict set */
3448  SCIP_CALL( detectImpliedBounds(set, transprob, stat, tree, blkmem, origprob, reopt, lp, conflictset, &nbdchgs, &nredvars, &redundant) );
3449 
3450  /* all variables where removed, we have an infeasibility proof */
3451  if( conflictset->nbdchginfos == 0 )
3452  return SCIP_OKAY;
3453 
3454  /* debug check for reduced conflict set */
3455  if( nredvars > 0 )
3456  {
3457  /* check conflict set on debugging solution */
3458  SCIP_CALL( SCIPdebugCheckConflict(blkmem, set, tree->root, conflictset->bdchginfos, conflictset->relaxedbds, conflictset->nbdchginfos) ); /*lint !e506 !e774*/
3459  }
3460 
3461 #ifdef SCIP_DEBUG
3462  SCIPsetDebugMsg(set, " -> conflict set removed %d redundant variables (old nvars %d, new nvars = %d)\n", nredvars, oldnbdchginfos, conflictset->nbdchginfos);
3463  SCIPsetDebugMsg(set, " -> conflict set led to %d global bound changes %s(cdpt:%d, fdpt:%d, confdpt:%d, len:%d):\n",
3464  nbdchgs, redundant ? "(conflict became redundant) " : "", SCIPtreeGetCurrentDepth(tree), SCIPtreeGetFocusDepth(tree),
3465  conflictset->conflictdepth, conflictset->nbdchginfos);
3466  conflictsetPrint(conflictset);
3467 #endif
3468 
3469  SCIPclockStop(conflict->dIBclock, set);
3470 
3471  if( redundant )
3472  {
3473  if( nbdchgs > 0 )
3474  *success = TRUE;
3475 
3476  return SCIP_OKAY;
3477  }
3478  }
3479 
3480  /* in case the conflict set contains only one bound change which is globally valid we apply that bound change
3481  * directly (except if we are in strong branching or diving - in this case a bound change would yield an unflushed LP
3482  * and is not handled when restoring the information)
3483  *
3484  * @note A bound change can only be applied if it is are related to the active node or if is a global bound
3485  * change. Bound changes which are related to any other node cannot be handled at point due to the internal
3486  * data structure
3487  */
3488  if( conflictset->nbdchginfos == 1 && insertdepth == 0 && !lp->strongbranching && !lp->diving )
3489  {
3490  SCIP_VAR* var;
3491  SCIP_Real bound;
3492  SCIP_BOUNDTYPE boundtype;
3493 
3494  var = conflictset->bdchginfos[0]->var;
3495  assert(var != NULL);
3496 
3497  boundtype = SCIPboundtypeOpposite((SCIP_BOUNDTYPE) conflictset->bdchginfos[0]->boundtype);
3498  bound = conflictset->relaxedbds[0];
3499 
3500  /* for continuous variables, we can only use the relaxed version of the bounds negation: !(x <= u) -> x >= u */
3501  if( SCIPvarIsIntegral(var) )
3502  {
3503  assert(SCIPsetIsIntegral(set, bound));
3504  bound += (boundtype == SCIP_BOUNDTYPE_LOWER ? +1.0 : -1.0);
3505  }
3506 
3507  SCIPsetDebugMsg(set, " -> apply global bound change: <%s> %s %g\n",
3508  SCIPvarGetName(var), boundtype == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=", bound);
3509 
3510  SCIP_CALL( SCIPnodeAddBoundchg(tree->path[conflictset->validdepth], blkmem, set, stat, transprob, origprob, tree,
3511  reopt, lp, branchcand, eventqueue, cliquetable, var, bound, boundtype, FALSE) );
3512 
3513  *success = TRUE;
3514  SCIP_CALL( updateStatistics(conflict, blkmem, set, stat, conflictset, insertdepth) );
3515  }
3516  else if( !conflictset->hasrelaxonlyvar )
3517  {
3518  /* sort conflict handlers by priority */
3520 
3521  /* call conflict handlers to create a conflict constraint */
3522  for( h = 0; h < set->nconflicthdlrs; ++h )
3523  {
3524  SCIP_RESULT result;
3525 
3526  assert(conflictset->conflicttype != SCIP_CONFTYPE_UNKNOWN);
3527 
3528  SCIP_CALL( SCIPconflicthdlrExec(set->conflicthdlrs[h], set, tree->path[insertdepth],
3529  tree->path[conflictset->validdepth], conflictset->bdchginfos, conflictset->relaxedbds,
3530  conflictset->nbdchginfos, conflictset->conflicttype, conflictset->usescutoffbound, *success, &result) );
3531  if( result == SCIP_CONSADDED )
3532  {
3533  *success = TRUE;
3534  SCIP_CALL( updateStatistics(conflict, blkmem, set, stat, conflictset, insertdepth) );
3535  }
3536 
3537  SCIPsetDebugMsg(set, " -> call conflict handler <%s> (prio=%d) to create conflict set with %d bounds returned result %d\n",
3538  SCIPconflicthdlrGetName(set->conflicthdlrs[h]), SCIPconflicthdlrGetPriority(set->conflicthdlrs[h]),
3539  conflictset->nbdchginfos, result);
3540  }
3541  }
3542  else
3543  {
3544  SCIPsetDebugMsg(set, " -> skip conflict set with relaxation-only variable\n");
3545  /* TODO would be nice to still create a constraint?, if we can make sure that we the constraint does not survive a restart */
3546  }
3547 
3548  return SCIP_OKAY;
3549 }
3550 
3551 /** adds the collected conflict constraints to the corresponding nodes; the best set->conf_maxconss conflict constraints
3552  * are added to the node of their validdepth; additionally (if not yet added, and if repropagation is activated), the
3553  * conflict constraint that triggers the earliest repropagation is added to the node of its validdepth
3554  */
3556  SCIP_CONFLICT* conflict, /**< conflict analysis data */
3557  BMS_BLKMEM* blkmem, /**< block memory of transformed problem */
3558  SCIP_SET* set, /**< global SCIP settings */
3559  SCIP_STAT* stat, /**< dynamic problem statistics */
3560  SCIP_PROB* transprob, /**< transformed problem */
3561  SCIP_PROB* origprob, /**< original problem */
3562  SCIP_TREE* tree, /**< branch and bound tree */
3563  SCIP_REOPT* reopt, /**< reoptimization data structure */
3564  SCIP_LP* lp, /**< current LP data */
3565  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
3566  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
3567  SCIP_CLIQUETABLE* cliquetable /**< clique table data structure */
3568  )
3569 {
3570  assert(conflict != NULL);
3571  assert(set != NULL);
3572  assert(stat != NULL);
3573  assert(transprob != NULL);
3574  assert(tree != NULL);
3575 
3576  /* is there anything to do? */
3577  if( conflict->nconflictsets > 0 )
3578  {
3579  SCIP_CONFLICTSET* repropconflictset;
3580  int nconflictsetsused;
3581  int focusdepth;
3582 #ifndef NDEBUG
3583  int currentdepth;
3584 #endif
3585  int cutoffdepth;
3586  int repropdepth;
3587  int maxconflictsets;
3588  int maxsize;
3589  int i;
3590 
3591  /* calculate the maximal number of conflict sets to accept, and the maximal size of each accepted conflict set */
3592  maxconflictsets = (set->conf_maxconss == -1 ? INT_MAX : set->conf_maxconss);
3593  maxsize = conflictCalcMaxsize(set, transprob);
3594 
3595  focusdepth = SCIPtreeGetFocusDepth(tree);
3596 #ifndef NDEBUG
3597  currentdepth = SCIPtreeGetCurrentDepth(tree);
3598  assert(focusdepth <= currentdepth);
3599  assert(currentdepth == tree->pathlen-1);
3600 #endif
3601 
3602  SCIPsetDebugMsg(set, "flushing %d conflict sets at focus depth %d (maxconflictsets: %d, maxsize: %d)\n",
3603  conflict->nconflictsets, focusdepth, maxconflictsets, maxsize);
3604 
3605  /* mark the focus node to have produced conflict sets in the visualization output */
3606  SCIPvisualFoundConflict(stat->visual, stat, tree->path[focusdepth]);
3607 
3608  /* insert the conflict sets at the corresponding nodes */
3609  nconflictsetsused = 0;
3610  cutoffdepth = INT_MAX;
3611  repropdepth = INT_MAX;
3612  repropconflictset = NULL;
3613  for( i = 0; i < conflict->nconflictsets && nconflictsetsused < maxconflictsets; ++i )
3614  {
3615  SCIP_CONFLICTSET* conflictset;
3616 
3617  conflictset = conflict->conflictsets[i];
3618  assert(conflictset != NULL);
3619  assert(0 <= conflictset->validdepth);
3620  assert(conflictset->validdepth <= conflictset->insertdepth);
3621  assert(conflictset->insertdepth <= focusdepth);
3622  assert(conflictset->insertdepth <= conflictset->repropdepth);
3623  assert(conflictset->repropdepth <= currentdepth || conflictset->repropdepth == INT_MAX); /* INT_MAX for dive/probing/strong */
3624  assert(conflictset->conflictdepth <= currentdepth || conflictset->conflictdepth == INT_MAX); /* INT_MAX for dive/probing/strong */
3625 
3626  /* ignore conflict sets that are only valid at a node that was already cut off */
3627  if( conflictset->insertdepth >= cutoffdepth )
3628  {
3629  SCIPsetDebugMsg(set, " -> ignoring conflict set with insertdepth %d >= cutoffdepth %d\n",
3630  conflictset->validdepth, cutoffdepth);
3631  continue;
3632  }
3633 
3634  /* if no conflict bounds exist, the node and its sub tree in the conflict set's valid depth can be
3635  * cut off completely
3636  */
3637  if( conflictset->nbdchginfos == 0 )
3638  {
3639  SCIPsetDebugMsg(set, " -> empty conflict set in depth %d cuts off sub tree at depth %d\n",
3640  focusdepth, conflictset->validdepth);
3641 
3642  SCIP_CALL( SCIPnodeCutoff(tree->path[conflictset->validdepth], set, stat, tree, transprob, origprob, reopt, lp, blkmem) );
3643  cutoffdepth = conflictset->validdepth;
3644  continue;
3645  }
3646 
3647  /* if the conflict set is too long, use the conflict set only if it decreases the repropagation depth */
3648  if( conflictset->nbdchginfos > maxsize )
3649  {
3650  SCIPsetDebugMsg(set, " -> conflict set is too long: %d > %d literals\n", conflictset->nbdchginfos, maxsize);
3651  if( set->conf_keepreprop && conflictset->repropagate && conflictset->repropdepth < repropdepth )
3652  {
3653  repropdepth = conflictset->repropdepth;
3654  repropconflictset = conflictset;
3655  }
3656  }
3657  else
3658  {
3659  SCIP_Bool success;
3660 
3661  /* call conflict handlers to create a conflict constraint */
3662  SCIP_CALL( conflictAddConflictCons(conflict, blkmem, set, stat, transprob, origprob, tree, reopt, lp, \
3663  branchcand, eventqueue, cliquetable, conflictset, conflictset->insertdepth, &success) );
3664 
3665  /* if no conflict bounds exist, the node and its sub tree in the conflict set's valid depth can be
3666  * cut off completely
3667  */
3668  if( conflictset->nbdchginfos == 0 )
3669  {
3670  assert(!success);
3671 
3672  SCIPsetDebugMsg(set, " -> empty conflict set in depth %d cuts off sub tree at depth %d\n",
3673  focusdepth, conflictset->validdepth);
3674 
3675  SCIP_CALL( SCIPnodeCutoff(tree->path[conflictset->validdepth], set, stat, tree, transprob, origprob, \
3676  reopt, lp, blkmem) );
3677  cutoffdepth = conflictset->validdepth;
3678  continue;
3679  }
3680 
3681  if( success )
3682  {
3683  SCIPsetDebugMsg(set, " -> conflict set %d/%d added (cdpt:%d, fdpt:%d, insert:%d, valid:%d, conf:%d, reprop:%d, len:%d):\n",
3684  nconflictsetsused+1, maxconflictsets, SCIPtreeGetCurrentDepth(tree), SCIPtreeGetFocusDepth(tree),
3685  conflictset->insertdepth, conflictset->validdepth, conflictset->conflictdepth, conflictset->repropdepth,
3686  conflictset->nbdchginfos);
3687  SCIPdebug(conflictsetPrint(conflictset));
3688 
3689  if( conflictset->repropagate && conflictset->repropdepth <= repropdepth )
3690  {
3691  repropdepth = conflictset->repropdepth;
3692  repropconflictset = NULL;
3693  }
3694  nconflictsetsused++;
3695  }
3696  }
3697  }
3698 
3699  /* reactivate propagation on the first node where one of the new conflict sets trigger a deduction */
3700  if( set->conf_repropagate && repropdepth < cutoffdepth && repropdepth < tree->pathlen )
3701  {
3702  assert(0 <= repropdepth && repropdepth < tree->pathlen);
3703  assert((int) tree->path[repropdepth]->depth == repropdepth);
3704 
3705  /* if the conflict constraint of smallest repropagation depth was not yet added, insert it now */
3706  if( repropconflictset != NULL )
3707  {
3708  SCIP_Bool success;
3709 
3710  assert(repropconflictset->repropagate);
3711  assert(repropconflictset->repropdepth == repropdepth);
3712 
3713  SCIP_CALL( conflictAddConflictCons(conflict, blkmem, set, stat, transprob, origprob, tree, reopt, lp, \
3714  branchcand, eventqueue, cliquetable, repropconflictset, repropdepth, &success) );
3715 
3716  /* if no conflict bounds exist, the node and its sub tree in the conflict set's valid depth can be
3717  * cut off completely
3718  */
3719  if( repropconflictset->nbdchginfos == 0 )
3720  {
3721  assert(!success);
3722 
3723  SCIPsetDebugMsg(set, " -> empty reprop conflict set in depth %d cuts off sub tree at depth %d\n",
3724  focusdepth, repropconflictset->validdepth);
3725 
3726  SCIP_CALL( SCIPnodeCutoff(tree->path[repropconflictset->validdepth], set, stat, tree, transprob, \
3727  origprob, reopt, lp, blkmem) );
3728  }
3729 
3730 #ifdef SCIP_DEBUG
3731  if( success )
3732  {
3733  SCIPsetDebugMsg(set, " -> additional reprop conflict set added (cdpt:%d, fdpt:%d, insert:%d, valid:%d, conf:%d, reprop:%d, len:%d):\n",
3735  repropconflictset->insertdepth, repropconflictset->validdepth, repropconflictset->conflictdepth,
3736  repropconflictset->repropdepth, repropconflictset->nbdchginfos);
3737  SCIPdebug(conflictsetPrint(repropconflictset));
3738  }
3739 #endif
3740  }
3741 
3742  /* mark the node in the repropdepth to be propagated again */
3743  SCIPnodePropagateAgain(tree->path[repropdepth], set, stat, tree);
3744 
3745  SCIPsetDebugMsg(set, "marked node %p in depth %d to be repropagated due to conflicts found in depth %d\n",
3746  (void*)tree->path[repropdepth], repropdepth, focusdepth);
3747  }
3748 
3749  /* free the conflict store */
3750  for( i = 0; i < conflict->nconflictsets; ++i )
3751  {
3752  conflictsetFree(&conflict->conflictsets[i], blkmem);
3753  }
3754  conflict->nconflictsets = 0;
3755  }
3756 
3757  /* free all temporarily created bound change information data */
3758  conflictFreeTmpBdchginfos(conflict, blkmem);
3759 
3760  return SCIP_OKAY;
3761 }
3762 
3763 /** returns the current number of conflict sets in the conflict set storage */
3765  SCIP_CONFLICT* conflict /**< conflict analysis data */
3766  )
3767 {
3768  assert(conflict != NULL);
3769 
3770  return conflict->nconflictsets;
3771 }
3772 
3773 /** returns the total number of conflict constraints that were added to the problem */
3775  SCIP_CONFLICT* conflict /**< conflict analysis data */
3776  )
3777 {
3778  assert(conflict != NULL);
3779 
3780  return conflict->nappliedglbconss + conflict->nappliedlocconss;
3781 }
3782 
3783 /** returns the total number of literals in conflict constraints that were added to the problem */
3785  SCIP_CONFLICT* conflict /**< conflict analysis data */
3786  )
3787 {
3788  assert(conflict != NULL);
3789 
3790  return conflict->nappliedglbliterals + conflict->nappliedlocliterals;
3791 }
3792 
3793 /** returns the total number of global bound changes applied by the conflict analysis */
3795  SCIP_CONFLICT* conflict /**< conflict analysis data */
3796  )
3797 {
3798  assert(conflict != NULL);
3799 
3800  return conflict->nglbchgbds;
3801 }
3802 
3803 /** returns the total number of conflict constraints that were added globally to the problem */
3805  SCIP_CONFLICT* conflict /**< conflict analysis data */
3806  )
3807 {
3808  assert(conflict != NULL);
3809 
3810  return conflict->nappliedglbconss;
3811 }
3812 
3813 /** returns the total number of literals in conflict constraints that were added globally to the problem */
3815  SCIP_CONFLICT* conflict /**< conflict analysis data */
3816  )
3817 {
3818  assert(conflict != NULL);
3819 
3820  return conflict->nappliedglbliterals;
3821 }
3822 
3823 /** returns the total number of local bound changes applied by the conflict analysis */
3825  SCIP_CONFLICT* conflict /**< conflict analysis data */
3826  )
3827 {
3828  assert(conflict != NULL);
3829 
3830  return conflict->nlocchgbds;
3831 }
3832 
3833 /** returns the total number of conflict constraints that were added locally to the problem */
3835  SCIP_CONFLICT* conflict /**< conflict analysis data */
3836  )
3837 {
3838  assert(conflict != NULL);
3839 
3840  return conflict->nappliedlocconss;
3841 }
3842 
3843 /** returns the total number of literals in conflict constraints that were added locally to the problem */
3845  SCIP_CONFLICT* conflict /**< conflict analysis data */
3846  )
3847 {
3848  assert(conflict != NULL);
3849 
3850  return conflict->nappliedlocliterals;
3851 }
3852 
3853 
3854 
3855 
3856 /*
3857  * Propagation Conflict Analysis
3858  */
3859 
3860 /** returns whether bound change has a valid reason that can be resolved in conflict analysis */
3861 static
3863  SCIP_BDCHGINFO* bdchginfo /**< bound change information */
3864  )
3865 {
3866  assert(bdchginfo != NULL);
3867  assert(!SCIPbdchginfoIsRedundant(bdchginfo));
3868 
3871  && SCIPbdchginfoGetInferProp(bdchginfo) != NULL));
3872 }
3873 
3874 /** compares two conflict set entries, such that bound changes inferred later are
3875  * ordered prior to ones that were inferred earlier
3876  */
3877 static
3878 SCIP_DECL_SORTPTRCOMP(conflictBdchginfoComp)
3879 { /*lint --e{715}*/
3880  SCIP_BDCHGINFO* bdchginfo1;
3881  SCIP_BDCHGINFO* bdchginfo2;
3882 
3883  bdchginfo1 = (SCIP_BDCHGINFO*)elem1;
3884  bdchginfo2 = (SCIP_BDCHGINFO*)elem2;
3885  assert(bdchginfo1 != NULL);
3886  assert(bdchginfo2 != NULL);
3887  assert(!SCIPbdchginfoIsRedundant(bdchginfo1));
3888  assert(!SCIPbdchginfoIsRedundant(bdchginfo2));
3889 
3890  if( bdchginfo1 == bdchginfo2 )
3891  return 0;
3892 
3894  return -1;
3895  else
3896  return +1;
3897 }
3898 
3899 /** return TRUE if conflict analysis is applicable; In case the function return FALSE there is no need to initialize the
3900  * conflict analysis since it will not be applied
3901  */
3903  SCIP_SET* set /**< global SCIP settings */
3904  )
3905 {
3906  /* check, if propagation conflict analysis is enabled */
3907  if( !set->conf_enable || !set->conf_useprop )
3908  return FALSE;
3909 
3910  /* check, if there are any conflict handlers to use a conflict set */
3911  if( set->nconflicthdlrs == 0 )
3912  return FALSE;
3913 
3914  return TRUE;
3915 }
3916 
3917 /** creates conflict analysis data for propagation conflicts */
3919  SCIP_CONFLICT** conflict, /**< pointer to conflict analysis data */
3920  BMS_BLKMEM* blkmem, /**< block memory of transformed problem */
3921  SCIP_SET* set /**< global SCIP settings */
3922  )
3923 {
3924  assert(conflict != NULL);
3925 
3926  SCIP_ALLOC( BMSallocMemory(conflict) );
3927 
3928  SCIP_CALL( SCIPclockCreate(&(*conflict)->dIBclock, SCIP_CLOCKTYPE_DEFAULT) );
3929  SCIP_CALL( SCIPclockCreate(&(*conflict)->propanalyzetime, SCIP_CLOCKTYPE_DEFAULT) );
3930  SCIP_CALL( SCIPclockCreate(&(*conflict)->inflpanalyzetime, SCIP_CLOCKTYPE_DEFAULT) );
3931  SCIP_CALL( SCIPclockCreate(&(*conflict)->boundlpanalyzetime, SCIP_CLOCKTYPE_DEFAULT) );
3932  SCIP_CALL( SCIPclockCreate(&(*conflict)->sbanalyzetime, SCIP_CLOCKTYPE_DEFAULT) );
3933  SCIP_CALL( SCIPclockCreate(&(*conflict)->pseudoanalyzetime, SCIP_CLOCKTYPE_DEFAULT) );
3934 
3935  /* enable or disable timing depending on the parameter statistic timing */
3936  SCIPconflictEnableOrDisableClocks((*conflict), set->time_statistictiming);
3937 
3938  SCIP_CALL( SCIPpqueueCreate(&(*conflict)->bdchgqueue, set->mem_arraygrowinit, set->mem_arraygrowfac,
3939  conflictBdchginfoComp, NULL) );
3940  SCIP_CALL( SCIPpqueueCreate(&(*conflict)->forcedbdchgqueue, set->mem_arraygrowinit, set->mem_arraygrowfac,
3941  conflictBdchginfoComp, NULL) );
3942  SCIP_CALL( conflictsetCreate(&(*conflict)->conflictset, blkmem) );
3943  (*conflict)->conflictsets = NULL;
3944  (*conflict)->conflictsetscores = NULL;
3945  (*conflict)->tmpbdchginfos = NULL;
3946  (*conflict)->conflictsetssize = 0;
3947  (*conflict)->nconflictsets = 0;
3948  (*conflict)->proofsets = NULL;
3949  (*conflict)->proofsetssize = 0;
3950  (*conflict)->nproofsets = 0;
3951  (*conflict)->tmpbdchginfossize = 0;
3952  (*conflict)->ntmpbdchginfos = 0;
3953  (*conflict)->count = 0;
3954  (*conflict)->nglbchgbds = 0;
3955  (*conflict)->nappliedglbconss = 0;
3956  (*conflict)->nappliedglbliterals = 0;
3957  (*conflict)->nlocchgbds = 0;
3958  (*conflict)->nappliedlocconss = 0;
3959  (*conflict)->nappliedlocliterals = 0;
3960  (*conflict)->npropcalls = 0;
3961  (*conflict)->npropsuccess = 0;
3962  (*conflict)->npropconfconss = 0;
3963  (*conflict)->npropconfliterals = 0;
3964  (*conflict)->npropreconvconss = 0;
3965  (*conflict)->npropreconvliterals = 0;
3966  (*conflict)->ninflpcalls = 0;
3967  (*conflict)->ninflpsuccess = 0;
3968  (*conflict)->ninflpconfconss = 0;
3969  (*conflict)->ninflpconfliterals = 0;
3970  (*conflict)->ninflpreconvconss = 0;
3971  (*conflict)->ninflpreconvliterals = 0;
3972  (*conflict)->ninflpiterations = 0;
3973  (*conflict)->nboundlpcalls = 0;
3974  (*conflict)->nboundlpsuccess = 0;
3975  (*conflict)->nboundlpconfconss = 0;
3976  (*conflict)->nboundlpconfliterals = 0;
3977  (*conflict)->nboundlpreconvconss = 0;
3978  (*conflict)->nboundlpreconvliterals = 0;
3979  (*conflict)->nboundlpiterations = 0;
3980  (*conflict)->nsbcalls = 0;
3981  (*conflict)->nsbsuccess = 0;
3982  (*conflict)->nsbconfconss = 0;
3983  (*conflict)->nsbconfliterals = 0;
3984  (*conflict)->nsbreconvconss = 0;
3985  (*conflict)->nsbreconvliterals = 0;
3986  (*conflict)->nsbiterations = 0;
3987  (*conflict)->npseudocalls = 0;
3988  (*conflict)->npseudosuccess = 0;
3989  (*conflict)->npseudoconfconss = 0;
3990  (*conflict)->npseudoconfliterals = 0;
3991  (*conflict)->npseudoreconvconss = 0;
3992  (*conflict)->npseudoreconvliterals = 0;
3993  (*conflict)->ndualproofsinfglobal = 0;
3994  (*conflict)->ndualproofsinflocal = 0;
3995  (*conflict)->ndualproofsinfsuccess = 0;
3996  (*conflict)->dualproofsinfnnonzeros = 0;
3997  (*conflict)->ndualproofsbndglobal = 0;
3998  (*conflict)->ndualproofsbndlocal = 0;
3999  (*conflict)->ndualproofsbndsuccess = 0;
4000  (*conflict)->dualproofsbndnnonzeros = 0;
4001 
4002  SCIP_CALL( conflictInitProofset((*conflict), blkmem) );
4003 
4004  return SCIP_OKAY;
4005 }
4006 
4007 /** frees conflict analysis data for propagation conflicts */
4009  SCIP_CONFLICT** conflict, /**< pointer to conflict analysis data */
4010  BMS_BLKMEM* blkmem /**< block memory of transformed problem */
4011  )
4012 {
4013  assert(conflict != NULL);
4014  assert(*conflict != NULL);
4015  assert((*conflict)->nconflictsets == 0);
4016  assert((*conflict)->ntmpbdchginfos == 0);
4017 
4018 #ifdef SCIP_CONFGRAPH
4019  confgraphFree();
4020 #endif
4021 
4022  SCIPclockFree(&(*conflict)->dIBclock);
4023  SCIPclockFree(&(*conflict)->propanalyzetime);
4024  SCIPclockFree(&(*conflict)->inflpanalyzetime);
4025  SCIPclockFree(&(*conflict)->boundlpanalyzetime);
4026  SCIPclockFree(&(*conflict)->sbanalyzetime);
4027  SCIPclockFree(&(*conflict)->pseudoanalyzetime);
4028  SCIPpqueueFree(&(*conflict)->bdchgqueue);
4029  SCIPpqueueFree(&(*conflict)->forcedbdchgqueue);
4030  conflictsetFree(&(*conflict)->conflictset, blkmem);
4031  proofsetFree(&(*conflict)->proofset, blkmem);
4032 
4033  BMSfreeMemoryArrayNull(&(*conflict)->conflictsets);
4034  BMSfreeMemoryArrayNull(&(*conflict)->conflictsetscores);
4035  BMSfreeMemoryArrayNull(&(*conflict)->proofsets);
4036  BMSfreeMemoryArrayNull(&(*conflict)->tmpbdchginfos);
4037  BMSfreeMemory(conflict);
4038 
4039  return SCIP_OKAY;
4040 }
4041 
4042 /** clears the conflict queue and the current conflict set */
4043 static
4045  SCIP_CONFLICT* conflict /**< conflict analysis data */
4046  )
4047 {
4048  assert(conflict != NULL);
4049 
4050  SCIPpqueueClear(conflict->bdchgqueue);
4051  SCIPpqueueClear(conflict->forcedbdchgqueue);
4052  conflictsetClear(conflict->conflictset);
4053 }
4054 
4055 /** initializes the propagation conflict analysis by clearing the conflict candidate queue */
4057  SCIP_CONFLICT* conflict, /**< conflict analysis data */
4058  SCIP_SET* set, /**< global SCIP settings */
4059  SCIP_STAT* stat, /**< problem statistics */
4060  SCIP_PROB* prob, /**< problem data */
4061  SCIP_CONFTYPE conftype, /**< type of the conflict */
4062  SCIP_Bool usescutoffbound /**< depends the conflict on a cutoff bound? */
4063  )
4064 {
4065  assert(conflict != NULL);
4066  assert(set != NULL);
4067  assert(stat != NULL);
4068  assert(prob != NULL);
4069 
4070  SCIPsetDebugMsg(set, "initializing conflict analysis\n");
4071 
4072  /* clear the conflict candidate queue and the conflict set */
4073  conflictClear(conflict);
4074 
4075  /* set conflict type */
4076  assert(conftype == SCIP_CONFTYPE_BNDEXCEEDING || conftype == SCIP_CONFTYPE_INFEASLP
4077  || conftype == SCIP_CONFTYPE_PROPAGATION);
4078  conflict->conflictset->conflicttype = conftype;
4079 
4080  /* set whether a cutoff bound is involved */
4081  conflict->conflictset->usescutoffbound = usescutoffbound;
4082 
4083  /* increase the conflict counter, such that binary variables of new conflict set and new conflict queue are labeled
4084  * with this new counter
4085  */
4086  conflict->count++;
4087  if( conflict->count == 0 ) /* make sure, 0 is not a valid conflict counter (may happen due to integer overflow) */
4088  conflict->count = 1;
4089 
4090  /* increase the conflict score weight for history updates of future conflict reasons */
4091  if( stat->nnodes > stat->lastconflictnode )
4092  {
4093  assert(0.0 < set->conf_scorefac && set->conf_scorefac <= 1.0);
4094  stat->vsidsweight /= set->conf_scorefac;
4095  assert(stat->vsidsweight > 0.0);
4096 
4097  /* if the conflict score for the next conflict exceeds 1000.0, rescale all history conflict scores */
4098  if( stat->vsidsweight >= 1000.0 )
4099  {
4100  int v;
4101 
4102  for( v = 0; v < prob->nvars; ++v )
4103  {
4104  SCIP_CALL( SCIPvarScaleVSIDS(prob->vars[v], 1.0/stat->vsidsweight) );
4105  }
4106  SCIPhistoryScaleVSIDS(stat->glbhistory, 1.0/stat->vsidsweight);
4108  stat->vsidsweight = 1.0;
4109  }
4110  stat->lastconflictnode = stat->nnodes;
4111  }
4112 
4113 #ifdef SCIP_CONFGRAPH
4114  confgraphFree();
4115  SCIP_CALL( confgraphCreate(set, conflict) );
4116 #endif
4117 
4118  return SCIP_OKAY;
4119 }
4120 
4121 /** marks bound to be present in the current conflict and returns whether a bound which is at least as tight was already
4122  * member of the current conflict (i.e., the given bound change does not need to be added)
4123  */
4124 static
4126  SCIP_CONFLICT* conflict, /**< conflict analysis data */
4127  SCIP_SET* set, /**< global SCIP settings */
4128  SCIP_BDCHGINFO* bdchginfo, /**< bound change to add to the conflict set */
4129  SCIP_Real relaxedbd /**< relaxed bound */
4130  )
4131 {
4132  SCIP_VAR* var;
4133  SCIP_Real newbound;
4134 
4135  assert(conflict != NULL);
4136 
4137  var = SCIPbdchginfoGetVar(bdchginfo);
4138  newbound = SCIPbdchginfoGetNewbound(bdchginfo);
4139  assert(var != NULL);
4140 
4141  switch( SCIPbdchginfoGetBoundtype(bdchginfo) )
4142  {
4143  case SCIP_BOUNDTYPE_LOWER:
4144  /* check if the variables lower bound is already member of the conflict */
4145  if( var->conflictlbcount == conflict->count )
4146  {
4147  /* the variable is already member of the conflict; hence check if the new bound is redundant */
4148  if( var->conflictlb > newbound )
4149  {
4150  SCIPsetDebugMsg(set, "ignoring redundant bound change <%s> >= %g since a stronger lower bound exist <%s> >= %g\n",
4151  SCIPvarGetName(var), newbound, SCIPvarGetName(var), var->conflictlb);
4152  return TRUE;
4153  }
4154  else if( var->conflictlb == newbound ) /*lint !e777*/
4155  {
4156  SCIPsetDebugMsg(set, "ignoring redundant bound change <%s> >= %g since this lower bound is already present\n", SCIPvarGetName(var), newbound);
4157  SCIPsetDebugMsg(set, "adjust relaxed lower bound <%g> -> <%g>\n", var->conflictlb, relaxedbd);
4158  var->conflictrelaxedlb = MAX(var->conflictrelaxedlb, relaxedbd);
4159  return TRUE;
4160  }
4161  }
4162 
4163  /* add the variable lower bound to the current conflict */
4164  var->conflictlbcount = conflict->count;
4165 
4166  /* remember the lower bound and relaxed bound to allow only better/tighter lower bounds for that variables
4167  * w.r.t. this conflict
4168  */
4169  var->conflictlb = newbound;
4170  var->conflictrelaxedlb = relaxedbd;
4171 
4172  return FALSE;
4173 
4174  case SCIP_BOUNDTYPE_UPPER:
4175  /* check if the variables upper bound is already member of the conflict */
4176  if( var->conflictubcount == conflict->count )
4177  {
4178  /* the variable is already member of the conflict; hence check if the new bound is redundant */
4179  if( var->conflictub < newbound )
4180  {
4181  SCIPsetDebugMsg(set, "ignoring redundant bound change <%s> <= %g since a stronger upper bound exist <%s> <= %g\n",
4182  SCIPvarGetName(var), newbound, SCIPvarGetName(var), var->conflictub);
4183  return TRUE;
4184  }
4185  else if( var->conflictub == newbound ) /*lint !e777*/
4186  {
4187  SCIPsetDebugMsg(set, "ignoring redundant bound change <%s> <= %g since this upper bound is already present\n", SCIPvarGetName(var), newbound);
4188  SCIPsetDebugMsg(set, "adjust relaxed upper bound <%g> -> <%g>\n", var->conflictub, relaxedbd);
4189  var->conflictrelaxedub = MIN(var->conflictrelaxedub, relaxedbd);
4190  return TRUE;
4191  }
4192  }
4193 
4194  /* add the variable upper bound to the current conflict */
4195  var->conflictubcount = conflict->count;
4196 
4197  /* remember the upper bound and relaxed bound to allow only better/tighter upper bounds for that variables
4198  * w.r.t. this conflict
4199  */
4200  var->conflictub = newbound;
4201  var->conflictrelaxedub = relaxedbd;
4202 
4203  return FALSE;
4204 
4205  default:
4206  SCIPerrorMessage("invalid bound type %d\n", SCIPbdchginfoGetBoundtype(bdchginfo));
4207  SCIPABORT();
4208  return FALSE; /*lint !e527*/
4209  }
4210 }
4211 
4212 /** puts bound change into the current conflict set */
4213 static
4215  SCIP_CONFLICT* conflict, /**< conflict analysis data */
4216  BMS_BLKMEM* blkmem, /**< block memory of transformed problem */
4217  SCIP_SET* set, /**< global SCIP settings */
4218  SCIP_BDCHGINFO* bdchginfo, /**< bound change to add to the conflict set */
4219  SCIP_Real relaxedbd /**< relaxed bound */
4220  )
4221 {
4222  assert(conflict != NULL);
4223  assert(!SCIPbdchginfoIsRedundant(bdchginfo));
4224 
4225  /* check if the relaxed bound is really a relaxed bound */
4226  assert(SCIPbdchginfoGetBoundtype(bdchginfo) == SCIP_BOUNDTYPE_LOWER || SCIPsetIsGE(set, relaxedbd, SCIPbdchginfoGetNewbound(bdchginfo)));
4227  assert(SCIPbdchginfoGetBoundtype(bdchginfo) == SCIP_BOUNDTYPE_UPPER || SCIPsetIsLE(set, relaxedbd, SCIPbdchginfoGetNewbound(bdchginfo)));
4228 
4229  SCIPsetDebugMsg(set, "putting bound change <%s> %s %g(%g) at depth %d to current conflict set\n",
4230  SCIPvarGetName(SCIPbdchginfoGetVar(bdchginfo)),
4231  SCIPbdchginfoGetBoundtype(bdchginfo) == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=", SCIPbdchginfoGetNewbound(bdchginfo),
4232  relaxedbd, SCIPbdchginfoGetDepth(bdchginfo));
4233 
4234  /* mark the bound to be member of the conflict and check if a bound which is at least as tight is already member of
4235  * the conflict
4236  */
4237  if( !conflictMarkBoundCheckPresence(conflict, set, bdchginfo, relaxedbd) )
4238  {
4239  /* add the bound change to the current conflict set */
4240  SCIP_CALL( conflictsetAddBound(conflict->conflictset, blkmem, set, bdchginfo, relaxedbd) );
4241 
4242 #ifdef SCIP_CONFGRAPH
4243  if( bdchginfo != confgraphcurrentbdchginfo )
4244  confgraphAddBdchg(bdchginfo);
4245 #endif
4246  }
4247 #ifdef SCIP_CONFGRAPH
4248  else
4249  confgraphLinkBdchg(bdchginfo);
4250 #endif
4251 
4252  return SCIP_OKAY;
4253 }
4254 
4255 /** returns whether the negation of the given bound change would lead to a globally valid literal */
4256 static
4258  SCIP_SET* set, /**< global SCIP settings */
4259  SCIP_BDCHGINFO* bdchginfo /**< bound change information */
4260  )
4261 {
4262  SCIP_VAR* var;
4263  SCIP_BOUNDTYPE boundtype;
4264  SCIP_Real bound;
4265 
4266  var = SCIPbdchginfoGetVar(bdchginfo);
4267  boundtype = SCIPbdchginfoGetBoundtype(bdchginfo);
4268  bound = SCIPbdchginfoGetNewbound(bdchginfo);
4269 
4270  return (SCIPvarGetType(var) == SCIP_VARTYPE_CONTINUOUS
4271  && ((boundtype == SCIP_BOUNDTYPE_LOWER && SCIPsetIsFeasGE(set, bound, SCIPvarGetUbGlobal(var)))
4272  || (boundtype == SCIP_BOUNDTYPE_UPPER && SCIPsetIsFeasLE(set, bound, SCIPvarGetLbGlobal(var)))));
4273 }
4274 
4275 /** adds given bound change information to the conflict candidate queue */
4276 static
4278  SCIP_CONFLICT* conflict, /**< conflict analysis data */
4279  SCIP_SET* set, /**< global SCIP settings */
4280  SCIP_BDCHGINFO* bdchginfo, /**< bound change information */
4281  SCIP_Real relaxedbd /**< relaxed bound */
4282  )
4283 {
4284  assert(conflict != NULL);
4285  assert(set != NULL);
4286  assert(bdchginfo != NULL);
4287  assert(!SCIPbdchginfoIsRedundant(bdchginfo));
4288 
4289  /* check if the relaxed bound is really a relaxed bound */
4290  assert(SCIPbdchginfoGetBoundtype(bdchginfo) == SCIP_BOUNDTYPE_LOWER || SCIPsetIsGE(set, relaxedbd, SCIPbdchginfoGetNewbound(bdchginfo)));
4291  assert(SCIPbdchginfoGetBoundtype(bdchginfo) == SCIP_BOUNDTYPE_UPPER || SCIPsetIsLE(set, relaxedbd, SCIPbdchginfoGetNewbound(bdchginfo)));
4292 
4293  /* mark the bound to be member of the conflict and check if a bound which is at least as tight is already member of
4294  * the conflict
4295  */
4296  if( !conflictMarkBoundCheckPresence(conflict, set, bdchginfo, relaxedbd) )
4297  {
4298  /* insert the bound change into the conflict queue */
4299  if( (!set->conf_preferbinary || SCIPvarIsBinary(SCIPbdchginfoGetVar(bdchginfo)))
4300  && !isBoundchgUseless(set, bdchginfo) )
4301  {
4302  SCIP_CALL( SCIPpqueueInsert(conflict->bdchgqueue, (void*)bdchginfo) );
4303  }
4304  else
4305  {
4306  SCIP_CALL( SCIPpqueueInsert(conflict->forcedbdchgqueue, (void*)bdchginfo) );
4307  }
4308 
4309 #ifdef SCIP_CONFGRAPH
4310  confgraphAddBdchg(bdchginfo);
4311 #endif
4312  }
4313 #ifdef SCIP_CONFGRAPH
4314  else
4315  confgraphLinkBdchg(bdchginfo);
4316 #endif
4317 
4318  return SCIP_OKAY;
4319 }
4320 
4321 /** convert variable and bound change to active variable */
4322 static
4324  SCIP_VAR** var, /**< pointer to variable */
4325  SCIP_SET* set, /**< global SCIP settings */
4326  SCIP_BOUNDTYPE* boundtype, /**< pointer to type of bound that was changed: lower or upper bound */
4327  SCIP_Real* bound /**< pointer to bound to convert, or NULL */
4328  )
4329 {
4330  SCIP_Real scalar;
4331  SCIP_Real constant;
4332 
4333  scalar = 1.0;
4334  constant = 0.0;
4335 
4336  /* transform given varibale to active varibale */
4337  SCIP_CALL( SCIPvarGetProbvarSum(var, set, &scalar, &constant) );
4338  assert(SCIPvarGetStatus(*var) == SCIP_VARSTATUS_FIXED || scalar != 0.0); /*lint !e777*/
4339 
4340  if( SCIPvarGetStatus(*var) == SCIP_VARSTATUS_FIXED )
4341  return SCIP_OKAY;
4342 
4343  /* if the scalar of the aggregation is negative, we have to switch the bound type */
4344  if( scalar < 0.0 )
4345  (*boundtype) = SCIPboundtypeOpposite(*boundtype);
4346 
4347  if( bound != NULL )
4348  {
4349  (*bound) -= constant;
4350  (*bound) /= scalar;
4351  }
4352 
4353  return SCIP_OKAY;
4354 }
4355 
4356 /** adds variable's bound to conflict candidate queue */
4357 static
4359  SCIP_CONFLICT* conflict, /**< conflict analysis data */
4360  BMS_BLKMEM* blkmem, /**< block memory */
4361  SCIP_SET* set, /**< global SCIP settings */
4362  SCIP_STAT* stat, /**< dynamic problem statistics */
4363  SCIP_VAR* var, /**< problem variable */
4364  SCIP_BOUNDTYPE boundtype, /**< type of bound that was changed: lower or upper bound */
4365  SCIP_BDCHGINFO* bdchginfo, /**< bound change info, or NULL */
4366  SCIP_Real relaxedbd /**< relaxed bound */
4367  )
4368 {
4369  assert(SCIPvarIsActive(var));
4370  assert(bdchginfo != NULL);
4371  assert(!SCIPbdchginfoIsRedundant(bdchginfo));
4372 
4373  SCIPsetDebugMsg(set, " -> adding bound <%s> %s %.15g(%.15g) [status:%d, type:%d, depth:%d, pos:%d, reason:<%s>, info:%d] to candidates\n",
4374  SCIPvarGetName(var),
4375  boundtype == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=",
4376  SCIPbdchginfoGetNewbound(bdchginfo), relaxedbd,
4377  SCIPvarGetStatus(var), SCIPvarGetType(var),
4378  SCIPbdchginfoGetDepth(bdchginfo), SCIPbdchginfoGetPos(bdchginfo),
4379  SCIPbdchginfoGetChgtype(bdchginfo) == SCIP_BOUNDCHGTYPE_BRANCHING ? "branch"
4383  : "none")),
4385 
4386  /* the local bound change may be resolved and has to be put on the candidate queue;
4387  * we even put bound changes without inference information on the queue in order to automatically
4388  * eliminate multiple insertions of the same bound change
4389  */
4390  assert(SCIPbdchginfoGetVar(bdchginfo) == var);
4391  assert(SCIPbdchginfoGetBoundtype(bdchginfo) == boundtype);
4392  assert(SCIPbdchginfoGetDepth(bdchginfo) >= 0);
4393  assert(SCIPbdchginfoGetPos(bdchginfo) >= 0);
4394 
4395  /* the relaxed bound should be a relaxation */
4396  assert(boundtype == SCIP_BOUNDTYPE_LOWER ? SCIPsetIsLE(set, relaxedbd, SCIPbdchginfoGetNewbound(bdchginfo)) : SCIPsetIsGE(set, relaxedbd, SCIPbdchginfoGetNewbound(bdchginfo)));
4397 
4398  /* the relaxed bound should be worse then the old bound of the bound change info */
4399  assert(boundtype == SCIP_BOUNDTYPE_LOWER ? SCIPsetIsGT(set, relaxedbd, SCIPbdchginfoGetOldbound(bdchginfo)) : SCIPsetIsLT(set, relaxedbd, SCIPbdchginfoGetOldbound(bdchginfo)));
4400 
4401  /* put bound change information into priority queue */
4402  SCIP_CALL( conflictQueueBound(conflict, set, bdchginfo, relaxedbd) );
4403 
4404  /* each variable which is add to the conflict graph gets an increase in the VSIDS
4405  *
4406  * @note That is different to the VSIDS preseted in the literature
4407  */
4408  SCIP_CALL( incVSIDS(var, blkmem, set, stat, boundtype, relaxedbd, set->conf_conflictgraphweight) );
4409 
4410  return SCIP_OKAY;
4411 }
4412 
4413 /** adds variable's bound to conflict candidate queue */
4415  SCIP_CONFLICT* conflict, /**< conflict analysis data */
4416  BMS_BLKMEM* blkmem, /**< block memory */
4417  SCIP_SET* set, /**< global SCIP settings */
4418  SCIP_STAT* stat, /**< dynamic problem statistics */
4419  SCIP_VAR* var, /**< problem variable */
4420  SCIP_BOUNDTYPE boundtype, /**< type of bound that was changed: lower or upper bound */
4421  SCIP_BDCHGIDX* bdchgidx /**< bound change index (time stamp of bound change), or NULL for current time */
4422  )
4423 {
4424  SCIP_BDCHGINFO* bdchginfo;
4425 
4426  assert(conflict != NULL);
4427  assert(stat != NULL);
4428  assert(var != NULL);
4429 
4430  /* convert bound to active problem variable */
4431  SCIP_CALL( convertToActiveVar(&var, set, &boundtype, NULL) );
4432 
4433  /* we can ignore fixed variables */
4435  return SCIP_OKAY;
4436 
4437  /* if the variable is multi-aggregated, add the bounds of all aggregation variables */
4439  {
4440  SCIP_VAR** vars;
4441  SCIP_Real* scalars;
4442  int nvars;
4443  int i;
4444 
4445  vars = SCIPvarGetMultaggrVars(var);
4446  scalars = SCIPvarGetMultaggrScalars(var);
4447  nvars = SCIPvarGetMultaggrNVars(var);
4448  for( i = 0; i < nvars; ++i )
4449  {
4450  SCIP_CALL( SCIPconflictAddBound(conflict, blkmem, set, stat, vars[i],
4451  (scalars[i] < 0.0 ? SCIPboundtypeOpposite(boundtype) : boundtype), bdchgidx) );
4452  }
4453 
4454  return SCIP_OKAY;
4455  }
4456  assert(SCIPvarIsActive(var));
4457 
4458  /* get bound change information */
4459  bdchginfo = SCIPvarGetBdchgInfo(var, boundtype, bdchgidx, FALSE);
4460 
4461  /* if bound of variable was not changed (this means it is still the global bound), we can ignore the conflicting
4462  * bound
4463  */
4464  if( bdchginfo == NULL )
4465  return SCIP_OKAY;
4466 
4467  assert(SCIPbdchgidxIsEarlier(SCIPbdchginfoGetIdx(bdchginfo), bdchgidx));
4468 
4469  SCIP_CALL( conflictAddBound(conflict, blkmem, set, stat, var, boundtype, bdchginfo, SCIPbdchginfoGetNewbound(bdchginfo)) );
4470 
4471  return SCIP_OKAY;
4472 }
4473 
4474 /** adds variable's bound to conflict candidate queue */
4476  SCIP_CONFLICT* conflict, /**< conflict analysis data */
4477  BMS_BLKMEM* blkmem, /**< block memory */
4478  SCIP_SET* set, /**< global SCIP settings */
4479  SCIP_STAT* stat, /**< dynamic problem statistics */
4480  SCIP_VAR* var, /**< problem variable */
4481  SCIP_BOUNDTYPE boundtype, /**< type of bound that was changed: lower or upper bound */
4482  SCIP_BDCHGIDX* bdchgidx, /**< bound change index (time stamp of bound change), or NULL for current time */
4483  SCIP_Real relaxedbd /**< the relaxed bound */
4484  )
4485 {
4486  SCIP_BDCHGINFO* bdchginfo;
4487  int nbdchgs;
4488 
4489  assert(conflict != NULL);
4490  assert(stat != NULL);
4491  assert(var != NULL);
4492 
4493  if( !SCIPvarIsActive(var) )
4494  {
4495  /* convert bound to active problem variable */
4496  SCIP_CALL( convertToActiveVar(&var, set, &boundtype, &relaxedbd) );
4497 
4498  /* we can ignore fixed variables */
4500  return SCIP_OKAY;
4501 
4502  /* if the variable is multi-aggregated, add the bounds of all aggregation variables */
4504  {
4505  SCIPsetDebugMsg(set, "ignoring relaxed bound information since variable <%s> is multi-aggregated active\n", SCIPvarGetName(var));
4506 
4507  SCIP_CALL( SCIPconflictAddBound(conflict, blkmem, set, stat, var, boundtype, bdchgidx) );
4508 
4509  return SCIP_OKAY;
4510  }
4511  }
4512  assert(SCIPvarIsActive(var));
4513 
4514  /* get bound change information */
4515  bdchginfo = SCIPvarGetBdchgInfo(var, boundtype, bdchgidx, FALSE);
4516 
4517  /* if bound of variable was not changed (this means it is still the global bound), we can ignore the conflicting
4518  * bound
4519  */
4520  if( bdchginfo == NULL )
4521  return SCIP_OKAY;
4522 
4523  /* check that the bound change info is not a temporary one */
4524  assert(SCIPbdchgidxGetPos(&bdchginfo->bdchgidx) >= 0);
4525 
4526  /* get the position of the bound change information within the bound change array of the variable */
4527  nbdchgs = (int) bdchginfo->pos;
4528  assert(nbdchgs >= 0);
4529 
4530  /* if the relaxed bound should be ignored, set the relaxed bound to the bound given by the bdchgidx; that ensures
4531  * that the loop(s) below will be skipped
4532  */
4533  if( set->conf_ignorerelaxedbd )
4534  relaxedbd = SCIPbdchginfoGetNewbound(bdchginfo);
4535 
4536  /* search for the bound change information which includes the relaxed bound */
4537  if( boundtype == SCIP_BOUNDTYPE_LOWER )
4538  {
4539  SCIP_Real newbound;
4540 
4541  /* adjust relaxed lower bound w.r.t. variable type */
4542  SCIPvarAdjustLb(var, set, &relaxedbd);
4543 
4544  /* due to numericis we compare the relaxed lower bound to the one present at the particular time point and take
4545  * the better one
4546  */
4547  newbound = SCIPbdchginfoGetNewbound(bdchginfo);
4548  relaxedbd = MIN(relaxedbd, newbound);
4549 
4550  /* check if relaxed lower bound is smaller or equal to global lower bound; if so we can ignore the conflicting
4551  * bound
4552  */
4553  if( SCIPsetIsLE(set, relaxedbd, SCIPvarGetLbGlobal(var)) )
4554  return SCIP_OKAY;
4555 
4556  while( nbdchgs > 0 )
4557  {
4558  assert(SCIPsetIsLE(set, relaxedbd, SCIPbdchginfoGetNewbound(bdchginfo)));
4559 
4560  /* check if the old lower bound is greater than or equal to relaxed lower bound; if not we found the bound
4561  * change info which we need to report
4562  */
4563  if( SCIPsetIsGT(set, relaxedbd, SCIPbdchginfoGetOldbound(bdchginfo)) )
4564  break;
4565 
4566  bdchginfo = SCIPvarGetBdchgInfoLb(var, nbdchgs-1);
4567 
4568  SCIPsetDebugMsg(set, "lower bound change %d oldbd=%.15g, newbd=%.15g, depth=%d, pos=%d, redundant=%u\n",
4569  nbdchgs, SCIPbdchginfoGetOldbound(bdchginfo), SCIPbdchginfoGetNewbound(bdchginfo),
4570  SCIPbdchginfoGetDepth(bdchginfo), SCIPbdchginfoGetPos(bdchginfo),
4571  SCIPbdchginfoIsRedundant(bdchginfo));
4572 
4573  /* if bound change is redundant (this means it now a global bound), we can ignore the conflicting bound */
4574  if( SCIPbdchginfoIsRedundant(bdchginfo) )
4575  return SCIP_OKAY;
4576 
4577  nbdchgs--;
4578  }
4579  assert(SCIPsetIsGT(set, relaxedbd, SCIPbdchginfoGetOldbound(bdchginfo)));
4580  }
4581  else
4582  {
4583  SCIP_Real newbound;
4584 
4585  assert(boundtype == SCIP_BOUNDTYPE_UPPER);
4586 
4587  /* adjust relaxed upper bound w.r.t. variable type */
4588  SCIPvarAdjustUb(var, set, &relaxedbd);
4589 
4590  /* due to numericis we compare the relaxed upper bound to the one present at the particular time point and take
4591  * the better one
4592  */
4593  newbound = SCIPbdchginfoGetNewbound(bdchginfo);
4594  relaxedbd = MAX(relaxedbd, newbound);
4595 
4596  /* check if relaxed upper bound is greater or equal to global upper bound; if so we can ignore the conflicting
4597  * bound
4598  */
4599  if( SCIPsetIsGE(set, relaxedbd, SCIPvarGetUbGlobal(var)) )
4600  return SCIP_OKAY;
4601 
4602  while( nbdchgs > 0 )
4603  {
4604  assert(SCIPsetIsGE(set, relaxedbd, SCIPbdchginfoGetNewbound(bdchginfo)));
4605 
4606  /* check if the old upper bound is smaller than or equal to the relaxed upper bound; if not we found the
4607  * bound change info which we need to report
4608  */
4609  if( SCIPsetIsLT(set, relaxedbd, SCIPbdchginfoGetOldbound(bdchginfo)) )
4610  break;
4611 
4612  bdchginfo = SCIPvarGetBdchgInfoUb(var, nbdchgs-1);
4613 
4614  SCIPsetDebugMsg(set, "upper bound change %d oldbd=%.15g, newbd=%.15g, depth=%d, pos=%d, redundant=%u\n",
4615  nbdchgs, SCIPbdchginfoGetOldbound(bdchginfo), SCIPbdchginfoGetNewbound(bdchginfo),
4616  SCIPbdchginfoGetDepth(bdchginfo), SCIPbdchginfoGetPos(bdchginfo),
4617  SCIPbdchginfoIsRedundant(bdchginfo));
4618 
4619  /* if bound change is redundant (this means it now a global bound), we can ignore the conflicting bound */
4620  if( SCIPbdchginfoIsRedundant(bdchginfo) )
4621  return SCIP_OKAY;
4622 
4623  nbdchgs--;
4624  }
4625  assert(SCIPsetIsLT(set, relaxedbd, SCIPbdchginfoGetOldbound(bdchginfo)));
4626  }
4627 
4628  assert(SCIPbdchgidxIsEarlier(SCIPbdchginfoGetIdx(bdchginfo), bdchgidx));
4629 
4630  /* put bound change information into priority queue */
4631  SCIP_CALL( conflictAddBound(conflict, blkmem, set, stat, var, boundtype, bdchginfo, relaxedbd) );
4632 
4633  return SCIP_OKAY;
4634 }
4635 
4636 /** checks if the given variable is already part of the current conflict set or queued for resolving with the same or
4637  * even stronger bound
4638  */
4640  SCIP_CONFLICT* conflict, /**< conflict analysis data */
4641  SCIP_VAR* var, /**< problem variable */
4642  SCIP_SET* set, /**< global SCIP settings */
4643  SCIP_BOUNDTYPE boundtype, /**< type of bound for which the score should be increased */
4644  SCIP_BDCHGIDX* bdchgidx, /**< bound change index (time stamp of bound change), or NULL for current time */
4645  SCIP_Bool* used /**< pointer to store if the variable is already used */
4646  )
4647 {
4648  SCIP_Real newbound;
4649 
4650  /* convert bound to active problem variable */
4651  SCIP_CALL( convertToActiveVar(&var, set, &boundtype, NULL) );
4652 
4654  *used = FALSE;
4655  else
4656  {
4657  assert(SCIPvarIsActive(var));
4658  assert(var != NULL);
4659 
4660  switch( boundtype )
4661  {
4662  case SCIP_BOUNDTYPE_LOWER:
4663 
4664  newbound = SCIPgetVarLbAtIndex(set->scip, var, bdchgidx, FALSE);
4665 
4666  if( var->conflictlbcount == conflict->count && var->conflictlb >= newbound )
4667  {
4668  SCIPsetDebugMsg(set, "already queued bound change <%s> >= %g\n", SCIPvarGetName(var), newbound);
4669  *used = TRUE;
4670  }
4671  else
4672  *used = FALSE;
4673  break;
4674  case SCIP_BOUNDTYPE_UPPER:
4675 
4676  newbound = SCIPgetVarUbAtIndex(set->scip, var, bdchgidx, FALSE);
4677 
4678  if( var->conflictubcount == conflict->count && var->conflictub <= newbound )
4679  {
4680  SCIPsetDebugMsg(set, "already queued bound change <%s> <= %g\n", SCIPvarGetName(var), newbound);
4681  *used = TRUE;
4682  }
4683  else
4684  *used = FALSE;
4685  break;
4686  default:
4687  SCIPerrorMessage("invalid bound type %d\n", boundtype);
4688  SCIPABORT();
4689  *used = FALSE; /*lint !e527*/
4690  }
4691  }
4692 
4693  return SCIP_OKAY;
4694 }
4695 
4696 /** returns the conflict lower bound if the variable is present in the current conflict set; otherwise the global lower
4697  * bound
4698  */
4700  SCIP_CONFLICT* conflict, /**< conflict analysis data */
4701  SCIP_VAR* var /**< problem variable */
4702  )
4703 {
4704  if( var->conflictlbcount == conflict->count )
4705  {
4706  assert(EPSGE(var->conflictlb, var->conflictrelaxedlb, 1e-09));
4707  return var->conflictrelaxedlb;
4708  }
4709 
4710  return SCIPvarGetLbGlobal(var);
4711 }
4712 
4713 /** returns the conflict upper bound if the variable is present in the current conflict set; otherwise the global upper
4714  * bound
4715  */
4717  SCIP_CONFLICT* conflict, /**< conflict analysis data */
4718  SCIP_VAR* var /**< problem variable */
4719  )
4720 {
4721  if( var->conflictubcount == conflict->count )
4722  {
4723  assert(EPSLE(var->conflictub, var->conflictrelaxedub, 1e-09));
4724  return var->conflictrelaxedub;
4725  }
4726 
4727  return SCIPvarGetUbGlobal(var);
4728 }
4729 
4730 /** removes and returns next conflict analysis candidate from the candidate queue */
4731 static
4733  SCIP_CONFLICT* conflict /**< conflict analysis data */
4734  )
4735 {
4736  SCIP_BDCHGINFO* bdchginfo;
4737  SCIP_VAR* var;
4738 
4739  assert(conflict != NULL);
4740 
4741  if( SCIPpqueueNElems(conflict->forcedbdchgqueue) > 0 )
4742  bdchginfo = (SCIP_BDCHGINFO*)(SCIPpqueueRemove(conflict->forcedbdchgqueue));
4743  else
4744  bdchginfo = (SCIP_BDCHGINFO*)(SCIPpqueueRemove(conflict->bdchgqueue));
4745 
4746  assert(!SCIPbdchginfoIsRedundant(bdchginfo));
4747 
4748  /* if we have a candidate this one should be valid for the current conflict analysis */
4749  assert(!bdchginfoIsInvalid(conflict, bdchginfo));
4750 
4751  /* mark the bound change to be no longer in the conflict (it will be either added again to the conflict set or
4752  * replaced by resolving, which might add a weaker change on the same bound to the queue)
4753  */
4754  var = SCIPbdchginfoGetVar(bdchginfo);
4756  {
4757  var->conflictlbcount = 0;
4759  }
4760  else
4761  {
4762  assert(SCIPbdchginfoGetBoundtype(bdchginfo) == SCIP_BOUNDTYPE_UPPER);
4763  var->conflictubcount = 0;
4765  }
4766 
4767 #ifdef SCIP_CONFGRAPH
4768  confgraphSetCurrentBdchg(bdchginfo);
4769 #endif
4770 
4771  return bdchginfo;
4772 }
4773 
4774 /** returns next conflict analysis candidate from the candidate queue without removing it */
4775 static
4777  SCIP_CONFLICT* conflict /**< conflict analysis data */
4778  )
4779 {
4780  SCIP_BDCHGINFO* bdchginfo;
4781 
4782  assert(conflict != NULL);
4783 
4784  if( SCIPpqueueNElems(conflict->forcedbdchgqueue) > 0 )
4785  {
4786  /* get next potetioal candidate */
4787  bdchginfo = (SCIP_BDCHGINFO*)(SCIPpqueueFirst(conflict->forcedbdchgqueue));
4788 
4789  /* check if this candidate is valid */
4790  if( bdchginfoIsInvalid(conflict, bdchginfo) )
4791  {
4792  SCIPdebugMessage("bound change info [%d:<%s> %s %g] is invaild -> pop it from the force queue\n", SCIPbdchginfoGetDepth(bdchginfo),
4793  SCIPvarGetName(SCIPbdchginfoGetVar(bdchginfo)),
4794  SCIPbdchginfoGetBoundtype(bdchginfo) == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=",
4795  SCIPbdchginfoGetNewbound(bdchginfo));
4796 
4797  /* pop the invalid bound change info from the queue */
4798  (void)(SCIPpqueueRemove(conflict->forcedbdchgqueue));
4799 
4800  /* call method recursively to get next conflict analysis candidate */
4801  bdchginfo = conflictFirstCand(conflict);
4802  }
4803  }
4804  else
4805  {
4806  bdchginfo = (SCIP_BDCHGINFO*)(SCIPpqueueFirst(conflict->bdchgqueue));
4807 
4808  /* check if this candidate is valid */
4809  if( bdchginfo != NULL && bdchginfoIsInvalid(conflict, bdchginfo) )
4810  {
4811  SCIPdebugMessage("bound change info [%d:<%s> %s %g] is invaild -> pop it from the queue\n", SCIPbdchginfoGetDepth(bdchginfo),
4812  SCIPvarGetName(SCIPbdchginfoGetVar(bdchginfo)),
4813  SCIPbdchginfoGetBoundtype(bdchginfo) == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=",
4814  SCIPbdchginfoGetNewbound(bdchginfo));
4815 
4816  /* pop the invalid bound change info from the queue */
4817  (void)(SCIPpqueueRemove(conflict->bdchgqueue));
4818 
4819  /* call method recursively to get next conflict analysis candidate */
4820  bdchginfo = conflictFirstCand(conflict);
4821  }
4822  }
4823  assert(bdchginfo == NULL || !SCIPbdchginfoIsRedundant(bdchginfo));
4824 
4825  return bdchginfo;
4826 }
4827 
4828 /** adds the current conflict set (extended by all remaining bound changes in the queue) to the pool of conflict sets */
4829 static
4831  SCIP_CONFLICT* conflict, /**< conflict analysis data */
4832  BMS_BLKMEM* blkmem, /**< block memory of transformed problem */
4833  SCIP_SET* set, /**< global SCIP settings */
4834  SCIP_STAT* stat, /**< dynamic problem statistics */
4835  SCIP_TREE* tree, /**< branch and bound tree */
4836  int validdepth, /**< minimal depth level at which the conflict set is valid */
4837  SCIP_Bool diving, /**< are we in strong branching or diving mode? */
4838  SCIP_Bool repropagate, /**< should the constraint trigger a repropagation? */
4839  SCIP_Bool* success, /**< pointer to store whether the conflict set is valid */
4840  int* nliterals /**< pointer to store the number of literals in the generated conflictset */
4841  )
4842 {
4843  SCIP_CONFLICTSET* conflictset;
4844  SCIP_BDCHGINFO** bdchginfos;
4845  int nbdchginfos;
4846  int currentdepth;
4847  int focusdepth;
4848 
4849  assert(conflict != NULL);
4850  assert(conflict->conflictset != NULL);
4851  assert(set != NULL);
4852  assert(stat != NULL);
4853  assert(tree != NULL);
4854  assert(success != NULL);
4855  assert(nliterals != NULL);
4856  assert(SCIPpqueueNElems(conflict->forcedbdchgqueue) == 0);
4857 
4858  *success = FALSE;
4859  *nliterals = 0;
4860 
4861  /* check, whether local conflicts are allowed */
4862  validdepth = MAX(validdepth, conflict->conflictset->validdepth);
4863  if( !set->conf_allowlocal && validdepth > 0 )
4864  return SCIP_OKAY;
4865 
4866  focusdepth = SCIPtreeGetFocusDepth(tree);
4867  currentdepth = SCIPtreeGetCurrentDepth(tree);
4868  assert(currentdepth == tree->pathlen-1);
4869  assert(focusdepth <= currentdepth);
4870  assert(0 <= conflict->conflictset->validdepth && conflict->conflictset->validdepth <= currentdepth);
4871  assert(0 <= validdepth && validdepth <= currentdepth);
4872 
4873  /* get the elements of the bound change queue */
4874  bdchginfos = (SCIP_BDCHGINFO**)SCIPpqueueElems(conflict->bdchgqueue);
4875  nbdchginfos = SCIPpqueueNElems(conflict->bdchgqueue);
4876 
4877  /* create a copy of the current conflict set, allocating memory for the additional elements of the queue */
4878  SCIP_CALL( conflictsetCopy(&conflictset, blkmem, conflict->conflictset, nbdchginfos) );
4879  conflictset->validdepth = validdepth;
4880  conflictset->repropagate = repropagate;
4881 
4882  /* add the valid queue elements to the conflict set */
4883  SCIPsetDebugMsg(set, "adding %d variables from the queue as temporary conflict variables\n", nbdchginfos);
4884  SCIP_CALL( conflictsetAddBounds(conflict, conflictset, blkmem, set, bdchginfos, nbdchginfos) );
4885 
4886  /* calculate the depth, at which the conflictset should be inserted */
4887  SCIP_CALL( conflictsetCalcInsertDepth(conflictset, set, tree) );
4888  assert(conflictset->validdepth <= conflictset->insertdepth && conflictset->insertdepth <= currentdepth);
4889  SCIPsetDebugMsg(set, " -> conflict with %d literals found at depth %d is active in depth %d and valid in depth %d\n",
4890  conflictset->nbdchginfos, currentdepth, conflictset->insertdepth, conflictset->validdepth);
4891 
4892  /* if all branching variables are in the conflict set, the conflict set is of no use;
4893  * don't use conflict sets that are only valid in the probing path but not in the problem tree
4894  */
4895  if( (diving || conflictset->insertdepth < currentdepth) && conflictset->insertdepth <= focusdepth )
4896  {
4897  /* if the conflict should not be located only in the subtree where it is useful, put it to its valid depth level */
4898  if( !set->conf_settlelocal )
4899  conflictset->insertdepth = conflictset->validdepth;
4900 
4901  *nliterals = conflictset->nbdchginfos;
4902  SCIPsetDebugMsg(set, " -> final conflict set has %d literals\n", *nliterals);
4903 
4904  /* check conflict set on debugging solution */
4905  SCIP_CALL( SCIPdebugCheckConflict(blkmem, set, tree->path[validdepth], \
4906  conflictset->bdchginfos, conflictset->relaxedbds, conflictset->nbdchginfos) ); /*lint !e506 !e774*/
4907 
4908  /* move conflictset to the conflictset storage */
4909  SCIP_CALL( conflictInsertConflictset(conflict, blkmem, set, &conflictset) );
4910  *success = TRUE;
4911  }
4912  else
4913  {
4914  /* free the temporary conflict set */
4915  conflictsetFree(&conflictset, blkmem);
4916  }
4917 
4918  return SCIP_OKAY;
4919 }
4920 
4921 /** tries to resolve given bound change
4922  * - resolutions on local constraints are only applied, if the constraint is valid at the
4923  * current minimal valid depth level, because this depth level is the topmost level to add the conflict
4924  * constraint to anyways
4925  *
4926  * @note it is sufficient to explain the relaxed bound change
4927  */
4928 static
4930  SCIP_CONFLICT* conflict, /**< conflict analysis data */
4931  SCIP_SET* set, /**< global SCIP settings */
4932  SCIP_BDCHGINFO* bdchginfo, /**< bound change to resolve */
4933  SCIP_Real relaxedbd, /**< the relaxed bound */
4934  int validdepth, /**< minimal depth level at which the conflict is valid */
4935  SCIP_Bool* resolved /**< pointer to store whether the bound change was resolved */
4936  )
4937 {
4938  SCIP_VAR* actvar;
4939  SCIP_CONS* infercons;
4940  SCIP_PROP* inferprop;
4941  SCIP_RESULT result;
4942 
4943 #ifndef NDEBUG
4944  int nforcedbdchgqueue;
4945  int nbdchgqueue;
4946 
4947  /* store the current size of the conflict queues */
4948  assert(conflict != NULL);
4949  nforcedbdchgqueue = SCIPpqueueNElems(conflict->forcedbdchgqueue);
4950  nbdchgqueue = SCIPpqueueNElems(conflict->bdchgqueue);
4951 #else
4952  assert(conflict != NULL);
4953 #endif
4954 
4955  assert(resolved != NULL);
4956  assert(!SCIPbdchginfoIsRedundant(bdchginfo));
4957 
4958  *resolved = FALSE;
4959 
4960  actvar = SCIPbdchginfoGetVar(bdchginfo);
4961  assert(actvar != NULL);
4962  assert(SCIPvarIsActive(actvar));
4963 
4964 #ifdef SCIP_DEBUG
4965  {
4966  int i;
4967  SCIPsetDebugMsg(set, "processing next conflicting bound (depth: %d, valid depth: %d, bdchgtype: %s [%s], vartype: %d): [<%s> %s %g(%g)]\n",
4968  SCIPbdchginfoGetDepth(bdchginfo), validdepth,
4969  SCIPbdchginfoGetChgtype(bdchginfo) == SCIP_BOUNDCHGTYPE_BRANCHING ? "branch"
4970  : SCIPbdchginfoGetChgtype(bdchginfo) == SCIP_BOUNDCHGTYPE_CONSINFER ? "cons" : "prop",
4974  : SCIPbdchginfoGetInferProp(bdchginfo) == NULL ? "-"
4976  SCIPvarGetType(actvar), SCIPvarGetName(actvar),
4977  SCIPbdchginfoGetBoundtype(bdchginfo) == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=",
4978  SCIPbdchginfoGetNewbound(bdchginfo), relaxedbd);
4979  SCIPsetDebugMsg(set, " - conflict set :");
4980 
4981  for( i = 0; i < conflict->conflictset->nbdchginfos; ++i )
4982  {
4983  SCIPsetDebugMsgPrint(set, " [%d:<%s> %s %g(%g)]", SCIPbdchginfoGetDepth(conflict->conflictset->bdchginfos[i]),
4985  SCIPbdchginfoGetBoundtype(conflict->conflictset->bdchginfos[i]) == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=",
4986  SCIPbdchginfoGetNewbound(conflict->conflictset->bdchginfos[i]), conflict->conflictset->relaxedbds[i]);
4987  }
4988  SCIPsetDebugMsgPrint(set, "\n");
4989  SCIPsetDebugMsg(set, " - forced candidates :");
4990 
4991  for( i = 0; i < SCIPpqueueNElems(conflict->forcedbdchgqueue); ++i )
4992  {
4994  SCIPsetDebugMsgPrint(set, " [%d:<%s> %s %g(%g)]", SCIPbdchginfoGetDepth(info), SCIPvarGetName(SCIPbdchginfoGetVar(info)),
4995  bdchginfoIsInvalid(conflict, info) ? "<!>" : SCIPbdchginfoGetBoundtype(info) == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=",
4997  }
4998  SCIPsetDebugMsgPrint(set, "\n");
4999  SCIPsetDebugMsg(set, " - optional candidates:");
5000 
5001  for( i = 0; i < SCIPpqueueNElems(conflict->bdchgqueue); ++i )
5002  {
5003  SCIP_BDCHGINFO* info = (SCIP_BDCHGINFO*)(SCIPpqueueElems(conflict->bdchgqueue)[i]);
5004  SCIPsetDebugMsgPrint(set, " [%d:<%s> %s %g(%g)]", SCIPbdchginfoGetDepth(info), SCIPvarGetName(SCIPbdchginfoGetVar(info)),
5005  bdchginfoIsInvalid(conflict, info) ? "<!>" : SCIPbdchginfoGetBoundtype(info) == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=",
5007  }
5008  SCIPsetDebugMsgPrint(set, "\n");
5009  }
5010 #endif
5011 
5012  /* check, if the bound change can and should be resolved:
5013  * - resolutions on local constraints should only be applied, if the constraint is valid at the
5014  * current minimal valid depth level (which is initialized with the valid depth level of the initial
5015  * conflict set), because this depth level is the topmost level to add the conflict constraint to anyways
5016  */
5017  switch( SCIPbdchginfoGetChgtype(bdchginfo) )
5018  {
5020  infercons = SCIPbdchginfoGetInferCons(bdchginfo);
5021  assert(infercons != NULL);
5022 
5023  if( SCIPconsIsGlobal(infercons) || SCIPconsGetValidDepth(infercons) <= validdepth )
5024  {
5025  SCIP_VAR* infervar;
5026  int inferinfo;
5027  SCIP_BOUNDTYPE inferboundtype;
5028  SCIP_BDCHGIDX* bdchgidx;
5029 
5030  /* resolve bound change by asking the constraint that inferred the bound to put all bounds that were
5031  * the reasons for the conflicting bound change on the priority queue
5032  */
5033  infervar = SCIPbdchginfoGetInferVar(bdchginfo);
5034  inferinfo = SCIPbdchginfoGetInferInfo(bdchginfo);
5035  inferboundtype = SCIPbdchginfoGetInferBoundtype(bdchginfo);
5036  bdchgidx = SCIPbdchginfoGetIdx(bdchginfo);
5037  assert(infervar != NULL);
5038 
5039  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",
5040  SCIPvarGetName(actvar),
5041  SCIPbdchginfoGetBoundtype(bdchginfo) == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=",
5042  SCIPbdchginfoGetNewbound(bdchginfo), relaxedbd,
5043  SCIPvarGetStatus(actvar), SCIPvarGetType(actvar),
5044  SCIPbdchginfoGetDepth(bdchginfo), SCIPbdchginfoGetPos(bdchginfo),
5045  SCIPvarGetName(infervar),
5046  inferboundtype == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=",
5047  SCIPgetVarBdAtIndex(set->scip, infervar, inferboundtype, bdchgidx, TRUE),
5048  SCIPconsGetName(infercons),
5049  SCIPconsIsGlobal(infercons) ? "global" : "local",
5050  inferinfo);
5051 
5052  /* in case the inference variables is not an active variables, we need to transform the relaxed bound */
5053  if( actvar != infervar )
5054  {
5055  SCIP_VAR* var;
5056  SCIP_Real scalar;
5057  SCIP_Real constant;
5058 
5059  assert(SCIPvarGetStatus(infervar) == SCIP_VARSTATUS_AGGREGATED
5061  || (SCIPvarGetStatus(infervar) == SCIP_VARSTATUS_MULTAGGR && SCIPvarGetMultaggrNVars(infervar) == 1));
5062 
5063  scalar = 1.0;
5064  constant = 0.0;
5065 
5066  var = infervar;
5067 
5068  /* transform given varibale to active varibale */
5069  SCIP_CALL( SCIPvarGetProbvarSum(&var, set, &scalar, &constant) );
5070  assert(var == actvar);
5071 
5072  relaxedbd *= scalar;
5073  relaxedbd += constant;
5074  }
5075 
5076  SCIP_CALL( SCIPconsResolvePropagation(infercons, set, infervar, inferinfo, inferboundtype, bdchgidx, relaxedbd, &result) );
5077  *resolved = (result == SCIP_SUCCESS);
5078  }
5079  break;
5080 
5082  inferprop = SCIPbdchginfoGetInferProp(bdchginfo);
5083  if( inferprop != NULL )
5084  {
5085  SCIP_VAR* infervar;
5086  int inferinfo;
5087  SCIP_BOUNDTYPE inferboundtype;
5088  SCIP_BDCHGIDX* bdchgidx;
5089 
5090  /* resolve bound change by asking the propagator that inferred the bound to put all bounds that were
5091  * the reasons for the conflicting bound change on the priority queue
5092  */
5093  infervar = SCIPbdchginfoGetInferVar(bdchginfo);
5094  inferinfo = SCIPbdchginfoGetInferInfo(bdchginfo);
5095  inferboundtype = SCIPbdchginfoGetInferBoundtype(bdchginfo);
5096  bdchgidx = SCIPbdchginfoGetIdx(bdchginfo);
5097  assert(infervar != NULL);
5098 
5099  SCIPsetDebugMsg(set, "resolving bound <%s> %s %g(%g) [status:%d, depth:%d, pos:%d]: <%s> %s %g [prop:<%s>, info:%d]\n",
5100  SCIPvarGetName(actvar),
5101  SCIPbdchginfoGetBoundtype(bdchginfo) == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=",
5102  SCIPbdchginfoGetNewbound(bdchginfo), relaxedbd,
5103  SCIPvarGetStatus(actvar), SCIPbdchginfoGetDepth(bdchginfo), SCIPbdchginfoGetPos(bdchginfo),
5104  SCIPvarGetName(infervar),
5105  inferboundtype == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=",
5106  SCIPgetVarBdAtIndex(set->scip, infervar, inferboundtype, bdchgidx, TRUE),
5107  SCIPpropGetName(inferprop), inferinfo);
5108 
5109  SCIP_CALL( SCIPpropResolvePropagation(inferprop, set, infervar, inferinfo, inferboundtype, bdchgidx, relaxedbd, &result) );
5110  *resolved = (result == SCIP_SUCCESS);
5111  }
5112  break;
5113 
5115  assert(!(*resolved));
5116  break;
5117 
5118  default:
5119  SCIPerrorMessage("invalid bound change type <%d>\n", SCIPbdchginfoGetChgtype(bdchginfo));
5120  return SCIP_INVALIDDATA;
5121  }
5122 
5123  SCIPsetDebugMsg(set, "resolving status: %u\n", *resolved);
5124 
5125 #ifndef NDEBUG
5126  /* subtract the size of the conflicq queues */
5127  nforcedbdchgqueue -= SCIPpqueueNElems(conflict->forcedbdchgqueue);
5128  nbdchgqueue -= SCIPpqueueNElems(conflict->bdchgqueue);
5129 
5130  /* in case the bound change was not resolved, the conflict queues should have the same size (contents) */
5131  assert((*resolved) || (nforcedbdchgqueue == 0 && nbdchgqueue == 0));
5132 #endif
5133 
5134  return SCIP_OKAY;
5135 }
5136 
5137 /** if only one conflicting bound change of the last depth level was used, and if this can be resolved,
5138  * creates GRASP-like reconvergence conflict constraints in the conflict graph up to the branching variable of this
5139  * depth level
5140  */
5141 static
5143  SCIP_CONFLICT* conflict, /**< conflict analysis data */
5144  BMS_BLKMEM* blkmem, /**< block memory of transformed problem */
5145  SCIP_SET* set, /**< global SCIP settings */
5146  SCIP_STAT* stat, /**< problem statistics */
5147  SCIP_PROB* prob, /**< problem data */
5148  SCIP_TREE* tree, /**< branch and bound tree */
5149  SCIP_Bool diving, /**< are we in strong branching or diving mode? */
5150  int validdepth, /**< minimal depth level at which the initial conflict set is valid */
5151  SCIP_BDCHGINFO* firstuip, /**< first UIP of conflict graph */
5152  int* nreconvconss, /**< pointer to store the number of generated reconvergence constraints */
5153  int* nreconvliterals /**< pointer to store the number of literals generated reconvergence constraints */
5154  )
5155 {
5156  SCIP_BDCHGINFO* uip;
5157  SCIP_CONFTYPE conftype;
5158  SCIP_Bool usescutoffbound;
5159  int firstuipdepth;
5160  int focusdepth;
5161  int currentdepth;
5162  int maxvaliddepth;
5163 
5164  assert(conflict != NULL);
5165  assert(firstuip != NULL);
5166  assert(nreconvconss != NULL);
5167  assert(nreconvliterals != NULL);
5168  assert(!SCIPbdchginfoIsRedundant(firstuip));
5169 
5170  focusdepth = SCIPtreeGetFocusDepth(tree);
5171  currentdepth = SCIPtreeGetCurrentDepth(tree);
5172  assert(currentdepth == tree->pathlen-1);
5173  assert(focusdepth <= currentdepth);
5174 
5175  /* check, whether local constraints are allowed; however, don't generate reconvergence constraints that are only valid
5176  * in the probing path and not in the problem tree (i.e. that exceed the focusdepth)
5177  */
5178  maxvaliddepth = (set->conf_allowlocal ? MIN(currentdepth-1, focusdepth) : 0);
5179  if( validdepth > maxvaliddepth )
5180  return SCIP_OKAY;
5181 
5182  firstuipdepth = SCIPbdchginfoGetDepth(firstuip);
5183 
5184  conftype = conflict->conflictset->conflicttype;
5185  usescutoffbound = conflict->conflictset->usescutoffbound;
5186 
5187  /* for each succeeding UIP pair of the last depth level, create one reconvergence constraint */
5188  uip = firstuip;
5189  while( uip != NULL && SCIPbdchginfoGetDepth(uip) == SCIPbdchginfoGetDepth(firstuip) && bdchginfoIsResolvable(uip) )
5190  {
5191  SCIP_BDCHGINFO* oppositeuip;
5192  SCIP_BDCHGINFO* bdchginfo;
5193  SCIP_BDCHGINFO* nextuip;
5194  SCIP_VAR* uipvar;
5195  SCIP_Real oppositeuipbound;
5196  SCIP_BOUNDTYPE oppositeuipboundtype;
5197  int nresolutions;
5198 
5199  assert(!SCIPbdchginfoIsRedundant(uip));
5200 
5201  SCIPsetDebugMsg(set, "creating reconvergence constraint for UIP <%s> %s %g in depth %d pos %d\n",
5204 
5205  /* initialize conflict data */
5206  SCIP_CALL( SCIPconflictInit(conflict, set, stat, prob, conftype, usescutoffbound) );
5207 
5208  conflict->conflictset->conflicttype = conftype;
5209  conflict->conflictset->usescutoffbound = usescutoffbound;
5210 
5211  /* create a temporary bound change information for the negation of the UIP's bound change;
5212  * this bound change information is freed in the SCIPconflictFlushConss() call;
5213  * for reconvergence constraints for continuous variables we can only use the "negation" !(x <= u) == (x >= u);
5214  * during conflict analysis, we treat a continuous bound "x >= u" in the conflict set as "x > u", and in the
5215  * generated constraint this is negated again to "x <= u" which is correct.
5216  */
5217  uipvar = SCIPbdchginfoGetVar(uip);
5218  oppositeuipboundtype = SCIPboundtypeOpposite(SCIPbdchginfoGetBoundtype(uip));
5219  oppositeuipbound = SCIPbdchginfoGetNewbound(uip);
5220  if( SCIPvarIsIntegral(uipvar) )
5221  {
5222  assert(SCIPsetIsIntegral(set, oppositeuipbound));
5223  oppositeuipbound += (oppositeuipboundtype == SCIP_BOUNDTYPE_LOWER ? +1.0 : -1.0);
5224  }
5225  SCIP_CALL( conflictCreateTmpBdchginfo(conflict, blkmem, set, uipvar, oppositeuipboundtype, \
5226  oppositeuipboundtype == SCIP_BOUNDTYPE_LOWER ? SCIP_REAL_MIN : SCIP_REAL_MAX, oppositeuipbound, &oppositeuip) );
5227 
5228  /* put the negated UIP into the conflict set */
5229  SCIP_CALL( conflictAddConflictBound(conflict, blkmem, set, oppositeuip, oppositeuipbound) );
5230 
5231  /* put positive UIP into priority queue */
5232  SCIP_CALL( conflictQueueBound(conflict, set, uip, SCIPbdchginfoGetNewbound(uip) ) );
5233 
5234  /* resolve the queue until the next UIP is reached */
5235  bdchginfo = conflictFirstCand(conflict);
5236  nextuip = NULL;
5237  nresolutions = 0;
5238  while( bdchginfo != NULL && validdepth <= maxvaliddepth )
5239  {
5240  SCIP_BDCHGINFO* nextbdchginfo;
5241  SCIP_Real relaxedbd;
5242  SCIP_Bool forceresolve;
5243  int bdchgdepth;
5244 
5245  /* check if the next bound change must be resolved in every case */
5246  forceresolve = (SCIPpqueueNElems(conflict->forcedbdchgqueue) > 0);
5247 
5248  /* remove currently processed candidate and get next conflicting bound from the conflict candidate queue before
5249  * we remove the candidate we have to collect the relaxed bound since removing the candidate from the queue
5250  * invalidates the relaxed bound
5251  */
5252  assert(bdchginfo == conflictFirstCand(conflict));
5253  relaxedbd = SCIPbdchginfoGetRelaxedBound(bdchginfo);
5254  bdchginfo = conflictRemoveCand(conflict);
5255  nextbdchginfo = conflictFirstCand(conflict);
5256  bdchgdepth = SCIPbdchginfoGetDepth(bdchginfo);
5257  assert(bdchginfo != NULL);
5258  assert(!SCIPbdchginfoIsRedundant(bdchginfo));
5259  assert(nextbdchginfo == NULL || SCIPbdchginfoGetDepth(bdchginfo) >= SCIPbdchginfoGetDepth(nextbdchginfo)
5260  || forceresolve);
5261  assert(bdchgdepth <= firstuipdepth);
5262 
5263  /* bound changes that are higher in the tree than the valid depth of the conflict can be ignored;
5264  * multiple insertions of the same bound change can be ignored
5265  */
5266  if( bdchgdepth > validdepth && bdchginfo != nextbdchginfo )
5267  {
5268  SCIP_VAR* actvar;
5269  SCIP_Bool resolved;
5270 
5271  actvar = SCIPbdchginfoGetVar(bdchginfo);
5272  assert(actvar != NULL);
5273  assert(SCIPvarIsActive(actvar));
5274 
5275  /* check if we have to resolve the bound change in this depth level
5276  * - the starting uip has to be resolved
5277  * - a bound change should be resolved, if it is in the fuip's depth level and not the
5278  * next uip (i.e., if it is not the last bound change in the fuip's depth level)
5279  * - a forced bound change must be resolved in any case
5280  */
5281  resolved = FALSE;
5282  if( bdchginfo == uip
5283  || (bdchgdepth == firstuipdepth
5284  && nextbdchginfo != NULL
5285  && SCIPbdchginfoGetDepth(nextbdchginfo) == bdchgdepth)
5286  || forceresolve )
5287  {
5288  SCIP_CALL( conflictResolveBound(conflict, set, bdchginfo, relaxedbd, validdepth, &resolved) );
5289  }
5290 
5291  if( resolved )
5292  nresolutions++;
5293  else if( forceresolve )
5294  {
5295  /* variable cannot enter the conflict clause: we have to make the conflict clause local, s.t.
5296  * the unresolved bound change is active in the whole sub tree of the conflict clause
5297  */
5298  assert(bdchgdepth >= validdepth);
5299  validdepth = bdchgdepth;
5300 
5301  SCIPsetDebugMsg(set, "couldn't resolve forced bound change on <%s> -> new valid depth: %d\n",
5302  SCIPvarGetName(actvar), validdepth);
5303  }
5304  else if( bdchginfo != uip )
5305  {
5306  assert(conflict->conflictset != NULL);
5307  assert(conflict->conflictset->nbdchginfos >= 1); /* starting UIP is already member of the conflict set */
5308 
5309  /* if this is the first variable of the conflict set besides the current starting UIP, it is the next
5310  * UIP (or the first unresolvable bound change)
5311  */
5312  if( bdchgdepth == firstuipdepth && conflict->conflictset->nbdchginfos == 1 )
5313  {
5314  assert(nextuip == NULL);
5315  nextuip = bdchginfo;
5316  }
5317 
5318  /* put bound change into the conflict set */
5319  SCIP_CALL( conflictAddConflictBound(conflict, blkmem, set, bdchginfo, relaxedbd) );
5320  assert(conflict->conflictset->nbdchginfos >= 2);
5321  }
5322  else
5323  assert(conflictFirstCand(conflict) == NULL); /* the starting UIP was not resolved */
5324  }
5325 
5326  /* get next conflicting bound from the conflict candidate queue (this does not need to be nextbdchginfo, because
5327  * due to resolving the bound changes, a variable could be added to the queue which must be
5328  * resolved before nextbdchginfo)
5329  */
5330  bdchginfo = conflictFirstCand(conflict);
5331  }
5332  assert(nextuip != uip);
5333 
5334  /* if only one propagation was resolved, the reconvergence constraint is already member of the constraint set
5335  * (it is exactly the constraint that produced the propagation)
5336  */
5337  if( nextuip != NULL && nresolutions >= 2 && bdchginfo == NULL && validdepth <= maxvaliddepth )
5338  {
5339  int nlits;
5340  SCIP_Bool success;
5341 
5342  assert(SCIPbdchginfoGetDepth(nextuip) == SCIPbdchginfoGetDepth(uip));
5343 
5344  /* check conflict graph frontier on debugging solution */
5345  SCIP_CALL( SCIPdebugCheckConflictFrontier(blkmem, set, tree->path[validdepth], \
5346  bdchginfo, conflict->conflictset->bdchginfos, conflict->conflictset->relaxedbds, \
5347  conflict->conflictset->nbdchginfos, conflict->bdchgqueue, conflict->forcedbdchgqueue) ); /*lint !e506 !e774*/
5348 
5349  SCIPsetDebugMsg(set, "creating reconvergence constraint from UIP <%s> to UIP <%s> in depth %d with %d literals after %d resolutions\n",
5351  SCIPbdchginfoGetDepth(uip), conflict->conflictset->nbdchginfos, nresolutions);
5352 
5353  /* call the conflict handlers to create a conflict set */
5354  SCIP_CALL( conflictAddConflictset(conflict, blkmem, set, stat, tree, validdepth, diving, FALSE, &success, &nlits) );
5355  if( success )
5356  {
5357  (*nreconvconss)++;
5358  (*nreconvliterals) += nlits;
5359  }
5360  }
5361 
5362  /* clear the conflict candidate queue and the conflict set (to make sure, oppositeuip is not referenced anymore) */
5363  conflictClear(conflict);
5364 
5365  uip = nextuip;
5366  }
5367 
5368  conflict->conflictset->conflicttype = conftype;
5369  conflict->conflictset->usescutoffbound = usescutoffbound;
5370 
5371  return SCIP_OKAY;
5372 }
5373 
5374 /** analyzes conflicting bound changes that were added with calls to SCIPconflictAddBound() and
5375  * SCIPconflictAddRelaxedBound(), and on success, calls the conflict handlers to create a conflict constraint out of
5376  * the resulting conflict set; afterwards the conflict queue and the conflict set is cleared
5377  */
5378 static
5380  SCIP_CONFLICT* conflict, /**< conflict analysis data */
5381  BMS_BLKMEM* blkmem, /**< block memory of transformed problem */
5382  SCIP_SET* set, /**< global SCIP settings */
5383  SCIP_STAT* stat, /**< problem statistics */
5384  SCIP_PROB* prob, /**< problem data */
5385  SCIP_TREE* tree, /**< branch and bound tree */
5386  SCIP_Bool diving, /**< are we in strong branching or diving mode? */
5387  int validdepth, /**< minimal depth level at which the initial conflict set is valid */
5388  SCIP_Bool mustresolve, /**< should the conflict set only be used, if a resolution was applied? */
5389  int* nconss, /**< pointer to store the number of generated conflict constraints */
5390  int* nliterals, /**< pointer to store the number of literals in generated conflict constraints */
5391  int* nreconvconss, /**< pointer to store the number of generated reconvergence constraints */
5392  int* nreconvliterals /**< pointer to store the number of literals generated reconvergence constraints */
5393  )
5394 {
5395  SCIP_BDCHGINFO* bdchginfo;
5396  SCIP_BDCHGINFO** firstuips;
5397  SCIP_CONFTYPE conftype;
5398  int nfirstuips;
5399  int focusdepth;
5400  int currentdepth;
5401  int maxvaliddepth;
5402  int resolvedepth;
5403  int nresolutions;
5404  int lastconsnresolutions;
5405  int lastconsresoldepth;
5406 
5407  assert(conflict != NULL);
5408  assert(conflict->conflictset != NULL);
5409  assert(conflict->conflictset->nbdchginfos >= 0);
5410  assert(set != NULL);
5411  assert(stat != NULL);
5412  assert(0 <= validdepth && validdepth <= SCIPtreeGetCurrentDepth(tree));
5413  assert(nconss != NULL);
5414  assert(nliterals != NULL);
5415  assert(nreconvconss != NULL);
5416  assert(nreconvliterals != NULL);
5417 
5418  focusdepth = SCIPtreeGetFocusDepth(tree);
5419  currentdepth = SCIPtreeGetCurrentDepth(tree);
5420  assert(currentdepth == tree->pathlen-1);
5421  assert(focusdepth <= currentdepth);
5422 
5423  resolvedepth = ((set->conf_fuiplevels >= 0 && set->conf_fuiplevels <= currentdepth)
5424  ? currentdepth - set->conf_fuiplevels + 1 : 0);
5425  assert(0 <= resolvedepth && resolvedepth <= currentdepth + 1);
5426 
5427  /* if we must resolve at least one bound change, find the first UIP at least in the last depth level */
5428  if( mustresolve )
5429  resolvedepth = MIN(resolvedepth, currentdepth);
5430 
5431  SCIPsetDebugMsg(set, "analyzing conflict with %d+%d conflict candidates and starting conflict set of size %d in depth %d (resolvedepth=%d)\n",
5433  conflict->conflictset->nbdchginfos, currentdepth, resolvedepth);
5434 
5435  *nconss = 0;
5436  *nliterals = 0;
5437  *nreconvconss = 0;
5438  *nreconvliterals = 0;
5439 
5440  /* check, whether local conflicts are allowed; however, don't generate conflict constraints that are only valid in the
5441  * probing path and not in the problem tree (i.e. that exceed the focusdepth)
5442  */
5443  maxvaliddepth = (set->conf_allowlocal ? MIN(currentdepth-1, focusdepth) : 0);
5444  if( validdepth > maxvaliddepth )
5445  return SCIP_OKAY;
5446 
5447  /* allocate temporary memory for storing first UIPs (in each depth level, at most two bound changes can be flagged
5448  * as UIP, namely a binary and a non-binary bound change)
5449  */
5450  SCIP_CALL( SCIPsetAllocBufferArray(set, &firstuips, 2*(currentdepth+1)) ); /*lint !e647*/
5451 
5452  /* process all bound changes in the conflict candidate queue */
5453  nresolutions = 0;
5454  lastconsnresolutions = (mustresolve ? 0 : -1);
5455  lastconsresoldepth = (mustresolve ? currentdepth : INT_MAX);
5456  bdchginfo = conflictFirstCand(conflict);
5457  nfirstuips = 0;
5458 
5459  /* check if the initial reason on debugging solution */
5460  SCIP_CALL( SCIPdebugCheckConflictFrontier(blkmem, set, tree->path[validdepth], \
5461  NULL, conflict->conflictset->bdchginfos, conflict->conflictset->relaxedbds, conflict->conflictset->nbdchginfos, \
5462  conflict->bdchgqueue, conflict->forcedbdchgqueue) ); /*lint !e506 !e774*/
5463 
5464  while( bdchginfo != NULL && validdepth <= maxvaliddepth )
5465  {
5466  SCIP_BDCHGINFO* nextbdchginfo;
5467  SCIP_Real relaxedbd;
5468  SCIP_Bool forceresolve;
5469  int bdchgdepth;
5470 
5471  assert(!SCIPbdchginfoIsRedundant(bdchginfo));
5472 
5473  /* check if the next bound change must be resolved in every case */
5474  forceresolve = (SCIPpqueueNElems(conflict->forcedbdchgqueue) > 0);
5475 
5476  /* resolve next bound change in queue */
5477  bdchgdepth = SCIPbdchginfoGetDepth(bdchginfo);
5478  assert(0 <= bdchgdepth && bdchgdepth <= currentdepth);
5479  assert(SCIPvarIsActive(SCIPbdchginfoGetVar(bdchginfo)));
5480  assert(bdchgdepth < tree->pathlen);
5481  assert(tree->path[bdchgdepth] != NULL);
5482  assert(tree->path[bdchgdepth]->domchg != NULL);
5483  assert(SCIPbdchginfoGetPos(bdchginfo) < (int)tree->path[bdchgdepth]->domchg->domchgbound.nboundchgs);
5484  assert(tree->path[bdchgdepth]->domchg->domchgbound.boundchgs[SCIPbdchginfoGetPos(bdchginfo)].var
5485  == SCIPbdchginfoGetVar(bdchginfo));
5486  assert(tree->path[bdchgdepth]->domchg->domchgbound.boundchgs[SCIPbdchginfoGetPos(bdchginfo)].newbound
5487  == SCIPbdchginfoGetNewbound(bdchginfo)
5490  == SCIPbdchginfoGetNewbound(bdchginfo)); /*lint !e777*/
5491  assert((SCIP_BOUNDTYPE)tree->path[bdchgdepth]->domchg->domchgbound.boundchgs[SCIPbdchginfoGetPos(bdchginfo)].boundtype
5492  == SCIPbdchginfoGetBoundtype(bdchginfo));
5493 
5494  /* create intermediate conflict constraint */
5495  assert(nresolutions >= lastconsnresolutions);
5496  if( !forceresolve )
5497  {
5498  if( nresolutions == lastconsnresolutions )
5499  lastconsresoldepth = bdchgdepth; /* all intermediate depth levels consisted of only unresolved bound changes */
5500  else if( bdchgdepth < lastconsresoldepth && (set->conf_interconss == -1 || *nconss < set->conf_interconss) )
5501  {
5502  int nlits;
5503  SCIP_Bool success;
5504 
5505  /* call the conflict handlers to create a conflict set */
5506  SCIPsetDebugMsg(set, "creating intermediate conflictset after %d resolutions up to depth %d (valid at depth %d): %d conflict bounds, %d bounds in queue\n",
5507  nresolutions, bdchgdepth, validdepth, conflict->conflictset->nbdchginfos,
5508  SCIPpqueueNElems(conflict->bdchgqueue));
5509 
5510  SCIP_CALL( conflictAddConflictset(conflict, blkmem, set, stat, tree, validdepth, diving, TRUE, &success, &nlits) );
5511  lastconsnresolutions = nresolutions;
5512  lastconsresoldepth = bdchgdepth;
5513  if( success )
5514  {
5515  (*nconss)++;
5516  (*nliterals) += nlits;
5517  }
5518  }
5519  }
5520 
5521  /* remove currently processed candidate and get next conflicting bound from the conflict candidate queue before
5522  * we remove the candidate we have to collect the relaxed bound since removing the candidate from the queue
5523  * invalidates the relaxed bound
5524  */
5525  assert(bdchginfo == conflictFirstCand(conflict));
5526  relaxedbd = SCIPbdchginfoGetRelaxedBound(bdchginfo);
5527  bdchginfo = conflictRemoveCand(conflict);
5528  nextbdchginfo = conflictFirstCand(conflict);
5529  assert(bdchginfo != NULL);
5530  assert(!SCIPbdchginfoIsRedundant(bdchginfo));
5531  assert(nextbdchginfo == NULL || SCIPbdchginfoGetDepth(bdchginfo) >= SCIPbdchginfoGetDepth(nextbdchginfo)
5532  || forceresolve);
5533 
5534  /* we don't need to resolve bound changes that are already active in the valid depth of the current conflict set,
5535  * because the conflict set can only be added locally at the valid depth, and all bound changes applied in this
5536  * depth or earlier can be removed from the conflict constraint, since they are already applied in the constraint's
5537  * subtree;
5538  * if the next bound change on the remaining queue is equal to the current bound change,
5539  * this is a multiple insertion in the conflict candidate queue and we can ignore the current
5540  * bound change
5541  */
5542  if( bdchgdepth > validdepth && bdchginfo != nextbdchginfo )
5543  {
5544  SCIP_VAR* actvar;
5545  SCIP_Bool resolved;
5546 
5547  actvar = SCIPbdchginfoGetVar(bdchginfo);
5548  assert(actvar != NULL);
5549  assert(SCIPvarIsActive(actvar));
5550 
5551  /* check if we want to resolve the bound change in this depth level
5552  * - bound changes should be resolved, if
5553  * (i) we must apply at least one resolution and didn't resolve a bound change yet, or
5554  * (ii) their depth level is at least equal to the minimal resolving depth, and
5555  * they are not the last remaining conflicting bound change in their depth level
5556  * (iii) the bound change resolving is forced (i.e., the forced queue was non-empty)
5557  */
5558  resolved = FALSE;
5559  if( (mustresolve && nresolutions == 0)
5560  || (bdchgdepth >= resolvedepth
5561  && nextbdchginfo != NULL
5562  && SCIPbdchginfoGetDepth(nextbdchginfo) == bdchgdepth)
5563  || forceresolve )
5564  {
5565  SCIP_CALL( conflictResolveBound(conflict, set, bdchginfo, relaxedbd, validdepth, &resolved) );
5566  }
5567 
5568  if( resolved )
5569  nresolutions++;
5570  else if( forceresolve )
5571  {
5572  /* variable cannot enter the conflict clause: we have to make the conflict clause local, s.t.
5573  * the unresolved bound change is active in the whole sub tree of the conflict clause
5574  */
5575  assert(bdchgdepth >= validdepth);
5576  validdepth = bdchgdepth;
5577 
5578  SCIPsetDebugMsg(set, "couldn't resolve forced bound change on <%s> -> new valid depth: %d\n",
5579  SCIPvarGetName(actvar), validdepth);
5580  }
5581  else
5582  {
5583  /* if this is a UIP (the last bound change in its depth level), it can be used to generate a
5584  * UIP reconvergence constraint
5585  */
5586  if( nextbdchginfo == NULL || SCIPbdchginfoGetDepth(nextbdchginfo) != bdchgdepth )
5587  {
5588  assert(nfirstuips < 2*(currentdepth+1));
5589  firstuips[nfirstuips] = bdchginfo;
5590  nfirstuips++;
5591  }
5592 
5593  /* put variable into the conflict set, using the literal that is currently fixed to FALSE */
5594  SCIP_CALL( conflictAddConflictBound(conflict, blkmem, set, bdchginfo, relaxedbd) );
5595  }
5596  }
5597 
5598  /* check conflict graph frontier on debugging solution */
5599  SCIP_CALL( SCIPdebugCheckConflictFrontier(blkmem, set, tree->path[validdepth], \
5600  bdchginfo, conflict->conflictset->bdchginfos, conflict->conflictset->relaxedbds, conflict->conflictset->nbdchginfos, \
5601  conflict->bdchgqueue, conflict->forcedbdchgqueue) ); /*lint !e506 !e774*/
5602 
5603  /* get next conflicting bound from the conflict candidate queue (this needs not to be nextbdchginfo, because
5604  * due to resolving the bound changes, a bound change could be added to the queue which must be
5605  * resolved before nextbdchginfo)
5606  */
5607  bdchginfo = conflictFirstCand(conflict);
5608  }
5609 
5610  /* check, if a valid conflict set was found */
5611  if( bdchginfo == NULL
5612  && nresolutions > lastconsnresolutions
5613  && validdepth <= maxvaliddepth
5614  && (!mustresolve || nresolutions > 0 || conflict->conflictset->nbdchginfos == 0)
5615  && SCIPpqueueNElems(conflict->forcedbdchgqueue) == 0 )
5616  {
5617  int nlits;
5618  SCIP_Bool success;
5619 
5620  /* call the conflict handlers to create a conflict set */
5621  SCIP_CALL( conflictAddConflictset(conflict, blkmem, set, stat, tree, validdepth, diving, TRUE, &success, &nlits) );
5622  if( success )
5623  {
5624  (*nconss)++;
5625  (*nliterals) += nlits;
5626  }
5627  }
5628 
5629  /* produce reconvergence constraints defined by succeeding UIP's of the last depth level */
5630  if( set->conf_reconvlevels != 0 && validdepth <= maxvaliddepth )
5631  {
5632  int reconvlevels;
5633  int i;
5634 
5635  reconvlevels = (set->conf_reconvlevels == -1 ? INT_MAX : set->conf_reconvlevels);
5636  for( i = 0; i < nfirstuips; ++i )
5637  {
5638  if( SCIPbdchginfoHasInferenceReason(firstuips[i])
5639  && currentdepth - SCIPbdchginfoGetDepth(firstuips[i]) < reconvlevels )
5640  {
5641  SCIP_CALL( conflictCreateReconvergenceConss(conflict, blkmem, set, stat, prob, tree, diving, \
5642  validdepth, firstuips[i], nreconvconss, nreconvliterals) );
5643  }
5644  }
5645  }
5646 
5647  /* free the temporary memory */
5648  SCIPsetFreeBufferArray(set, &firstuips);
5649 
5650  /* store last conflict type */
5651  conftype = conflict->conflictset->conflicttype;
5652 
5653  /* clear the conflict candidate queue and the conflict set */
5654  conflictClear(conflict);
5655 
5656  /* restore last conflict type */
5657  conflict->conflictset->conflicttype = conftype;
5658 
5659  return SCIP_OKAY;
5660 }
5661 
5662 /** analyzes conflicting bound changes that were added with calls to SCIPconflictAddBound(), and on success, calls the
5663  * conflict handlers to create a conflict constraint out of the resulting conflict set;
5664  * updates statistics for propagation conflict analysis
5665  */
5667  SCIP_CONFLICT* conflict, /**< conflict analysis data */
5668  BMS_BLKMEM* blkmem, /**< block memory of transformed problem */
5669  SCIP_SET* set, /**< global SCIP settings */
5670  SCIP_STAT* stat, /**< problem statistics */
5671  SCIP_PROB* prob, /**< problem data */
5672  SCIP_TREE* tree, /**< branch and bound tree */
5673  int validdepth, /**< minimal depth level at which the initial conflict set is valid */
5674  SCIP_Bool* success /**< pointer to store whether a conflict constraint was created, or NULL */
5675  )
5676 {
5677  int nconss;
5678  int nliterals;
5679  int nreconvconss;
5680  int nreconvliterals;
5681 
5682  assert(conflict != NULL);
5683  assert(conflict->conflictset != NULL);
5684  assert(set != NULL);
5685  assert(prob != NULL);
5686 
5687  if( success != NULL )
5688  *success = FALSE;
5689 
5690  /* check if the conflict analysis is applicable */
5691  if( !SCIPconflictApplicable(set) )
5692  return SCIP_OKAY;
5693 
5694  /* check, if the conflict set will get too large with high probability */
5695  if( conflict->conflictset->nbdchginfos + SCIPpqueueNElems(conflict->bdchgqueue)
5696  + SCIPpqueueNElems(conflict->forcedbdchgqueue) >= 2*conflictCalcMaxsize(set, prob) )
5697  return SCIP_OKAY;
5698 
5699  SCIPsetDebugMsg(set, "analyzing conflict after infeasible propagation in depth %d\n", SCIPtreeGetCurrentDepth(tree));
5700 
5701  /* start timing */
5702  SCIPclockStart(conflict->propanalyzetime, set);
5703 
5704  conflict->npropcalls++;
5705 
5706  /* analyze the conflict set, and create a conflict constraint on success */
5707  SCIP_CALL( conflictAnalyze(conflict, blkmem, set, stat, prob, tree, FALSE, validdepth, TRUE, &nconss, &nliterals, \
5708  &nreconvconss, &nreconvliterals) );
5709  conflict->npropsuccess += (nconss > 0 ? 1 : 0);
5710  conflict->npropconfconss += nconss;
5711  conflict->npropconfliterals += nliterals;
5712  conflict->npropreconvconss += nreconvconss;
5713  conflict->npropreconvliterals += nreconvliterals;
5714  if( success != NULL )
5715  *success = (nconss > 0);
5716 
5717  /* stop timing */
5718  SCIPclockStop(conflict->propanalyzetime, set);
5719 
5720  return SCIP_OKAY;
5721 }
5722 
5723 /** gets time in seconds used for preprocessing global conflict constraint before appliance */
5725  SCIP_CONFLICT* conflict /**< conflict analysis data */
5726  )
5727 {
5728  assert(conflict != NULL);
5729 
5730  return SCIPclockGetTime(conflict->dIBclock);
5731 }
5732 
5733 /** gets time in seconds used for analyzing propagation conflicts */
5735  SCIP_CONFLICT* conflict /**< conflict analysis data */
5736  )
5737 {
5738  assert(conflict != NULL);
5739 
5740  return SCIPclockGetTime(conflict->propanalyzetime);
5741 }
5742 
5743 /** gets number of calls to propagation conflict analysis */
5745  SCIP_CONFLICT* conflict /**< conflict analysis data */
5746  )
5747 {
5748  assert(conflict != NULL);
5749 
5750  return conflict->npropcalls;
5751 }
5752 
5753 /** gets number of calls to propagation conflict analysis that yield at least one conflict constraint */
5755  SCIP_CONFLICT* conflict /**< conflict analysis data */
5756  )
5757 {
5758  assert(conflict != NULL);
5759 
5760  return conflict->npropsuccess;
5761 }
5762 
5763 /** gets number of conflict constraints detected in propagation conflict analysis */
5765  SCIP_CONFLICT* conflict /**< conflict analysis data */
5766  )
5767 {
5768  assert(conflict != NULL);
5769 
5770  return conflict->npropconfconss;
5771 }
5772 
5773 /** gets total number of literals in conflict constraints created in propagation conflict analysis */
5775  SCIP_CONFLICT* conflict /**< conflict analysis data */
5776  )
5777 {
5778  assert(conflict != NULL);
5779 
5780  return conflict->npropconfliterals;
5781 }
5782 
5783 /** gets number of reconvergence constraints detected in propagation conflict analysis */
5785  SCIP_CONFLICT* conflict /**< conflict analysis data */
5786  )
5787 {
5788  assert(conflict != NULL);
5789 
5790  return conflict->npropreconvconss;
5791 }
5792 
5793 /** gets total number of literals in reconvergence constraints created in propagation conflict analysis */
5795  SCIP_CONFLICT* conflict /**< conflict analysis data */
5796  )
5797 {
5798  assert(conflict != NULL);
5799 
5800  return conflict->npropreconvliterals;
5801 }
5802 
5803 
5804 
5805 
5806 /*
5807  * Infeasible LP Conflict Analysis
5808  */
5809 
5810 /** ensures, that side change arrays can store at least num entries */
5811 static
5813  SCIP_SET* set, /**< global SCIP settings */
5814  int** sidechginds, /**< pointer to side change index array */
5815  SCIP_Real** sidechgoldlhss, /**< pointer to side change old left hand sides array */
5816  SCIP_Real** sidechgoldrhss, /**< pointer to side change old right hand sides array */
5817  SCIP_Real** sidechgnewlhss, /**< pointer to side change new left hand sides array */
5818  SCIP_Real** sidechgnewrhss, /**< pointer to side change new right hand sides array */
5819  int* sidechgssize, /**< pointer to size of side change arrays */
5820  int num /**< minimal number of entries to be able to store in side change arrays */
5821  )
5822 {
5823  assert(sidechginds != NULL);
5824  assert(sidechgoldlhss != NULL);
5825  assert(sidechgoldrhss != NULL);
5826  assert(sidechgnewlhss != NULL);
5827  assert(sidechgnewrhss != NULL);
5828  assert(sidechgssize != NULL);
5829 
5830  if( num > *sidechgssize )
5831  {
5832  int newsize;
5833 
5834  newsize = SCIPsetCalcMemGrowSize(set, num);
5835  SCIP_CALL( SCIPsetReallocBufferArray(set, sidechginds, newsize) );
5836  SCIP_CALL( SCIPsetReallocBufferArray(set, sidechgoldlhss, newsize) );
5837  SCIP_CALL( SCIPsetReallocBufferArray(set, sidechgoldrhss, newsize) );
5838  SCIP_CALL( SCIPsetReallocBufferArray(set, sidechgnewlhss, newsize) );
5839  SCIP_CALL( SCIPsetReallocBufferArray(set, sidechgnewrhss, newsize) );
5840  *sidechgssize = newsize;
5841  }
5842  assert(num <= *sidechgssize);
5843 
5844  return SCIP_OKAY;
5845 }
5846 
5847 /** adds removal of row's side to side change arrays; finite sides are only replaced by near infinite sides, such
5848  * that the row's sense in the LP solver is not changed
5849  */
5850 static
5852  SCIP_SET* set, /**< global SCIP settings */
5853  SCIP_ROW* row, /**< LP row to change the sides for */
5854  SCIP_Real lpiinfinity, /**< value treated as infinity in LP solver */
5855  int** sidechginds, /**< pointer to side change index array */
5856  SCIP_Real** sidechgoldlhss, /**< pointer to side change old left hand sides array */
5857  SCIP_Real** sidechgoldrhss, /**< pointer to side change old right hand sides array */
5858  SCIP_Real** sidechgnewlhss, /**< pointer to side change new left hand sides array */
5859  SCIP_Real** sidechgnewrhss, /**< pointer to side change new right hand sides array */
5860  int* sidechgssize, /**< pointer to size of side change arrays */
5861  int* nsidechgs /**< pointer to number of used slots in side change arrays */
5862  )
5863 {
5864  SCIP_Real lhs;
5865  SCIP_Real rhs;
5866  SCIP_Real constant;
5867 
5868  assert(sidechginds != NULL);
5869  assert(sidechgoldlhss != NULL);
5870  assert(sidechgoldrhss != NULL);
5871  assert(sidechgnewlhss != NULL);
5872  assert(sidechgnewrhss != NULL);
5873  assert(sidechgssize != NULL);
5874  assert(nsidechgs != NULL);
5875 
5876  lhs = SCIProwGetLhs(row);
5877  rhs = SCIProwGetRhs(row);
5878  constant = SCIProwGetConstant(row);
5879  assert(!SCIPsetIsInfinity(set, -lhs) || !SCIPsetIsInfinity(set, rhs));
5880 
5881  /* get memory to store additional side change */
5882  SCIP_CALL( ensureSidechgsSize(set, sidechginds, sidechgoldlhss, sidechgoldrhss, sidechgnewlhss, sidechgnewrhss, \
5883  sidechgssize, (*nsidechgs)+1) );
5884  assert(*nsidechgs < *sidechgssize);
5885  assert(*sidechginds != NULL);
5886  assert(*sidechgoldlhss != NULL);
5887  assert(*sidechgoldrhss != NULL);
5888  assert(*sidechgnewlhss != NULL);
5889  assert(*sidechgnewrhss != NULL);
5890 
5891  /* store side change */
5892  (*sidechginds)[*nsidechgs] = SCIProwGetLPPos(row);
5893  if( SCIPsetIsInfinity(set, -lhs) )
5894  {
5895  (*sidechgoldlhss)[*nsidechgs] = -lpiinfinity;
5896  (*sidechgnewlhss)[*nsidechgs] = -lpiinfinity;
5897  }
5898  else
5899  {
5900  (*sidechgoldlhss)[*nsidechgs] = lhs - constant;
5901  (*sidechgnewlhss)[*nsidechgs] = -lpiinfinity;
5902  }
5903  if( SCIPsetIsInfinity(set, rhs) )
5904  {
5905  (*sidechgoldrhss)[*nsidechgs] = lpiinfinity;
5906  (*sidechgnewrhss)[*nsidechgs] = lpiinfinity;
5907  }
5908  else
5909  {
5910  (*sidechgoldrhss)[*nsidechgs] = rhs - constant;
5911  (*sidechgnewrhss)[*nsidechgs] = lpiinfinity;
5912  }
5913  (*nsidechgs)++;
5914 
5915  return SCIP_OKAY;
5916 }
5917 
5918 /** inserts variable's new bounds into bound change arrays */
5919 static
5921  SCIP_SET* set, /**< global SCIP settings */
5922  SCIP_VAR* var, /**< variable to change the LP bounds for */
5923  SCIP_Real newlb, /**< new lower bound */
5924  SCIP_Real newub, /**< new upper bound */
5925  SCIP_LPBDCHGS* oldlpbdchgs, /**< old LP bound changes used for reset the LP bound change */
5926  SCIP_LPBDCHGS* relaxedlpbdchgs, /**< relaxed LP bound changes used for reset the LP bound change */
5927  SCIP_LPI* lpi /**< pointer to LPi to access infinity of LP solver; necessary to set correct value */
5928  )
5929 {
5930  assert(newlb <= newub);
5931  assert(oldlpbdchgs != NULL);
5932  assert(relaxedlpbdchgs != NULL);
5933 
5935  {
5936  SCIP_COL* col;
5937  int idx;
5938  int c;
5939 
5940  col = SCIPvarGetCol(var);
5941  c = SCIPcolGetLPPos(col);
5942 
5943  if( c >= 0 )
5944  {
5945  /* store old bound change for resetting the LP later */
5946  if( !oldlpbdchgs->usedcols[c] )
5947  {
5948  idx = oldlpbdchgs->nbdchgs;
5949  oldlpbdchgs->usedcols[c] = TRUE;
5950  oldlpbdchgs->bdchgcolinds[c] = idx;
5951  oldlpbdchgs->nbdchgs++;
5952 
5953  oldlpbdchgs->bdchginds[idx] = c;
5954  oldlpbdchgs->bdchglbs[idx] = SCIPvarGetLbLP(var, set);
5955  oldlpbdchgs->bdchgubs[idx] = SCIPvarGetUbLP(var, set);
5956  }
5957  assert(oldlpbdchgs->bdchginds[oldlpbdchgs->bdchgcolinds[c]] == c);
5958  assert((SCIPlpiIsInfinity(lpi, -oldlpbdchgs->bdchglbs[oldlpbdchgs->bdchgcolinds[c]]) && SCIPsetIsInfinity(set, -SCIPvarGetLbLP(var, set))) ||
5959  SCIPsetIsEQ(set, oldlpbdchgs->bdchglbs[oldlpbdchgs->bdchgcolinds[c]], SCIPvarGetLbLP(var, set)));
5960  assert((SCIPlpiIsInfinity(lpi, oldlpbdchgs->bdchgubs[oldlpbdchgs->bdchgcolinds[c]]) && SCIPsetIsInfinity(set, SCIPvarGetUbLP(var, set))) ||
5961  SCIPsetIsEQ(set, oldlpbdchgs->bdchgubs[oldlpbdchgs->bdchgcolinds[c]], SCIPvarGetUbLP(var, set)));
5962 
5963  /* store bound change for conflict analysis */
5964  if( !relaxedlpbdchgs->usedcols[c] )
5965  {
5966  idx = relaxedlpbdchgs->nbdchgs;
5967  relaxedlpbdchgs->usedcols[c] = TRUE;
5968  relaxedlpbdchgs->bdchgcolinds[c] = idx;
5969  relaxedlpbdchgs->nbdchgs++;
5970 
5971  /* remember the positive for later further bound widenings */
5972  relaxedlpbdchgs->bdchginds[idx] = c;
5973  }
5974  else
5975  {
5976  idx = relaxedlpbdchgs->bdchgcolinds[c];
5977  assert(relaxedlpbdchgs->bdchginds[idx] == c);
5978 
5979  /* the new bound should be the same or more relaxed */
5980  assert(relaxedlpbdchgs->bdchglbs[idx] >= newlb ||
5981  (SCIPlpiIsInfinity(lpi, -relaxedlpbdchgs->bdchglbs[idx]) && SCIPsetIsInfinity(set, -newlb)));
5982  assert(relaxedlpbdchgs->bdchgubs[idx] <= newub ||
5983  (SCIPlpiIsInfinity(lpi, relaxedlpbdchgs->bdchgubs[idx]) && SCIPsetIsInfinity(set, newub)));
5984  }
5985 
5986  /* set the new bounds for the LP with the correct infinity value */
5987  relaxedlpbdchgs->bdchglbs[idx] = SCIPsetIsInfinity(set, -newlb) ? -SCIPlpiInfinity(lpi) : newlb;
5988  relaxedlpbdchgs->bdchgubs[idx] = SCIPsetIsInfinity(set, newub) ? SCIPlpiInfinity(lpi) : newub;
5989  if( SCIPsetIsInfinity(set, -oldlpbdchgs->bdchglbs[idx]) )
5990  oldlpbdchgs->bdchglbs[idx] = -SCIPlpiInfinity(lpi);
5991  if( SCIPsetIsInfinity(set, oldlpbdchgs->bdchgubs[idx]) )
5992  oldlpbdchgs->bdchgubs[idx] = SCIPlpiInfinity(lpi);
5993  }
5994  }
5995 
5996  return SCIP_OKAY;
5997 }
5998 
5999 /** ensures, that candidate array can store at least num entries */
6000 static
6002  SCIP_SET* set, /**< global SCIP settings */
6003  SCIP_VAR*** cands, /**< pointer to candidate array */
6004  SCIP_Real** candscores, /**< pointer to candidate score array */
6005  SCIP_Real** newbounds, /**< pointer to candidate new bounds array */
6006  SCIP_Real** proofactdeltas, /**< pointer to candidate proof delta array */
6007  int* candssize, /**< pointer to size of array */
6008  int num /**< minimal number of candidates to store in array */
6009  )
6010 {
6011  assert(cands != NULL);
6012  assert(candssize != NULL);
6013 
6014  if( num > *candssize )
6015  {
6016  int newsize;
6017 
6018  newsize = SCIPsetCalcMemGrowSize(set, num);
6019  SCIP_CALL( SCIPsetReallocBufferArray(set, cands, newsize) );
6020  SCIP_CALL( SCIPsetReallocBufferArray(set, candscores, newsize) );
6021  SCIP_CALL( SCIPsetReallocBufferArray(set, newbounds, newsize) );
6022  SCIP_CALL( SCIPsetReallocBufferArray(set, proofactdeltas, newsize) );
6023  *candssize = newsize;
6024  }
6025  assert(num <= *candssize);
6026 
6027  return SCIP_OKAY;
6028 }
6029 
6030 /** adds variable to candidate list, if the current best bound corresponding to the proof coefficient is local;
6031  * returns the array position in the candidate list, where the new candidate was inserted, or -1 if the
6032  * variable can relaxed to global bounds immediately without increasing the proof's activity;
6033  * the candidates are sorted with respect to the following two criteria:
6034  * - prefer bound changes that have been applied deeper in the tree, to get a more global conflict
6035  * - prefer variables with small Farkas coefficient to get rid of as many bound changes as possible
6036  */
6037 static
6039  SCIP_SET* set, /**< global SCIP settings */
6040  int currentdepth, /**< current depth in the tree */
6041  SCIP_VAR* var, /**< variable to add to candidate array */
6042  int lbchginfopos, /**< positions of currently active lower bound change information in variable's array */
6043  int ubchginfopos, /**< positions of currently active upper bound change information in variable's array */
6044  SCIP_Real proofcoef, /**< coefficient of variable in infeasibility/bound proof */
6045  SCIP_Real prooflhs, /**< left hand side of infeasibility/bound proof */
6046  SCIP_Real proofact, /**< activity of infeasibility/bound proof row */
6047  SCIP_VAR*** cands, /**< pointer to candidate array for undoing bound changes */
6048  SCIP_Real** candscores, /**< pointer to candidate score array for undoing bound changes */
6049  SCIP_Real** newbounds, /**< pointer to candidate new bounds array for undoing bound changes */
6050  SCIP_Real** proofactdeltas, /**< pointer to proof activity increase array for undoing bound changes */
6051  int* candssize, /**< pointer to size of cands arrays */
6052  int* ncands, /**< pointer to count number of candidates in bound change list */
6053  int firstcand /**< position of first unprocessed bound change candidate */
6054  )
6055 {
6056  SCIP_Real oldbound;
6057  SCIP_Real newbound;
6058  SCIP_Real QUAD(proofactdelta);
6059  SCIP_Real score;
6060  int depth;
6061  int i;
6062  SCIP_Bool resolvable;
6063 
6064  assert(set != NULL);
6065  assert(var != NULL);
6066  assert(-1 <= lbchginfopos && lbchginfopos <= var->nlbchginfos);
6067  assert(-1 <= ubchginfopos && ubchginfopos <= var->nubchginfos);
6068  assert(!SCIPsetIsZero(set, proofcoef));
6069  assert(SCIPsetIsGT(set, prooflhs, proofact));
6070  assert(cands != NULL);
6071  assert(candscores != NULL);
6072  assert(newbounds != NULL);
6073  assert(proofactdeltas != NULL);
6074  assert(candssize != NULL);
6075  assert(ncands != NULL);
6076  assert(*ncands <= *candssize);
6077  assert(0 <= firstcand && firstcand <= *ncands);
6078 
6079  /* in the infeasibility or dual bound proof, the variable's bound is chosen to maximize the proof's activity */
6080  if( proofcoef > 0.0 )
6081  {
6082  assert(ubchginfopos >= 0); /* otherwise, undoBdchgsProof() should already have relaxed the local bound */
6083 
6084  /* calculate the difference of current bound to the previous bound the variable was set to */
6085  if( ubchginfopos == var->nubchginfos )
6086  {
6087  /* current bound is the strong branching or diving bound */
6088  oldbound = SCIPvarGetUbLP(var, set);
6089  newbound = SCIPvarGetUbLocal(var);
6090  depth = currentdepth+1;
6091  resolvable = FALSE;
6092  }
6093  else
6094  {
6095  /* current bound is the result of a local bound change */
6096  resolvable = bdchginfoIsResolvable(&var->ubchginfos[ubchginfopos]);
6097  depth = var->ubchginfos[ubchginfopos].bdchgidx.depth;
6098  oldbound = var->ubchginfos[ubchginfopos].newbound;
6099  newbound = var->ubchginfos[ubchginfopos].oldbound;
6100  }
6101  }
6102  else
6103  {
6104  assert(lbchginfopos >= 0); /* otherwise, undoBdchgsProof() should already have relaxed the local bound */
6105 
6106  /* calculate the difference of current bound to the previous bound the variable was set to */
6107  if( lbchginfopos == var->nlbchginfos )
6108  {
6109  /* current bound is the strong branching or diving bound */
6110  oldbound = SCIPvarGetLbLP(var, set);
6111  newbound = SCIPvarGetLbLocal(var);
6112  depth = currentdepth+1;
6113  resolvable = FALSE;
6114  }
6115  else
6116  {
6117  /* current bound is the result of a local bound change */
6118  resolvable = bdchginfoIsResolvable(&var->lbchginfos[lbchginfopos]);
6119  depth = var->lbchginfos[lbchginfopos].bdchgidx.depth;
6120  oldbound = var->lbchginfos[lbchginfopos].newbound;
6121  newbound = var->lbchginfos[lbchginfopos].oldbound;
6122  }
6123  }
6124 
6125  /* calculate the increase in the proof's activity */
6126  SCIPquadprecSumDD(proofactdelta, newbound, -oldbound);
6127  SCIPquadprecProdQD(proofactdelta, proofactdelta, proofcoef);
6128  assert(QUAD_TO_DBL(proofactdelta) > 0.0);
6129 
6130  /* calculate score for undoing the bound change */
6131  score = calcBdchgScore(prooflhs, proofact, QUAD_TO_DBL(proofactdelta), proofcoef, depth, currentdepth, var, set);
6132 
6133  if( !resolvable )
6134  {
6135  score += 10.0;
6136  if( !SCIPvarIsBinary(var) )
6137  score += 10.0;
6138  }
6139 
6140  /* get enough memory to store new candidate */
6141  SCIP_CALL( ensureCandsSize(set, cands, candscores, newbounds, proofactdeltas, candssize, (*ncands)+1) );
6142  assert(*cands != NULL);
6143  assert(*candscores != NULL);
6144  assert(*newbounds != NULL);
6145  assert(*proofactdeltas != NULL);
6146 
6147  SCIPsetDebugMsg(set, " -> local <%s> %s %g, relax <%s> %s %g, proofcoef=%g, dpt=%d, resolve=%u, delta=%g, score=%g\n",
6148  SCIPvarGetName(var), proofcoef > 0.0 ? "<=" : ">=", oldbound,
6149  SCIPvarGetName(var), proofcoef > 0.0 ? "<=" : ">=", newbound,
6150  proofcoef, depth, resolvable, QUAD_TO_DBL(proofactdelta), score);
6151 
6152  /* insert variable in candidate list without touching the already processed candidates */
6153  for( i = *ncands; i > firstcand && score > (*candscores)[i-1]; --i )
6154  {
6155  (*cands)[i] = (*cands)[i-1];
6156  (*candscores)[i] = (*candscores)[i-1];
6157  (*newbounds)[i] = (*newbounds)[i-1];
6158  (*proofactdeltas)[i] = (*proofactdeltas)[i-1];
6159  }
6160  (*cands)[i] = var;
6161  (*candscores)[i] = score;
6162  (*newbounds)[i] = newbound;
6163  (*proofactdeltas)[i] = QUAD_TO_DBL(proofactdelta);
6164  (*ncands)++;
6165 
6166  return SCIP_OKAY;
6167 }
6168 
6169 /** after changing the global bound of a variable, the bdchginfos that are now redundant are replaced with
6170  * oldbound = newbound = global bound; if the current bdchginfo is of such kind, the bound is equal to the
6171  * global bound and we can ignore it by installing a -1 as the corresponding bound change info position
6172  */
6173 static
6175  SCIP_VAR* var, /**< problem variable */
6176  int* lbchginfopos, /**< pointer to lower bound change information position */
6177  int* ubchginfopos /**< pointer to upper bound change information position */
6178  )
6179 {
6180  assert(var != NULL);
6181  assert(lbchginfopos != NULL);
6182  assert(ubchginfopos != NULL);
6183  assert(-1 <= *lbchginfopos && *lbchginfopos <= var->nlbchginfos);
6184  assert(-1 <= *ubchginfopos && *ubchginfopos <= var->nubchginfos);
6185  assert(*lbchginfopos == -1 || *lbchginfopos == var->nlbchginfos
6186  || var->lbchginfos[*lbchginfopos].redundant
6187  == (var->lbchginfos[*lbchginfopos].oldbound == var->lbchginfos[*lbchginfopos].newbound)); /*lint !e777*/
6188  assert(*ubchginfopos == -1 || *ubchginfopos == var->nubchginfos
6189  || var->ubchginfos[*ubchginfopos].redundant
6190  == (var->ubchginfos[*ubchginfopos].oldbound == var->ubchginfos[*ubchginfopos].newbound)); /*lint !e777*/
6191 
6192  if( *lbchginfopos >= 0 && *lbchginfopos < var->nlbchginfos && var->lbchginfos[*lbchginfopos].redundant )
6193  {
6194  assert(SCIPvarGetLbGlobal(var) == var->lbchginfos[*lbchginfopos].oldbound); /*lint !e777*/
6195  *lbchginfopos = -1;
6196  }
6197  if( *ubchginfopos >= 0 && *ubchginfopos < var->nubchginfos && var->ubchginfos[*ubchginfopos].redundant )
6198  {
6199  assert(SCIPvarGetUbGlobal(var) == var->ubchginfos[*ubchginfopos].oldbound); /*lint !e777*/
6200  *ubchginfopos = -1;
6201  }
6202 }
6203 
6204 /** undoes bound changes on variables, still leaving the given infeasibility proof valid */
6205 static
6207  SCIP_SET* set, /**< global SCIP settings */
6208  SCIP_PROB* prob, /**< problem data */
6209  int currentdepth, /**< current depth in the tree */
6210  SCIP_Real* proofcoefs, /**< coefficients in infeasibility proof */
6211  SCIP_Real prooflhs, /**< left hand side of proof */
6212  SCIP_Real* proofact, /**< current activity of proof */
6213  SCIP_Real* curvarlbs, /**< current lower bounds of active problem variables */
6214  SCIP_Real* curvarubs, /**< current upper bounds of active problem variables */
6215  int* lbchginfoposs, /**< positions of currently active lower bound change information in variables' arrays */
6216  int* ubchginfoposs, /**< positions of currently active upper bound change information in variables' arrays */
6217  SCIP_LPBDCHGS* oldlpbdchgs, /**< old LP bound changes used for reset the LP bound change, or NULL */
6218  SCIP_LPBDCHGS* relaxedlpbdchgs, /**< relaxed LP bound changes used for reset the LP bound change, or NULL */
6219  SCIP_Bool* resolve, /**< pointer to store whether the changed LP should be resolved again, or NULL */
6220  SCIP_LPI* lpi /**< pointer to LPi to access infinity of LP solver; necessary to set correct values */
6221  )
6222 {
6223  SCIP_VAR** vars;
6224  SCIP_VAR** cands;
6225  SCIP_Real* candscores;
6226  SCIP_Real* newbounds;
6227  SCIP_Real* proofactdeltas;
6228  int nvars;
6229  int ncands;
6230  int candssize;
6231  int v;
6232  int i;
6233 
6234  assert(prob != NULL);
6235  assert(proofcoefs != NULL);
6236  assert(SCIPsetIsFeasGT(set, prooflhs, (*proofact)));
6237  assert(curvarlbs != NULL);
6238  assert(curvarubs != NULL);
6239  assert(lbchginfoposs != NULL);
6240  assert(ubchginfoposs != NULL);
6241 
6242  if( resolve != NULL )
6243  *resolve = FALSE;
6244 
6245  vars = prob->vars;
6246  nvars = prob->nvars;
6247  assert(nvars == 0 || vars != NULL);
6248 
6249  /* calculate the order in which the bound changes are tried to be undone, and relax all bounds if this doesn't
6250  * increase the proof's activity
6251  */
6252  SCIP_CALL( SCIPsetAllocBufferArray(set, &cands, nvars) );
6253  SCIP_CALL( SCIPsetAllocBufferArray(set, &candscores, nvars) );
6254  SCIP_CALL( SCIPsetAllocBufferArray(set, &newbounds, nvars) );
6255  SCIP_CALL( SCIPsetAllocBufferArray(set, &proofactdeltas, nvars) );
6256  ncands = 0;
6257  candssize = nvars;
6258  for( v = 0; v < nvars; ++v )
6259  {
6260  SCIP_VAR* var;
6261  SCIP_Bool relaxed;
6262 
6263  var = vars[v];
6264 
6265  /* after changing the global bound of a variable, the bdchginfos that are now redundant are replaced with
6266  * oldbound = newbound = global bound; if the current bdchginfo is of such kind, the bound is equal to the
6267  * global bound and we can ignore it
6268  */
6269  skipRedundantBdchginfos(var, &lbchginfoposs[v], &ubchginfoposs[v]);
6270 
6271  /* ignore variables already relaxed to global bounds */
6272  if( (lbchginfoposs[v] == -1 && ubchginfoposs[v] == -1) )
6273  {
6274  proofcoefs[v] = 0.0;
6275  continue;
6276  }
6277 
6278  /* relax bounds that are not used in the proof to the global bounds */
6279  relaxed = FALSE;
6280  if( !SCIPsetIsNegative(set, proofcoefs[v]) )
6281  {
6282  /* the lower bound is not used */
6283  if( lbchginfoposs[v] >= 0 )
6284  {
6285  SCIPsetDebugMsg(set, " -> relaxing variable <%s>[%g,%g] to [%g,%g]: proofcoef=%g, %g <= %g\n",
6286  SCIPvarGetName(var), curvarlbs[v], curvarubs[v], SCIPvarGetLbGlobal(var), curvarubs[v],
6287  proofcoefs[v], prooflhs, (*proofact));
6288  curvarlbs[v] = SCIPvarGetLbGlobal(var);
6289  lbchginfoposs[v] = -1;
6290  relaxed = TRUE;
6291  }
6292  }
6293  if( !SCIPsetIsPositive(set, proofcoefs[v]) )
6294  {
6295  /* the upper bound is not used */
6296  if( ubchginfoposs[v] >= 0 )
6297  {
6298  SCIPsetDebugMsg(set, " -> relaxing variable <%s>[%g,%g] to [%g,%g]: proofcoef=%g, %g <= %g\n",
6299  SCIPvarGetName(var), curvarlbs[v], curvarubs[v], curvarlbs[v], SCIPvarGetUbGlobal(var),
6300  proofcoefs[v], prooflhs, (*proofact));
6301  curvarubs[v] = SCIPvarGetUbGlobal(var);
6302  ubchginfoposs[v] = -1;
6303  relaxed = TRUE;
6304  }
6305  }
6306  if( relaxed && oldlpbdchgs != NULL )
6307  {
6308  SCIP_CALL( addBdchg(set, var, curvarlbs[v], curvarubs[v], oldlpbdchgs, relaxedlpbdchgs, lpi) );
6309  }
6310 
6311  /* add bound to candidate list */
6312  if( lbchginfoposs[v] >= 0 || ubchginfoposs[v] >= 0 )
6313  {
6314  SCIP_CALL( addCand(set, currentdepth, var, lbchginfoposs[v], ubchginfoposs[v], proofcoefs[v],
6315  prooflhs, (*proofact), &cands, &candscores, &newbounds, &proofactdeltas, &candssize, &ncands, 0) );
6316  }
6317  /* we can set the proof coefficient to zero, because the variable is not needed */
6318  else
6319  proofcoefs[v] = 0.0;
6320  }
6321 
6322  /* try to undo remaining local bound changes while still keeping the proof row violated:
6323  * bound changes can be undone, if prooflhs > proofact + proofactdelta;
6324  * afterwards, the current proof activity has to be updated
6325  */
6326  for( i = 0; i < ncands; ++i )
6327  {
6328  assert(proofactdeltas[i] > 0.0);
6329  assert((lbchginfoposs[SCIPvarGetProbindex(cands[i])] >= 0) != (ubchginfoposs[SCIPvarGetProbindex(cands[i])] >= 0));
6330 
6331  /* when relaxing a constraint we still need to stay infeasible; therefore we need to do the comparison in
6332  * feasibility tolerance because if 'prooflhs' is (feas-))equal to 'proofact + proofactdeltas[i]' it would mean
6333  * that there is no violation
6334  */
6335  if( SCIPsetIsFeasGT(set, prooflhs, (*proofact) + proofactdeltas[i]) )
6336  {
6337  v = SCIPvarGetProbindex(cands[i]);
6338  assert(0 <= v && v < nvars);
6339  assert((lbchginfoposs[v] >= 0) != (ubchginfoposs[v] >= 0));
6340 
6341  SCIPsetDebugMsg(set, " -> relaxing variable <%s>[%g,%g] to [%g,%g]: proofcoef=%g, %g <= %g + %g\n",
6342  SCIPvarGetName(cands[i]), curvarlbs[v], curvarubs[v],
6343  proofcoefs[v] > 0.0 ? curvarlbs[v] : newbounds[i],
6344  proofcoefs[v] > 0.0 ? newbounds[i] : curvarubs[v],
6345  proofcoefs[v], prooflhs, (*proofact), proofactdeltas[i]);
6346 
6347 #ifndef NDEBUG
6348  {
6349  SCIP_Real QUAD(verifylb);
6350  SCIP_Real QUAD(verifyub);
6351 
6352  SCIPquadprecSumDD(verifylb, newbounds[i], -curvarlbs[v]);
6353  SCIPquadprecProdQD(verifylb, verifylb, proofcoefs[v]);
6354 
6355  SCIPquadprecSumDD(verifyub, newbounds[i], -curvarubs[v]);
6356  SCIPquadprecProdQD(verifyub, verifyub, proofcoefs[v]);
6357 
6358  assert((SCIPsetIsPositive(set, proofcoefs[v]) && SCIPsetIsGT(set, newbounds[i], curvarubs[v]))
6359  || (SCIPsetIsNegative(set, proofcoefs[v]) && SCIPsetIsLT(set, newbounds[i], curvarlbs[v])));
6360  assert((SCIPsetIsPositive(set, proofcoefs[v])
6361  && SCIPsetIsEQ(set, proofactdeltas[i], QUAD_TO_DBL(verifyub)))
6362  || (SCIPsetIsNegative(set, proofcoefs[v])
6363  && SCIPsetIsEQ(set, proofactdeltas[i], QUAD_TO_DBL(verifylb))));
6364  assert(!SCIPsetIsZero(set, proofcoefs[v]));
6365  }
6366 #endif
6367 
6368  if( proofcoefs[v] > 0.0 )
6369  {
6370  assert(ubchginfoposs[v] >= 0);
6371  assert(lbchginfoposs[v] == -1);
6372  curvarubs[v] = newbounds[i];
6373  ubchginfoposs[v]--;
6374  }
6375  else
6376  {
6377  assert(lbchginfoposs[v] >= 0);
6378  assert(ubchginfoposs[v] == -1);
6379  curvarlbs[v] = newbounds[i];
6380  lbchginfoposs[v]--;
6381  }
6382  if( oldlpbdchgs != NULL )
6383  {
6384  SCIP_CALL( addBdchg(set, cands[i], curvarlbs[v], curvarubs[v], oldlpbdchgs, relaxedlpbdchgs, lpi) );
6385  }
6386  (*proofact) += proofactdeltas[i];
6387  if( resolve != NULL && SCIPvarIsInLP(cands[i]) )
6388  *resolve = TRUE;
6389 
6390  /* after changing the global bound of a variable, the bdchginfos that are now redundant are replaced with
6391  * oldbound = newbound = global bound; if the current bdchginfo is of such kind, the bound is equal to the
6392  * global bound and we can ignore it
6393  */
6394  skipRedundantBdchginfos(cands[i], &lbchginfoposs[v], &ubchginfoposs[v]);
6395 
6396  /* insert the new local bound of the variable into the candidate list */
6397  if( lbchginfoposs[v] >= 0 || ubchginfoposs[v] >= 0 )
6398  {
6399  SCIP_CALL( addCand(set, currentdepth, cands[i], lbchginfoposs[v], ubchginfoposs[v], proofcoefs[v],
6400  prooflhs, (*proofact), &cands, &candscores, &newbounds, &proofactdeltas, &candssize, &ncands, i+1) );
6401  }
6402  else
6403  proofcoefs[v] = 0.0;
6404  }
6405  }
6406 
6407  /* free the buffer for the sorted bound change candidates */
6408  SCIPsetFreeBufferArray(set, &proofactdeltas);
6409  SCIPsetFreeBufferArray(set, &newbounds);
6410  SCIPsetFreeBufferArray(set, &candscores);
6411  SCIPsetFreeBufferArray(set, &cands);
6412 
6413  return SCIP_OKAY;
6414 }
6415 
6416 /* because calculations might cancel out some values, we stop the infeasibility analysis if a value is bigger than
6417  * 2^53 = 9007199254740992
6418  */
6419 #define NUMSTOP 9007199254740992.0
6420 
6421 /** analyzes an infeasible LP and undoes additional bound changes while staying infeasible */
6422 static
6424  SCIP_SET* set, /**< global SCIP settings */
6425  SCIP_PROB* prob, /**< problem data */
6426  SCIP_LP* lp, /**< LP data */
6427  int currentdepth, /**< current depth in the tree */
6428  SCIP_Real* curvarlbs, /**< current lower bounds of active problem variables */
6429  SCIP_Real* curvarubs, /**< current upper bounds of active problem variables */
6430  int* lbchginfoposs, /**< positions of currently active lower bound change information in variables' arrays */
6431  int* ubchginfoposs, /**< positions of currently active upper bound change information in variables' arrays */
6432  SCIP_LPBDCHGS* oldlpbdchgs, /**< old LP bound changes used for reset the LP bound change, or NULL */
6433  SCIP_LPBDCHGS* relaxedlpbdchgs, /**< relaxed LP bound changes used for reset the LP bound change, or NULL */
6434  SCIP_Bool* valid, /**< pointer to store whether the unfixings are valid */
6435  SCIP_Bool* resolve, /**< pointer to store whether the changed LP should be resolved again */
6436  SCIP_Real* farkascoefs, /**< coefficients in the proof constraint */
6437  SCIP_Real farkaslhs, /**< lhs of the proof constraint */
6438  SCIP_Real* farkasactivity /**< maximal activity of the proof constraint */
6439  )
6440 {
6441  SCIP_LPI* lpi;
6442 
6443  assert(prob != NULL);
6444  assert(lp != NULL);
6445  assert(lp->flushed);
6446  assert(lp->solved);
6447  assert(curvarlbs != NULL);
6448  assert(curvarubs != NULL);
6449  assert(lbchginfoposs != NULL);
6450  assert(ubchginfoposs != NULL);
6451  assert(valid != NULL);
6452  assert(resolve != NULL);
6453 
6454  SCIPsetDebugMsg(set, "undoing bound changes in infeasible LP: cutoff=%g\n", lp->cutoffbound);
6455 
6456  *valid = FALSE;
6457  *resolve = FALSE;
6458 
6459  lpi = SCIPlpGetLPI(lp);
6460 
6461  /* check, if the Farkas row is still violated (using current bounds and ignoring local rows) */
6462  if( SCIPsetIsFeasGT(set, farkaslhs, *farkasactivity) )
6463  {
6464  /* undo bound changes while keeping the infeasibility proof valid */
6465  SCIP_CALL( undoBdchgsProof(set, prob, currentdepth, farkascoefs, farkaslhs, farkasactivity, \
6466  curvarlbs, curvarubs, lbchginfoposs, ubchginfoposs, oldlpbdchgs, relaxedlpbdchgs, resolve, lpi) );
6467 
6468  *valid = TRUE;
6469 
6470  /* resolving does not make sense: the old dual ray is still valid -> resolving will not change the solution */
6471  *resolve = FALSE;
6472  }
6473 
6474  return SCIP_OKAY;
6475 }
6476 
6477 /** analyzes an LP exceeding the objective limit and undoes additional bound changes while staying beyond the
6478  * objective limit
6479  */
6480 static
6482  SCIP_SET* set, /**< global SCIP settings */
6483  SCIP_PROB* prob, /**< problem data */
6484  SCIP_LP* lp, /**< LP data */
6485  int currentdepth, /**< current depth in the tree */
6486  SCIP_Real* curvarlbs, /**< current lower bounds of active problem variables */
6487  SCIP_Real* curvarubs, /**< current upper bounds of active problem variables */
6488  int* lbchginfoposs, /**< positions of currently active lower bound change information in variables' arrays */
6489  int* ubchginfoposs, /**< positions of currently active upper bound change information in variables' arrays */
6490  SCIP_LPBDCHGS* oldlpbdchgs, /**< old LP bound changes used for reset the LP bound change, or NULL */
6491  SCIP_LPBDCHGS* relaxedlpbdchgs, /**< relaxed LP bound changes used for reset the LP bound change, or NULL */
6492  SCIP_Bool* valid, /**< pointer to store whether the unfixings are valid */
6493  SCIP_Bool* resolve, /**< pointer to store whether the changed LP should be resolved again */
6494  SCIP_Real* dualcoefs, /**< coefficients in the proof constraint */
6495  SCIP_Real duallhs, /**< lhs of the proof constraint */
6496  SCIP_Real* dualactivity /**< maximal activity of the proof constraint */
6497  )
6498 {
6499  SCIP_LPI* lpi;
6500 
6501  assert(set != NULL);
6502  assert(prob != NULL);
6503  assert(lp != NULL);
6504  assert(lp->flushed);
6505  assert(lp->solved);
6506  assert(curvarlbs != NULL);
6507  assert(curvarubs != NULL);
6508  assert(lbchginfoposs != NULL);
6509  assert(ubchginfoposs != NULL);
6510  assert(valid != NULL);
6511  assert(resolve != NULL);
6512 
6513  *valid = FALSE;
6514  *resolve = FALSE;
6515 
6516  SCIPsetDebugMsg(set, "undoing bound changes in LP exceeding cutoff: cutoff=%g\n", lp->cutoffbound);
6517 
6518  /* get LP solver interface */
6519  lpi = SCIPlpGetLPI(lp);
6520 
6521  /* check, if the dual row is still violated (using current bounds and ignoring local rows) */
6522  if( SCIPsetIsFeasGT(set, duallhs, *dualactivity) )
6523  {
6524  /* undo bound changes while keeping the infeasibility proof valid */
6525  SCIP_CALL( undoBdchgsProof(set, prob, currentdepth, dualcoefs, duallhs, dualactivity, curvarlbs, curvarubs, \
6526  lbchginfoposs, ubchginfoposs, oldlpbdchgs, relaxedlpbdchgs, resolve, lpi) );
6527 
6528  *valid = TRUE;
6529  }
6530 
6531  return SCIP_OKAY;
6532 }
6533 
6534 /** applies conflict analysis starting with given bound changes, that could not be undone during previous
6535  * infeasibility analysis
6536  */
6537 static
6539  SCIP_CONFLICT* conflict, /**< conflict analysis data */
6540  BMS_BLKMEM* blkmem, /**< block memory of transformed problem */
6541  SCIP_SET* set, /**< global SCIP settings */
6542  SCIP_STAT* stat, /**< problem statistics */
6543  SCIP_PROB* prob, /**< problem data */
6544  SCIP_TREE* tree, /**< branch and bound tree */
6545  SCIP_Bool diving, /**< are we in strong branching or diving mode? */
6546  int* lbchginfoposs, /**< positions of currently active lower bound change information in variables' arrays */
6547  int* ubchginfoposs, /**< positions of currently active upper bound change information in variables' arrays */
6548  int* nconss, /**< pointer to store the number of generated conflict constraints */
6549  int* nliterals, /**< pointer to store the number of literals in generated conflict constraints */
6550  int* nreconvconss, /**< pointer to store the number of generated reconvergence constraints */
6551  int* nreconvliterals /**< pointer to store the number of literals generated reconvergence constraints */
6552  )
6553 {
6554  SCIP_VAR** vars;
6555  SCIP_VAR* var;
6556  SCIP_CONFTYPE conftype;
6557  SCIP_Bool usescutoffbound;
6558  int nvars;
6559  int v;
6560  int nbdchgs;
6561  int maxsize;
6562 
6563  assert(prob != NULL);
6564  assert(lbchginfoposs != NULL);
6565  assert(ubchginfoposs != NULL);
6566  assert(nconss != NULL);
6567  assert(nliterals != NULL);
6568  assert(nreconvconss != NULL);
6569  assert(nreconvliterals != NULL);
6570 
6571  *nconss = 0;
6572  *nliterals = 0;
6573  *nreconvconss = 0;
6574  *nreconvliterals = 0;
6575 
6576  vars = prob->vars;
6577  nvars = prob->nvars;
6578  assert(nvars == 0 || vars != NULL);
6579 
6580  maxsize = 2*conflictCalcMaxsize(set, prob);
6581 
6582  /* initialize conflict data */
6583  conftype = conflict->conflictset->conflicttype;
6584  usescutoffbound = conflict->conflictset->usescutoffbound;
6585 
6586  SCIP_CALL( SCIPconflictInit(conflict, set, stat, prob, conftype, usescutoffbound) );
6587 
6588  conflict->conflictset->conflicttype = conftype;
6589  conflict->conflictset->usescutoffbound = usescutoffbound;
6590 
6591  /* add remaining bound changes to conflict queue */
6592  SCIPsetDebugMsg(set, "initial conflict set after undoing bound changes:\n");
6593 
6594  nbdchgs = 0;
6595  for( v = 0; v < nvars && nbdchgs < maxsize; ++v )
6596  {
6597  var = vars[v];
6598  assert(var != NULL);
6599  assert(var->nlbchginfos >= 0);
6600  assert(var->nubchginfos >= 0);
6601  assert(-1 <= lbchginfoposs[v] && lbchginfoposs[v] <= var->nlbchginfos);
6602  assert(-1 <= ubchginfoposs[v] && ubchginfoposs[v] <= var->nubchginfos);
6603 
6604  if( lbchginfoposs[v] == var->nlbchginfos || ubchginfoposs[v] == var->nubchginfos )
6605  {
6606  SCIP_BDCHGINFO* bdchginfo;
6607  SCIP_Real relaxedbd;
6608 
6609  /* the strong branching or diving bound stored in the column is responsible for the conflict:
6610  * it cannot be resolved and therefore has to be directly put into the conflict set
6611  */
6612  assert((lbchginfoposs[v] == var->nlbchginfos) != (ubchginfoposs[v] == var->nubchginfos)); /* only one can be tight in the dual! */
6613  assert(lbchginfoposs[v] < var->nlbchginfos || SCIPvarGetLbLP(var, set) > SCIPvarGetLbLocal(var));
6614  assert(ubchginfoposs[v] < var->nubchginfos || SCIPvarGetUbLP(var, set) < SCIPvarGetUbLocal(var));
6615 
6616  /* create an artificial bound change information for the diving/strong branching bound change;
6617  * they are freed in the SCIPconflictFlushConss() call
6618  */
6619  if( lbchginfoposs[v] == var->nlbchginfos )
6620  {
6621  SCIP_CALL( conflictCreateTmpBdchginfo(conflict, blkmem, set, var, SCIP_BOUNDTYPE_LOWER,
6622  SCIPvarGetLbLocal(var), SCIPvarGetLbLP(var, set), &bdchginfo) );
6623  relaxedbd = SCIPvarGetLbLP(var, set);
6624  }
6625  else
6626  {
6627  SCIP_CALL( conflictCreateTmpBdchginfo(conflict, blkmem, set, var, SCIP_BOUNDTYPE_UPPER,
6628  SCIPvarGetUbLocal(var), SCIPvarGetUbLP(var, set), &bdchginfo) );
6629  relaxedbd = SCIPvarGetUbLP(var, set);
6630  }
6631 
6632  /* put variable into the conflict set */
6633  SCIPsetDebugMsg(set, " force: <%s> %s %g [status: %d, type: %d, dive/strong]\n",
6634  SCIPvarGetName(var), lbchginfoposs[v] == var->nlbchginfos ? ">=" : "<=",
6635  lbchginfoposs[v] == var->nlbchginfos ? SCIPvarGetLbLP(var, set) : SCIPvarGetUbLP(var, set),
6636  SCIPvarGetStatus(var), SCIPvarGetType(var));
6637  SCIP_CALL( conflictAddConflictBound(conflict, blkmem, set, bdchginfo, relaxedbd) );
6638 
6639  /* each variable which is add to the conflict graph gets an increase in the VSIDS
6640  *
6641  * @note That is different to the VSIDS preseted in the literature
6642  */
6643  SCIP_CALL( incVSIDS(var, blkmem, set, stat, SCIPbdchginfoGetBoundtype(bdchginfo), relaxedbd, set->conf_conflictgraphweight) );
6644  nbdchgs++;
6645  }
6646  else
6647  {
6648  /* put remaining bound changes into conflict candidate queue */
6649  if( lbchginfoposs[v] >= 0 )
6650  {
6651  SCIP_CALL( conflictAddBound(conflict, blkmem, set, stat, var, SCIP_BOUNDTYPE_LOWER, \
6652  &var->lbchginfos[lbchginfoposs[v]], SCIPbdchginfoGetNewbound(&var->lbchginfos[lbchginfoposs[v]])) );
6653  nbdchgs++;
6654  }
6655  if( ubchginfoposs[v] >= 0 )
6656  {
6657  assert(!SCIPbdchginfoIsRedundant(&var->ubchginfos[ubchginfoposs[v]]));
6658  SCIP_CALL( conflictAddBound(conflict, blkmem, set, stat, var, SCIP_BOUNDTYPE_UPPER, \
6659  &var->ubchginfos[ubchginfoposs[v]], SCIPbdchginfoGetNewbound(&var->ubchginfos[ubchginfoposs[v]])) );
6660  nbdchgs++;
6661  }
6662  }
6663  }
6664 
6665  if( v == nvars )
6666  {
6667  /* analyze the conflict set, and create conflict constraints on success */
6668  SCIP_CALL( conflictAnalyze(conflict, blkmem, set, stat, prob, tree, diving, 0, FALSE, nconss, nliterals, \
6669  nreconvconss, nreconvliterals) );
6670  }
6671 
6672  return SCIP_OKAY;
6673 }
6674 
6675 /** adds a weighted LP row to an aggregation row */
6676 static
6678  SCIP_SET* set, /**< global SCIP settings */
6679  SCIP_ROW* row, /**< LP row */
6680  SCIP_Real weight, /**< weight for scaling */
6681  SCIP_AGGRROW* aggrrow /**< aggregation row */
6682  )
6683 {
6684  assert(set != NULL);
6685  assert(row != NULL);
6686  assert(weight != 0.0);
6687 
6688  /* add minimal value to dual row's left hand side: y_i < 0 -> lhs, y_i > 0 -> rhs */
6689  if( weight < 0.0 )
6690  {
6691  assert(!SCIPsetIsInfinity(set, -row->lhs));
6692  SCIP_CALL( SCIPaggrRowAddRow(set->scip, aggrrow, row, weight, -1) );
6693  }
6694  else
6695  {
6696  assert(!SCIPsetIsInfinity(set, row->rhs));
6697  SCIP_CALL( SCIPaggrRowAddRow(set->scip, aggrrow, row, weight, +1) );
6698  }
6699  SCIPsetDebugMsg(set, " -> add %s row <%s>[%g,%g](lp depth: %d): dual=%g -> dualrhs=%g\n",
6700  row->local ? "local" : "global",
6701  SCIProwGetName(row), row->lhs - row->constant, row->rhs - row->constant,
6702  row->lpdepth, weight, SCIPaggrRowGetRhs(aggrrow));
6703 
6704  return SCIP_OKAY;
6705 }
6706 
6707 /** checks validity of an LP row and a corresponding weight */
6708 static
6710  SCIP_SET* set, /**< global SCIP settings */
6711  SCIP_ROW* row, /**< LP row */
6712  SCIP_Real weight, /**< weight for scaling */
6713  SCIP_Bool* zerocontribution /**< pointer to store whether every row entry is zero within tolerances */
6714  )
6715 {
6716  SCIP_Bool valid = TRUE;
6717 
6718  *zerocontribution = TRUE;
6719 
6720  /* dual solution values of 0.0 are always valid */
6721  if( REALABS(weight) > QUAD_EPSILON )
6722  {
6723  *zerocontribution = FALSE;
6724 
6725  /* check dual feasibility */
6726  if( (SCIPsetIsInfinity(set, -row->lhs) && weight > 0.0) || (SCIPsetIsInfinity(set, row->rhs) && weight < 0.0) )
6727  {
6728  int i;
6729 
6730  /* ignore slight numerical violations if the contribution of every component of the row is close to zero */
6731  if( weight > 0.0 )
6732  *zerocontribution = SCIPsetIsDualfeasZero(set, row->rhs * weight);
6733  else
6734  *zerocontribution = SCIPsetIsDualfeasZero(set, row->lhs * weight);
6735 
6736  for( i = 0; i < row->len && *zerocontribution; i++ )
6737  {
6738  if( !SCIPsetIsDualfeasZero(set, weight * row->vals[i]) )
6739  *zerocontribution = FALSE;
6740  }
6741 
6742  if( !(*zerocontribution) )
6743  {
6744  SCIPsetDebugMsg(set, " -> invalid dual solution value %g for row <%s>: lhs=%g, rhs=%g\n",
6745  weight, SCIProwGetName(row), row->lhs, row->rhs);
6746 
6747  valid = FALSE;
6748  }
6749  }
6750  }
6751 
6752  return valid;
6753 }
6754 
6755 /** sort local rows by increasing depth and number of nonzeros as tie-breaker */
6756 static
6758  SCIP_SET* set, /**< global SCIP settings */
6759  SCIP_AGGRROW* aggrrow, /**< aggregation row */
6760  SCIP_ROW** rows, /**< array of local rows */
6761  int* rowinds, /**< array of row indices */
6762  int* rowdepth, /**< array of LP depths */
6763  int nrows /**< number of local rows */
6764  )
6765 {
6766  int* rownnz;
6767  int i;
6768 
6769  assert(aggrrow != NULL);
6770  assert(rows != NULL);
6771  assert(nrows > 0);
6772  assert(rowinds != NULL);
6773  assert(rowdepth != NULL);
6774 
6775  /* sort row indices by increasing depth */
6776  SCIPsortIntInt(rowdepth, rowinds, nrows);
6777  assert(rowdepth[0] <= rowdepth[nrows-1]);
6778 
6779  SCIP_CALL( SCIPsetAllocBufferArray(set, &rownnz, nrows) );
6780 
6781  /* get number of nonzero entries for every row */
6782  for( i = 0; i < nrows; i++ )
6783  {
6784  SCIP_ROW* row = rows[rowinds[i]];
6785  assert(row != NULL);
6786 
6787  rownnz[i] = row->len;
6788  }
6789 
6790  /* since SCIP has no stable sorting function we sort each bucket separately */
6791  for( i = 0; i < nrows; i++ )
6792  {
6793  int j = i;
6794  int d = rowdepth[i];
6795 
6796  /* search for the next row with a greater depth */
6797  while( j+1 < nrows && rowdepth[j+1] == d )
6798  j++;
6799 
6800  /* the bucket has size one */
6801  if( j == i )
6802  continue;
6803 
6804  assert(j-i+1 <= nrows);
6805 
6806  /* sort row indices by increasing number of nonzero elements */
6807  SCIPsortIntIntInt(&rownnz[i], &rowdepth[i], &rowinds[i], j-i+1);
6808  assert(rownnz[i] <= rownnz[j]);
6809 
6810  i = j;
6811  } /*lint --e{850} i is modified in the body of the for loop */
6812 
6813 #ifndef NDEBUG
6814  for( i = 0; i < nrows-1; i++ )
6815  assert(rowdepth[i] < rowdepth[i+1] || (rowdepth[i] == rowdepth[i+1] && rownnz[i] <= rownnz[i+1]));
6816 #endif
6817 
6818  SCIPsetFreeBufferArray(set, &rownnz);
6819 
6820  return SCIP_OKAY;
6821 }
6822 
6823 /** adds locally valid rows to the proof constraint */
6824 static
6826  SCIP_SET* set, /**< global SCIP settings */
6827  SCIP_PROB* transprob, /**< transformed problem */
6828  SCIP_LP* lp, /**< LP data */
6829  SCIP_AGGRROW* proofrow, /**< aggregated row representing the proof */
6830  SCIP_ROW** rows, /**< array if locally valid rows */
6831  SCIP_Real* dualsols, /**< dual solution vector */
6832  int* localrowinds, /**< array of row indecies */
6833  int* localrowdepth, /**< array of row depths */
6834  int nlocalrows, /**< number of local rows stored in rows array */
6835  SCIP_Real* proofact, /**< pointer to store the activity of the proof constraint */
6836  int* validdepth, /**< pointer to store the depth where the proof constraint is valid */
6837  SCIP_Real* curvarlbs, /**< current lower bounds of active problem variables */
6838  SCIP_Real* curvarubs, /**< current upper bounds of active problem variables */
6839  SCIP_Bool* valid /**< pointer store whether the proof constraint is valid */
6840  )
6841 {
6842  SCIP_Bool infdelta;
6843  int i;
6844 
6845  assert(set != NULL);
6846  assert(lp != NULL);
6847 
6848  *validdepth = 0;
6849 
6850  if( !set->conf_uselocalrows )
6851  return SCIP_OKAY;
6852 
6853  SCIPsetDebugMsg(set, "add local rows to dual proof:\n");
6854 
6855  /* check whether the proof is already valid, e.g., violated within the local bounds */
6856  *proofact = aggrRowGetMinActivity(set, transprob, proofrow, curvarlbs, curvarubs, &infdelta);
6857 
6858  /* we stop if the minimal activity is infinite but all variables have a finite activity delta (bad numerics) */
6859  if( !infdelta && SCIPsetIsInfinity(set, REALABS(*proofact)) )
6860  {
6861  *valid = FALSE;
6862  return SCIP_OKAY;
6863  }
6864 
6865  /* break if the proof is valid w.r.t local bounds
6866  * note: it can happen that the proof contains a variable with an infinite activity delta.
6867  * here, we don't break immediately because we might be able to fix it by adding local rows
6868  */
6869  if( !infdelta && SCIPsetIsGT(set, *proofact, SCIPaggrRowGetRhs(proofrow)) )
6870  {
6871  *valid = TRUE;
6872  return SCIP_OKAY;
6873  }
6874 
6875  /* sort local rows by depth */
6876  SCIP_CALL( sortLocalRows(set, proofrow, rows, localrowinds, localrowdepth, nlocalrows) );
6877 
6878  /* add successively local rows */
6879  for( i = 0; i < nlocalrows; ++i )
6880  {
6881  SCIP_ROW* row;
6882  int r;
6883 
6884  r = localrowinds[i];
6885  row = rows[r];
6886 
6887  assert(row != NULL);
6888  assert(row->len == 0 || row->cols != NULL);
6889  assert(row->len == 0 || row->vals != NULL);
6890  assert(row == lp->lpirows[r]);
6891  assert(row->local);
6892  assert(row->lpdepth == localrowdepth[i]);
6893 
6894  /* ignore dual solution values of 0.0 (in this case: y_i == 0) */
6895  if( REALABS(dualsols[r]) > 0.0 )
6896  {
6897 #ifndef NDEBUG
6898  SCIP_Bool zerocontribution;
6899 
6900  /* check dual feasibility */
6901  *valid = checkDualFeasibility(set, row, dualsols[r], &zerocontribution);
6902  assert(*valid);
6903  assert(!zerocontribution);
6904 #endif
6905 
6906  if( SCIPsetIsDualfeasZero(set, dualsols[r]) )
6907  continue;
6908 
6909  /* add row to dual proof */
6910  SCIP_CALL( addRowToAggrRow(set, row, -dualsols[r], proofrow) );
6911 
6912  /* update depth where the proof is valid */
6913  if( *validdepth < localrowdepth[i] )
6914  *validdepth = localrowdepth[i];
6915 
6916  /* get the new minimal activity */
6917  *proofact = aggrRowGetMinActivity(set, transprob, proofrow, curvarlbs, curvarubs, &infdelta);
6918 
6919  /* we stop if the minimal activity is infinite but all variables have a finite activity delta (bad numerics) */
6920  if( !infdelta && SCIPsetIsInfinity(set, REALABS(*proofact)) )
6921  {
6922  *valid = FALSE;
6923  goto TERMINATE;
6924  }
6925 
6926  /* break if the proof is valid w.r.t local bounds */
6927  if( !infdelta && SCIPsetIsGT(set, *proofact, SCIPaggrRowGetRhs(proofrow)) )
6928  {
6929  *valid = TRUE;
6930  break;
6931  }
6932  }
6933  }
6934 
6935  /* remove all nearly zero coefficients */
6936  SCIPaggrRowRemoveZeros(set->scip, proofrow, TRUE, valid);
6937 
6938  TERMINATE:
6939  if( !(*valid) )
6940  {
6941  SCIPsetDebugMsg(set, " -> proof is not valid: %g <= %g\n", *proofact, SCIPaggrRowGetRhs(proofrow));
6942  SCIPsetDebugMsg(set, " -> stop due to numerical troubles\n");
6943  }
6944  else
6945  {
6946  *proofact = aggrRowGetMinActivity(set, transprob, proofrow, curvarlbs, curvarubs, &infdelta);
6947 
6948  /* we stop if the minimal activity is infinite but all variables have a finite activity delta (bad numerics) */
6949  if( !infdelta && SCIPsetIsInfinity(set, REALABS(*proofact)) )
6950  {
6951  *valid = FALSE;
6952  SCIPsetDebugMsg(set, " -> proof is not valid: %g <= %g [infdelta: %u]\n", *proofact, SCIPaggrRowGetRhs(proofrow), infdelta);
6953  }
6954  else if( infdelta || SCIPsetIsLE(set, *proofact, SCIPaggrRowGetRhs(proofrow)) )
6955  {
6956  *valid = FALSE;
6957  SCIPsetDebugMsg(set, " -> proof is not valid: %g <= %g [infdelta: %u]\n", *proofact, SCIPaggrRowGetRhs(proofrow), infdelta);
6958  }
6959  }
6960 
6961  return SCIP_OKAY;
6962 }
6963 
6964 /** calculates a Farkas proof from the current dual LP solution */
6965 static
6967  SCIP_SET* set, /**< global SCIP settings */
6968  SCIP_PROB* prob, /**< transformed problem */
6969  SCIP_LP* lp, /**< LP data */
6970  SCIP_LPI* lpi, /**< LPI data */
6971  SCIP_TREE* tree, /**< tree data */
6972  SCIP_AGGRROW* farkasrow, /**< aggregated row representing the proof */
6973  SCIP_Real* farkasact, /**< maximal activity of the proof constraint */
6974  int* validdepth, /**< pointer to store the valid depth of the proof constraint */
6975  SCIP_Real* curvarlbs, /**< current lower bounds of active problem variables */
6976  SCIP_Real* curvarubs, /**< current upper bounds of active problem variables */
6977  SCIP_Bool* valid /**< pointer store whether the proof constraint is valid */
6978  )
6979 {
6980  SCIP_ROW** rows;
6981  SCIP_Real* dualfarkas;
6982  SCIP_ROW* row;
6983  int* localrowinds;
6984  int* localrowdepth;
6985  SCIP_Bool infdelta;
6986  int nlocalrows;
6987  int nrows;
6988  int r;
6989 
6990  assert(set != NULL);
6991  assert(prob != NULL);
6992  assert(lp != NULL);
6993  assert(lp->flushed);
6994  assert(lp->solved);
6995  assert(curvarlbs != NULL);
6996  assert(curvarubs != NULL);
6997  assert(valid != NULL);
6998 
7001 
7002  /* get LP rows and problem variables */
7003  rows = SCIPlpGetRows(lp);
7004  nrows = SCIPlpGetNRows(lp);
7005  assert(nrows == 0 || rows != NULL);
7006  assert(nrows == lp->nlpirows);
7007 
7008  /* it can happen that infeasibility is detetected within LP presolve. in that case, the LP solver may not be able to
7009  * to return the dual ray.
7010  */
7011  if( !SCIPlpiHasDualRay(lpi) )
7012  {
7013  *valid = FALSE;
7014  return SCIP_OKAY;
7015  }
7016 
7017  assert(farkasrow != NULL);
7018 
7019  /* allocate temporary memory */
7020  SCIP_CALL( SCIPsetAllocBufferArray(set, &dualfarkas, nrows) );
7021  BMSclearMemoryArray(dualfarkas, nrows);
7022 
7023  /* get dual Farkas values of rows */
7024  SCIP_CALL( SCIPlpiGetDualfarkas(lpi, dualfarkas) );
7025 
7026  localrowinds = NULL;
7027  localrowdepth = NULL;
7028  nlocalrows = 0;
7029 
7030  /* calculate the Farkas row */
7031  (*valid) = TRUE;
7032  (*validdepth) = 0;
7033 
7034  for( r = 0; r < nrows; ++r )
7035  {
7036  row = rows[r];
7037  assert(row != NULL);
7038  assert(row->len == 0 || row->cols != NULL);
7039  assert(row->len == 0 || row->vals != NULL);
7040  assert(row == lp->lpirows[r]);
7041 
7042  /* ignore dual ray values of 0.0 (in this case: y_i == z_i == 0) */
7043  if( REALABS(dualfarkas[r]) > 0.0 )
7044  {
7045  SCIP_Bool zerocontribution;
7046 
7047  /* check dual feasibility */
7048  *valid = checkDualFeasibility(set, row, dualfarkas[r], &zerocontribution);
7049 
7050  if( !(*valid) )
7051  goto TERMINATE;
7052 
7053  if( zerocontribution )
7054  continue;
7055 
7056  if( SCIPsetIsDualfeasZero(set, dualfarkas[r]) )
7057  continue;
7058 
7059  if( !row->local )
7060  {
7061  SCIP_CALL( addRowToAggrRow(set, row, -dualfarkas[r], farkasrow) );
7062 
7063  /* due to numerical reasons we want to stop */
7064  if( REALABS(SCIPaggrRowGetRhs(farkasrow)) > NUMSTOP )
7065  {
7066  (*valid) = FALSE;
7067  goto TERMINATE;
7068  }
7069  }
7070  else
7071  {
7072  int lpdepth = SCIProwGetLPDepth(row);
7073 
7074  if( nlocalrows == 0 && lpdepth < SCIPtreeGetFocusDepth(tree) )
7075  {
7076  SCIP_CALL( SCIPsetAllocBufferArray(set, &localrowinds, nrows-r) );
7077  SCIP_CALL( SCIPsetAllocBufferArray(set, &localrowdepth, nrows-r) );
7078  }
7079 
7080  if( lpdepth < SCIPtreeGetFocusDepth(tree) )
7081  {
7082  assert(localrowinds != NULL);
7083  assert(localrowdepth != NULL);
7084 
7085  localrowinds[nlocalrows] = r;
7086  localrowdepth[nlocalrows++] = lpdepth;
7087  }
7088  }
7089  }
7090  }
7091 
7092  /* remove all coefficients that are too close to zero */
7093  SCIPaggrRowRemoveZeros(set->scip, farkasrow, TRUE, valid);
7094 
7095  if( !(*valid) )
7096  goto TERMINATE;
7097 
7098  infdelta = FALSE;
7099 
7100  /* calculate the current Farkas activity, always using the best bound w.r.t. the Farkas coefficient */
7101  *farkasact = aggrRowGetMinActivity(set, prob, farkasrow, curvarlbs, curvarubs, &infdelta);
7102 
7103  SCIPsetDebugMsg(set, " -> farkasact=%g farkasrhs=%g [infdelta: %u], \n",
7104  (*farkasact), SCIPaggrRowGetRhs(farkasrow), infdelta);
7105 
7106  /* The constructed proof is not valid, this can happen due to numerical reasons,
7107  * e.g., we only consider rows r with !SCIPsetIsZero(set, dualfarkas[r]),
7108  * or because of local rows were ignored so far.
7109  * Due to the latter case, it might happen at least one variable contributes
7110  * with an infinite value to the activity (see: https://git.zib.de/integer/scip/issues/2743)
7111  */
7112  if( infdelta || SCIPsetIsFeasLE(set, *farkasact, SCIPaggrRowGetRhs(farkasrow)))
7113  {
7114  /* add contribution of local rows */
7115  if( nlocalrows > 0 && set->conf_uselocalrows > 0 )
7116  {
7117  SCIP_CALL( addLocalRows(set, prob, lp, farkasrow, rows, dualfarkas, localrowinds, localrowdepth,
7118  nlocalrows, farkasact, validdepth, curvarlbs, curvarubs, valid) );
7119  }
7120  else
7121  {
7122  (*valid) = FALSE;
7123  SCIPsetDebugMsg(set, " -> proof is not valid to due infinite activity delta\n");
7124  }
7125  }
7126 
7127  TERMINATE:
7128 
7129  SCIPfreeBufferArrayNull(set->scip, &localrowdepth);
7130  SCIPfreeBufferArrayNull(set->scip, &localrowinds);
7131  SCIPsetFreeBufferArray(set, &dualfarkas);
7132 
7133  return SCIP_OKAY;
7134 }
7135 
7136 /** calculates a Farkas proof from the current dual LP solution */
7137 static
7139  SCIP_SET* set, /**< global SCIP settings */
7140  SCIP_PROB* transprob, /**< transformed problem */
7141  SCIP_LP* lp, /**< LP data */
7142  SCIP_LPI* lpi, /**< LPI data */
7143  SCIP_TREE* tree, /**< tree data */
7144  SCIP_AGGRROW* farkasrow, /**< aggregated row representing the proof */
7145  SCIP_Real* farkasact, /**< maximal activity of the proof constraint */
7146  int* validdepth, /**< pointer to store the valid depth of the proof constraint */
7147  SCIP_Real* curvarlbs, /**< current lower bounds of active problem variables */
7148  SCIP_Real* curvarubs, /**< current upper bounds of active problem variables */
7149  SCIP_Bool* valid /**< pointer store whether the proof constraint is valid */
7150  )
7151 {
7152  SCIP_RETCODE retcode;
7153  SCIP_ROW** rows;
7154  SCIP_ROW* row;
7155  SCIP_Real* primsols;
7156  SCIP_Real* dualsols;
7157  SCIP_Real* redcosts;
7158  int* localrowinds;
7159  int* localrowdepth;
7160  SCIP_Real maxabsdualsol;
7161  SCIP_Bool infdelta;
7162  int nlocalrows;
7163  int nrows;
7164  int ncols;
7165  int r;
7166 
7167  assert(set != NULL);
7168  assert(transprob != NULL);
7169  assert(lp != NULL);
7170  assert(lp->flushed);
7171  assert(lp->solved);
7172  assert(curvarlbs != NULL);
7173  assert(curvarubs != NULL);
7174  assert(valid != NULL);
7175 
7176  *validdepth = 0;
7177  *valid = TRUE;
7178 
7179  localrowinds = NULL;
7180  localrowdepth = NULL;
7181  nlocalrows = 0;
7182 
7183  /* get LP rows and problem variables */
7184  rows = SCIPlpGetRows(lp);
7185  nrows = SCIPlpGetNRows(lp);
7186  ncols = SCIPlpGetNCols(lp);
7187  assert(nrows == 0 || rows != NULL);
7188  assert(nrows == lp->nlpirows);
7189 
7190  /* get temporary memory */
7191  SCIP_CALL( SCIPsetAllocBufferArray(set, &primsols, ncols) );
7192  SCIP_CALL( SCIPsetAllocBufferArray(set, &dualsols, nrows) );
7193  SCIP_CALL( SCIPsetAllocBufferArray(set, &redcosts, ncols) );
7194 
7195  /* get solution from LPI */
7196  retcode = SCIPlpiGetSol(lpi, NULL, primsols, dualsols, NULL, redcosts);
7197  if( retcode == SCIP_LPERROR ) /* on an error in the LP solver, just abort the conflict analysis */
7198  {
7199  (*valid) = FALSE;
7200  goto TERMINATE;
7201  }
7202  SCIP_CALL( retcode );
7203 #ifdef SCIP_DEBUG
7204  {
7205  SCIP_Real objval;
7206  SCIP_CALL( SCIPlpiGetObjval(lpi, &objval) );
7207  SCIPsetDebugMsg(set, " -> LP objval: %g\n", objval);
7208  }
7209 #endif
7210 
7211  /* check whether the dual solution is numerically stable */
7212  maxabsdualsol = 0;
7213  for( r = 0; r < nrows; r++ )
7214  {
7215  SCIP_Real absdualsol = REALABS(dualsols[r]);
7216 
7217  if( absdualsol > maxabsdualsol )
7218  maxabsdualsol = absdualsol;
7219  }
7220 
7221  /* don't consider dual solution with maxabsdualsol > 1e+07, this would almost cancel out the objective constraint */
7222  if( maxabsdualsol > 1e+07 )
7223  {
7224  (*valid) = FALSE;
7225  goto TERMINATE;
7226  }
7227 
7228  /* clear the proof */
7229  SCIPaggrRowClear(farkasrow);
7230 
7231  /* Let y be the dual solution and r be the reduced cost vector. Let z be defined as
7232  * z_i := y_i if i is a global row,
7233  * z_i := 0 if i is a local row.
7234  * Define the set X := {x | lhs <= Ax <= rhs, lb <= x <= ub, c^Tx <= c*}, with c* being the current primal bound.
7235  * Then the following inequalities are valid for all x \in X:
7236  * - c* <= -c^Tx
7237  * <=> z^TAx - c* <= (z^TA - c^T) x
7238  * <=> z^TAx - c* <= (y^TA - c^T - (y-z)^TA) x
7239  * <=> z^TAx - c* <= (-r^T - (y-z)^TA) x (dual feasibility of (y,r): y^TA + r^T == c^T)
7240  * Because lhs <= Ax <= rhs and lb <= x <= ub, the inequality can be relaxed to give
7241  * min{z^Tq | lhs <= q <= rhs} - c* <= max{(-r^T - (y-z)^TA) x | lb <= x <= ub}, or X = {}.
7242  *
7243  * The resulting dual row is: z^T{lhs,rhs} - c* <= (-r^T - (y-z)^TA){lb,ub},
7244  * where lhs, rhs, lb, and ub are selected in order to maximize the feasibility of the row.
7245  */
7246 
7247  /* add the objective function to the aggregation row with respect to the current cutoff bound
7248  *
7249  * for an integral objective the right-hand side is reduced by the cutoff bound delta to cut off up to the next
7250  * possible objective value below the cutoff bound
7251  */
7252  SCIP_CALL( SCIPaggrRowAddObjectiveFunction(set->scip, farkasrow, lp->cutoffbound - (SCIPprobIsObjIntegral(transprob) ? SCIPsetCutoffbounddelta(set) : 0.0), 1.0) );
7253 
7254  /* dual row: z^T{lhs,rhs} - c* <= (-r^T - (y-z)^TA){lb,ub}
7255  * 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
7256  */
7257  for( r = 0; r < nrows; ++r )
7258  {
7259  row = rows[r];
7260  assert(row != NULL);
7261  assert(row->len == 0 || row->cols != NULL);
7262  assert(row->len == 0 || row->vals != NULL);
7263  assert(row == lp->lpirows[r]);
7264 
7265  /* ignore dual solution values of 0.0 (in this case: y_i == z_i == 0) */
7266  if( REALABS(dualsols[r]) > 0.0 )
7267  {
7268  SCIP_Bool zerocontribution;
7269 
7270  /* check dual feasibility */
7271  *valid = checkDualFeasibility(set, row, dualsols[r], &zerocontribution);
7272 
7273  if( !(*valid) )
7274  goto TERMINATE;
7275 
7276  if( zerocontribution )
7277  continue;
7278 
7279  if( SCIPsetIsDualfeasZero(set, dualsols[r]) )
7280  continue;
7281 
7282  /* skip local row */
7283  if( !row->local )
7284  {
7285  SCIP_CALL( addRowToAggrRow(set, row, -dualsols[r], farkasrow) );
7286 
7287  /* due to numerical reasons we want to stop */
7288  if( REALABS(SCIPaggrRowGetRhs(farkasrow)) > NUMSTOP )
7289  {
7290  (*valid) = FALSE;
7291  goto TERMINATE;
7292  }
7293  }
7294  else
7295  {
7296  int lpdepth = SCIProwGetLPDepth(row);
7297 
7298  if( nlocalrows == 0 && lpdepth < SCIPtreeGetFocusDepth(tree) )
7299  {
7300  SCIP_CALL( SCIPsetAllocBufferArray(set, &localrowinds, nrows-r) );
7301  SCIP_CALL( SCIPsetAllocBufferArray(set, &localrowdepth, nrows-r) );
7302  }
7303 
7304  if( lpdepth < SCIPtreeGetFocusDepth(tree) )
7305  {
7306  assert(localrowinds != NULL);
7307  assert(localrowdepth != NULL);
7308 
7309  localrowinds[nlocalrows] = r;
7310  localrowdepth[nlocalrows++] = lpdepth;
7311  }
7312  }
7313  }
7314  }
7315 
7316  /* remove all nearly zero coefficients */
7317  SCIPaggrRowRemoveZeros(set->scip, farkasrow, TRUE, valid);
7318 
7319  if( !(*valid) )
7320  goto TERMINATE;
7321 
7322  infdelta = FALSE;
7323 
7324  /* check validity of the proof */
7325  *farkasact = aggrRowGetMinActivity(set, transprob, farkasrow, curvarlbs, curvarubs, &infdelta);
7326 
7327  SCIPsetDebugMsg(set, " -> farkasact=%g farkasrhs=%g [infdelta: %u], \n",
7328  (*farkasact), SCIPaggrRowGetRhs(farkasrow), infdelta);
7329 
7330  /* The constructed proof is not valid, this can happen due to numerical reasons,
7331  * e.g., we only consider rows r with !SCIPsetIsZero(set, dualsol[r]),
7332  * or because of local rows were ignored so far.
7333  * Due to the latter case, it might happen at least one variable contributes
7334  * with an infinite value to the activity (see: https://git.zib.de/integer/scip/issues/2743)
7335  */
7336  if( infdelta || SCIPsetIsFeasLE(set, *farkasact, SCIPaggrRowGetRhs(farkasrow)))
7337  {
7338  /* add contribution of local rows */
7339  if( nlocalrows > 0 && set->conf_uselocalrows > 0 )
7340  {
7341  SCIP_CALL( addLocalRows(set, transprob, lp, farkasrow, rows, dualsols, localrowinds, localrowdepth,
7342  nlocalrows, farkasact, validdepth, curvarlbs, curvarubs, valid) );
7343  }
7344  else
7345  {
7346  (*valid) = FALSE;
7347  SCIPsetDebugMsg(set, " -> proof is not valid to due infinite activity delta\n");
7348  }
7349  }
7350 
7351  TERMINATE:
7352 
7353  SCIPfreeBufferArrayNull(set->scip, &localrowdepth);
7354  SCIPfreeBufferArrayNull(set->scip, &localrowinds);
7355  SCIPsetFreeBufferArray(set, &redcosts);
7356  SCIPsetFreeBufferArray(set, &dualsols);
7357  SCIPsetFreeBufferArray(set, &primsols);
7358 
7359  return SCIP_OKAY;
7360 }
7361 
7362 #ifdef SCIP_DEBUG
7363 static
7365  SCIP_SET* set, /**< global SCIP settings */
7366  SCIP_Real minact, /**< min activity */
7367  SCIP_Real rhs, /**< right hand side */
7368  const char* infostr /**< additional info for this debug message, or NULL */
7369  )
7370 {
7371  SCIPsetDebugMsg(set, "-> %sminact=%.15g rhs=%.15g violation=%.15g\n",infostr != NULL ? infostr : "" , minact, rhs, minact - rhs);
7372 }
7373 #else
7374 #define debugPrintViolationInfo(...) /**/
7375 #endif
7376 
7377 /** apply coefficient tightening */
7378 static
7380  SCIP_SET* set, /**< global SCIP settings */
7381  SCIP_PROOFSET* proofset, /**< proof set */
7382  int* nchgcoefs, /**< pointer to store number of changed coefficients */
7383  SCIP_Bool* redundant /**< pointer to store whether the proof set is redundant */
7384  )
7385 {
7386 #ifdef SCIP_DEBUG
7387  SCIP_Real absmax = 0.0;
7388  SCIP_Real absmin = SCIPsetInfinity(set);
7389  int i;
7390 
7391  for( i = 0; i < proofset->nnz; i++ )
7392  {
7393  absmax = MAX(absmax, REALABS(proofset->vals[i]));
7394  absmin = MIN(absmin, REALABS(proofset->vals[i]));
7395  }
7396 #endif
7397 
7398  (*redundant) = SCIPcutsTightenCoefficients(set->scip, FALSE, proofset->vals, &proofset->rhs, proofset->inds, &proofset->nnz, nchgcoefs);
7399 
7400 #ifdef SCIP_DEBUG
7401  {
7402  SCIP_Real newabsmax = 0.0;
7403  SCIP_Real newabsmin = SCIPsetInfinity(set);
7404 
7405  for( i = 0; i < proofset->nnz; i++ )
7406  {
7407  newabsmax = MAX(newabsmax, REALABS(proofset->vals[i]));
7408  newabsmin = MIN(newabsmin, REALABS(proofset->vals[i]));
7409  }
7410 
7411  SCIPsetDebugMsg(set, "coefficient tightening: [%.15g,%.15g] -> [%.15g,%.15g] (nnz: %d, nchg: %d rhs: %.15g)\n",
7412  absmin, absmax, newabsmin, newabsmax, proofsetGetNVars(proofset), *nchgcoefs, proofsetGetRhs(proofset));
7413  printf("coefficient tightening: [%.15g,%.15g] -> [%.15g,%.15g] (nnz: %d, nchg: %d rhs: %.15g)\n",
7414  absmin, absmax, newabsmin, newabsmax, proofsetGetNVars(proofset), *nchgcoefs, proofsetGetRhs(proofset));
7415  }
7416 #endif
7417 }
7418 
7419 /** try to generate alternative proofs by applying subadditive functions */
7420 static
7422  SCIP_CONFLICT* conflict, /**< conflict analysis data */
7423  SCIP_SET* set, /**< global SCIP settings */
7424  SCIP_STAT* stat, /**< dynamic SCIP statistics */
7425  SCIP_PROB* transprob, /**< transformed problem */
7426  SCIP_TREE* tree, /**< tree data */
7427  BMS_BLKMEM* blkmem, /**< block memory */
7428  SCIP_AGGRROW* proofrow, /**< proof rows data */
7429  SCIP_Real* curvarlbs, /**< current lower bounds of active problem variables */
7430  SCIP_Real* curvarubs, /**< current upper bounds of active problem variables */
7431  SCIP_CONFTYPE conflicttype /**< type of the conflict */
7432  )
7433 {
7434  SCIP_VAR** vars;
7435  SCIP_SOL* refsol;
7436  SCIP_Real* cutcoefs;
7437  SCIP_Real cutefficacy;
7438  SCIP_Real cutrhs;
7439  SCIP_Real proofefficiacy;
7440  SCIP_Real efficiacynorm;
7441  SCIP_Bool islocal;
7442  SCIP_Bool cutsuccess;
7443  SCIP_Bool success;
7444  SCIP_Bool infdelta;
7445  int* cutinds;
7446  int* inds;
7447  int cutnnz;
7448  int nnz;
7449  int nvars;
7450  int i;
7451 
7452  vars = SCIPprobGetVars(transprob);
7453  nvars = SCIPprobGetNVars(transprob);
7454 
7455  inds = SCIPaggrRowGetInds(proofrow);
7456  nnz = SCIPaggrRowGetNNz(proofrow);
7457 
7458  proofefficiacy = aggrRowGetMinActivity(set, transprob, proofrow, curvarlbs, curvarubs, &infdelta);
7459 
7460  if( infdelta )
7461  return SCIP_OKAY;
7462 
7463  proofefficiacy -= SCIPaggrRowGetRhs(proofrow);
7464 
7465  efficiacynorm = SCIPaggrRowCalcEfficacyNorm(set->scip, proofrow);
7466  proofefficiacy /= MAX(1e-6, efficiacynorm);
7467 
7468  /* create reference solution */
7469  SCIP_CALL( SCIPcreateSol(set->scip, &refsol, NULL) );
7470 
7471  /* initialize with average solution */
7472  for( i = 0; i < nvars; i++ )
7473  {
7474  SCIP_CALL( SCIPsolSetVal(refsol, set, stat, tree, vars[i], SCIPvarGetAvgSol(vars[i])) );
7475  }
7476 
7477  /* set all variables that are part of the proof to its active local bound */
7478  for( i = 0; i < nnz; i++ )
7479  {
7480  SCIP_Real val = SCIPaggrRowGetProbvarValue(proofrow, inds[i]);
7481 
7482  if( val > 0.0 )
7483  {
7484  SCIP_CALL( SCIPsolSetVal(refsol, set, stat, tree, vars[inds[i]], curvarubs[inds[i]]) );
7485  }
7486  else
7487  {
7488  SCIP_CALL( SCIPsolSetVal(refsol, set, stat, tree, vars[inds[i]], curvarlbs[inds[i]]) );
7489  }
7490  }
7491 
7492  SCIP_CALL( SCIPsetAllocBufferArray(set, &cutcoefs, nvars) );
7493  SCIP_CALL( SCIPsetAllocBufferArray(set, &cutinds, nvars) );
7494 
7495  cutnnz = 0;
7496  cutefficacy = -SCIPsetInfinity(set);
7497 
7498  /* apply flow cover */
7499  SCIP_CALL( SCIPcalcFlowCover(set->scip, refsol, POSTPROCESS, BOUNDSWITCH, ALLOWLOCAL, proofrow, \
7500  cutcoefs, &cutrhs, cutinds, &cutnnz, &cutefficacy, NULL, &islocal, &cutsuccess) );
7501  success = cutsuccess;
7502 
7503  /* apply MIR */
7505  NULL, NULL, MINFRAC, MAXFRAC, proofrow, cutcoefs, &cutrhs, cutinds, &cutnnz, &cutefficacy, NULL, \
7506  &islocal, &cutsuccess) );
7507  success = (success || cutsuccess);
7508 
7509  /* replace the current proof */
7510  if( success && !islocal && SCIPsetIsPositive(set, cutefficacy) && cutefficacy * nnz > proofefficiacy * cutnnz )
7511  {
7512  SCIP_PROOFSET* alternativeproofset;
7513  SCIP_Bool redundant;
7514  int nchgcoefs;
7515 
7516  SCIP_CALL( proofsetCreate(&alternativeproofset, blkmem) );
7517  alternativeproofset->conflicttype = (conflicttype == SCIP_CONFTYPE_INFEASLP ? SCIP_CONFTYPE_ALTINFPROOF : SCIP_CONFTYPE_ALTBNDPROOF);
7518 
7519  SCIP_CALL( proofsetAddSparseData(alternativeproofset, blkmem, cutcoefs, cutinds, cutnnz, cutrhs) );
7520 
7521  /* apply coefficient tightening */
7522  tightenCoefficients(set, alternativeproofset, &nchgcoefs, &redundant);
7523 
7524  if( !redundant )
7525  {
7526  SCIP_CALL( conflictInsertProofset(conflict, set, alternativeproofset) );
7527  }
7528  else
7529  {
7530  proofsetFree(&alternativeproofset, blkmem);
7531  }
7532  } /*lint !e438*/
7533 
7534  SCIPsetFreeBufferArray(set, &cutinds);
7535  SCIPsetFreeBufferArray(set, &cutcoefs);
7536 
7537  SCIP_CALL( SCIPfreeSol(set->scip, &refsol) );
7538 
7539  return SCIP_OKAY;
7540 }
7541 
7542 /** tighten a given infeasibility proof a^Tx <= b with minact > b w.r.t. local bounds
7543  *
7544  * 1) Apply cut generating functions
7545  * - c-MIR
7546  * - Flow-cover
7547  * - TODO: implement other subadditive functions
7548  * 2) Remove continuous variables contributing with its global bound
7549  * - TODO: implement a variant of non-zero-cancellation
7550  */
7551 static
7553  SCIP_CONFLICT* conflict, /**< conflict analysis data */
7554  SCIP_SET* set, /**< global SCIP settings */
7555  SCIP_STAT* stat, /**< dynamic SCIP statistics */
7556  BMS_BLKMEM* blkmem, /**< block memory */
7557  SCIP_PROB* transprob, /**< transformed problem */
7558  SCIP_TREE* tree, /**< tree data */
7559  SCIP_AGGRROW* proofrow, /**< aggregated row representing the proof */
7560  int validdepth, /**< depth where the proof is valid */
7561  SCIP_Real* curvarlbs, /**< current lower bounds of active problem variables */
7562  SCIP_Real* curvarubs, /**< current upper bounds of active problem variables */
7563  SCIP_Bool initialproof /**< do we analyze the initial reason of infeasibility? */
7564  )
7565 {
7566  SCIP_VAR** vars;
7567  SCIP_Real* vals;
7568  int* inds;
7569  SCIP_PROOFSET* proofset;
7570  SCIP_Bool valid;
7571  SCIP_Bool redundant;
7572  int nnz;
7573  int nchgcoefs;
7574  int nbinvars;
7575  int ncontvars;
7576  int nintvars;
7577  int i;
7578 
7579  assert(conflict->proofset != NULL);
7580  assert(curvarlbs != NULL);
7581  assert(curvarubs != NULL);
7582 
7583  vars = SCIPprobGetVars(transprob);
7584  nbinvars = 0;
7585  nintvars = 0;
7586  ncontvars = 0;
7587 
7588  inds = SCIPaggrRowGetInds(proofrow);
7589  nnz = SCIPaggrRowGetNNz(proofrow);
7590 
7591  /* count number of binary, integer, and continuous variables */
7592  for( i = 0; i < nnz; i++ )
7593  {
7594  assert(SCIPvarGetProbindex(vars[inds[i]]) == inds[i]);
7595 
7596  if( SCIPvarIsBinary(vars[inds[i]]) )
7597  ++nbinvars;
7598  else if( SCIPvarIsIntegral(vars[inds[i]]) )
7599  ++nintvars;
7600  else
7601  ++ncontvars;
7602  }
7603 
7604  SCIPsetDebugMsg(set, "start dual proof tightening:\n");
7605  SCIPsetDebugMsg(set, "-> tighten dual proof: nvars=%d (bin=%d, int=%d, cont=%d)\n",
7606  nnz, nbinvars, nintvars, ncontvars);
7607  debugPrintViolationInfo(set, aggrRowGetMinActivity(set, transprob, proofrow, curvarlbs, curvarubs, NULL), SCIPaggrRowGetRhs(proofrow), NULL);
7608 
7609  /* try to find an alternative proof of local infeasibility that is stronger */
7610  if( set->conf_sepaaltproofs )
7611  {
7612  SCIP_CALL( separateAlternativeProofs(conflict, set, stat, transprob, tree, blkmem, proofrow, curvarlbs, curvarubs,
7613  conflict->conflictset->conflicttype) );
7614  }
7615 
7616  if( initialproof )
7617  proofset = conflict->proofset;
7618  else
7619  {
7620  SCIP_CALL( proofsetCreate(&proofset, blkmem) );
7621  }
7622 
7623  /* start with a proofset containing all variables with a non-zero coefficient in the dual proof */
7624  SCIP_CALL( proofsetAddAggrrow(proofset, set, blkmem, proofrow) );
7625  proofset->conflicttype = conflict->conflictset->conflicttype;
7626  proofset->validdepth = validdepth;
7627 
7628  /* get proof data */
7629  vals = proofsetGetVals(proofset);
7630  inds = proofsetGetInds(proofset);
7631  nnz = proofsetGetNVars(proofset);
7632 
7633 #ifndef NDEBUG
7634  for( i = 0; i < nnz; i++ )
7635  {
7636  int idx = inds[i];
7637  if( vals[i] > 0.0 )
7638  assert(!SCIPsetIsInfinity(set, -curvarlbs[idx]));
7639  if( vals[i] < 0.0 )
7640  assert(!SCIPsetIsInfinity(set, curvarubs[idx]));
7641  }
7642 #endif
7643 
7644  /* remove continuous variable contributing with their global bound
7645  *
7646  * todo: check whether we also want to do that for bound exceeding proofs, but then we cannot update the
7647  * conflict anymore
7648  */
7649  if( proofset->conflicttype == SCIP_CONFTYPE_INFEASLP )
7650  {
7651  /* remove all continuous variables that have equal global and local bounds (ub or lb depend on the sign)
7652  * from the proof
7653  */
7654 
7655  for( i = 0; i < nnz && nnz > 1; )
7656  {
7657  SCIP_Real val;
7658  int idx = inds[i];
7659 
7660  assert(vars[idx] != NULL);
7661 
7662  val = vals[i];
7663  assert(!SCIPsetIsZero(set, val));
7664 
7665  /* skip integral variables */
7666  if( SCIPvarGetType(vars[idx]) != SCIP_VARTYPE_CONTINUOUS && SCIPvarGetType(vars[idx]) != SCIP_VARTYPE_IMPLINT )
7667  {
7668  i++;
7669  continue;
7670  }
7671  else
7672  {
7673  SCIP_Real glbbd;
7674  SCIP_Real locbd;
7675 
7676  /* get appropriate global and local bounds */
7677  glbbd = (val < 0.0 ? SCIPvarGetUbGlobal(vars[idx]) : SCIPvarGetLbGlobal(vars[idx]));
7678  locbd = (val < 0.0 ? curvarubs[idx] : curvarlbs[idx]);
7679 
7680  if( !SCIPsetIsEQ(set, glbbd, locbd) )
7681  {
7682  i++;
7683  continue;
7684  }
7685 
7686  SCIPsetDebugMsg(set, "-> remove continuous variable <%s>: glb=[%g,%g], loc=[%g,%g], val=%g\n",
7687  SCIPvarGetName(vars[idx]), SCIPvarGetLbGlobal(vars[idx]), SCIPvarGetUbGlobal(vars[idx]),
7688  curvarlbs[idx], curvarubs[idx], val);
7689 
7690  proofsetCancelVarWithBound(proofset, set, vars[idx], i, &valid);
7691  assert(valid); /* this should be always fulfilled at this place */
7692 
7693  --nnz;
7694  }
7695  }
7696  }
7697 
7698  /* apply coefficient tightening to initial proof */
7699  tightenCoefficients(set, proofset, &nchgcoefs, &redundant);
7700 
7701  /* it can happen that the constraints is almost globally redundant w.r.t to the maximal activity,
7702  * e.g., due to numerics. in this case, we want to discard the proof
7703  */
7704  if( redundant )
7705  {
7706 #ifndef NDEBUG
7707  SCIP_Real eps = MIN(0.01, 10.0*set->num_feastol);
7708  assert(proofset->rhs - getMaxActivity(set, transprob, proofset->vals, proofset->inds, proofset->nnz, NULL, NULL) < eps);
7709 #endif
7710  if( initialproof )
7711  {
7712  proofsetClear(proofset);
7713  }
7714  else
7715  {
7716  proofsetFree(&proofset, blkmem);
7717  }
7718  }
7719  else
7720  {
7721  if( !initialproof )
7722  {
7723  SCIP_CALL( conflictInsertProofset(conflict, set, proofset) );
7724  }
7725 
7726  if( nchgcoefs > 0 )
7727  {
7728  if( proofset->conflicttype == SCIP_CONFTYPE_INFEASLP )
7730  else if( proofset->conflicttype == SCIP_CONFTYPE_BNDEXCEEDING )
7732  }
7733  }
7734 
7735  return SCIP_OKAY;
7736 }
7737 
7738 /** perform conflict analysis based on a dual unbounded ray
7739  *
7740  * given an aggregation of rows lhs <= a^Tx such that lhs > maxactivity. if the constraint has size one we add a
7741  * bound change instead of the constraint.
7742  */
7743 static
7745  SCIP_CONFLICT* conflict, /**< conflict analysis data */
7746  SCIP_SET* set, /**< global SCIP settings */
7747  SCIP_STAT* stat, /**< dynamic SCIP statistics */
7748  BMS_BLKMEM* blkmem, /**< block memory */
7749  SCIP_PROB* origprob, /**< original problem */
7750  SCIP_PROB* transprob, /**< transformed problem */
7751  SCIP_TREE* tree, /**< tree data */
7752  SCIP_REOPT* reopt, /**< reoptimization data */
7753  SCIP_LP* lp, /**< LP data */
7754  SCIP_AGGRROW* proofrow, /**< aggregated row representing the proof */
7755  int validdepth, /**< valid depth of the dual proof */
7756  SCIP_Real* curvarlbs, /**< current lower bounds of active problem variables */
7757  SCIP_Real* curvarubs, /**< current upper bounds of active problem variables */
7758  SCIP_Bool initialproof, /**< do we analyze the initial reason of infeasibility? */
7759  SCIP_Bool* globalinfeasible, /**< pointer to store whether global infeasibility could be proven */
7760  SCIP_Bool* success /**< pointer to store success result */
7761  )
7762 {
7763  SCIP_Real rhs;
7764  SCIP_Real minact;
7765  SCIP_Bool infdelta;
7766  int nnz;
7767 
7768  assert(set != NULL);
7769  assert(transprob != NULL);
7770  assert(validdepth >= 0);
7771  assert(validdepth == 0 || validdepth < SCIPtreeGetFocusDepth(tree));
7772 
7773  /* get sparse data */
7774  nnz = SCIPaggrRowGetNNz(proofrow);
7775  rhs = SCIPaggrRowGetRhs(proofrow);
7776 
7777  *globalinfeasible = FALSE;
7778  *success = FALSE;
7779 
7780  /* get minimal activity w.r.t. local bounds */
7781  minact = aggrRowGetMinActivity(set, transprob, proofrow, curvarlbs, curvarubs, &infdelta);
7782 
7783  if( infdelta )
7784  return SCIP_OKAY;
7785 
7786  /* only run is the proof proves local infeasibility */
7787  if( SCIPsetIsFeasLE(set, minact, rhs) )
7788  return SCIP_OKAY;
7789 
7790  /* if the farkas-proof is empty, the node and its sub tree can be cut off completely */
7791  if( nnz == 0 )
7792  {
7793  SCIPsetDebugMsg(set, " -> empty farkas-proof in depth %d cuts off sub tree at depth %d\n", SCIPtreeGetFocusDepth(tree), validdepth);
7794 
7795  SCIP_CALL( SCIPnodeCutoff(tree->path[validdepth], set, stat, tree, transprob, origprob, reopt, lp, blkmem) );
7796 
7797  *globalinfeasible = TRUE;
7798  *success = TRUE;
7799 
7800  ++conflict->ndualproofsinfsuccess;
7801 
7802  return SCIP_OKAY;
7803  }
7804 
7805  /* try to enforce the constraint based on a dual ray */
7806  SCIP_CALL( tightenDualproof(conflict, set, stat, blkmem, transprob, tree, proofrow, validdepth,
7807  curvarlbs, curvarubs, initialproof) );
7808 
7809  if( *globalinfeasible )
7810  {
7811  SCIPsetDebugMsg(set, "detect global: cutoff root node\n");
7812  SCIP_CALL( SCIPnodeCutoff(tree->path[0], set, stat, tree, transprob, origprob, reopt, lp, blkmem) );
7813  *success = TRUE;
7814 
7815  ++conflict->ndualproofsinfsuccess;
7816  }
7817 
7818  return SCIP_OKAY;
7819 }
7820 
7821 /** try to find a subset of changed bounds leading to an infeasible LP
7822  *
7823  * 1. call undoBdchgsDualfarkas() or undoBdchgsDualsol()
7824  * -> update lb/ubchginfoposs arrays
7825  * -> store additional changes in bdchg and curvarlbs/ubs arrays
7826  * -> apply additional changes to the LPI
7827  * 2. (optional) if additional bound changes were undone:
7828  * -> resolve LP
7829  * -> goto 1.
7830  * 3. redo all bound changes in the LPI to restore the LPI to its original state
7831  * 4. analyze conflict
7832  * -> put remaining changed bounds (see lb/ubchginfoposs arrays) into starting conflict set
7833  */
7834 static
7836  SCIP_CONFLICT* conflict, /**< conflict data */
7837  SCIP_SET* set, /**< global SCIP settings */
7838  SCIP_STAT* stat, /**< problem statistics */
7839  SCIP_PROB* origprob, /**< original problem */
7840  SCIP_PROB* transprob, /**< transformed problem */
7841  SCIP_TREE* tree, /**< branch and bound tree */
7842  SCIP_REOPT* reopt, /**< reoptimization data */
7843  SCIP_LP* lp, /**< LP data */
7844  SCIP_LPI* lpi, /**< LPI data */
7845  BMS_BLKMEM* blkmem, /**< block memory */
7846  SCIP_Real* proofcoefs, /**< coefficients in the proof constraint */
7847  SCIP_Real* prooflhs, /**< lhs of the proof constraint */
7848  SCIP_Real* proofactivity, /**< maximal activity of the proof constraint */
7849  SCIP_Real* curvarlbs, /**< current lower bounds of active problem variables */
7850  SCIP_Real* curvarubs, /**< current upper bounds of active problem variables */
7851  int* lbchginfoposs, /**< positions of currently active lower bound change information in variables' arrays */
7852  int* ubchginfoposs, /**< positions of currently active upper bound change information in variables' arrays */
7853  int* iterations, /**< pointer to store the total number of LP iterations used */
7854  SCIP_Bool marklpunsolved, /**< whether LP should be marked unsolved after analysis (needed for strong branching) */
7855  SCIP_Bool* dualproofsuccess, /**< pointer to store success result of dual proof analysis */
7856  SCIP_Bool* valid /**< pointer to store whether the result is still a valid proof */
7857  )
7858 {
7859  SCIP_LPBDCHGS* oldlpbdchgs;
7860  SCIP_LPBDCHGS* relaxedlpbdchgs;
7861  SCIP_Bool solvelp;
7862  SCIP_Bool resolve;
7863  int ncols;
7864 
7865  assert(set != NULL);
7866 
7867  /* get number of columns in the LP */
7868  ncols = SCIPlpGetNCols(lp);
7869 
7870  /* get temporary memory for remembering bound changes on LPI columns */
7871  SCIP_CALL( lpbdchgsCreate(&oldlpbdchgs, set, ncols) );
7872  SCIP_CALL( lpbdchgsCreate(&relaxedlpbdchgs, set, ncols) );
7873 
7874  /* undo as many bound changes as possible with the current LP solution */
7875  resolve = FALSE;
7876  if( (*valid) )
7877  {
7878  int currentdepth;
7879  currentdepth = SCIPtreeGetCurrentDepth(tree);
7880 
7881  if( SCIPlpiIsPrimalInfeasible(lpi) )
7882  {
7883  SCIP_CALL( undoBdchgsDualfarkas(set, transprob, lp, currentdepth, curvarlbs, curvarubs, lbchginfoposs, \
7884  ubchginfoposs, oldlpbdchgs, relaxedlpbdchgs, valid, &resolve, proofcoefs, *prooflhs, proofactivity) );
7885  }
7886  else
7887  {
7888  assert(SCIPlpiIsDualFeasible(lpi) || SCIPlpiIsObjlimExc(lpi));
7889  SCIP_CALL( undoBdchgsDualsol(set, transprob, lp, currentdepth, curvarlbs, curvarubs, lbchginfoposs, ubchginfoposs, \
7890  oldlpbdchgs, relaxedlpbdchgs, valid, &resolve, proofcoefs, *prooflhs, proofactivity) );
7891  }
7892  }
7893 
7894  /* check if we want to solve the LP */
7895  assert(SCIPprobAllColsInLP(transprob, set, lp));
7896  solvelp = (set->conf_maxlploops != 0 && set->conf_lpiterations != 0);
7897 
7898  if( (*valid) && resolve && solvelp )
7899  {
7900  SCIP_RETCODE retcode;
7901  SCIP_ROW** rows;
7902  int* sidechginds;
7903  SCIP_Real* sidechgoldlhss;
7904  SCIP_Real* sidechgoldrhss;
7905  SCIP_Real* sidechgnewlhss;
7906  SCIP_Real* sidechgnewrhss;
7907  SCIP_Real lpiinfinity;
7908  SCIP_Bool globalinfeasible;
7909  int maxlploops;
7910  int lpiterations;
7911  int sidechgssize;
7912  int nsidechgs;
7913  int nrows;
7914  int nloops;
7915  int r;
7916 
7917  /* get infinity value of LP solver */
7918  lpiinfinity = SCIPlpiInfinity(lpi);
7919 
7920  /* temporarily disable objective limit and install an iteration limit */
7921  maxlploops = (set->conf_maxlploops >= 0 ? set->conf_maxlploops : INT_MAX);
7922  lpiterations = (set->conf_lpiterations >= 0 ? set->conf_lpiterations : INT_MAX);
7923  SCIP_CALL( SCIPlpiSetRealpar(lpi, SCIP_LPPAR_OBJLIM, lpiinfinity) );
7924  SCIP_CALL( SCIPlpiSetIntpar(lpi, SCIP_LPPAR_LPITLIM, lpiterations) );
7925 
7926  /* get LP rows */
7927  rows = SCIPlpGetRows(lp);
7928  nrows = SCIPlpGetNRows(lp);
7929  assert(nrows == 0 || rows != NULL);
7930 
7931  /* get temporary memory for remembering side changes on LPI rows */
7932  SCIP_CALL( SCIPsetAllocBufferArray(set, &sidechginds, nrows) );
7933  SCIP_CALL( SCIPsetAllocBufferArray(set, &sidechgoldlhss, nrows) );
7934  SCIP_CALL( SCIPsetAllocBufferArray(set, &sidechgoldrhss, nrows) );
7935  SCIP_CALL( SCIPsetAllocBufferArray(set, &sidechgnewlhss, nrows) );
7936  SCIP_CALL( SCIPsetAllocBufferArray(set, &sidechgnewrhss, nrows) );
7937  sidechgssize = nrows;
7938  nsidechgs = 0;
7939 
7940  /* remove all local rows by setting their sides to infinity;
7941  * finite sides are only changed to near infinity, such that the row's sense in the LP solver
7942  * is not affected (e.g. CPLEX cannot handle free rows)
7943  */
7944  for( r = 0; r < nrows; ++r )
7945  {
7946  assert(SCIProwGetLPPos(rows[r]) == r);
7947 
7948  if( SCIProwIsLocal(rows[r]) )
7949  {
7950  SCIPsetDebugMsg(set, " -> removing local row <%s> [%g,%g]\n",
7951  SCIProwGetName(rows[r]), SCIProwGetLhs(rows[r]), SCIProwGetRhs(rows[r]));
7952  SCIP_CALL( addSideRemoval(set, rows[r], lpiinfinity, &sidechginds, &sidechgoldlhss, &sidechgoldrhss,
7953  &sidechgnewlhss, &sidechgnewrhss, &sidechgssize, &nsidechgs) );
7954  }
7955  }
7956 
7957  /* apply changes of local rows to the LP solver */
7958  if( nsidechgs > 0 )
7959  {
7960  SCIP_CALL( SCIPlpiChgSides(lpi, nsidechgs, sidechginds, sidechgnewlhss, sidechgnewrhss) );
7961  }
7962 
7963  /* undo as many additional bound changes as possible by resolving the LP */
7964  assert((*valid));
7965  assert(resolve);
7966  nloops = 0;
7967  globalinfeasible = FALSE;
7968  while( (*valid) && resolve && nloops < maxlploops )
7969  {
7970  int iter;
7971 
7972  assert(!globalinfeasible);
7973 
7974  nloops++;
7975  resolve = FALSE;
7976 
7977  SCIPsetDebugMsg(set, "infeasible LP conflict analysis loop %d (changed col bounds: %d)\n", nloops, relaxedlpbdchgs->nbdchgs);
7978 
7979  /* apply bound changes to the LP solver */
7980  assert(relaxedlpbdchgs->nbdchgs >= 0);
7981  if( relaxedlpbdchgs->nbdchgs > 0 )
7982  {
7983  SCIPsetDebugMsg(set, " -> applying %d bound changes to the LP solver\n", relaxedlpbdchgs->nbdchgs);
7984  SCIP_CALL( SCIPlpiChgBounds(lpi, relaxedlpbdchgs->nbdchgs, relaxedlpbdchgs->bdchginds, \
7985  relaxedlpbdchgs->bdchglbs, relaxedlpbdchgs->bdchgubs) );
7986 
7987  /* reset conflict LP bound change data structure */
7988  lpbdchgsReset(relaxedlpbdchgs, ncols);
7989  }
7990 
7991  /* start LP timer */
7992  SCIPclockStart(stat->conflictlptime, set);
7993 
7994  /* resolve LP */
7995  retcode = SCIPlpiSolveDual(lpi);
7996 
7997  /* stop LP timer */
7998  SCIPclockStop(stat->conflictlptime, set);
7999 
8000  /* check return code of LP solving call */
8001  if( retcode == SCIP_LPERROR )
8002  {
8003  (*valid) = FALSE;
8004  break;
8005  }
8006  SCIP_CALL( retcode );
8007 
8008  /* count number of LP iterations */
8009  SCIP_CALL( SCIPlpiGetIterations(lpi, &iter) );
8010  (*iterations) += iter;
8011  stat->nconflictlps++;
8012  stat->nconflictlpiterations += iter;
8013  SCIPsetDebugMsg(set, " -> resolved LP in %d iterations (total: %" SCIP_LONGINT_FORMAT ") (infeasible:%u)\n",
8015 
8016  /* evaluate result */
8017  if( SCIPlpiIsDualFeasible(lpi) || SCIPlpiIsObjlimExc(lpi) )
8018  {
8019  SCIP_Real objval;
8020 
8021  SCIP_CALL( SCIPlpiGetObjval(lpi, &objval) );
8022  (*valid) = (objval >= lp->lpiobjlim && !SCIPlpDivingObjChanged(lp));
8023  }
8024  else
8025  (*valid) = SCIPlpiIsPrimalInfeasible(lpi);
8026 
8027  if( (*valid) )
8028  {
8029  int currentdepth;
8030  currentdepth = SCIPtreeGetCurrentDepth(tree);
8031 
8032  /* undo additional bound changes */
8033  if( SCIPlpiIsPrimalInfeasible(lpi) )
8034  {
8035  SCIP_AGGRROW* farkasrow;
8036  int* inds;
8037  int validdepth;
8038  int nnz;
8039  int v;
8040 
8041 #ifndef NDEBUG
8042  SCIP_VAR** vars = SCIPprobGetVars(transprob);
8043 #endif
8044 
8045  SCIP_CALL( SCIPaggrRowCreate(set->scip, &farkasrow) );
8046 
8047  /* the original LP exceeds the current cutoff bound, thus, we have not constructed the Farkas proof */
8048  SCIP_CALL( getFarkasProof(set, transprob, lp, lpi, tree, farkasrow, proofactivity, &validdepth,
8049  curvarlbs, curvarubs, valid) );
8050 
8051  /* the constructed Farkas proof is not valid, we need to break here */
8052  if( !(*valid) )
8053  {
8054  SCIPaggrRowFree(set->scip, &farkasrow);
8055  break;
8056  }
8057 
8058  /* start dual proof analysis */
8059  if( set->conf_useinflp == 'd' || set->conf_useinflp == 'b' )
8060  {
8061  /* change the conflict type */
8062  SCIP_CONFTYPE oldconftype = conflict->conflictset->conflicttype;
8064 
8065  /* start dual proof analysis */
8066  SCIP_CALL( conflictAnalyzeDualProof(conflict, set, stat, blkmem, origprob, transprob, tree, reopt, lp, \
8067  farkasrow, validdepth, curvarlbs, curvarubs, FALSE, &globalinfeasible, dualproofsuccess) );
8068 
8069  conflict->conflictset->conflicttype = oldconftype;
8070  }
8071 
8072  /* todo: in theory, we could apply conflict graph analysis for locally valid proofs, too, but this needs to be implemented */
8073  if( globalinfeasible || validdepth > SCIPtreeGetEffectiveRootDepth(tree) )
8074  {
8075  SCIPaggrRowFree(set->scip, &farkasrow);
8076  goto TERMINATE;
8077  }
8078 
8079  BMSclearMemoryArray(proofcoefs, SCIPprobGetNVars(transprob));
8080  (*prooflhs) = -SCIPaggrRowGetRhs(farkasrow);
8081  (*proofactivity) = -(*proofactivity);
8082 
8083  inds = SCIPaggrRowGetInds(farkasrow);
8084  nnz = SCIPaggrRowGetNNz(farkasrow);
8085 
8086  for( v = 0; v < nnz; v++ )
8087  {
8088  int i = inds[v];
8089 
8090  assert(SCIPvarGetProbindex(vars[i]) == inds[v]);
8091 
8092  proofcoefs[i] = -SCIPaggrRowGetProbvarValue(farkasrow, i);
8093  }
8094 
8095  /* free aggregation rows */
8096  SCIPaggrRowFree(set->scip, &farkasrow);
8097 
8098  SCIP_CALL( undoBdchgsDualfarkas(set, transprob, lp, currentdepth, curvarlbs, curvarubs, lbchginfoposs, \
8099  ubchginfoposs, oldlpbdchgs, relaxedlpbdchgs, valid, &resolve, proofcoefs, (*prooflhs), proofactivity) );
8100  }
8101  else
8102  {
8103  SCIP_AGGRROW* proofrow;
8104  int* inds;
8105  int validdepth;
8106  int nnz;
8107  int v;
8108 
8109 #ifndef NDEBUG
8110  SCIP_VAR** vars = SCIPprobGetVars(transprob);
8111 #endif
8112 
8113  assert(SCIPlpiIsDualFeasible(lpi) || SCIPlpiIsObjlimExc(lpi));
8114 
8115  SCIP_CALL( SCIPaggrRowCreate(set->scip, &proofrow) );
8116 
8117  SCIP_CALL( getDualProof(set, transprob, lp, lpi, tree, proofrow, proofactivity, &validdepth,
8118  curvarlbs, curvarubs, valid) );
8119 
8120  /* the constructed dual proof is not valid, we need to break here */
8121  if( !(*valid) || validdepth > SCIPtreeGetEffectiveRootDepth(tree) )
8122  {
8123  SCIPaggrRowFree(set->scip, &proofrow);
8124  break;
8125  }
8126  /* in contrast to the infeasible case we don't want to analyze the (probably identical) proof again. */
8127 
8128  BMSclearMemoryArray(proofcoefs, SCIPprobGetNVars(transprob));
8129  (*prooflhs) = -SCIPaggrRowGetRhs(proofrow);
8130  (*proofactivity) = -(*proofactivity);
8131 
8132  inds = SCIPaggrRowGetInds(proofrow);
8133  nnz = SCIPaggrRowGetNNz(proofrow);
8134 
8135  for( v = 0; v < nnz; v++ )
8136  {
8137  int i = inds[v];
8138 
8139  assert(SCIPvarGetProbindex(vars[i]) == inds[v]);
8140 
8141  proofcoefs[i] = -SCIPaggrRowGetProbvarValue(proofrow, i);
8142  }
8143 
8144  /* free aggregation rows */
8145  SCIPaggrRowFree(set->scip, &proofrow);
8146 
8147  SCIP_CALL( undoBdchgsDualsol(set, transprob, lp, currentdepth, curvarlbs, curvarubs, lbchginfoposs, \
8148  ubchginfoposs, oldlpbdchgs, relaxedlpbdchgs, valid, &resolve, proofcoefs, *prooflhs, proofactivity) );
8149  }
8150  }
8151  assert(!resolve || (*valid));
8152  assert(!resolve || relaxedlpbdchgs->nbdchgs > 0);
8153  SCIPsetDebugMsg(set, " -> finished infeasible LP conflict analysis loop %d (iter: %d, nbdchgs: %d)\n",
8154  nloops, iter, relaxedlpbdchgs->nbdchgs);
8155  }
8156 
8157  SCIPsetDebugMsg(set, "finished undoing bound changes after %d loops (valid=%u, nbdchgs: %d)\n",
8158  nloops, (*valid), oldlpbdchgs->nbdchgs);
8159 
8160  TERMINATE:
8161  /* reset variables to local bounds */
8162  if( oldlpbdchgs->nbdchgs > 0 )
8163  {
8164  SCIP_CALL( SCIPlpiChgBounds(lpi, oldlpbdchgs->nbdchgs, oldlpbdchgs->bdchginds, oldlpbdchgs->bdchglbs, oldlpbdchgs->bdchgubs) );
8165  }
8166 
8167  /* reset changes of local rows */
8168  if( nsidechgs > 0 )
8169  {
8170  SCIP_CALL( SCIPlpiChgSides(lpi, nsidechgs, sidechginds, sidechgoldlhss, sidechgoldrhss) );
8171  }
8172 
8173  /* mark the LP unsolved */
8174  if( oldlpbdchgs->nbdchgs > 0 || nsidechgs > 0 )
8175  {
8176  /* The LPI data are out of sync with LP data. Thus, the LP should be marked
8177  * unsolved. However, for strong branching calls, the LP has to have status 'solved'; in
8178  * this case, marklpunsolved is FALSE and synchronization is performed later. */
8179  if ( marklpunsolved )
8180  {
8181  lp->solved = FALSE;
8182  lp->primalfeasible = FALSE;
8183  lp->primalchecked = FALSE;
8184  lp->dualfeasible = FALSE;
8185  lp->dualchecked = FALSE;
8186  lp->lpobjval = SCIP_INVALID;
8188  }
8189  }
8190 
8191  /* reinstall old objective and iteration limits in LP solver */
8194 
8195  /* free temporary memory */
8196  SCIPsetFreeBufferArray(set, &sidechgnewrhss);
8197  SCIPsetFreeBufferArray(set, &sidechgnewlhss);
8198  SCIPsetFreeBufferArray(set, &sidechgoldrhss);
8199  SCIPsetFreeBufferArray(set, &sidechgoldlhss);
8200  SCIPsetFreeBufferArray(set, &sidechginds);
8201  }
8202 
8203  /* free temporary memory */
8204  lpbdchgsFree(&relaxedlpbdchgs, set);
8205  lpbdchgsFree(&oldlpbdchgs, set);
8206 
8207  return SCIP_OKAY;
8208 }
8209 
8210 /** actually performs analysis of infeasible LP */
8211 static
8213  SCIP_CONFLICT* conflict, /**< conflict analysis data */
8214  SCIP_CONFLICTSTORE* conflictstore, /**< conflict store */
8215  BMS_BLKMEM* blkmem, /**< block memory of transformed problem */
8216  SCIP_SET* set, /**< global SCIP settings */
8217  SCIP_STAT* stat, /**< problem statistics */
8218  SCIP_PROB* transprob, /**< transformed problem */
8219  SCIP_PROB* origprob, /**< original problem */
8220  SCIP_TREE* tree, /**< branch and bound tree */
8221  SCIP_REOPT* reopt, /**< reoptimization data structure */
8222  SCIP_LP* lp, /**< LP data */
8223  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
8224  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
8225  SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
8226  SCIP_Bool diving, /**< are we in strong branching or diving mode? */
8227  SCIP_Bool* dualproofsuccess, /**< pointer to store success result of dual proof analysis */
8228  int* iterations, /**< pointer to store the total number of LP iterations used */
8229  int* nconss, /**< pointer to store the number of generated conflict constraints */
8230  int* nliterals, /**< pointer to store the number of literals in generated conflict constraints */
8231  int* nreconvconss, /**< pointer to store the number of generated reconvergence constraints */
8232  int* nreconvliterals, /**< pointer to store the number of literals generated reconvergence constraints */
8233  SCIP_Bool marklpunsolved /**< whether LP should be marked unsolved after analysis (needed for strong branching) */
8234  )
8235 {
8236  SCIP_VAR** vars;
8237  SCIP_AGGRROW* farkasrow;
8238  SCIP_LPI* lpi;
8239  SCIP_Bool valid;
8240  SCIP_Bool globalinfeasible;
8241  int* lbchginfoposs;
8242  int* ubchginfoposs;
8243  int validdepth;
8244  int nvars;
8245  int v;
8246  SCIP_Real* curvarlbs;
8247  SCIP_Real* curvarubs;
8248  SCIP_Real farkasactivity;
8249 
8250  assert(conflict != NULL);
8251  assert(conflict->nconflictsets == 0);
8252  assert(set != NULL);
8253  assert(SCIPprobAllColsInLP(transprob, set, lp)); /* LP conflict analysis is only valid, if all variables are known */
8254  assert(stat != NULL);
8255  assert(transprob != NULL);
8256  assert(lp != NULL);
8257  assert(lp->flushed);
8258  assert(lp->solved);
8259  assert(iterations != NULL);
8260  assert(nconss != NULL);
8261  assert(nliterals != NULL);
8262  assert(nreconvconss != NULL);
8263  assert(nreconvliterals != NULL);
8264 
8265  *iterations = 0;
8266  *nconss = 0;
8267  *nliterals = 0;
8268  *nreconvconss = 0;
8269  *nreconvliterals = 0;
8270 
8271  vars = transprob->vars;
8272  nvars = transprob->nvars;
8273 
8274  valid = TRUE;
8275  validdepth = 0;
8276 
8277  /* get LP solver interface */
8278  lpi = SCIPlpGetLPI(lp);
8281 
8282  if( !SCIPlpiIsPrimalInfeasible(lpi) )
8283  {
8284  SCIP_Real objval;
8285 
8286  assert(!SCIPlpDivingObjChanged(lp));
8287 
8288  /* make sure, a dual feasible solution exists, that exceeds the objective limit;
8289  * With FASTMIP setting, CPLEX does not apply the final pivot to reach the dual solution exceeding the objective
8290  * limit. Therefore, we have to either turn off FASTMIP and resolve the problem or continue solving it without
8291  * objective limit for at least one iteration. It seems that the strategy to continue with FASTMIP for one
8292  * additional simplex iteration yields better results.
8293  */
8294  SCIP_CALL( SCIPlpiGetObjval(lpi, &objval) );
8295  if( objval < lp->lpiobjlim )
8296  {
8297  SCIP_RETCODE retcode;
8298 
8299  /* temporarily disable objective limit and install an iteration limit */
8302 
8303  /* start LP timer */
8304  SCIPclockStart(stat->conflictlptime, set);
8305 
8306  /* resolve LP */
8307  retcode = SCIPlpiSolveDual(lpi);
8308 
8309  /* stop LP timer */
8310  SCIPclockStop(stat->conflictlptime, set);
8311 
8312  /* check return code of LP solving call */
8313  valid = (retcode != SCIP_LPERROR);
8314  if( valid )
8315  {
8316  int iter;
8317 
8318  SCIP_CALL( retcode );
8319 
8320  /* count number of LP iterations */
8321  SCIP_CALL( SCIPlpiGetIterations(lpi, &iter) );
8322  (*iterations) += iter;
8323  stat->nconflictlps++;
8324  stat->nconflictlpiterations += iter;
8325  SCIPsetDebugMsg(set, " -> resolved objlim exceeding LP in %d iterations (total: %" SCIP_LONGINT_FORMAT ") (infeasible:%u, objlim: %u, optimal:%u)\n",
8328  }
8329 
8330  /* reinstall old objective and iteration limits in LP solver */
8333 
8334  /* abort, if the LP produced an error */
8335  if( !valid )
8336  return SCIP_OKAY;
8337  }
8338  }
8340 
8341  if( !SCIPlpiIsPrimalInfeasible(lpi) )
8342  {
8343  SCIP_Real objval;
8344 
8345  assert(!SCIPlpDivingObjChanged(lp));
8346 
8347  SCIP_CALL( SCIPlpiGetObjval(lpi, &objval) );
8348  if( objval < lp->lpiobjlim )
8349  {
8350  SCIPsetDebugMsg(set, " -> LP does not exceed the cutoff bound: obj=%g, cutoff=%g\n", objval, lp->lpiobjlim);
8351  return SCIP_OKAY;
8352  }
8353  else
8354  {
8355  SCIPsetDebugMsg(set, " -> LP exceeds the cutoff bound: obj=%g, cutoff=%g\n", objval, lp->lpiobjlim);
8356  }
8357  }
8358 
8359  assert(valid);
8360 
8361  SCIP_CALL( SCIPaggrRowCreate(set->scip, &farkasrow) );
8362  SCIP_CALL( SCIPsetAllocBufferArray(set, &lbchginfoposs, transprob->nvars) );
8363  SCIP_CALL( SCIPsetAllocBufferArray(set, &ubchginfoposs, transprob->nvars) );
8364 
8365  farkasactivity = 0.0;
8366 
8367  /* get temporary memory for remembering variables' current bounds and corresponding bound change information
8368  * positions in variable's bound change information arrays
8369  */
8370  SCIP_CALL( SCIPsetAllocBufferArray(set, &curvarlbs, nvars) );
8371  SCIP_CALL( SCIPsetAllocBufferArray(set, &curvarubs, nvars) );
8372 
8373  /* get current bounds and current positions in lb/ubchginfos arrays of variables */
8374  valid = TRUE;
8375  for( v = 0; v < nvars && valid; ++v )
8376  {
8377  SCIP_VAR* var;
8378 
8379  var = vars[v];
8380 
8381  curvarlbs[v] = SCIPvarGetLbLP(var, set);
8382  curvarubs[v] = SCIPvarGetUbLP(var, set);
8383  lbchginfoposs[v] = var->nlbchginfos-1;
8384  ubchginfoposs[v] = var->nubchginfos-1;
8385  assert(diving || SCIPsetIsEQ(set, curvarlbs[v], SCIPvarGetLbLocal(var)));
8386  assert(diving || SCIPsetIsEQ(set, curvarubs[v], SCIPvarGetUbLocal(var)));
8387 
8388  /* check, if last bound changes were due to strong branching or diving */
8389  if( diving )
8390  {
8391  SCIP_Real lb;
8392  SCIP_Real ub;
8393 
8394  lb = SCIPvarGetLbLocal(var);
8395  ub = SCIPvarGetUbLocal(var);
8396  if( SCIPsetIsGT(set, curvarlbs[v], lb) )
8397  lbchginfoposs[v] = var->nlbchginfos;
8398  else if( SCIPsetIsLT(set, curvarlbs[v], lb) )
8399  {
8400  /* the bound in the diving LP was relaxed -> the LP is not a subproblem of the current node -> abort! */
8401  /**@todo we could still analyze such a conflict, but we would have to take care with our data structures */
8402  valid = FALSE;
8403  }
8404  if( SCIPsetIsLT(set, curvarubs[v], ub) )
8405  ubchginfoposs[v] = var->nubchginfos;
8406  else if( SCIPsetIsGT(set, curvarubs[v], ub) )
8407  {
8408  /* the bound in the diving LP was relaxed -> the LP is not a subproblem of the current node -> abort! */
8409  /**@todo we could still analyze such a conflict, but we would have to take care with our data structures */
8410  valid = FALSE;
8411  }
8412  }
8413  }
8414 
8415  if( !valid )
8416  goto TERMINATE;
8417 
8418  /* the LP is prooven to be infeasible */
8419  if( SCIPlpiIsPrimalInfeasible(lpi) )
8420  {
8421  SCIP_CALL( getFarkasProof(set, transprob, lp, lpi, tree, farkasrow, &farkasactivity, &validdepth,
8422  curvarlbs, curvarubs, &valid) );
8423  }
8424  /* the LP is dual feasible and/or exceeds the current incumbant solution */
8425  else
8426  {
8427  assert(SCIPlpiIsDualFeasible(lpi) || SCIPlpiIsObjlimExc(lpi));
8428  SCIP_CALL( getDualProof(set, transprob, lp, lpi, tree, farkasrow, &farkasactivity, &validdepth,
8429  curvarlbs, curvarubs, &valid) );
8430  }
8431 
8432  if( !valid || validdepth >= SCIPtreeGetCurrentDepth(tree) )
8433  goto TERMINATE;
8434 
8435  globalinfeasible = FALSE;
8436 
8437  /* start dual proof analysis */
8438  if( ((set->conf_useinflp == 'b' || set->conf_useinflp == 'd') && conflict->conflictset->conflicttype == SCIP_CONFTYPE_INFEASLP)
8439  || ((set->conf_useboundlp == 'b' || set->conf_useboundlp == 'd') && conflict->conflictset->conflicttype == SCIP_CONFTYPE_BNDEXCEEDING) )
8440  {
8441  /* start dual proof analysis */
8442  SCIP_CALL( conflictAnalyzeDualProof(conflict, set, stat, blkmem, origprob, transprob, tree, reopt, lp, farkasrow, \
8443  validdepth, curvarlbs, curvarubs, TRUE, &globalinfeasible, dualproofsuccess) );
8444  }
8445 
8446  assert(valid);
8447 
8448  /* todo: in theory, we could apply conflict graph analysis for locally valid proofs, too, but this needs to be implemented */
8449  if( !globalinfeasible && validdepth <= SCIPtreeGetEffectiveRootDepth(tree)
8450  && (((set->conf_useinflp == 'b' || set->conf_useinflp == 'c') && conflict->conflictset->conflicttype == SCIP_CONFTYPE_INFEASLP)
8451  || ((set->conf_useboundlp == 'b' || set->conf_useboundlp == 'c') && conflict->conflictset->conflicttype == SCIP_CONFTYPE_BNDEXCEEDING)) )
8452  {
8453  SCIP_Real* farkascoefs;
8454  SCIP_Real farkaslhs;
8455  int* inds;
8456  int nnz;
8457 
8458 #ifdef SCIP_DEBUG
8459  {
8460  SCIP_Real objlim;
8461  SCIPsetDebugMsg(set, "analyzing conflict on infeasible LP (infeasible: %u, objlimexc: %u, optimal:%u) in depth %d (diving: %u)\n",
8463 
8464  SCIP_CALL( SCIPlpiGetRealpar(lpi, SCIP_LPPAR_OBJLIM, &objlim) );
8465  SCIPsetDebugMsg(set, " -> objective limit in LP solver: %g (in LP: %g)\n", objlim, lp->lpiobjlim);
8466  }
8467 #endif
8468 
8469  SCIP_CALL( SCIPsetAllocBufferArray(set, &farkascoefs, SCIPprobGetNVars(transprob)) );
8470  BMSclearMemoryArray(farkascoefs, SCIPprobGetNVars(transprob));
8471 
8472  farkaslhs = -SCIPaggrRowGetRhs(farkasrow);
8473  farkasactivity = -farkasactivity;
8474 
8475  inds = SCIPaggrRowGetInds(farkasrow);
8476  nnz = SCIPaggrRowGetNNz(farkasrow);
8477 
8478  for( v = 0; v < nnz; v++ )
8479  {
8480  int i = inds[v];
8481 
8482  assert(SCIPvarGetProbindex(vars[i]) == inds[v]);
8483 
8484  farkascoefs[i] = -SCIPaggrRowGetProbvarValue(farkasrow, i);
8485  }
8486 
8487  SCIP_CALL( runBoundHeuristic(conflict, set, stat, origprob, transprob, tree, reopt, lp, lpi, blkmem, farkascoefs,
8488  &farkaslhs, &farkasactivity, curvarlbs, curvarubs, lbchginfoposs, ubchginfoposs, iterations, marklpunsolved,
8489  dualproofsuccess, &valid) );
8490 
8491  SCIPsetFreeBufferArray(set, &farkascoefs);
8492 
8493  if( !valid )
8494  goto FLUSHPROOFSETS;
8495 
8496  /* analyze the conflict starting with remaining bound changes */
8497  SCIP_CALL( conflictAnalyzeRemainingBdchgs(conflict, blkmem, set, stat, transprob, tree, diving, \
8498  lbchginfoposs, ubchginfoposs, nconss, nliterals, nreconvconss, nreconvliterals) );
8499 
8500  /* flush conflict set storage */
8501  SCIP_CALL( SCIPconflictFlushConss(conflict, blkmem, set, stat, transprob, origprob, tree, reopt, lp, branchcand, \
8502  eventqueue, cliquetable) );
8503  }
8504 
8505  FLUSHPROOFSETS:
8506  /* flush proof set */
8507  if( proofsetGetNVars(conflict->proofset) > 0 || conflict->nproofsets > 0 )
8508  {
8509  SCIP_CALL( conflictFlushProofset(conflict, conflictstore, blkmem, set, stat, transprob, origprob, tree, reopt, lp, \
8510  branchcand, eventqueue, cliquetable) );
8511  }
8512 
8513  TERMINATE:
8514  SCIPsetFreeBufferArray(set, &curvarubs);
8515  SCIPsetFreeBufferArray(set, &curvarlbs);
8516  SCIPsetFreeBufferArray(set, &ubchginfoposs);
8517  SCIPsetFreeBufferArray(set, &lbchginfoposs);
8518  SCIPaggrRowFree(set->scip, &farkasrow);
8519 
8520  return SCIP_OKAY;
8521 }
8522 
8523 /** analyzes an infeasible LP to find out the bound changes on variables that were responsible for the infeasibility;
8524  * on success, calls standard conflict analysis with the responsible variables as starting conflict set, thus creating
8525  * a conflict constraint out of the resulting conflict set;
8526  * updates statistics for infeasible LP conflict analysis
8527  */
8528 static
8530  SCIP_CONFLICT* conflict, /**< conflict analysis data */
8531  SCIP_CONFLICTSTORE* conflictstore, /**< conflict store */
8532  BMS_BLKMEM* blkmem, /**< block memory of transformed problem */
8533  SCIP_SET* set, /**< global SCIP settings */
8534  SCIP_STAT* stat, /**< problem statistics */
8535  SCIP_PROB* transprob, /**< transformed problem */
8536  SCIP_PROB* origprob, /**< original problem */
8537  SCIP_TREE* tree, /**< branch and bound tree */
8538  SCIP_REOPT* reopt, /**< reoptimization data structure */
8539  SCIP_LP* lp, /**< LP data */
8540  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
8541  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
8542  SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
8543  SCIP_Bool* success /**< pointer to store whether a conflict constraint was created, or NULL */
8544  )
8545 {
8546  SCIP_Bool dualraysuccess = FALSE;
8547  SCIP_Longint olddualproofsuccess;
8548  int iterations;
8549  int nconss;
8550  int nliterals;
8551  int nreconvconss;
8552  int nreconvliterals;
8553 
8554  assert(conflict != NULL);
8555  assert(set != NULL);
8556  assert(lp != NULL);
8557  assert(SCIPprobAllColsInLP(transprob, set, lp)); /* LP conflict analysis is only valid, if all variables are known */
8558 
8559  assert(success == NULL || *success == FALSE);
8560 
8561  /* check, if infeasible LP conflict analysis is enabled */
8562  if( !set->conf_enable || set->conf_useinflp == 'o' )
8563  return SCIP_OKAY;
8564 
8565  /* check, if there are any conflict handlers to use a conflict set */
8566  if( set->nconflicthdlrs == 0 )
8567  return SCIP_OKAY;
8568 
8569  SCIPsetDebugMsg(set, "analyzing conflict on infeasible LP in depth %d (solstat: %d, objchanged: %u)\n",
8571 
8572  /* start timing */
8573  SCIPclockStart(conflict->inflpanalyzetime, set);
8574  conflict->ninflpcalls++;
8575 
8577 
8578  olddualproofsuccess = conflict->ndualproofsinfsuccess;
8579 
8580  /* perform conflict analysis */
8581  SCIP_CALL( conflictAnalyzeLP(conflict, conflictstore, blkmem, set, stat, transprob, origprob, tree, reopt, lp, branchcand, eventqueue, \
8582  cliquetable, SCIPlpDiving(lp), &dualraysuccess, &iterations, &nconss, &nliterals, &nreconvconss, &nreconvliterals, TRUE) );
8583  conflict->ninflpsuccess += ((nconss > 0 || conflict->ndualproofsinfsuccess > olddualproofsuccess) ? 1 : 0);
8584  conflict->ninflpiterations += iterations;
8585  conflict->ninflpconfconss += nconss;
8586  conflict->ninflpconfliterals += nliterals;
8587  conflict->ninflpreconvconss += nreconvconss;
8588  conflict->ninflpreconvliterals += nreconvliterals;
8589  if( success != NULL )
8590  *success = (nconss > 0 || conflict->ndualproofsinfsuccess > olddualproofsuccess);
8591 
8592  /* stop timing */
8593  SCIPclockStop(conflict->inflpanalyzetime, set);
8594 
8595  return SCIP_OKAY;
8596 }
8597 
8598 /** analyzes a bound exceeding LP to find out the bound changes on variables that were responsible for exceeding the
8599  * primal bound;
8600  * on success, calls standard conflict analysis with the responsible variables as starting conflict set, thus creating
8601  * a conflict constraint out of the resulting conflict set;
8602  * updates statistics for bound exceeding LP conflict analysis
8603  */
8604 static
8606  SCIP_CONFLICT* conflict, /**< conflict analysis data */
8607  SCIP_CONFLICTSTORE* conflictstore, /**< conflict store */
8608  BMS_BLKMEM* blkmem, /**< block memory of transformed problem */
8609  SCIP_SET* set, /**< global SCIP settings */
8610  SCIP_STAT* stat, /**< problem statistics */
8611  SCIP_PROB* transprob, /**< transformed problem */
8612  SCIP_PROB* origprob, /**< original problem */
8613  SCIP_TREE* tree, /**< branch and bound tree */
8614  SCIP_REOPT* reopt, /**< reoptimization data structure */
8615  SCIP_LP* lp, /**< LP data */
8616  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
8617  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
8618  SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
8619  SCIP_Bool* success /**< pointer to store whether a conflict constraint was created, or NULL */
8620  )
8621 {
8622  SCIP_Bool dualraysuccess;
8623  SCIP_Longint oldnsuccess;
8624  int iterations;
8625  int nconss;
8626  int nliterals;
8627  int nreconvconss;
8628  int nreconvliterals;
8629 
8630  assert(conflict != NULL);
8631  assert(set != NULL);
8632  assert(lp != NULL);
8633  assert(!SCIPlpDivingObjChanged(lp));
8634  assert(SCIPprobAllColsInLP(transprob, set, lp)); /* LP conflict analysis is only valid, if all variables are known */
8635 
8636  assert(success == NULL || *success == FALSE);
8637 
8638  /* check, if bound exceeding LP conflict analysis is enabled */
8639  if( !set->conf_enable || set->conf_useboundlp == 'o')
8640  return SCIP_OKAY;
8641 
8642  /* check, if there are any conflict handlers to use a conflict set */
8643  if( set->nconflicthdlrs == 0 )
8644  return SCIP_OKAY;
8645 
8646  SCIPsetDebugMsg(set, "analyzing conflict on bound exceeding LP in depth %d (solstat: %d)\n",
8648 
8649  /* start timing */
8650  SCIPclockStart(conflict->boundlpanalyzetime, set);
8651  conflict->nboundlpcalls++;
8652 
8653  /* mark the conflict to depend on the cutoff bound */
8655  conflict->conflictset->usescutoffbound = TRUE;
8656 
8657  oldnsuccess = conflict->ndualproofsbndsuccess + conflict->ndualproofsinfsuccess;
8658 
8659  /* perform conflict analysis */
8660  SCIP_CALL( conflictAnalyzeLP(conflict, conflictstore, blkmem, set, stat, transprob, origprob, tree, reopt, lp, branchcand, eventqueue, \
8661  cliquetable, SCIPlpDiving(lp), &dualraysuccess, &iterations, &nconss, &nliterals, &nreconvconss, &nreconvliterals, TRUE) );
8662  conflict->nboundlpsuccess += ((nconss > 0 || conflict->ndualproofsbndsuccess + conflict->ndualproofsinfsuccess > oldnsuccess) ? 1 : 0);
8663  conflict->nboundlpiterations += iterations;
8664  conflict->nboundlpconfconss += nconss;
8665  conflict->nboundlpconfliterals += nliterals;
8666  conflict->nboundlpreconvconss += nreconvconss;
8667  conflict->nboundlpreconvliterals += nreconvliterals;
8668  if( success != NULL )
8669  *success = (nconss > 0 || conflict->ndualproofsbndsuccess + conflict->ndualproofsinfsuccess > oldnsuccess);
8670 
8671  /* stop timing */
8672  SCIPclockStop(conflict->boundlpanalyzetime, set);
8673 
8674  return SCIP_OKAY;
8675 }
8676 
8677 /** analyzes an infeasible or bound exceeding LP to find out the bound changes on variables that were responsible for the
8678  * infeasibility or for exceeding the primal bound;
8679  * on success, calls standard conflict analysis with the responsible variables as starting conflict set, thus creating
8680  * a conflict constraint out of the resulting conflict set;
8681  * updates statistics for infeasible or bound exceeding LP conflict analysis;
8682  * may only be called if SCIPprobAllColsInLP()
8683  */
8685  SCIP_CONFLICT* conflict, /**< conflict analysis data */
8686  SCIP_CONFLICTSTORE* conflictstore, /**< conflict store */
8687  BMS_BLKMEM* blkmem, /**< block memory of transformed problem */
8688  SCIP_SET* set, /**< global SCIP settings */
8689  SCIP_STAT* stat, /**< problem statistics */
8690  SCIP_PROB* transprob, /**< transformed problem */
8691  SCIP_PROB* origprob, /**< original problem */
8692  SCIP_TREE* tree, /**< branch and bound tree */
8693  SCIP_REOPT* reopt, /**< reoptimization data structure */
8694  SCIP_LP* lp, /**< LP data */
8695  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
8696  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
8697  SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
8698  SCIP_Bool* success /**< pointer to store whether a conflict constraint was created, or NULL */
8699  )
8700 {
8701  SCIP_LPSOLVALS storedsolvals;
8702  SCIP_COLSOLVALS* storedcolsolvals;
8703  SCIP_ROWSOLVALS* storedrowsolvals;
8704  int c;
8705  int r;
8706 
8707  if( success != NULL )
8708  *success = FALSE;
8709 
8710  /* check if the conflict analysis is applicable */
8711  if( !set->conf_enable || (set->conf_useinflp == 'o' && set->conf_useboundlp == 'o') )
8712  return SCIP_OKAY;
8713 
8714  /* in rare cases, it might happen that the solution stati of the LP and the LPI are out of sync; in particular this
8715  * happens when a new incumbent which cuts off the current node is found during the LP solving loop; in this case the
8716  * LP has status objlimit, but if diving has been used, the LPI only has the basis information, but is not solved
8717  *
8718  * @todo: alternatively, solve the LPI
8719  */
8720  if( !SCIPlpiWasSolved(SCIPlpGetLPI(lp)) )
8721  return SCIP_OKAY;
8722 
8723  /* LP conflict analysis is only valid, if all variables are known */
8724  assert( SCIPprobAllColsInLP(transprob, set, lp) );
8726  || (SCIPlpGetSolstat(lp) == SCIP_LPSOLSTAT_OPTIMAL && set->lp_disablecutoff == 1) );
8727 
8728  /* save status */
8729  storedsolvals.lpsolstat = lp->lpsolstat;
8730  storedsolvals.lpobjval = lp->lpobjval;
8731  storedsolvals.primalfeasible = lp->primalfeasible;
8732  storedsolvals.primalchecked = lp->primalchecked;
8733  storedsolvals.dualfeasible = lp->dualfeasible;
8734  storedsolvals.dualchecked = lp->dualchecked;
8735  storedsolvals.solisbasic = lp->solisbasic;
8736  storedsolvals.lpissolved = lp->solved;
8737 
8738  /* store solution values */
8739  SCIP_CALL( SCIPsetAllocBufferArray(set, &storedcolsolvals, lp->ncols) );
8740  SCIP_CALL( SCIPsetAllocBufferArray(set, &storedrowsolvals, lp->nrows) );
8741  for (c = 0; c < lp->ncols; ++c)
8742  {
8743  SCIP_COL* col;
8744 
8745  col = lp->cols[c];
8746  assert( col != NULL );
8747 
8748  storedcolsolvals[c].primsol = col->primsol;
8749  storedcolsolvals[c].redcost = col->redcost;
8750  storedcolsolvals[c].basisstatus = col->basisstatus; /*lint !e641 !e732*/
8751  }
8752  for (r = 0; r < lp->nrows; ++r)
8753  {
8754  SCIP_ROW* row;
8755 
8756  row = lp->rows[r];
8757  assert( row != NULL );
8758 
8759  if ( lp->lpsolstat == SCIP_LPSOLSTAT_INFEASIBLE )
8760  storedrowsolvals[r].dualsol = row->dualfarkas;
8761  else
8762  {
8763  assert( lp->lpsolstat == SCIP_LPSOLSTAT_OBJLIMIT ||
8764  (SCIPlpGetSolstat(lp) == SCIP_LPSOLSTAT_OPTIMAL && set->lp_disablecutoff == 1) );
8765  storedrowsolvals[r].dualsol = row->dualsol;
8766  }
8767  storedrowsolvals[r].activity = row->activity;
8768  storedrowsolvals[r].basisstatus = row->basisstatus; /*lint !e641 !e732*/
8769  }
8770 
8771  /* check, if the LP was infeasible or bound exceeding */
8773  {
8774  SCIP_CALL( conflictAnalyzeInfeasibleLP(conflict, conflictstore, blkmem, set, stat, transprob, origprob, tree, \
8775  reopt, lp, branchcand, eventqueue, cliquetable, success) );
8776  }
8777  else
8778  {
8779  SCIP_CALL( conflictAnalyzeBoundexceedingLP(conflict, conflictstore, blkmem, set, stat, transprob, origprob, tree, \
8780  reopt, lp, branchcand, eventqueue, cliquetable, success) );
8781  }
8782 
8783  /* possibly restore solution values */
8785  {
8786  /* restore status */
8787  lp->lpsolstat = storedsolvals.lpsolstat;
8788  lp->lpobjval = storedsolvals.lpobjval;
8789  lp->primalfeasible = storedsolvals.primalfeasible;
8790  lp->primalchecked = storedsolvals.primalchecked;
8791  lp->dualfeasible = storedsolvals.dualfeasible;
8792  lp->dualchecked = storedsolvals.dualchecked;
8793  lp->solisbasic = storedsolvals.solisbasic;
8794  lp->solved = storedsolvals.lpissolved;
8795 
8796  for (c = 0; c < lp->ncols; ++c)
8797  {
8798  SCIP_COL* col;
8799 
8800  col = lp->cols[c];
8801  assert( col != NULL );
8802  col->primsol = storedcolsolvals[c].primsol;
8803  col->redcost = storedcolsolvals[c].redcost;
8804  col->basisstatus = storedcolsolvals[c].basisstatus; /*lint !e641 !e732*/
8805  }
8806  for (r = 0; r < lp->nrows; ++r)
8807  {
8808  SCIP_ROW* row;
8809 
8810  row = lp->rows[r];
8811  assert( row != NULL );
8812 
8813  if ( lp->lpsolstat == SCIP_LPSOLSTAT_INFEASIBLE )
8814  row->dualfarkas = storedrowsolvals[r].dualsol;
8815  else
8816  {
8817  assert( lp->lpsolstat == SCIP_LPSOLSTAT_OBJLIMIT );
8818  row->dualsol = storedrowsolvals[r].dualsol;
8819  }
8820  row->activity = storedrowsolvals[r].activity;
8821  row->basisstatus = storedrowsolvals[r].basisstatus; /*lint !e641 !e732*/
8822  }
8823  }
8824  SCIPsetFreeBufferArray(set, &storedrowsolvals);
8825  SCIPsetFreeBufferArray(set, &storedcolsolvals);
8826 
8827  return SCIP_OKAY;
8828 }
8829 
8830 /** gets time in seconds used for analyzing infeasible LP conflicts */
8832  SCIP_CONFLICT* conflict /**< conflict analysis data */
8833  )
8834 {
8835  assert(conflict != NULL);
8836 
8837  return SCIPclockGetTime(conflict->inflpanalyzetime);
8838 }
8839 
8840 /** gets number of calls to infeasible LP conflict analysis */
8842  SCIP_CONFLICT* conflict /**< conflict analysis data */
8843  )
8844 {
8845  assert(conflict != NULL);
8846 
8847  return conflict->ninflpcalls;
8848 }
8849 
8850 /** gets number of calls to infeasible LP conflict analysis that yield at least one conflict constraint */
8852  SCIP_CONFLICT* conflict /**< conflict analysis data */
8853  )
8854 {
8855  assert(conflict != NULL);
8856 
8857  return conflict->ninflpsuccess;
8858 }
8859 
8860 /** gets number of conflict constraints detected in infeasible LP conflict analysis */
8862  SCIP_CONFLICT* conflict /**< conflict analysis data */
8863  )
8864 {
8865  assert(conflict != NULL);
8866 
8867  return conflict->ninflpconfconss;
8868 }
8869 
8870 /** gets total number of literals in conflict constraints created in infeasible LP conflict analysis */
8872  SCIP_CONFLICT* conflict /**< conflict analysis data */
8873  )
8874 {
8875  assert(conflict != NULL);
8876 
8877  return conflict->ninflpconfliterals;
8878 }
8879 
8880 /** gets number of reconvergence constraints detected in infeasible LP conflict analysis */
8882  SCIP_CONFLICT* conflict /**< conflict analysis data */
8883  )
8884 {
8885  assert(conflict != NULL);
8886 
8887  return conflict->ninflpreconvconss;
8888 }
8889 
8890 /** gets total number of literals in reconvergence constraints created in infeasible LP conflict analysis */
8892  SCIP_CONFLICT* conflict /**< conflict analysis data */
8893  )
8894 {
8895  assert(conflict != NULL);
8896 
8897  return conflict->ninflpreconvliterals;
8898 }
8899 
8900 /** gets number of LP iterations in infeasible LP conflict analysis */
8902  SCIP_CONFLICT* conflict /**< conflict analysis data */
8903  )
8904 {
8905  assert(conflict != NULL);
8906 
8907  return conflict->ninflpiterations;
8908 }
8909 
8910 /** gets time in seconds used for analyzing bound exceeding LP conflicts */
8912  SCIP_CONFLICT* conflict /**< conflict analysis data */
8913  )
8914 {
8915  assert(conflict != NULL);
8916 
8917  return SCIPclockGetTime(conflict->boundlpanalyzetime);
8918 }
8919 
8920 /** gets number of calls to bound exceeding LP conflict analysis */
8922  SCIP_CONFLICT* conflict /**< conflict analysis data */
8923  )
8924 {
8925  assert(conflict != NULL);
8926 
8927  return conflict->nboundlpcalls;
8928 }
8929 
8930 /** gets number of calls to bound exceeding LP conflict analysis that yield at least one conflict constraint */
8932  SCIP_CONFLICT* conflict /**< conflict analysis data */
8933  )
8934 {
8935  assert(conflict != NULL);
8936 
8937  return conflict->nboundlpsuccess;
8938 }
8939 
8940 /** gets number of conflict constraints detected in bound exceeding LP conflict analysis */
8942  SCIP_CONFLICT* conflict /**< conflict analysis data */
8943  )
8944 {
8945  assert(conflict != NULL);
8946 
8947  return conflict->nboundlpconfconss;
8948 }
8949 
8950 /** gets total number of literals in conflict constraints created in bound exceeding LP conflict analysis */
8952  SCIP_CONFLICT* conflict /**< conflict analysis data */
8953  )
8954 {
8955  assert(conflict != NULL);
8956 
8957  return conflict->nboundlpconfliterals;
8958 }
8959 
8960 /** gets number of reconvergence constraints detected in bound exceeding LP conflict analysis */
8962  SCIP_CONFLICT* conflict /**< conflict analysis data */
8963  )
8964 {
8965  assert(conflict != NULL);
8966 
8967  return conflict->nboundlpreconvconss;
8968 }
8969 
8970 /** gets total number of literals in reconvergence constraints created in bound exceeding LP conflict analysis */
8972  SCIP_CONFLICT* conflict /**< conflict analysis data */
8973  )
8974 {
8975  assert(conflict != NULL);
8976 
8977  return conflict->nboundlpreconvliterals;
8978 }
8979 
8980 /** gets number of LP iterations in bound exceeding LP conflict analysis */
8982  SCIP_CONFLICT* conflict /**< conflict analysis data */
8983  )
8984 {
8985  assert(conflict != NULL);
8986 
8987  return conflict->nboundlpiterations;
8988 }
8989 
8990 
8991 
8992 
8993 /*
8994  * infeasible strong branching conflict analysis
8995  */
8996 
8997 /** analyses infeasible strong branching sub problems for conflicts */
8999  SCIP_CONFLICT* conflict, /**< conflict analysis data */
9000  SCIP_CONFLICTSTORE* conflictstore, /**< conflict store */
9001  BMS_BLKMEM* blkmem, /**< block memory buffers */
9002  SCIP_SET* set, /**< global SCIP settings */
9003  SCIP_STAT* stat, /**< dynamic problem statistics */
9004  SCIP_PROB* transprob, /**< transformed problem */
9005  SCIP_PROB* origprob, /**< original problem */
9006  SCIP_TREE* tree, /**< branch and bound tree */
9007  SCIP_REOPT* reopt, /**< reoptimization data structure */
9008  SCIP_LP* lp, /**< LP data */
9009  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
9010  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
9011  SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
9012  SCIP_COL* col, /**< LP column with at least one infeasible strong branching subproblem */
9013  SCIP_Bool* downconflict, /**< pointer to store whether a conflict constraint was created for an
9014  * infeasible downwards branch, or NULL */
9015  SCIP_Bool* upconflict /**< pointer to store whether a conflict constraint was created for an
9016  * infeasible upwards branch, or NULL */
9017  )
9018 {
9019  int* cstat;
9020  int* rstat;
9021  SCIP_RETCODE retcode;
9022  SCIP_Bool resolve;
9023  SCIP_Real oldlb;
9024  SCIP_Real oldub;
9025  SCIP_Real newlb;
9026  SCIP_Real newub;
9027  SCIP_Bool dualraysuccess;
9028  int iter;
9029  int nconss;
9030  int nliterals;
9031  int nreconvconss;
9032  int nreconvliterals;
9033 
9034  assert(stat != NULL);
9035  assert(lp != NULL);
9036  assert(lp->flushed);
9037  assert(lp->solved);
9038  assert(SCIPprobAllColsInLP(transprob, set, lp)); /* LP conflict analysis is only valid, if all variables are known */
9039  assert(col != NULL);
9040  assert((col->sbdownvalid && SCIPsetIsGE(set, col->sbdown, lp->cutoffbound)
9041  && SCIPsetFeasCeil(set, col->primsol-1.0) >= col->lb - 0.5)
9042  || (col->sbupvalid && SCIPsetIsGE(set, col->sbup, lp->cutoffbound)
9043  && SCIPsetFeasFloor(set, col->primsol+1.0) <= col->ub + 0.5));
9044  assert(SCIPtreeGetCurrentDepth(tree) > 0);
9045 
9046  if( downconflict != NULL )
9047  *downconflict = FALSE;
9048  if( upconflict != NULL )
9049  *upconflict = FALSE;
9050 
9051  /* check, if infeasible LP conflict analysis is enabled */
9052  if( !set->conf_enable || !set->conf_usesb )
9053  return SCIP_OKAY;
9054 
9055  /* check, if there are any conflict handlers to use a conflict set */
9056  if( set->nconflicthdlrs == 0 )
9057  return SCIP_OKAY;
9058 
9059  /* inform the LPI that strong branch is (temporarily) finished */
9061 
9062  /* start timing */
9063  SCIPclockStart(conflict->sbanalyzetime, set);
9064 
9065  /* get temporary memory for storing current LP basis */
9066  SCIP_CALL( SCIPsetAllocBufferArray(set, &cstat, lp->nlpicols) );
9067  SCIP_CALL( SCIPsetAllocBufferArray(set, &rstat, lp->nlpirows) );
9068 
9069  /* get current LP basis */
9070  SCIP_CALL( SCIPlpiGetBase(lp->lpi, cstat, rstat) );
9071 
9072  /* remember old bounds */
9073  oldlb = col->lb;
9074  oldub = col->ub;
9075 
9076  resolve = FALSE;
9077 
9078  /* is down branch infeasible? */
9079  if( col->sbdownvalid && SCIPsetIsGE(set, col->sbdown, lp->cutoffbound) )
9080  {
9081  newub = SCIPsetFeasCeil(set, col->primsol-1.0);
9082  if( newub >= col->lb - 0.5 )
9083  {
9084  SCIPsetDebugMsg(set, "analyzing conflict on infeasible downwards strongbranch for variable <%s>[%g,%g] in depth %d\n",
9086  SCIPtreeGetCurrentDepth(tree));
9087 
9089  conflict->nsbcalls++;
9090 
9091  /* change the upper bound */
9092  col->ub = newub;
9093  SCIP_CALL( SCIPlpiChgBounds(lp->lpi, 1, &col->lpipos, &col->lb, &col->ub) );
9094 
9095  /* start LP timer */
9096  SCIPclockStart(stat->conflictlptime, set);
9097 
9098  /* resolve the LP */
9099  retcode = SCIPlpiSolveDual(lp->lpi);
9100 
9101  /* stop LP timer */
9102  SCIPclockStop(stat->conflictlptime, set);
9103 
9104  /* check return code of LP solving call */
9105  if( retcode != SCIP_LPERROR )
9106  {
9107  SCIP_CALL( retcode );
9108 
9109  /* count number of LP iterations */
9110  SCIP_CALL( SCIPlpiGetIterations(lp->lpi, &iter) );
9111  stat->nconflictlps++;
9112  stat->nconflictlpiterations += iter;
9113  conflict->nsbiterations += iter;
9114  SCIPsetDebugMsg(set, " -> resolved downwards strong branching LP in %d iterations\n", iter);
9115 
9116  /* perform conflict analysis on infeasible LP; last parameter guarantees status 'solved' on return */
9117  SCIP_CALL( conflictAnalyzeLP(conflict, conflictstore, blkmem, set, stat, transprob, origprob, tree, reopt, \
9118  lp, branchcand, eventqueue, cliquetable, TRUE, &dualraysuccess, &iter, &nconss, &nliterals, \
9119  &nreconvconss, &nreconvliterals, FALSE) );
9120  conflict->nsbsuccess += ((nconss > 0 || dualraysuccess) ? 1 : 0);
9121  conflict->nsbiterations += iter;
9122  conflict->nsbconfconss += nconss;
9123  conflict->nsbconfliterals += nliterals;
9124  conflict->nsbreconvconss += nreconvconss;
9125  conflict->nsbreconvliterals += nreconvliterals;
9126  if( downconflict != NULL )
9127  *downconflict = (nconss > 0);
9128  }
9129 
9130  /* reset the upper bound */
9131  col->ub = oldub;
9132  SCIP_CALL( SCIPlpiChgBounds(lp->lpi, 1, &col->lpipos, &col->lb, &col->ub) );
9133 
9134  /* reset LP basis */
9135  SCIP_CALL( SCIPlpiSetBase(lp->lpi, cstat, rstat) );
9136 
9137  /* mark the LP to be resolved at the end */
9138  resolve = TRUE;
9139  }
9140  }
9141 
9142  /* is up branch infeasible? */
9143  if( col->sbupvalid && SCIPsetIsGE(set, col->sbup, lp->cutoffbound) )
9144  {
9145  newlb = SCIPsetFeasFloor(set, col->primsol+1.0);
9146  if( newlb <= col->ub + 0.5 )
9147  {
9148  SCIPsetDebugMsg(set, "analyzing conflict on infeasible upwards strongbranch for variable <%s>[%g,%g] in depth %d\n",
9150  SCIPtreeGetCurrentDepth(tree));
9151 
9153  conflict->nsbcalls++;
9154 
9155  /* change the lower bound */
9156  col->lb = newlb;
9157  SCIP_CALL( SCIPlpiChgBounds(lp->lpi, 1, &col->lpipos, &col->lb, &col->ub) );
9158 
9159  /* start LP timer */
9160  SCIPclockStart(stat->conflictlptime, set);
9161 
9162  /* resolve the LP */
9163  retcode = SCIPlpiSolveDual(lp->lpi);
9164 
9165  /* stop LP timer */
9166  SCIPclockStop(stat->conflictlptime, set);
9167 
9168  /* check return code of LP solving call */
9169  if( retcode != SCIP_LPERROR )
9170  {
9171  SCIP_CALL( retcode );
9172 
9173  /* count number of LP iterations */
9174  SCIP_CALL( SCIPlpiGetIterations(lp->lpi, &iter) );
9175  stat->nconflictlps++;
9176  stat->nconflictlpiterations += iter;
9177  conflict->nsbiterations += iter;
9178  SCIPsetDebugMsg(set, " -> resolved upwards strong branching LP in %d iterations\n", iter);
9179 
9180  /* perform conflict analysis on infeasible LP; last parameter guarantees status 'solved' on return */
9181  SCIP_CALL( conflictAnalyzeLP(conflict, conflictstore, blkmem, set, stat, transprob, origprob, tree, reopt, \
9182  lp, branchcand, eventqueue, cliquetable, TRUE, &dualraysuccess, &iter, &nconss, &nliterals, \
9183  &nreconvconss, &nreconvliterals, FALSE) );
9184  conflict->nsbsuccess += ((nconss > 0 || dualraysuccess) ? 1 : 0);
9185  conflict->nsbiterations += iter;
9186  conflict->nsbconfconss += nconss;
9187  conflict->nsbconfliterals += nliterals;
9188  conflict->nsbreconvconss += nreconvconss;
9189  conflict->nsbreconvliterals += nreconvliterals;
9190  if( upconflict != NULL )
9191  *upconflict = (nconss > 0);
9192  }
9193 
9194  /* reset the lower bound */
9195  col->lb = oldlb;
9196  SCIP_CALL( SCIPlpiChgBounds(lp->lpi, 1, &col->lpipos, &col->lb, &col->ub) );
9197 
9198  /* reset LP basis */
9199  SCIP_CALL( SCIPlpiSetBase(lp->lpi, cstat, rstat) );
9200 
9201  /* mark the LP to be resolved at the end */
9202  resolve = TRUE;
9203  }
9204  }
9205 
9206  /* free temporary memory for storing current LP basis */
9207  SCIPsetFreeBufferArray(set, &rstat);
9208  SCIPsetFreeBufferArray(set, &cstat);
9209 
9210  assert(lp->flushed);
9211 
9212  /* resolve LP if something has changed in order to synchronize LPI and LP */
9213  if ( resolve )
9214  {
9215  /* start LP timer */
9216  SCIPclockStart(stat->conflictlptime, set);
9217 
9218  /* resolve the LP */
9219  SCIP_CALL( SCIPlpiSolveDual(lp->lpi) );
9220 
9221  /* stop LP timer */
9222  SCIPclockStop(stat->conflictlptime, set);
9223  }
9224 
9225  /* stop timing */
9226  SCIPclockStop(conflict->sbanalyzetime, set);
9227 
9228  /* inform the LPI that strong branch starts (again) */
9230 
9231  return SCIP_OKAY;
9232 }
9233 
9234 /** gets time in seconds used for analyzing infeasible strong branching conflicts */
9236  SCIP_CONFLICT* conflict /**< conflict analysis data */
9237  )
9238 {
9239  assert(conflict != NULL);
9240 
9241  return SCIPclockGetTime(conflict->sbanalyzetime);
9242 }
9243 
9244 /** gets number of successful calls to dual proof analysis derived from infeasible LPs */
9246  SCIP_CONFLICT* conflict /**< conflict analysis data */
9247  )
9248 {
9249  assert(conflict != NULL);
9250 
9251  return conflict->ndualproofsinfsuccess;
9252 }
9253 
9254 /** gets number of globally valid dual proof constraints derived from infeasible LPs */
9256  SCIP_CONFLICT* conflict /**< conflict analysis data */
9257  )
9258 {
9259  assert(conflict != NULL);
9260 
9261  return conflict->ndualproofsinfglobal;
9262 }
9263 
9264 /** gets number of locally valid dual proof constraints derived from infeasible LPs */
9266  SCIP_CONFLICT* conflict /**< conflict analysis data */
9267  )
9268 {
9269  assert(conflict != NULL);
9270 
9271  return conflict->ndualproofsinflocal;
9272 }
9273 
9274 /** gets average length of dual proof constraints derived from infeasible LPs */
9276  SCIP_CONFLICT* conflict /**< conflict analysis data */
9277  )
9278 {
9279  assert(conflict != NULL);
9280 
9281  return conflict->dualproofsinfnnonzeros;
9282 }
9283 
9284 /** gets number of successfully analyzed dual proofs derived from bound exceeding LPs */
9286  SCIP_CONFLICT* conflict /**< conflict analysis data */
9287  )
9288 {
9289  assert(conflict != NULL);
9290 
9291  return conflict->ndualproofsbndsuccess;
9292 }
9293 
9294 /** gets number of globally applied dual proofs derived from bound exceeding LPs */
9296  SCIP_CONFLICT* conflict /**< conflict analysis data */
9297  )
9298 {
9299  assert(conflict != NULL);
9300 
9301  return conflict->ndualproofsbndglobal;
9302 }
9303 
9304 /** gets number of locally applied dual proofs derived from bound exceeding LPs */
9306  SCIP_CONFLICT* conflict /**< conflict analysis data */
9307  )
9308 {
9309  assert(conflict != NULL);
9310 
9311  return conflict->ndualproofsbndlocal;
9312 }
9313 
9314 /** gets average length of dual proofs derived from bound exceeding LPs */
9316  SCIP_CONFLICT* conflict /**< conflict analysis data */
9317  )
9318 {
9319  assert(conflict != NULL);
9320 
9321  return conflict->dualproofsbndnnonzeros;
9322 }
9323 
9324 /** gets number of calls to infeasible strong branching conflict analysis */
9326  SCIP_CONFLICT* conflict /**< conflict analysis data */
9327  )
9328 {
9329  assert(conflict != NULL);
9330 
9331  return conflict->nsbcalls;
9332 }
9333 
9334 /** gets number of calls to infeasible strong branching conflict analysis that yield at least one conflict constraint */
9336  SCIP_CONFLICT* conflict /**< conflict analysis data */
9337  )
9338 {
9339  assert(conflict != NULL);
9340 
9341  return conflict->nsbsuccess;
9342 }
9343 
9344 /** gets number of conflict constraints detected in infeasible strong branching conflict analysis */
9346  SCIP_CONFLICT* conflict /**< conflict analysis data */
9347  )
9348 {
9349  assert(conflict != NULL);
9350 
9351  return conflict->nsbconfconss;
9352 }
9353 
9354 /** gets total number of literals in conflict constraints created in infeasible strong branching conflict analysis */
9356  SCIP_CONFLICT* conflict /**< conflict analysis data */
9357  )
9358 {
9359  assert(conflict != NULL);
9360 
9361  return conflict->nsbconfliterals;
9362 }
9363 
9364 /** gets number of reconvergence constraints detected in infeasible strong branching conflict analysis */
9366  SCIP_CONFLICT* conflict /**< conflict analysis data */
9367  )
9368 {
9369  assert(conflict != NULL);
9370 
9371  return conflict->nsbreconvconss;
9372 }
9373 
9374 /** gets total number of literals in reconvergence constraints created in infeasible strong branching conflict analysis */
9376  SCIP_CONFLICT* conflict /**< conflict analysis data */
9377  )
9378 {
9379  assert(conflict != NULL);
9380 
9381  return conflict->nsbreconvliterals;
9382 }
9383 
9384 /** gets number of LP iterations in infeasible strong branching conflict analysis */
9386  SCIP_CONFLICT* conflict /**< conflict analysis data */
9387  )
9388 {
9389  assert(conflict != NULL);
9390 
9391  return conflict->nsbiterations;
9392 }
9393 
9394 
9395 
9396 
9397 /*
9398  * pseudo solution conflict analysis
9399  */
9400 
9401 /** analyzes a pseudo solution with objective value exceeding the current cutoff to find out the bound changes on
9402  * variables that were responsible for the objective value degradation;
9403  * on success, calls standard conflict analysis with the responsible variables as starting conflict set, thus creating
9404  * a conflict constraint out of the resulting conflict set;
9405  * updates statistics for pseudo solution conflict analysis
9406  */
9408  SCIP_CONFLICT* conflict, /**< conflict analysis data */
9409  BMS_BLKMEM* blkmem, /**< block memory of transformed problem */
9410  SCIP_SET* set, /**< global SCIP settings */
9411  SCIP_STAT* stat, /**< problem statistics */
9412  SCIP_PROB* transprob, /**< transformed problem */
9413  SCIP_PROB* origprob, /**< original problem */
9414  SCIP_TREE* tree, /**< branch and bound tree */
9415  SCIP_REOPT* reopt, /**< reoptimization data structure */
9416  SCIP_LP* lp, /**< LP data */
9417  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
9418  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
9419  SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
9420  SCIP_Bool* success /**< pointer to store whether a conflict constraint was created, or NULL */
9421  )
9422 {
9423  SCIP_VAR** vars;
9424  SCIP_VAR* var;
9425  SCIP_Real* curvarlbs;
9426  SCIP_Real* curvarubs;
9427  int* lbchginfoposs;
9428  int* ubchginfoposs;
9429  SCIP_Real* pseudocoefs;
9430  SCIP_Real pseudolhs;
9431  SCIP_Real pseudoact;
9432  int nvars;
9433  int v;
9434 
9435  assert(conflict != NULL);
9436  assert(conflict->nconflictsets == 0);
9437  assert(set != NULL);
9438  assert(stat != NULL);
9439  assert(transprob != NULL);
9440  assert(lp != NULL);
9441  assert(!SCIPsetIsInfinity(set, -SCIPlpGetPseudoObjval(lp, set, transprob)));
9442  assert(!SCIPsetIsInfinity(set, lp->cutoffbound));
9443 
9444  if( success != NULL )
9445  *success = FALSE;
9446 
9447  /* check, if pseudo solution conflict analysis is enabled */
9448  if( !set->conf_enable || !set->conf_usepseudo )
9449  return SCIP_OKAY;
9450 
9451  /* check, if there are any conflict handlers to use a conflict set */
9452  if( set->nconflicthdlrs == 0 )
9453  return SCIP_OKAY;
9454 
9455  SCIPsetDebugMsg(set, "analyzing pseudo solution (obj: %g) that exceeds objective limit (%g)\n",
9456  SCIPlpGetPseudoObjval(lp, set, transprob), lp->cutoffbound);
9457 
9459  conflict->conflictset->usescutoffbound = TRUE;
9460 
9461  /* start timing */
9462  SCIPclockStart(conflict->pseudoanalyzetime, set);
9463  conflict->npseudocalls++;
9464 
9465  vars = transprob->vars;
9466  nvars = transprob->nvars;
9467  assert(nvars == 0 || vars != NULL);
9468 
9469  /* The current primal bound c* gives an upper bound for the current pseudo objective value:
9470  * min{c^T x | lb <= x <= ub} <= c*.
9471  * We have to transform this row into a >= inequality in order to use methods above:
9472  * -c* <= max{-c^T x | lb <= x <= ub}.
9473  * In the local subproblem, this row is violated. We want to undo bound changes while still keeping the
9474  * row violated.
9475  */
9476 
9477  /* get temporary memory for remembering variables' current bounds and corresponding bound change information
9478  * positions in variable's bound change information arrays
9479  */
9480  SCIP_CALL( SCIPsetAllocBufferArray(set, &curvarlbs, nvars) );
9481  SCIP_CALL( SCIPsetAllocBufferArray(set, &curvarubs, nvars) );
9482  SCIP_CALL( SCIPsetAllocBufferArray(set, &lbchginfoposs, nvars) );
9483  SCIP_CALL( SCIPsetAllocBufferArray(set, &ubchginfoposs, nvars) );
9484 
9485  /* get temporary memory for infeasibility proof coefficients */
9486  SCIP_CALL( SCIPsetAllocBufferArray(set, &pseudocoefs, nvars) );
9487 
9488  /* for an integral objective use the cutoff bound reduced by the cutoff bound delta to cut off up to the next better
9489  * objective value
9490  */
9491  pseudolhs = -(lp->cutoffbound - (SCIPprobIsObjIntegral(transprob) ? SCIPsetCutoffbounddelta(set) : 0.0));
9492 
9493  /* store the objective values as infeasibility proof coefficients, and recalculate the pseudo activity */
9494  pseudoact = 0.0;
9495  for( v = 0; v < nvars; ++v )
9496  {
9497  var = vars[v];
9498  pseudocoefs[v] = -SCIPvarGetObj(var);
9499  curvarlbs[v] = SCIPvarGetLbLocal(var);
9500  curvarubs[v] = SCIPvarGetUbLocal(var);
9501  lbchginfoposs[v] = var->nlbchginfos-1;
9502  ubchginfoposs[v] = var->nubchginfos-1;
9503 
9504  if( SCIPsetIsZero(set, pseudocoefs[v]) )
9505  {
9506  pseudocoefs[v] = 0.0;
9507  continue;
9508  }
9509 
9510  if( pseudocoefs[v] > 0.0 )
9511  pseudoact += pseudocoefs[v] * curvarubs[v];
9512  else
9513  pseudoact += pseudocoefs[v] * curvarlbs[v];
9514  }
9515  assert(SCIPsetIsFeasEQ(set, pseudoact, -SCIPlpGetPseudoObjval(lp, set, transprob)));
9516  SCIPsetDebugMsg(set, " -> recalculated pseudo infeasibility proof: %g <= %g\n", pseudolhs, pseudoact);
9517 
9518  /* check, if the pseudo row is still violated (after recalculation of pseudo activity) */
9519  if( SCIPsetIsFeasGT(set, pseudolhs, pseudoact) )
9520  {
9521  int nconss;
9522  int nliterals;
9523  int nreconvconss;
9524  int nreconvliterals;
9525 
9526  /* undo bound changes without destroying the infeasibility proof */
9527  SCIP_CALL( undoBdchgsProof(set, transprob, SCIPtreeGetCurrentDepth(tree), pseudocoefs, pseudolhs, &pseudoact,
9528  curvarlbs, curvarubs, lbchginfoposs, ubchginfoposs, NULL, NULL, NULL, lp->lpi) );
9529 
9530  /* analyze conflict on remaining bound changes */
9531  SCIP_CALL( conflictAnalyzeRemainingBdchgs(conflict, blkmem, set, stat, transprob, tree, FALSE, \
9532  lbchginfoposs, ubchginfoposs, &nconss, &nliterals, &nreconvconss, &nreconvliterals) );
9533  conflict->npseudosuccess += (nconss > 0 ? 1 : 0);
9534  conflict->npseudoconfconss += nconss;
9535  conflict->npseudoconfliterals += nliterals;
9536  conflict->npseudoreconvconss += nreconvconss;
9537  conflict->npseudoreconvliterals += nreconvliterals;
9538  if( success != NULL )
9539  *success = (nconss > 0);
9540  }
9541 
9542  /* free temporary memory */
9543  SCIPsetFreeBufferArray(set, &pseudocoefs);
9544  SCIPsetFreeBufferArray(set, &ubchginfoposs);
9545  SCIPsetFreeBufferArray(set, &lbchginfoposs);
9546  SCIPsetFreeBufferArray(set, &curvarubs);
9547  SCIPsetFreeBufferArray(set, &curvarlbs);
9548 
9549  /* flush conflict set storage */
9550  SCIP_CALL( SCIPconflictFlushConss(conflict, blkmem, set, stat, transprob, origprob, tree, reopt, lp, branchcand, eventqueue, cliquetable) );
9551 
9552  /* stop timing */
9553  SCIPclockStop(conflict->pseudoanalyzetime, set);
9554 
9555  return SCIP_OKAY;
9556 }
9557 
9558 /** gets time in seconds used for analyzing pseudo solution conflicts */
9560  SCIP_CONFLICT* conflict /**< conflict analysis data */
9561  )
9562 {
9563  assert(conflict != NULL);
9564 
9565  return SCIPclockGetTime(conflict->pseudoanalyzetime);
9566 }
9567 
9568 /** gets number of calls to pseudo solution conflict analysis */
9570  SCIP_CONFLICT* conflict /**< conflict analysis data */
9571  )
9572 {
9573  assert(conflict != NULL);
9574 
9575  return conflict->npseudocalls;
9576 }
9577 
9578 /** gets number of calls to pseudo solution conflict analysis that yield at least one conflict constraint */
9580  SCIP_CONFLICT* conflict /**< conflict analysis data */
9581  )
9582 {
9583  assert(conflict != NULL);
9584 
9585  return conflict->npseudosuccess;
9586 }
9587 
9588 /** gets number of conflict constraints detected in pseudo solution conflict analysis */
9590  SCIP_CONFLICT* conflict /**< conflict analysis data */
9591  )
9592 {
9593  assert(conflict != NULL);
9594 
9595  return conflict->npseudoconfconss;
9596 }
9597 
9598 /** gets total number of literals in conflict constraints created in pseudo solution conflict analysis */
9600  SCIP_CONFLICT* conflict /**< conflict analysis data */
9601  )
9602 {
9603  assert(conflict != NULL);
9604 
9605  return conflict->npseudoconfliterals;
9606 }
9607 
9608 /** gets number of reconvergence constraints detected in pseudo solution conflict analysis */
9610  SCIP_CONFLICT* conflict /**< conflict analysis data */
9611  )
9612 {
9613  assert(conflict != NULL);
9614 
9615  return conflict->npseudoreconvconss;
9616 }
9617 
9618 /** gets total number of literals in reconvergence constraints created in pseudo solution conflict analysis */
9620  SCIP_CONFLICT* conflict /**< conflict analysis data */
9621  )
9622 {
9623  assert(conflict != NULL);
9624 
9625  return conflict->npseudoreconvliterals;
9626 }
9627 
9628 
9629 /** enables or disables all clocks of \p conflict, depending on the value of the flag */
9631  SCIP_CONFLICT* conflict, /**< the conflict analysis data for which all clocks should be enabled or disabled */
9632  SCIP_Bool enable /**< should the clocks of the conflict analysis data be enabled? */
9633  )
9634 {
9635  assert(conflict != NULL);
9636 
9637  SCIPclockEnableOrDisable(conflict->boundlpanalyzetime, enable);
9638  SCIPclockEnableOrDisable(conflict->dIBclock, enable);
9639  SCIPclockEnableOrDisable(conflict->inflpanalyzetime, enable);
9640  SCIPclockEnableOrDisable(conflict->propanalyzetime, enable);
9641  SCIPclockEnableOrDisable(conflict->pseudoanalyzetime, enable);
9642  SCIPclockEnableOrDisable(conflict->sbanalyzetime, enable);
9643 }
9644 
enum SCIP_Result SCIP_RESULT
Definition: type_result.h:61
void SCIPconflictEnableOrDisableClocks(SCIP_CONFLICT *conflict, SCIP_Bool enable)
Definition: conflict.c:9630
SCIP_Longint SCIPconflictGetNStrongbranchSuccess(SCIP_CONFLICT *conflict)
Definition: conflict.c:9335
static SCIP_Bool bdchginfoIsResolvable(SCIP_BDCHGINFO *bdchginfo)
Definition: conflict.c:3862
SCIP_Bool solisbasic
Definition: struct_lp.h:372
#define ALLOWLOCAL
Definition: conflict.c:175
static SCIP_RETCODE conflictInitProofset(SCIP_CONFLICT *conflict, BMS_BLKMEM *blkmem)
Definition: conflict.c:967
enum SCIP_BoundType SCIP_BOUNDTYPE
Definition: type_lp.h:59
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:6481
SCIP_CLOCK * propanalyzetime
SCIP_Bool lpissolved
Definition: struct_lp.h:125
SCIP_Real SCIPbdchginfoGetRelaxedBound(SCIP_BDCHGINFO *bdchginfo)
Definition: var.c:18644
int SCIPpqueueNElems(SCIP_PQUEUE *pqueue)
Definition: misc.c:1477
SCIP_Bool SCIPconflicthdlrIsInitialized(SCIP_CONFLICTHDLR *conflicthdlr)
Definition: conflict.c:816
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:5851
void SCIPconflicthdlrSetInit(SCIP_CONFLICTHDLR *conflicthdlr, SCIP_DECL_CONFLICTINIT((*conflictinit)))
Definition: conflict.c:728
SCIP_Real sbup
Definition: struct_lp.h:154
SCIP_Longint ninflpconfliterals
SCIP_Longint SCIPconflictGetNLocalChgBds(SCIP_CONFLICT *conflict)
Definition: conflict.c:3824
SCIP_Bool primalchecked
Definition: struct_lp.h:121
void SCIPaggrRowFree(SCIP *scip, SCIP_AGGRROW **aggrrow)
Definition: cuts.c:1763
SCIP_Bool SCIPsetIsInfinity(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6215
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:8684
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:6825
#define BMSfreeBlockMemoryArrayNull(mem, ptr, num)
Definition: memory.h:470
#define NUMSTOP
Definition: conflict.c:6419
unsigned int repropagate
SCIP_Longint ninflpreconvconss
SCIP_Longint SCIPconflictGetNPropConflictConss(SCIP_CONFLICT *conflict)
Definition: conflict.c:5764
const char * SCIPconflicthdlrGetDesc(SCIP_CONFLICTHDLR *conflicthdlr)
Definition: conflict.c:782
#define MINFRAC
Definition: conflict.c:176
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:409
SCIP_Bool SCIPsetIsLE(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6273
static int conflictCalcMaxsize(SCIP_SET *set, SCIP_PROB *prob)
Definition: conflict.c:2091
internal methods for storing primal CIP solutions
void SCIPhistoryIncVSIDS(SCIP_HISTORY *history, SCIP_BRANCHDIR dir, SCIP_Real weight)
Definition: history.c:503
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:4414
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:15063
SCIP_PROP * SCIPbdchginfoGetInferProp(SCIP_BDCHGINFO *bdchginfo)
Definition: var.c:18609
SCIP_Real SCIPgetVarUbAtIndex(SCIP *scip, SCIP_VAR *var, SCIP_BDCHGIDX *bdchgidx, SCIP_Bool after)
Definition: scip_var.c:2128
int SCIPvarGetNLocksDownType(SCIP_VAR *var, SCIP_LOCKTYPE locktype)
Definition: var.c:3299
SCIP_Bool SCIPlpDiving(SCIP_LP *lp)
Definition: lp.c:17850
int nubchginfos
Definition: struct_var.h:269
SCIP_BDCHGINFO * SCIPvarGetBdchgInfoLb(SCIP_VAR *var, int pos)
Definition: var.c:18323
SCIP_Bool SCIPlpiIsInfinity(SCIP_LPI *lpi, SCIP_Real val)
Definition: lpi_clp.cpp:3931
#define BMSfreeMemoryArrayNull(ptr)
Definition: memory.h:150
SCIP_Longint ndualproofsinfsuccess
SCIP_Real * SCIPvarGetMultaggrScalars(SCIP_VAR *var)
Definition: var.c:17715
public methods for branch and bound tree
internal methods for branch and bound tree
SCIP_BDCHGIDX bdchgidx
Definition: struct_var.h:121
static SCIP_BDCHGINFO * conflictRemoveCand(SCIP_CONFLICT *conflict)
Definition: conflict.c:4732
SCIP_Real conflictlb
Definition: struct_var.h:219
static SCIP_Bool isBoundchgUseless(SCIP_SET *set, SCIP_BDCHGINFO *bdchginfo)
Definition: conflict.c:4257
SCIP_RETCODE SCIPaggrRowAddRow(SCIP *scip, SCIP_AGGRROW *aggrrow, SCIP_ROW *row, SCIP_Real weight, int sidetype)
Definition: cuts.c:1867
SCIP_Longint SCIPconflictGetNPropSuccess(SCIP_CONFLICT *conflict)
Definition: conflict.c:5754
SCIP_Real SCIPgetVarLbAtIndex(SCIP *scip, SCIP_VAR *var, SCIP_BDCHGIDX *bdchgidx, SCIP_Bool after)
Definition: scip_var.c:1992
SCIP_Real SCIPbdchginfoGetOldbound(SCIP_BDCHGINFO *bdchginfo)
Definition: var.c:18505
void SCIPconflicthdlrSetExit(SCIP_CONFLICTHDLR *conflicthdlr, SCIP_DECL_CONFLICTEXIT((*conflictexit)))
Definition: conflict.c:739
SCIP_PQUEUE * bdchgqueue
int SCIPconsGetValidDepth(SCIP_CONS *cons)
Definition: cons.c:8173
SCIP_Bool primalfeasible
Definition: struct_lp.h:368
SCIP_Longint dualproofsinfnnonzeros
public methods for memory management
SCIP_Longint nsbcalls
SCIP_RETCODE SCIPlpiGetDualfarkas(SCIP_LPI *lpi, SCIP_Real *dualfarkas)
Definition: lpi_clp.cpp:2857
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:1413
#define SCIPsetAllocBuffer(set, ptr)
Definition: set.h:1732
int nlpicols
Definition: struct_lp.h:317
SCIP_Bool SCIPsetIsFeasEQ(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6613
int SCIPvarGetNVlbs(SCIP_VAR *var)
Definition: var.c:18115
SCIP_VAR * SCIPbdchginfoGetVar(SCIP_BDCHGINFO *bdchginfo)
Definition: var.c:18525
SCIP_RETCODE SCIPlpiStartStrongbranch(SCIP_LPI *lpi)
Definition: lpi_clp.cpp:2006
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:2788
void SCIPconflicthdlrSetInitsol(SCIP_CONFLICTHDLR *conflicthdlr, SCIP_DECL_CONFLICTINITSOL((*conflictinitsol)))
Definition: conflict.c:750
SCIP_Longint SCIPconflictGetNBoundexceedingLPConflictConss(SCIP_CONFLICT *conflict)
Definition: conflict.c:8941
SCIP_PARAMDATA * SCIPparamGetData(SCIP_PARAM *param)
Definition: paramset.c:679
SCIP_Real SCIPvarGetLbGlobal(SCIP_VAR *var)
Definition: var.c:17923
SCIP_Longint SCIPconflictGetNAppliedGlobalConss(SCIP_CONFLICT *conflict)
Definition: conflict.c:3804
SCIP_Longint SCIPconflictGetNBoundexceedingLPIterations(SCIP_CONFLICT *conflict)
Definition: conflict.c:8981
SCIP_CLOCK * conflictlptime
Definition: struct_stat.h:171
SCIP_RETCODE SCIPlpiSetIntpar(SCIP_LPI *lpi, SCIP_LPPARAM type, int ival)
Definition: lpi_clp.cpp:3692
#define SCIP_MAXSTRLEN
Definition: def.h:302
int SCIPvarGetNLocksUpType(SCIP_VAR *var, SCIP_LOCKTYPE locktype)
Definition: var.c:3357
SCIP_Real SCIPconflicthdlrGetSetupTime(SCIP_CONFLICTHDLR *conflicthdlr)
Definition: conflict.c:838
public methods for conflict handler plugins and conflict analysis
static void lpbdchgsReset(SCIP_LPBDCHGS *lpbdchgs, int ncols)
Definition: conflict.c:886
void SCIPgmlWriteArc(FILE *file, unsigned int source, unsigned int target, const char *label, const char *color)
Definition: misc.c:638
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:1237
SCIP_Longint SCIPconflictGetNPseudoReconvergenceLiterals(SCIP_CONFLICT *conflict)
Definition: conflict.c:9619
internal methods for clocks and timing issues
SCIP_Longint SCIPconflictGetNGlobalChgBds(SCIP_CONFLICT *conflict)
Definition: conflict.c:3794
int lpdepth
Definition: struct_lp.h:241
SCIP_BOUNDCHG * boundchgs
Definition: struct_var.h:134
SCIP_Bool SCIPsetIsPositive(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6338
SCIP_Longint nappliedlocliterals
SCIP_VAR ** SCIPvarGetMultaggrVars(SCIP_VAR *var)
Definition: var.c:17703
static long bound
SCIP_CLOCK * inflpanalyzetime
SCIP_RETCODE SCIPlpiGetBase(SCIP_LPI *lpi, int *cstat, int *rstat)
Definition: lpi_clp.cpp:2967
SCIP_Real * bdchgubs
struct SCIP_ParamData SCIP_PARAMDATA
Definition: type_paramset.h:87
SCIP_Longint SCIPconflictGetNPseudoConflictLiterals(SCIP_CONFLICT *conflict)
Definition: conflict.c:9599
#define SCIPsetAllocCleanBufferArray(set, ptr, num)
Definition: set.h:1745
SCIP_RETCODE SCIPbdchginfoCreate(SCIP_BDCHGINFO **bdchginfo, BMS_BLKMEM *blkmem, SCIP_VAR *var, SCIP_BOUNDTYPE boundtype, SCIP_Real oldbound, SCIP_Real newbound)
Definition: var.c:16378
void SCIPconflicthdlrSetCopy(SCIP_CONFLICTHDLR *conflicthdlr, SCIP_DECL_CONFLICTCOPY((*conflictcopy)))
Definition: conflict.c:706
SCIP_Real SCIPvarGetLbLocal(SCIP_VAR *var)
Definition: var.c:17979
#define SCIP_CALL_FINALLY(x, y)
Definition: def.h:436
SCIP_Longint SCIPconflictGetNInfeasibleLPSuccess(SCIP_CONFLICT *conflict)
Definition: conflict.c:8851
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:6206
SCIP_Longint nappliedglbliterals
SCIP_Longint SCIPconflictGetNPropCalls(SCIP_CONFLICT *conflict)
Definition: conflict.c:5744
void SCIPsortIntIntInt(int *intarray1, int *intarray2, int *intarray3, int len)
SCIP_Longint npseudoreconvliterals
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:2766
static void proofsetCancelVarWithBound(SCIP_PROOFSET *proofset, SCIP_SET *set, SCIP_VAR *var, int pos, SCIP_Bool *valid)
Definition: conflict.c:1169
SCIP_RETCODE SCIPlpiChgSides(SCIP_LPI *lpi, int nrows, const int *ind, const SCIP_Real *lhs, const SCIP_Real *rhs)
Definition: lpi_clp.cpp:1167
const char * SCIProwGetName(SCIP_ROW *row)
Definition: lp.c:17354
void SCIPgmlWriteNode(FILE *file, unsigned int id, const char *label, const char *nodetype, const char *fillcolor, const char *bordercolor)
Definition: misc.c:496
static SCIP_RETCODE lpbdchgsCreate(SCIP_LPBDCHGS **lpbdchgs, SCIP_SET *set, int ncols)
Definition: conflict.c:864
SCIP_Longint SCIPconflictGetNStrongbranchIterations(SCIP_CONFLICT *conflict)
Definition: conflict.c:9385
SCIP_Real SCIPconflicthdlrGetTime(SCIP_CONFLICTHDLR *conflicthdlr)
Definition: conflict.c:848
static SCIP_RETCODE conflictsetCalcInsertDepth(SCIP_CONFLICTSET *conflictset, SCIP_SET *set, SCIP_TREE *tree)
Definition: conflict.c:1819
interface methods for specific LP solvers
SCIP_Bool SCIPvarIsBinary(SCIP_VAR *var)
Definition: var.c:17444
SCIP_Longint npropconfliterals
SCIP_Real SCIPsetInfinity(SCIP_SET *set)
Definition: set.c:6080
SCIP_RETCODE SCIPlpiGetIterations(SCIP_LPI *lpi, int *iterations)
Definition: lpi_clp.cpp:2921
static SCIP_RETCODE conflictAddConflictBound(SCIP_CONFLICT *conflict, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_BDCHGINFO *bdchginfo, SCIP_Real relaxedbd)
Definition: conflict.c:4214
int SCIPprobGetNVars(SCIP_PROB *prob)
Definition: prob.c:2352
SCIP_BDCHGINFO * ubchginfos
Definition: struct_var.h:249
SCIP_Bool SCIPbdchgidxIsEarlier(SCIP_BDCHGIDX *bdchgidx1, SCIP_BDCHGIDX *bdchgidx2)
Definition: var.c:18485
void SCIPconsMarkConflict(SCIP_CONS *cons)
Definition: cons.c:6996
SCIP_COL ** cols
Definition: struct_lp.h:301
int startnconss
Definition: struct_prob.h:85
void SCIPgmlWriteClosing(FILE *file)
Definition: misc.c:698
int nlpirows
Definition: struct_lp.h:320
SCIP_Longint nappliedglbconss
SCIP_Real SCIPvarGetLbLP(SCIP_VAR *var, SCIP_SET *set)
Definition: var.c:12944
SCIP_RETCODE SCIPvarScaleVSIDS(SCIP_VAR *var, SCIP_Real scalar)
Definition: var.c:15149
unsigned int nboundchgs
Definition: struct_var.h:132
SCIP_Longint SCIPconflictGetNDualproofsInfGlobal(SCIP_CONFLICT *conflict)
Definition: conflict.c:9255
datastructures for conflict analysis
SCIP_Longint npseudoreconvconss
void SCIPclockStop(SCIP_CLOCK *clck, SCIP_SET *set)
Definition: clock.c:360
SCIP_Longint SCIPconflictGetNInfeasibleLPReconvergenceConss(SCIP_CONFLICT *conflict)
Definition: conflict.c:8881
SCIP_Longint SCIPconflictGetNInfeasibleLPReconvergenceLiterals(SCIP_CONFLICT *conflict)
Definition: conflict.c:8891
SCIP_Real SCIProwGetLhs(SCIP_ROW *row)
Definition: lp.c:17295
#define FALSE
Definition: def.h:96
static void skipRedundantBdchginfos(SCIP_VAR *var, int *lbchginfopos, int *ubchginfopos)
Definition: conflict.c:6174
methods for the aggregation rows
static SCIP_BDCHGINFO * conflictFirstCand(SCIP_CONFLICT *conflict)
Definition: conflict.c:4776
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:5666
SCIP_Longint nlocchgbds
SCIP_Bool solved
Definition: struct_lp.h:367
void SCIPclockStart(SCIP_CLOCK *clck, SCIP_SET *set)
Definition: clock.c:290
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:638
SCIP_Bool dualchecked
Definition: struct_lp.h:371
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:6423
int SCIPsnprintf(char *t, int len, const char *s,...)
Definition: misc.c:10788
SCIP_Bool SCIPsetIsZero(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6327
#define TRUE
Definition: def.h:95
#define SCIPdebug(x)
Definition: pub_message.h:93
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:63
SCIP_Longint SCIPconflictGetNPropConflictLiterals(SCIP_CONFLICT *conflict)
Definition: conflict.c:5774
SCIP_Real * relaxedbds
unsigned int basisstatus
Definition: struct_lp.h:250
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:4218
int SCIPvarGetNVubs(SCIP_VAR *var)
Definition: var.c:18157
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:2897
int nlbchginfos
Definition: struct_var.h:267
int SCIPbdchginfoGetInferInfo(SCIP_BDCHGINFO *bdchginfo)
Definition: var.c:18620
SCIP_RETCODE SCIPlpiSetRealpar(SCIP_LPI *lpi, SCIP_LPPARAM type, SCIP_Real dval)
Definition: lpi_clp.cpp:3833
void SCIPconflicthdlrSetPriority(SCIP_CONFLICTHDLR *conflicthdlr, SCIP_SET *set, int priority)
Definition: conflict.c:802
SCIP_Real dualsol
Definition: struct_lp.h:107
SCIP_Real redcost
Definition: struct_lp.h:149
#define SCIPsetAllocBufferArray(set, ptr, num)
Definition: set.h:1734
int SCIPtreeGetCurrentDepth(SCIP_TREE *tree)
Definition: tree.c:8396
int SCIPvarGetProbindex(SCIP_VAR *var)
Definition: var.c:17613
SCIP_Longint npropcalls
unsigned int sbdownvalid
Definition: struct_lp.h:188
void * SCIPpqueueFirst(SCIP_PQUEUE *pqueue)
Definition: misc.c:1463
SCIP_RETCODE SCIPconflicthdlrExitsol(SCIP_CONFLICTHDLR *conflicthdlr, SCIP_SET *set)
Definition: conflict.c:614
SCIP_Real SCIPsetCutoffbounddelta(SCIP_SET *set)
Definition: set.c:6180
int SCIPsetCalcMemGrowSize(SCIP_SET *set, int num)
Definition: set.c:5794
unsigned int basisstatus
Definition: struct_lp.h:179
SCIP_Longint nglbchgbds
SCIP_Real * bdchglbs
public methods for problem variables
SCIP_Longint npropsuccess
SCIP_Real dualfarkas
Definition: struct_lp.h:215
#define EPSGE(x, y, eps)
Definition: def.h:215
int SCIPaggrRowGetNNz(SCIP_AGGRROW *aggrrow)
Definition: cuts.c:2559
SCIP_Real SCIPaggrRowGetRhs(SCIP_AGGRROW *aggrrow)
Definition: cuts.c:2589
void SCIPpqueueFree(SCIP_PQUEUE **pqueue)
Definition: misc.c:1272
static void conflictsetClear(SCIP_CONFLICTSET *conflictset)
Definition: conflict.c:1277
SCIP_ROW ** SCIPlpGetRows(SCIP_LP *lp)
Definition: lp.c:17615
SCIP_Bool diving
Definition: struct_lp.h:380
#define SCIPdebugMessage
Definition: pub_message.h:96
SCIP_RETCODE SCIPconflictFree(SCIP_CONFLICT **conflict, BMS_BLKMEM *blkmem)
Definition: conflict.c:4008
SCIP_Longint SCIPconflictGetNAppliedLiterals(SCIP_CONFLICT *conflict)
Definition: conflict.c:3784
SCIP_Real SCIPlpGetPseudoObjval(SCIP_LP *lp, SCIP_SET *set, SCIP_PROB *prob)
Definition: lp.c:13305
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:4358
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:463
static SCIP_RETCODE detectImpliedBounds(SCIP_SET *set, SCIP_PROB *prob, SCIP_STAT *stat, SCIP_TREE *tree, BMS_BLKMEM *blkmem, SCIP_PROB *origprob, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_CONFLICTSET *conflictset, int *nbdchgs, int *nredvars, SCIP_Bool *redundant)
Definition: conflict.c:2259
int SCIPbdchgidxGetPos(SCIP_BDCHGIDX *bdchgidx)
Definition: var.c:18455
static SCIP_RETCODE conflictQueueBound(SCIP_CONFLICT *conflict, SCIP_SET *set, SCIP_BDCHGINFO *bdchginfo, SCIP_Real relaxedbd)
Definition: conflict.c:4277
SCIP_Bool SCIPsetIsNegative(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6349
int SCIPnodeGetDepth(SCIP_NODE *node)
Definition: tree.c:7446
void SCIPconflicthdlrSetExitsol(SCIP_CONFLICTHDLR *conflicthdlr, SCIP_DECL_CONFLICTEXITSOL((*conflictexitsol)))
Definition: conflict.c:761
static SCIP_RETCODE conflictInsertProofset(SCIP_CONFLICT *conflict, SCIP_SET *set, SCIP_PROOFSET *proofset)
Definition: conflict.c:1977
methods for creating output for visualization tools (VBC, BAK)
void SCIPclockEnableOrDisable(SCIP_CLOCK *clck, SCIP_Bool enable)
Definition: clock.c:260
#define QUAD_ASSIGN(a, constant)
Definition: dbldblarith.h:51
SCIP_Real SCIPconflictGetGlobalApplTime(SCIP_CONFLICT *conflict)
Definition: conflict.c:5724
#define SCIPsetFreeBufferArray(set, ptr)
Definition: set.h:1741
unsigned int basisstatus
Definition: struct_lp.h:109
#define BMSfreeMemory(ptr)
Definition: memory.h:147
SCIP_Longint SCIPconflictGetNDualproofsInfNonzeros(SCIP_CONFLICT *conflict)
Definition: conflict.c:9275
void SCIPvarAdjustLb(SCIP_VAR *var, SCIP_SET *set, SCIP_Real *lb)
Definition: var.c:6526
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:3280
SCIP_Longint SCIPconflictGetNStrongbranchReconvergenceLiterals(SCIP_CONFLICT *conflict)
Definition: conflict.c:9375
SCIP_Longint SCIPconflictGetNDualproofsBndSuccess(SCIP_CONFLICT *conflict)
Definition: conflict.c:9285
SCIP_Real SCIPconflictGetPseudoTime(SCIP_CONFLICT *conflict)
Definition: conflict.c:9559
#define SCIP_DECL_CONFLICTEXIT(x)
SCIP_Longint nappliedlocconss
SCIP_Longint SCIPconflictGetNInfeasibleLPConflictLiterals(SCIP_CONFLICT *conflict)
Definition: conflict.c:8871
SCIP_Longint SCIPconflictGetNPropReconvergenceConss(SCIP_CONFLICT *conflict)
Definition: conflict.c:5784
SCIP_LPSOLSTAT SCIPlpGetSolstat(SCIP_LP *lp)
Definition: lp.c:13106
SCIP_VISUAL * visual
Definition: struct_stat.h:184
SCIP_Real SCIPgetRhsLinear(SCIP *scip, SCIP_CONS *cons)
int conflictlbcount
Definition: struct_var.h:270
internal methods for LP management
int SCIPvarGetNCliques(SCIP_VAR *var, SCIP_Bool varfixing)
Definition: var.c:18275
static void proofsetClear(SCIP_PROOFSET *proofset)
Definition: conflict.c:932
SCIP_Longint npseudosuccess
Definition: heur_padm.c:132
SCIP_RETCODE SCIPaddCoefLinear(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_Real val)
void SCIPinfoMessage(SCIP *scip, FILE *file, const char *formatstr,...)
Definition: scip_message.c:208
SCIP_Real SCIPconflictGetVarUb(SCIP_CONFLICT *conflict, SCIP_VAR *var)
Definition: conflict.c:4716
SCIP_Longint SCIPconflictGetNDualproofsInfSuccess(SCIP_CONFLICT *conflict)
Definition: conflict.c:9245
#define QUAD_TO_DBL(x)
Definition: dbldblarith.h:49
SCIP_Bool primalchecked
Definition: struct_lp.h:369
real eps
internal methods for branching and inference history
static char varGetChar(SCIP_VAR *var)
Definition: conflict.c:919
SCIP_Real SCIPconflictGetStrongbranchTime(SCIP_CONFLICT *conflict)
Definition: conflict.c:9235
SCIP_Longint SCIPconflictGetNAppliedLocalLiterals(SCIP_CONFLICT *conflict)
Definition: conflict.c:3844
SCIP_Bool strongbranching
Definition: struct_lp.h:377
SCIP_Longint SCIPconflictGetNPseudoConflictConss(SCIP_CONFLICT *conflict)
Definition: conflict.c:9589
SCIP_Longint ninflpiterations
#define POSTPROCESS
Definition: conflict.c:173
SCIP_Bool dualfeasible
Definition: struct_lp.h:122
int SCIPconflictstoreGetNDualInfProofs(SCIP_CONFLICTSTORE *conflictstore)
SCIP_Bool SCIPconsIsGlobal(SCIP_CONS *cons)
Definition: cons.c:8319
int SCIPlpGetNCols(SCIP_LP *lp)
Definition: lp.c:17578
SCIP_Real SCIPvarGetUbLP(SCIP_VAR *var, SCIP_SET *set)
Definition: var.c:13014
static SCIP_RETCODE conflictEnsureProofsetsMem(SCIP_CONFLICT *conflict, SCIP_SET *set, int num)
Definition: conflict.c:1928
SCIP_Bool SCIPsetIsGE(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6309
SCIP_HISTORY * glbhistorycrun
Definition: struct_stat.h:182
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:7138
static SCIP_Bool conflictsetIsRedundant(SCIP_CONFLICTSET *conflictset1, SCIP_CONFLICTSET *conflictset2)
Definition: conflict.c:1866
SCIP_RETCODE SCIPaggrRowAddObjectiveFunction(SCIP *scip, SCIP_AGGRROW *aggrrow, SCIP_Real rhs, SCIP_Real scale)
Definition: cuts.c:2012
int SCIPtreeGetFocusDepth(SCIP_TREE *tree)
Definition: tree.c:8321
#define SCIPdebugCheckConflict(blkmem, set, node, bdchginfos, relaxedbds, nliterals)
Definition: debug.h:295
void SCIPhistoryScaleVSIDS(SCIP_HISTORY *history, SCIP_Real scalar)
Definition: history.c:517
SCIP_Longint ndualproofsinflocal
SCIP_Longint npropconfconss
SCIP_Longint nboundlpcalls
SCIP_Real SCIPgetVarBdAtIndex(SCIP *scip, SCIP_VAR *var, SCIP_BOUNDTYPE boundtype, SCIP_BDCHGIDX *bdchgidx, SCIP_Bool after)
Definition: scip_var.c:2264
SCIP_Real * vals
Definition: struct_lp.h:229
enum SCIP_BranchDir SCIP_BRANCHDIR
Definition: type_history.h:48
SCIP_Real conflictrelaxedub
Definition: struct_var.h:222
SCIP_Longint SCIPnodeGetNumber(SCIP_NODE *node)
Definition: tree.c:7436
SCIP_Bool SCIPbdchginfoIsTighter(SCIP_BDCHGINFO *bdchginfo1, SCIP_BDCHGINFO *bdchginfo2)
Definition: var.c:18678
SCIP_RETCODE SCIPlpiSolveDual(SCIP_LPI *lpi)
Definition: lpi_clp.cpp:1880
SCIP_Real avgnnz
Definition: struct_stat.h:129
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:1188
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:9407
void SCIPconflicthdlrSetFree(SCIP_CONFLICTHDLR *conflicthdlr, SCIP_DECL_CONFLICTFREE((*conflictfree)))
Definition: conflict.c:717
SCIP_Real SCIPvarGetUbGlobal(SCIP_VAR *var)
Definition: var.c:17933
SCIP_Bool SCIPsetIsLT(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6255
#define BOUNDSWITCH
Definition: conflict.c:172
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:2687
SCIP_CLOCK * setuptime
SCIP_RETCODE SCIPconflicthdlrExit(SCIP_CONFLICTHDLR *conflicthdlr, SCIP_SET *set)
Definition: conflict.c:559
SCIP_CLOCK * pseudoanalyzetime
public methods for handling parameter settings
SCIP_RETCODE SCIPconflicthdlrInitsol(SCIP_CONFLICTHDLR *conflicthdlr, SCIP_SET *set)
Definition: conflict.c:590
public methods for managing constraints
SCIP_DOMCHG * domchg
Definition: struct_tree.h:159
static void proofsetFree(SCIP_PROOFSET **proofset, BMS_BLKMEM *blkmem)
Definition: conflict.c:982
int lpiitlim
Definition: struct_lp.h:345
SCIP_Real lb
Definition: struct_lp.h:138
SCIP_Real dualsol
Definition: struct_lp.h:213
SCIP_Real conflictrelaxedlb
Definition: struct_var.h:221
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:6038
#define SCIP_DECL_CONFLICTINITSOL(x)
SCIP_CLOCK * boundlpanalyzetime
#define BMSduplicateBlockMemoryArray(mem, ptr, source, num)
Definition: memory.h:464
SCIP_Longint SCIPconflictGetNInfeasibleLPConflictConss(SCIP_CONFLICT *conflict)
Definition: conflict.c:8861
SCIP_Real sbdown
Definition: struct_lp.h:153
SCIP_Longint ninflpreconvliterals
#define SCIP_DECL_CONFLICTEXEC(x)
SCIP_BDCHGINFO ** tmpbdchginfos
SCIP_CLOCK * conflicttime
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:7421
void SCIPhistoryIncNActiveConflicts(SCIP_HISTORY *history, SCIP_BRANCHDIR dir, SCIP_Real length)
Definition: history.c:542
SCIP_BOUNDTYPE SCIPboundtypeOpposite(SCIP_BOUNDTYPE boundtype)
Definition: lp.c:17206
internal methods for storing and manipulating the main problem
#define SCIPerrorMessage
Definition: pub_message.h:64
const char * SCIPconshdlrGetName(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4182
#define SCIPdebugPrintf
Definition: pub_message.h:99
#define QUAD_EPSILON
Definition: dbldblarith.h:42
void SCIPsortIntInt(int *intarray1, int *intarray2, int len)
static SCIP_RETCODE conflictsetAddBounds(SCIP_CONFLICT *conflict, SCIP_CONFLICTSET *conflictset, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_BDCHGINFO **bdchginfos, int nbdchginfos)
Definition: conflict.c:1606
static SCIP_RETCODE conflictsetEnsureBdchginfosMem(SCIP_CONFLICTSET *conflictset, BMS_BLKMEM *blkmem, SCIP_SET *set, int num)
Definition: conflict.c:1369
SCIP_Bool SCIPbdchgidxIsEarlierNonNull(SCIP_BDCHGIDX *bdchgidx1, SCIP_BDCHGIDX *bdchgidx2)
Definition: var.c:18465
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:8961
SCIP_Bool dualchecked
Definition: struct_lp.h:123
SCIP_COL ** cols
Definition: struct_lp.h:227
void SCIPclockReset(SCIP_CLOCK *clck)
Definition: clock.c:209
SCIP_Longint ndualproofsbndglobal
SCIP_Longint nconflictlpiterations
Definition: struct_stat.h:79
SCIP_RETCODE SCIPupgradeConsLinear(SCIP *scip, SCIP_CONS *cons, SCIP_CONS **upgdcons)
static SCIP_Bool conflictMarkBoundCheckPresence(SCIP_CONFLICT *conflict, SCIP_SET *set, SCIP_BDCHGINFO *bdchginfo, SCIP_Real relaxedbd)
Definition: conflict.c:4125
SCIP_Bool SCIProwIsLocal(SCIP_ROW *row)
Definition: lp.c:17404
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:7835
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:3001
SCIP_NODE ** path
Definition: struct_tree.h:188
SCIP_Longint SCIPconflictGetNPseudoReconvergenceConss(SCIP_CONFLICT *conflict)
Definition: conflict.c:9609
SCIP_ROW ** lpirows
Definition: struct_lp.h:298
#define SCIPfreeBufferArrayNull(scip, ptr)
Definition: scip_mem.h:137
unsigned int sbupvalid
Definition: struct_lp.h:190
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:1077
SCIP_Longint SCIPconflictGetNAppliedLocalConss(SCIP_CONFLICT *conflict)
Definition: conflict.c:3834
#define QUAD(x)
Definition: dbldblarith.h:47
SCIP_Real lhs
Definition: struct_lp.h:204
SCIP_Bool SCIPlpiIsPrimalInfeasible(SCIP_LPI *lpi)
Definition: lpi_clp.cpp:2502
const char * SCIPconsGetName(SCIP_CONS *cons)
Definition: cons.c:8090
static SCIP_RETCODE conflictEnsureConflictsetsMem(SCIP_CONFLICT *conflict, SCIP_SET *set, int num)
Definition: conflict.c:1952
static SCIP_RETCODE convertToActiveVar(SCIP_VAR **var, SCIP_SET *set, SCIP_BOUNDTYPE *boundtype, SCIP_Real *bound)
Definition: conflict.c:4323
SCIP_Longint npropreconvconss
unsigned int pos
Definition: struct_var.h:122
static SCIP_Real conflictsetCalcScore(SCIP_CONFLICTSET *conflictset, SCIP_SET *set)
Definition: conflict.c:1399
SCIP_PROOFSET * proofset
const char * SCIPvarGetName(SCIP_VAR *var)
Definition: var.c:17264
SCIP_Real SCIPconflictGetBoundexceedingLPTime(SCIP_CONFLICT *conflict)
Definition: conflict.c:8911
static SCIP_RETCODE conflictsetCreate(SCIP_CONFLICTSET **conflictset, BMS_BLKMEM *blkmem)
Definition: conflict.c:1296
SCIP_Real SCIPclockGetTime(SCIP_CLOCK *clck)
Definition: clock.c:438
SCIP_Real SCIPsetFeasCeil(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6791
#define SCIPsetReallocBufferArray(set, ptr, num)
Definition: set.h:1738
SCIP_Real cutoffbound
Definition: struct_lp.h:284
#define NULL
Definition: lpi_spx1.cpp:164
SCIP_PROOFSET ** proofsets
static SCIP_RETCODE proofsetCreate(SCIP_PROOFSET **proofset, BMS_BLKMEM *blkmem)
Definition: conflict.c:946
SCIP_Longint SCIPconflictGetNStrongbranchReconvergenceConss(SCIP_CONFLICT *conflict)
Definition: conflict.c:9365
int * SCIPaggrRowGetInds(SCIP_AGGRROW *aggrrow)
Definition: cuts.c:2549
data structures for branch and bound tree
SCIP_HISTORY * glbhistory
Definition: struct_stat.h:181
#define REALABS(x)
Definition: def.h:210
SCIP_Longint SCIPconflictGetNDualproofsBndNonzeros(SCIP_CONFLICT *conflict)
Definition: conflict.c:9315
void SCIPsortedvecInsertIntPtrReal(int *intarray, void **ptrarray, SCIP_Real *realarray, int keyval, void *field1val, SCIP_Real field2val, int *len, int *pos)
SCIP_Longint ninflpcalls
SCIP_Longint nconflictlps
Definition: struct_stat.h:213
SCIP_Bool SCIPprobIsObjIntegral(SCIP_PROB *prob)
Definition: prob.c:2297
void SCIPgmlWriteEdge(FILE *file, unsigned int source, unsigned int target, const char *label, const char *color)
Definition: misc.c:594
SCIP_RETCODE SCIPconflicthdlrFree(SCIP_CONFLICTHDLR **conflicthdlr, SCIP_SET *set)
Definition: conflict.c:494
void SCIPaggrRowRemoveZeros(SCIP *scip, SCIP_AGGRROW *aggrrow, SCIP_Bool useglbbounds, SCIP_Bool *valid)
Definition: cuts.c:2479
SCIP_Longint SCIPconflictGetNStrongbranchConflictLiterals(SCIP_CONFLICT *conflict)
Definition: conflict.c:9355
struct SCIP_ConflicthdlrData SCIP_CONFLICTHDLRDATA
Definition: type_conflict.h:49
SCIP_DECL_SORTPTRCOMP(SCIPconflicthdlrComp)
Definition: conflict.c:362
internal methods for global SCIP settings
internal methods for storing conflicts
#define SCIP_CALL(x)
Definition: def.h:394
SCIP_Longint SCIPconflictGetNDualproofsBndLocal(SCIP_CONFLICT *conflict)
Definition: conflict.c:9305
SCIP_Real activity
Definition: struct_lp.h:108
static SCIP_Real * proofsetGetVals(SCIP_PROOFSET *proofset)
Definition: conflict.c:1033
SCIP_Bool SCIPbdchginfoHasInferenceReason(SCIP_BDCHGINFO *bdchginfo)
Definition: var.c:18664
SCIP_Bool SCIPsetIsFeasGE(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6701
int SCIPlpGetNRows(SCIP_LP *lp)
Definition: lp.c:17625
SCIP_VAR * h
Definition: circlepacking.c:68
SCIP_Bool SCIPvarIsRelaxationOnly(SCIP_VAR *var)
Definition: var.c:17551
#define SCIP_DECL_CONFLICTCOPY(x)
Definition: type_conflict.h:86
SCIP_Longint SCIPconflictGetNPseudoSuccess(SCIP_CONFLICT *conflict)
Definition: conflict.c:9579
SCIP_Real SCIProwGetRhs(SCIP_ROW *row)
Definition: lp.c:17305
SCIP_Bool SCIPbdchginfoIsRedundant(SCIP_BDCHGINFO *bdchginfo)
Definition: var.c:18653
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:3029
SCIP_Bool SCIPsetIsEQ(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6237
SCIP_Real vsidsweight
Definition: struct_stat.h:132
SCIP_LPI * SCIPlpGetLPI(SCIP_LP *lp)
Definition: lp.c:17777
static SCIP_RETCODE conflictsetAddBound(SCIP_CONFLICTSET *conflictset, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_BDCHGINFO *bdchginfo, SCIP_Real relaxedbd)
Definition: conflict.c:1533
SCIP_LPI * lpi
Definition: struct_lp.h:296
#define SCIPquadprecProdDD(r, a, b)
Definition: dbldblarith.h:58
SCIP_Longint SCIPconflictGetNInfeasibleLPCalls(SCIP_CONFLICT *conflict)
Definition: conflict.c:8841
SCIP_BDCHGIDX * SCIPbdchginfoGetIdx(SCIP_BDCHGINFO *bdchginfo)
Definition: var.c:18575
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:4830
static SCIP_CONFTYPE proofsetGetConftype(SCIP_PROOFSET *proofset)
Definition: conflict.c:1066
void * SCIPpqueueRemove(SCIP_PQUEUE *pqueue)
Definition: misc.c:1443
SCIP_CLOCK * sbanalyzetime
SCIP_Longint dualproofsbndnnonzeros
SCIP_Bool SCIPsetIsFeasLE(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6657
#define BMSduplicateMemoryArray(ptr, source, num)
Definition: memory.h:145
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:6538
SCIP_RETCODE SCIPclockCreate(SCIP_CLOCK **clck, SCIP_CLOCKTYPE clocktype)
Definition: clock.c:170
methods commonly used for presolving
SCIP_Longint nboundlpsuccess
SCIP_RETCODE SCIPconflicthdlrInit(SCIP_CONFLICTHDLR *conflicthdlr, SCIP_SET *set)
Definition: conflict.c:522
void SCIPvarAdjustBd(SCIP_VAR *var, SCIP_SET *set, SCIP_BOUNDTYPE boundtype, SCIP_Real *bd)
Definition: var.c:6560
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:8605
SCIP_Bool SCIPlpiWasSolved(SCIP_LPI *lpi)
Definition: lpi_clp.cpp:2386
SCIP_CONFLICTSET * conflictset
#define BMSfreeBlockMemory(mem, ptr)
Definition: memory.h:467
SCIP_Longint nboundlpreconvconss
internal methods for problem variables
void SCIPsortedvecDelPosIntPtrReal(int *intarray, void **ptrarray, SCIP_Real *realarray, int pos, int *len)
SCIP_Bool SCIPsetIsIntegral(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6360
SCIP_RETCODE SCIPlpiGetObjval(SCIP_LPI *lpi, SCIP_Real *objval)
Definition: lpi_clp.cpp:2766
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:7744
void SCIPnodePropagateAgain(SCIP_NODE *node, SCIP_SET *set, SCIP_STAT *stat, SCIP_TREE *tree)
Definition: tree.c:1248
static SCIP_RETCODE sortLocalRows(SCIP_SET *set, SCIP_AGGRROW *aggrrow, SCIP_ROW **rows, int *rowinds, int *rowdepth, int nrows)
Definition: conflict.c:6757
int SCIPtreeGetEffectiveRootDepth(SCIP_TREE *tree)
Definition: tree.c:8435
#define SCIP_Bool
Definition: def.h:93
#define SCIPsetFreeBuffer(set, ptr)
Definition: set.h:1739
SCIP_Real redcost
Definition: struct_lp.h:96
SCIP_Real * vals
SCIP_Real SCIPaggrRowCalcEfficacyNorm(SCIP *scip, SCIP_AGGRROW *aggrrow)
Definition: cuts.c:2166
#define BMSallocBlockMemoryArray(mem, ptr, num)
Definition: memory.h:456
int SCIPconflicthdlrGetPriority(SCIP_CONFLICTHDLR *conflicthdlr)
Definition: conflict.c:792
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:737
SCIP_Bool SCIPcutsTightenCoefficients(SCIP *scip, SCIP_Bool cutislocal, SCIP_Real *cutcoefs, SCIP_Real *cutrhs, int *cutinds, int *cutnnz, int *nchgcoefs)
Definition: cuts.c:1535
int SCIPbdchginfoGetPos(SCIP_BDCHGINFO *bdchginfo)
Definition: var.c:18565
int ncontvars
Definition: struct_prob.h:74
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:6966
unsigned int depth
Definition: struct_tree.h:160
SCIP_Real SCIPlpiInfinity(SCIP_LPI *lpi)
Definition: lpi_clp.cpp:3919
static const char * paramname[]
Definition: lpi_msk.c:5040
SCIP_Bool SCIPlpiIsDualFeasible(SCIP_LPI *lpi)
Definition: lpi_clp.cpp:2609
SCIP_Bool SCIPconflictApplicable(SCIP_SET *set)
Definition: conflict.c:3902
SCIP_Bool SCIPvarIsInLP(SCIP_VAR *var)
Definition: var.c:17645
SCIP_RETCODE SCIPconsRelease(SCIP_CONS **cons, BMS_BLKMEM *blkmem, SCIP_SET *set)
Definition: cons.c:6208
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:7428
static SCIP_RETCODE proofsetAddAggrrow(SCIP_PROOFSET *proofset, SCIP_SET *set, BMS_BLKMEM *blkmem, SCIP_AGGRROW *aggrrow)
Definition: conflict.c:1128
void SCIPclockFree(SCIP_CLOCK **clck)
Definition: clock.c:185
SCIP_Bool SCIPlpDivingObjChanged(SCIP_LP *lp)
Definition: lp.c:17860
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:8998
#define MAX(x, y)
Definition: tclique_def.h:92
unsigned int basisstatus
Definition: struct_lp.h:97
SCIP_CONSHDLR * SCIPconsGetHdlr(SCIP_CONS *cons)
Definition: cons.c:8110
#define SCIPdebugCheckConflictFrontier(blkmem, set, node, bdchginfo, bdchginfos, relaxedbds, nliterals, bdchgqueue, forcedbdchgqueue)
Definition: debug.h:296
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:2109
#define SCIPsetDebugMsg
Definition: set.h:1770
SCIP_Real conflictub
Definition: struct_var.h:220
SCIP_PQUEUE * forcedbdchgqueue
SCIP_RETCODE SCIPfreeSol(SCIP *scip, SCIP_SOL **sol)
Definition: scip_sol.c:985
SCIP_Real oldbound
Definition: struct_var.h:117
SCIP_Bool SCIPprobAllColsInLP(SCIP_PROB *prob, SCIP_SET *set, SCIP_LP *lp)
Definition: prob.c:2309
SCIP_Real SCIPvarGetObj(SCIP_VAR *var)
Definition: var.c:17771
SCIP_Real SCIPbdchginfoGetNewbound(SCIP_BDCHGINFO *bdchginfo)
Definition: var.c:18515
SCIP_Longint SCIPconflictGetNStrongbranchConflictConss(SCIP_CONFLICT *conflict)
Definition: conflict.c:9345
static void conflictsetCalcConflictDepth(SCIP_CONFLICTSET *conflictset)
Definition: conflict.c:1775
static SCIP_DECL_PARAMCHGD(paramChgdConflicthdlrPriority)
Definition: conflict.c:375
#define EPSLE(x, y, eps)
Definition: def.h:213
void SCIPsortLongPtrRealRealBool(SCIP_Longint *longarray, void **ptrarray, SCIP_Real *realarray, SCIP_Real *realarray2, SCIP_Bool *boolarray, int len)
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:2537
#define SCIPquadprecProdQD(r, a, b)
Definition: dbldblarith.h:63
void ** SCIPpqueueElems(SCIP_PQUEUE *pqueue)
Definition: misc.c:1488
SCIP_RETCODE SCIPlpiSetBase(SCIP_LPI *lpi, const int *cstat, const int *rstat)
Definition: lpi_clp.cpp:3067
static SCIP_RETCODE updateStatistics(SCIP_CONFLICT *conflict, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_CONFLICTSET *conflictset, int insertdepth)
Definition: conflict.c:2140
#define BMScopyMemoryArray(ptr, source, num)
Definition: memory.h:136
int SCIPconflictGetNConflicts(SCIP_CONFLICT *conflict)
Definition: conflict.c:3764
SCIP_COL * SCIPvarGetCol(SCIP_VAR *var)
Definition: var.c:17634
SCIP_Longint SCIPconflictGetNBoundexceedingLPCalls(SCIP_CONFLICT *conflict)
Definition: conflict.c:8921
void SCIPsortIntPtrReal(int *intarray, void **ptrarray, SCIP_Real *realarray, int len)
Constraint handler for linear constraints in their most general form, .
#define MAXFRAC
Definition: conflict.c:177
datastructures for problem statistics
int SCIPvarGetMultaggrNVars(SCIP_VAR *var)
Definition: var.c:17691
SCIP_Longint nboundlpreconvliterals
SCIP_Real ub
Definition: struct_lp.h:139
SCIP_Longint nsbconfconss
#define BMSclearMemory(ptr)
Definition: memory.h:131
SCIP_Bool SCIPsetIsFeasLT(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6635
SCIP_Longint nsbconfliterals
SCIP_Bool SCIPlpiIsOptimal(SCIP_LPI *lpi)
Definition: lpi_clp.cpp:2623
SCIP_Longint SCIPconflictGetNBoundexceedingLPReconvergenceLiterals(SCIP_CONFLICT *conflict)
Definition: conflict.c:8971
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:15199
SCIP_ROW ** rows
Definition: struct_lp.h:303
SCIP_Longint nboundlpiterations
#define SCIPquadprecSumQQ(r, a, b)
Definition: dbldblarith.h:67
#define debugPrintViolationInfo(...)
Definition: conflict.c:7374
SCIP_Bool SCIPprobIsTransformed(SCIP_PROB *prob)
Definition: prob.c:2287
SCIP_BOUNDTYPE SCIPbdchginfoGetInferBoundtype(SCIP_BDCHGINFO *bdchginfo)
Definition: var.c:18632
const char * SCIPpropGetName(SCIP_PROP *prop)
Definition: prop.c:941
int conflictubcount
Definition: struct_var.h:271
SCIP_RETCODE SCIPlpiChgBounds(SCIP_LPI *lpi, int ncols, const int *ind, const SCIP_Real *lb, const SCIP_Real *ub)
Definition: lpi_clp.cpp:1084
SCIP_BDCHGINFO * SCIPvarGetBdchgInfoUb(SCIP_VAR *var, int pos)
Definition: var.c:18343
SCIP_Longint npseudoconfliterals
SCIP_Longint ninflpconfconss
SCIP_BDCHGINFO * SCIPvarGetBdchgInfo(SCIP_VAR *var, SCIP_BOUNDTYPE boundtype, SCIP_BDCHGIDX *bdchgidx, SCIP_Bool after)
Definition: var.c:16534
#define SCIP_REAL_MAX
Definition: def.h:187
static SCIP_RETCODE conflictsetCopy(SCIP_CONFLICTSET **targetconflictset, BMS_BLKMEM *blkmem, SCIP_CONFLICTSET *sourceconflictset, int nadditionalelems)
Definition: conflict.c:1316
int SCIPparamGetInt(SCIP_PARAM *param)
Definition: paramset.c:734
SCIP_Real rhs
Definition: struct_lp.h:205
SCIP_Longint SCIPconflictGetNPseudoCalls(SCIP_CONFLICT *conflict)
Definition: conflict.c:9569
SCIP_Real constant
Definition: struct_lp.h:203
static void lpbdchgsFree(SCIP_LPBDCHGS **lpbdchgs, SCIP_SET *set)
Definition: conflict.c:899
SCIP_RETCODE SCIPpqueueCreate(SCIP_PQUEUE **pqueue, int initsize, SCIP_Real sizefac, SCIP_DECL_SORTPTRCOMP((*ptrcomp)), SCIP_DECL_PQUEUEELEMCHGPOS((*elemchgpos)))
Definition: misc.c:1245
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:59
#define SCIP_REAL_MIN
Definition: def.h:188
methods for sorting joint arrays of various types
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_Real SCIPsetFeasFloor(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6780
SCIP_Real SCIProwGetConstant(SCIP_ROW *row)
Definition: lp.c:17261
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:5812
SCIP_DOMCHGBOUND domchgbound
Definition: struct_var.h:162
void SCIPconflicthdlrSetData(SCIP_CONFLICTHDLR *conflicthdlr, SCIP_CONFLICTHDLRDATA *conflicthdlrdata)
Definition: conflict.c:695
SCIP_Real SCIPconflictGetInfeasibleLPTime(SCIP_CONFLICT *conflict)
Definition: conflict.c:8831
SCIP_RETCODE SCIPconflictCreate(SCIP_CONFLICT **conflict, BMS_BLKMEM *blkmem, SCIP_SET *set)
Definition: conflict.c:3918
int SCIPcolGetNNonz(SCIP_COL *col)
Definition: lp.c:17129
void SCIPvisualFoundConflict(SCIP_VISUAL *visual, SCIP_STAT *stat, SCIP_NODE *node)
Definition: visual.c:612
SCIP_Longint SCIPconflictGetNBoundexceedingLPSuccess(SCIP_CONFLICT *conflict)
Definition: conflict.c:8931
SCIP_LPSOLSTAT lpsolstat
Definition: struct_lp.h:118
unsigned int boundtype
Definition: struct_var.h:124
SCIP_RETCODE SCIPlpiEndStrongbranch(SCIP_LPI *lpi)
Definition: lpi_clp.cpp:2018
SCIP_VAR * SCIPcolGetVar(SCIP_COL *col)
Definition: lp.c:17045
public methods for solutions
SCIP_Longint lastconflictnode
Definition: struct_stat.h:112
internal methods for conflict analysis
#define SCIPsetFreeCleanBufferArray(set, ptr)
Definition: set.h:1748
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:3399
SCIP_RETCODE SCIPpqueueInsert(SCIP_PQUEUE *pqueue, void *elem)
Definition: misc.c:1344
static const SCIP_Real scalars[]
Definition: lp.c:5747
SCIP_Longint nsbsuccess
int lpipos
Definition: struct_lp.h:173
SCIP_NODE * SCIPtreeGetRootNode(SCIP_TREE *tree)
Definition: tree.c:8446
static int * proofsetGetInds(SCIP_PROOFSET *proofset)
Definition: conflict.c:1022
void SCIPsetSortConflicthdlrs(SCIP_SET *set)
Definition: set.c:4079
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:2087
int SCIPbdchginfoGetDepth(SCIP_BDCHGINFO *bdchginfo)
Definition: var.c:18555
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:8529
unsigned int redundant
Definition: struct_var.h:126
public methods for conflict analysis handlers
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:6001
SCIP_Longint nsbreconvliterals
static void conflictsetFree(SCIP_CONFLICTSET **conflictset, BMS_BLKMEM *blkmem)
Definition: conflict.c:1353
SCIP_Longint nboundlpconfliterals
SCIP_Bool flushed
Definition: struct_lp.h:366
SCIP_RETCODE SCIPreleaseCons(SCIP *scip, SCIP_CONS **cons)
Definition: scip_cons.c:1119
SCIP_Bool SCIPlpiHasDualRay(SCIP_LPI *lpi)
Definition: lpi_clp.cpp:2556
int nrows
Definition: struct_lp.h:334
static SCIP_RETCODE conflictInsertConflictset(SCIP_CONFLICT *conflict, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_CONFLICTSET **conflictset)
Definition: conflict.c:1997
const char * SCIPconflicthdlrGetName(SCIP_CONFLICTHDLR *conflicthdlr)
Definition: conflict.c:772
SCIP_VAR * var
Definition: struct_var.h:119
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:4056
data structures for LP management
#define USEVBDS
Definition: conflict.c:174
SCIP_Real * conflictsetscores
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:4475
SCIP_Bool SCIPsetIsGT(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6291
datastructures for problem variables
SCIP_VARSTATUS SCIPvarGetStatus(SCIP_VAR *var)
Definition: var.c:17383
SCIP_Bool SCIPlpiIsObjlimExc(SCIP_LPI *lpi)
Definition: lpi_clp.cpp:2690
int SCIProwGetLPPos(SCIP_ROW *row)
Definition: lp.c:17504
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:5920
SCIP_Real lpobjval
Definition: struct_lp.h:271
SCIP_Real primsol
Definition: struct_lp.h:95
#define SCIP_Real
Definition: def.h:186
static SCIP_RETCODE addRowToAggrRow(SCIP_SET *set, SCIP_ROW *row, SCIP_Real weight, SCIP_AGGRROW *aggrrow)
Definition: conflict.c:6677
SCIP_Bool solisbasic
Definition: struct_lp.h:124
SCIP_VAR ** vars
Definition: struct_prob.h:64
enum SCIP_ConflictType SCIP_CONFTYPE
Definition: type_conflict.h:65
SCIP_VAR * SCIPbdchginfoGetInferVar(SCIP_BDCHGINFO *bdchginfo)
Definition: var.c:18585
SCIP_Longint npseudocalls
SCIP_Real lpiobjlim
Definition: struct_lp.h:286
SCIP_Longint SCIPconflictGetNStrongbranchCalls(SCIP_CONFLICT *conflict)
Definition: conflict.c:9325
SCIP_Longint SCIPconflictGetNInfeasibleLPIterations(SCIP_CONFLICT *conflict)
Definition: conflict.c:8901
SCIP_Real SCIPconflictGetVarLb(SCIP_CONFLICT *conflict, SCIP_VAR *var)
Definition: conflict.c:4699
#define SCIPsetDebugMsgPrint
Definition: set.h:1771
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:3555
unsigned int hasrelaxonlyvar
SCIP_VAR ** SCIPprobGetVars(SCIP_PROB *prob)
Definition: prob.c:2397
SCIP_RETCODE SCIPconflictIsVarUsed(SCIP_CONFLICT *conflict, SCIP_VAR *var, SCIP_SET *set, SCIP_BOUNDTYPE boundtype, SCIP_BDCHGIDX *bdchgidx, SCIP_Bool *used)
Definition: conflict.c:4639
#define BMSallocMemory(ptr)
Definition: memory.h:120
#define SCIP_INVALID
Definition: def.h:206
#define BMSreallocMemoryArray(ptr, num)
Definition: memory.h:129
SCIP_CLOCK * dIBclock
#define SCIP_DECL_CONFLICTINIT(x)
internal methods for constraints and constraint handlers
SCIP_RETCODE SCIPaggrRowCreate(SCIP *scip, SCIP_AGGRROW **aggrrow)
Definition: cuts.c:1731
static SCIP_Bool checkRedundancy(SCIP_SET *set, SCIP_CONFLICTSET *conflictset)
Definition: conflict.c:2194
#define SCIPquadprecSumDD(r, a, b)
Definition: dbldblarith.h:60
SCIP_Real primsol
Definition: struct_lp.h:148
SCIP_Longint nsbiterations
SCIP_Longint SCIPconflictGetNAppliedGlobalLiterals(SCIP_CONFLICT *conflict)
Definition: conflict.c:3814
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:5379
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:1608
#define SCIP_Longint
Definition: def.h:171
SCIP_CONS * SCIPbdchginfoGetInferCons(SCIP_BDCHGINFO *bdchginfo)
Definition: var.c:18597
SCIP_Bool SCIPsetIsDualfeasZero(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6934
SCIP_Real SCIPvarGetAvgSol(SCIP_VAR *var)
Definition: var.c:14074
int SCIPvarGetIndex(SCIP_VAR *var)
Definition: var.c:17603
int SCIProwGetLPDepth(SCIP_ROW *row)
Definition: lp.c:17515
void SCIPconflicthdlrEnableOrDisableClocks(SCIP_CONFLICTHDLR *conflicthdlr, SCIP_Bool enable)
Definition: conflict.c:826
SCIP_Bool SCIPsetIsFeasGT(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6679
SCIP_VARTYPE SCIPvarGetType(SCIP_VAR *var)
Definition: var.c:17429
SCIP_Longint npseudoconfconss
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:995
SCIP_Real SCIPconflictstoreGetAvgNnzDualInfProofs(SCIP_CONFLICTSTORE *conflictstore)
SCIP_Bool dualfeasible
Definition: struct_lp.h:370
static void conflictFreeTmpBdchginfos(SCIP_CONFLICT *conflict, BMS_BLKMEM *blkmem)
Definition: conflict.c:1261
enum SCIP_Vartype SCIP_VARTYPE
Definition: type_var.h:69
SCIP_Longint SCIPconflictGetNAppliedConss(SCIP_CONFLICT *conflict)
Definition: conflict.c:3774
static INLINE SCIP_Real SCIPaggrRowGetProbvarValue(SCIP_AGGRROW *aggrrow, int probindex)
Definition: cuts.h:251
SCIP_Real newbound
Definition: struct_var.h:118
SCIP_Real SCIPvarGetUbLocal(SCIP_VAR *var)
Definition: var.c:17989
SCIP_Longint SCIPconflictGetNBoundexceedingLPConflictLiterals(SCIP_CONFLICT *conflict)
Definition: conflict.c:8951
void SCIPgmlWriteOpening(FILE *file, SCIP_Bool directed)
Definition: misc.c:682
SCIP_RETCODE SCIPprobAddCons(SCIP_PROB *prob, SCIP_SET *set, SCIP_STAT *stat, SCIP_CONS *cons)
Definition: prob.c:1286
void SCIPbdchginfoFree(SCIP_BDCHGINFO **bdchginfo, BMS_BLKMEM *blkmem)
Definition: var.c:16408
SCIP_BDCHGINFO ** bdchginfos
void SCIPvarAdjustUb(SCIP_VAR *var, SCIP_SET *set, SCIP_Real *ub)
Definition: var.c:6543
#define BMSallocBlockMemory(mem, ptr)
Definition: memory.h:453
static int proofsetGetNVars(SCIP_PROOFSET *proofset)
Definition: conflict.c:1055
SCIP_Longint SCIPconflictGetNPropReconvergenceLiterals(SCIP_CONFLICT *conflict)
Definition: conflict.c:5794
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:8212
SCIP_BOUNDTYPE SCIPbdchginfoGetBoundtype(SCIP_BDCHGINFO *bdchginfo)
Definition: var.c:18545
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:2832
static void tightenCoefficients(SCIP_SET *set, SCIP_PROOFSET *proofset, int *nchgcoefs, SCIP_Bool *redundant)
Definition: conflict.c:7379
SCIP_CONFLICTSET ** conflictsets
#define BMSclearMemoryArray(ptr, num)
Definition: memory.h:132
SCIP_Real SCIPconflictGetPropTime(SCIP_CONFLICT *conflict)
Definition: conflict.c:5734
SCIP_Longint nnodes
Definition: struct_stat.h:82
struct BMS_BlkMem BMS_BLKMEM
Definition: memory.h:439
SCIP_RETCODE SCIPvarGetProbvarSum(SCIP_VAR **var, SCIP_SET *set, SCIP_Real *scalar, SCIP_Real *constant)
Definition: var.c:12659
SCIP_Longint SCIPconflictGetNDualproofsInfLocal(SCIP_CONFLICT *conflict)
Definition: conflict.c:9265
#define SCIP_DECL_CONFLICTFREE(x)
Definition: type_conflict.h:94
SCIP_NODE * root
Definition: struct_tree.h:186
void SCIPaggrRowClear(SCIP_AGGRROW *aggrrow)
Definition: cuts.c:2141
static SCIP_RETCODE conflictResolveBound(SCIP_CONFLICT *conflict, SCIP_SET *set, SCIP_BDCHGINFO *bdchginfo, SCIP_Real relaxedbd, int validdepth, SCIP_Bool *resolved)
Definition: conflict.c:4929
SCIP_CONFLICTHDLRDATA * SCIPconflicthdlrGetData(SCIP_CONFLICTHDLR *conflicthdlr)
Definition: conflict.c:685
SCIP_RETCODE SCIPconflicthdlrCopyInclude(SCIP_CONFLICTHDLR *conflicthdlr, SCIP_SET *set)
Definition: conflict.c:389
static SCIP_RETCODE conflictEnsureTmpbdchginfosMem(SCIP_CONFLICT *conflict, SCIP_SET *set, int num)
Definition: conflict.c:1213
SCIP_Bool primalfeasible
Definition: struct_lp.h:120
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:5142
SCIP_Longint ndualproofsbndsuccess
void SCIPpqueueClear(SCIP_PQUEUE *pqueue)
Definition: misc.c:1283
#define SCIP_ALLOC(x)
Definition: def.h:405
#define SCIPABORT()
Definition: def.h:366
SCIP_LPSOLSTAT lpsolstat
Definition: struct_lp.h:353
SCIP_Longint SCIPconflictGetNDualproofsBndGlobal(SCIP_CONFLICT *conflict)
Definition: conflict.c:9295
int SCIPcolGetLPPos(SCIP_COL *col)
Definition: lp.c:17096
SCIP_Bool SCIPvarIsIntegral(SCIP_VAR *var)
Definition: var.c:17455
const char * SCIPprobGetName(SCIP_PROB *prob)
Definition: prob.c:2343
int ncols
Definition: struct_lp.h:328
datastructures for global SCIP settings
static void conflictClear(SCIP_CONFLICT *conflict)
Definition: conflict.c:4044
static SCIP_Bool bdchginfoIsInvalid(SCIP_CONFLICT *conflict, SCIP_BDCHGINFO *bdchginfo)
Definition: conflict.c:1490
SCIP_Real lpobjval
Definition: struct_lp.h:119
SCIP_Longint nsbreconvconss
#define BMSreallocBlockMemoryArray(mem, ptr, oldnum, newnum)
Definition: memory.h:460
SCIP_Real SCIPgetLhsLinear(SCIP *scip, SCIP_CONS *cons)
unsigned int local
Definition: struct_lp.h:259
static SCIP_Bool checkDualFeasibility(SCIP_SET *set, SCIP_ROW *row, SCIP_Real weight, SCIP_Bool *zerocontribution)
Definition: conflict.c:6709
SCIP_RETCODE SCIPsetConflicthdlrPriority(SCIP *scip, SCIP_CONFLICTHDLR *conflicthdlr, int priority)
SCIP_Real activity
Definition: struct_lp.h:214
SCIP_RETCODE SCIPlpiGetRealpar(SCIP_LPI *lpi, SCIP_LPPARAM type, SCIP_Real *dval)
Definition: lpi_clp.cpp:3796
SCIP_Bool * usedcols
int len
Definition: struct_lp.h:235
static SCIP_RETCODE proofsetAddSparseData(SCIP_PROOFSET *proofset, BMS_BLKMEM *blkmem, SCIP_Real *vals, int *inds, int nnz, SCIP_Real rhs)
Definition: conflict.c:1077
SCIP_Bool SCIPvarIsActive(SCIP_VAR *var)
Definition: var.c:17593
SCIP_BDCHGINFO * lbchginfos
Definition: struct_var.h:248
public methods for propagators
SCIP_RETCODE SCIPcreateSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
Definition: scip_sol.c:328
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:7194
SCIP_BOUNDCHGTYPE SCIPbdchginfoGetChgtype(SCIP_BDCHGINFO *bdchginfo)
Definition: var.c:18535
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:7552
static SCIP_Real proofsetGetRhs(SCIP_PROOFSET *proofset)
Definition: conflict.c:1044