Scippy

SCIP

Solving Constraint Integer Programs

branch.c
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the program and library */
4 /* SCIP --- Solving Constraint Integer Programs */
5 /* */
6 /* Copyright (C) 2002-2017 Konrad-Zuse-Zentrum */
7 /* fuer Informationstechnik Berlin */
8 /* */
9 /* SCIP is distributed under the terms of the ZIB Academic License. */
10 /* */
11 /* You should have received a copy of the ZIB Academic License */
12 /* along with SCIP; see the file COPYING. If not email to scip@zib.de. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file branch.c
17  * @brief methods for branching rules and branching candidate storage
18  * @author Tobias Achterberg
19  * @author Timo Berthold
20  * @author Gerald Gamrath
21  * @author Stefan Heinz
22  * @author Michael Winkler
23  * @author Stefan Vigerske
24  */
25 
26 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
27 
28 #include <assert.h>
29 #include <string.h>
30 
31 #include "scip/def.h"
32 #include "blockmemshell/memory.h"
33 #include "scip/set.h"
34 #include "scip/stat.h"
35 #include "scip/clock.h"
36 #include "scip/paramset.h"
37 #include "scip/event.h"
38 #include "scip/lp.h"
39 #include "scip/var.h"
40 #include "scip/prob.h"
41 #include "scip/tree.h"
42 #include "scip/sepastore.h"
43 #include "scip/scip.h"
44 #include "scip/branch.h"
45 #include "scip/solve.h"
46 
47 #include "scip/struct_branch.h"
48 
49 /*
50  * memory growing methods for dynamically allocated arrays
51  */
52 
53 /** ensures, that lpcands array can store at least num entries */
54 static
56  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
57  SCIP_SET* set, /**< global SCIP settings */
58  int num /**< minimum number of entries to store */
59  )
60 {
61  assert(branchcand->nlpcands <= branchcand->lpcandssize);
62 
63  if( num > branchcand->lpcandssize )
64  {
65  int newsize;
66 
67  newsize = SCIPsetCalcMemGrowSize(set, num);
68  SCIP_ALLOC( BMSreallocMemoryArray(&branchcand->lpcands, newsize) );
69  SCIP_ALLOC( BMSreallocMemoryArray(&branchcand->lpcandssol, newsize) );
70  SCIP_ALLOC( BMSreallocMemoryArray(&branchcand->lpcandsfrac, newsize) );
71  branchcand->lpcandssize = newsize;
72  }
73  assert(num <= branchcand->lpcandssize);
74 
75  return SCIP_OKAY;
76 }
77 
78 /** ensures, that pseudocands array can store at least num entries */
79 static
81  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
82  SCIP_SET* set, /**< global SCIP settings */
83  int num /**< minimum number of entries to store */
84  )
85 {
86  assert(branchcand->npseudocands <= branchcand->pseudocandssize);
87 
88  if( num > branchcand->pseudocandssize )
89  {
90  int newsize;
91 
92  newsize = SCIPsetCalcMemGrowSize(set, num);
93  SCIP_ALLOC( BMSreallocMemoryArray(&branchcand->pseudocands, newsize) );
94  branchcand->pseudocandssize = newsize;
95  }
96  assert(num <= branchcand->pseudocandssize);
97 
98  return SCIP_OKAY;
99 }
100 
101 /** ensures, that externcands array can store at least num entries */
102 static
104  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
105  SCIP_SET* set, /**< global SCIP settings */
106  int num /**< minimum number of entries to store */
107  )
108 {
109  assert(branchcand->nexterncands <= branchcand->externcandssize);
110 
111  if( num > branchcand->externcandssize )
112  {
113  int newsize;
114 
115  newsize = SCIPsetCalcMemGrowSize(set, num);
116  SCIP_ALLOC( BMSreallocMemoryArray(&branchcand->externcands, newsize) );
117  SCIP_ALLOC( BMSreallocMemoryArray(&branchcand->externcandsscore, newsize) );
118  SCIP_ALLOC( BMSreallocMemoryArray(&branchcand->externcandssol, newsize) );
119  branchcand->externcandssize = newsize;
120  }
121  assert(num <= branchcand->externcandssize);
122 
123  return SCIP_OKAY;
124 }
125 
126 
127 
128 /*
129  * branching candidate storage methods
130  */
131 
132 /** creates a branching candidate storage */
134  SCIP_BRANCHCAND** branchcand /**< pointer to store branching candidate storage */
135  )
136 {
137  assert(branchcand != NULL);
138 
139  SCIP_ALLOC( BMSallocMemory(branchcand) );
140  (*branchcand)->lpcands = NULL;
141  (*branchcand)->lpcandssol = NULL;
142  (*branchcand)->lpcandsfrac = NULL;
143  (*branchcand)->externcands = NULL;
144  (*branchcand)->externcandssol = NULL;
145  (*branchcand)->externcandsscore = NULL;
146  (*branchcand)->pseudocands = NULL;
147  (*branchcand)->lpcandssize = 0;
148  (*branchcand)->nlpcands = 0;
149  (*branchcand)->nimpllpfracs = 0;
150  (*branchcand)->npriolpcands = 0;
151  (*branchcand)->npriolpbins = 0;
152  (*branchcand)->lpmaxpriority = INT_MIN;
153  (*branchcand)->externcandssize = 0;
154  (*branchcand)->nexterncands = 0;
155  (*branchcand)->nprioexterncands = 0;
156  (*branchcand)->nprioexternbins = 0;
157  (*branchcand)->nprioexternints = 0;
158  (*branchcand)->nprioexternimpls = 0;
159  (*branchcand)->externmaxpriority = INT_MIN;
160  (*branchcand)->pseudocandssize = 0;
161  (*branchcand)->npseudocands = 0;
162  (*branchcand)->npriopseudocands = 0;
163  (*branchcand)->npriopseudobins = 0;
164  (*branchcand)->npriopseudoints = 0;
165  (*branchcand)->pseudomaxpriority = INT_MIN;
166 
167  SCIPbranchcandInvalidate(*branchcand);
168 
169  return SCIP_OKAY;
170 }
171 
172 /** frees branching candidate storage */
174  SCIP_BRANCHCAND** branchcand /**< pointer to store branching candidate storage */
175  )
176 {
177  assert(branchcand != NULL);
178 
179  BMSfreeMemoryArrayNull(&(*branchcand)->lpcands);
180  BMSfreeMemoryArrayNull(&(*branchcand)->lpcandssol);
181  BMSfreeMemoryArrayNull(&(*branchcand)->lpcandsfrac);
182  BMSfreeMemoryArrayNull(&(*branchcand)->pseudocands);
183  BMSfreeMemoryArrayNull(&(*branchcand)->externcands);
184  BMSfreeMemoryArrayNull(&(*branchcand)->externcandsscore);
185  BMSfreeMemoryArrayNull(&(*branchcand)->externcandssol);
186  BMSfreeMemory(branchcand);
187 
188  return SCIP_OKAY;
189 }
190 
191 /** resets branching candidates storage */
193  SCIP_BRANCHCAND* branchcand /**< pointer to store branching candidate storage */
194  )
195 {
196  assert(branchcand != NULL);
197 
198  branchcand->validlpcandslp = -1;
199 }
200 
201 /** calculates branching candidates for LP solution branching (fractional variables) */
202 static
204  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
205  SCIP_SET* set, /**< global SCIP settings */
206  SCIP_STAT* stat, /**< problem statistics */
207  SCIP_LP* lp /**< current LP data */
208  )
209 {
210  assert(branchcand != NULL);
211  assert(stat != NULL);
212  assert(branchcand->validlpcandslp <= stat->lpcount);
213  assert(lp != NULL);
214  assert(lp->solved);
216 
217  SCIPsetDebugMsg(set, "calculating LP branching candidates: validlp=%" SCIP_LONGINT_FORMAT ", lpcount=%" SCIP_LONGINT_FORMAT "\n",
218  branchcand->validlpcandslp, stat->lpcount);
219 
221  {
222  branchcand->lpmaxpriority = INT_MIN / 2;
223  branchcand->nlpcands = 0;
224  branchcand->npriolpcands = 0;
225  branchcand->npriolpbins = 0;
226  branchcand->nimpllpfracs = 0;
227  branchcand->validlpcandslp = stat->lpcount;
228 
229  SCIPsetDebugMsg(set, " LP is unbounded -> no branching candidates\n");
230  return SCIP_OKAY;
231  }
232 
233  /* check, if the current LP branching candidate array is invalid */
234  if( branchcand->validlpcandslp < stat->lpcount )
235  {
236  SCIP_COL** cols;
237  SCIP_VAR* var;
238  SCIP_COL* col;
239  SCIP_Real primsol;
240  SCIP_Real frac;
241  SCIP_VARTYPE vartype;
242  int branchpriority;
243  int ncols;
244  int c;
245  int insertpos;
246 
247  SCIPsetDebugMsg(set, " -> recalculating LP branching candidates\n");
248 
249  cols = SCIPlpGetCols(lp);
250  ncols = SCIPlpGetNCols(lp);
251 
252  /* construct the LP branching candidate set, moving the candidates with maximal priority to the front */
253  SCIP_CALL( ensureLpcandsSize(branchcand, set, ncols) );
254 
255  branchcand->lpmaxpriority = INT_MIN / 2;
256  branchcand->nlpcands = 0;
257  branchcand->nimpllpfracs = 0;
258  branchcand->npriolpcands = 0;
259  branchcand->npriolpbins = 0;
260  for( c = 0; c < ncols; ++c )
261  {
262  col = cols[c];
263  assert(col != NULL);
264  assert(col->lppos == c);
265  assert(col->lpipos >= 0);
266 
267  primsol = SCIPcolGetPrimsol(col);
268  assert(primsol < SCIP_INVALID);
269  assert(SCIPsetIsInfinity(set, -col->lb) || SCIPsetIsFeasGE(set, primsol, col->lb));
270  assert(SCIPsetIsInfinity(set, col->ub) || SCIPsetIsFeasLE(set, primsol, col->ub));
271 
272  var = col->var;
273  assert(var != NULL);
274  assert(SCIPvarGetStatus(var) == SCIP_VARSTATUS_COLUMN);
275  assert(SCIPvarGetCol(var) == col);
276 
277  /* LP branching candidates are fractional binary and integer variables; implicit variables are kept at the end
278  * of the candidates array for some rounding heuristics
279  */
280  vartype = SCIPvarGetType(var);
281  if( vartype == SCIP_VARTYPE_CONTINUOUS )
282  continue;
283 
284  /* ignore fixed variables (due to numerics, it is possible, that the LP solution of a fixed integer variable
285  * (with large fixed value) is fractional in terms of absolute feasibility measure)
286  */
287  if( SCIPvarGetLbLocal(var) >= SCIPvarGetUbLocal(var) - 0.5 )
288  continue;
289 
290  /* check, if the LP solution value is fractional */
291  frac = SCIPsetFeasFrac(set, primsol);
292 
293  /* The fractionality should not be smaller than -feastol, however, if the primsol is large enough
294  * and close to an integer, fixed precision floating point arithmetic might give us values slightly
295  * smaller than -feastol. Originally, the "frac >= -feastol"-check was within SCIPsetIsFeasFracIntegral(),
296  * however, we relaxed it to "frac >= -2*feastol" and have the stricter check here for small-enough primsols.
297  */
298  assert(SCIPsetIsGE(set, frac, -SCIPsetFeastol(set)) || (primsol > 1e14 * SCIPsetFeastol(set)));
299 
300  if( SCIPsetIsFeasFracIntegral(set, frac) )
301  continue;
302 
303  /* insert candidate in candidate list */
304  branchpriority = SCIPvarGetBranchPriority(var);
305  insertpos = branchcand->nlpcands + branchcand->nimpllpfracs;
306  assert(insertpos < branchcand->lpcandssize);
307 
308  if( vartype == SCIP_VARTYPE_IMPLINT )
309  branchpriority = INT_MIN;
310 
311  assert(vartype == SCIP_VARTYPE_IMPLINT || branchpriority >= INT_MIN/2);
312  /* ensure that implicit variables are stored at the end of the array */
313  if( vartype != SCIP_VARTYPE_IMPLINT && branchcand->nimpllpfracs > 0 )
314  {
315  assert(branchcand->lpcands[branchcand->nlpcands] != NULL
316  && SCIPvarGetType(branchcand->lpcands[branchcand->nlpcands]) == SCIP_VARTYPE_IMPLINT );
317 
318  branchcand->lpcands[insertpos] = branchcand->lpcands[branchcand->nlpcands];
319  branchcand->lpcandssol[insertpos] = branchcand->lpcandssol[branchcand->nlpcands];
320  branchcand->lpcandsfrac[insertpos] = branchcand->lpcandsfrac[branchcand->nlpcands];
321 
322  insertpos = branchcand->nlpcands;
323  }
324 
325  if( branchpriority > branchcand->lpmaxpriority )
326  {
327  /* candidate has higher priority than the current maximum:
328  * move it to the front and declare it to be the single best candidate
329  */
330  if( insertpos != 0 )
331  {
332  branchcand->lpcands[insertpos] = branchcand->lpcands[0];
333  branchcand->lpcandssol[insertpos] = branchcand->lpcandssol[0];
334  branchcand->lpcandsfrac[insertpos] = branchcand->lpcandsfrac[0];
335  insertpos = 0;
336  }
337  branchcand->npriolpcands = 1;
338  branchcand->npriolpbins = (vartype == SCIP_VARTYPE_BINARY ? 1 : 0);
339  branchcand->lpmaxpriority = branchpriority;
340  }
341  else if( branchpriority == branchcand->lpmaxpriority )
342  {
343  /* candidate has equal priority as the current maximum:
344  * move away the first non-maximal priority candidate, move the current candidate to the correct
345  * slot (binaries first) and increase the number of maximal priority candidates
346  */
347  if( insertpos != branchcand->npriolpcands )
348  {
349  branchcand->lpcands[insertpos] = branchcand->lpcands[branchcand->npriolpcands];
350  branchcand->lpcandssol[insertpos] = branchcand->lpcandssol[branchcand->npriolpcands];
351  branchcand->lpcandsfrac[insertpos] = branchcand->lpcandsfrac[branchcand->npriolpcands];
352  insertpos = branchcand->npriolpcands;
353  }
354  branchcand->npriolpcands++;
355  if( vartype == SCIP_VARTYPE_BINARY )
356  {
357  if( insertpos != branchcand->npriolpbins )
358  {
359  branchcand->lpcands[insertpos] = branchcand->lpcands[branchcand->npriolpbins];
360  branchcand->lpcandssol[insertpos] = branchcand->lpcandssol[branchcand->npriolpbins];
361  branchcand->lpcandsfrac[insertpos] = branchcand->lpcandsfrac[branchcand->npriolpbins];
362  insertpos = branchcand->npriolpbins;
363  }
364  branchcand->npriolpbins++;
365  }
366  }
367  /* insert variable at the correct position of the candidates storage */
368  branchcand->lpcands[insertpos] = var;
369  branchcand->lpcandssol[insertpos] = primsol;
370  branchcand->lpcandsfrac[insertpos] = frac;
371 
372  /* increase the counter depending on the variable type */
373  if( vartype != SCIP_VARTYPE_IMPLINT )
374  branchcand->nlpcands++;
375  else
376  branchcand->nimpllpfracs++;
377 
378  SCIPsetDebugMsg(set, " -> candidate %d: var=<%s>, sol=%g, frac=%g, prio=%d (max: %d) -> pos %d\n",
379  branchcand->nlpcands, SCIPvarGetName(var), primsol, frac, branchpriority, branchcand->lpmaxpriority,
380  insertpos);
381  }
382 
383 #ifndef NDEBUG
384  /* in debug mode we assert that the variables are positioned correctly (binaries and integers first,
385  * implicit integers last)
386  */
387  for( c = 0; c < branchcand->nlpcands + branchcand->nimpllpfracs; ++c )
388  {
389  assert(c >= branchcand->nlpcands || SCIPvarGetType(branchcand->lpcands[c]) != SCIP_VARTYPE_IMPLINT);
390  assert(c < branchcand->nlpcands || SCIPvarGetType(branchcand->lpcands[c]) == SCIP_VARTYPE_IMPLINT);
391  }
392 #endif
393 
394  branchcand->validlpcandslp = stat->lpcount;
395  }
396  assert(0 <= branchcand->npriolpcands && branchcand->npriolpcands <= branchcand->nlpcands);
397 
398  SCIPsetDebugMsg(set, " -> %d fractional variables (%d of maximal priority)\n", branchcand->nlpcands, branchcand->npriolpcands);
399 
400  return SCIP_OKAY;
401 }
402 
403 /** gets branching candidates for LP solution branching (fractional variables) */
405  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
406  SCIP_SET* set, /**< global SCIP settings */
407  SCIP_STAT* stat, /**< problem statistics */
408  SCIP_LP* lp, /**< current LP data */
409  SCIP_VAR*** lpcands, /**< pointer to store the array of LP branching candidates, or NULL */
410  SCIP_Real** lpcandssol, /**< pointer to store the array of LP candidate solution values, or NULL */
411  SCIP_Real** lpcandsfrac, /**< pointer to store the array of LP candidate fractionalities, or NULL */
412  int* nlpcands, /**< pointer to store the number of LP branching candidates, or NULL */
413  int* npriolpcands, /**< pointer to store the number of candidates with maximal priority, or NULL */
414  int* nfracimplvars /**< pointer to store the number of implicit fractional variables, or NULL */
415  )
416 {
417  /* calculate branching candidates */
418  SCIP_CALL( branchcandCalcLPCands(branchcand, set, stat, lp) );
419 
420  /* assign return values */
421  if( lpcands != NULL )
422  *lpcands = branchcand->lpcands;
423  if( lpcandssol != NULL )
424  *lpcandssol = branchcand->lpcandssol;
425  if( lpcandsfrac != NULL )
426  *lpcandsfrac = branchcand->lpcandsfrac;
427  if( nlpcands != NULL )
428  *nlpcands = branchcand->nlpcands;
429  if( npriolpcands != NULL )
430  *npriolpcands = (set->branch_preferbinary && branchcand->npriolpbins > 0 ? branchcand->npriolpbins
431  : branchcand->npriolpcands);
432  if( nfracimplvars != NULL )
433  *nfracimplvars = branchcand->nimpllpfracs;
434 
435  return SCIP_OKAY;
436 }
437 
438 /** gets external branching candidates */
440  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
441  SCIP_VAR*** externcands, /**< pointer to store the array of external branching candidates, or NULL */
442  SCIP_Real** externcandssol, /**< pointer to store the array of external candidate solution values, or NULL */
443  SCIP_Real** externcandsscore, /**< pointer to store the array of external candidate scores, or NULL */
444  int* nexterncands, /**< pointer to store the number of external branching candidates, or NULL */
445  int* nprioexterncands, /**< pointer to store the number of candidates with maximal priority, or NULL */
446  int* nprioexternbins, /**< pointer to store the number of binary candidates with maximal priority, or NULL */
447  int* nprioexternints, /**< pointer to store the number of integer candidates with maximal priority, or NULL */
448  int* nprioexternimpls /**< pointer to store the number of implicit integer candidates with maximal priority,
449  * or NULL */
450  )
451 {
452  assert(branchcand != NULL);
453 
454  /* assign return values */
455  if( externcands != NULL )
456  *externcands = branchcand->externcands;
457  if( externcandssol != NULL )
458  *externcandssol = branchcand->externcandssol;
459  if( externcandsscore != NULL )
460  *externcandsscore = branchcand->externcandsscore;
461  if( nexterncands != NULL )
462  *nexterncands = branchcand->nexterncands;
463  if( nprioexterncands != NULL )
464  *nprioexterncands = branchcand->nprioexterncands;
465  if( nprioexternbins != NULL )
466  *nprioexternbins = branchcand->nprioexternbins;
467  if( nprioexternints != NULL )
468  *nprioexternints = branchcand->nprioexternints;
469  if( nprioexternimpls != NULL )
470  *nprioexternimpls = branchcand->nprioexternimpls;
471 
472  return SCIP_OKAY;
473 }
474 
475 /** gets maximal branching priority of LP branching candidates */
477  SCIP_BRANCHCAND* branchcand /**< branching candidate storage */
478  )
479 {
480  assert(branchcand != NULL);
481 
482  return branchcand->lpmaxpriority;
483 }
484 
485 /** gets number of LP branching candidates with maximal branch priority */
487  SCIP_BRANCHCAND* branchcand /**< branching candidate storage */
488  )
489 {
490  assert(branchcand != NULL);
491 
492  return branchcand->npriolpcands;
493 }
494 
495 /** gets maximal branching priority of external branching candidates */
497  SCIP_BRANCHCAND* branchcand /**< branching candidate storage */
498  )
499 {
500  assert(branchcand != NULL);
501 
502  return branchcand->externmaxpriority;
503 }
504 
505 /** gets number of external branching candidates */
507  SCIP_BRANCHCAND* branchcand /**< branching candidate storage */
508  )
509 {
510  assert(branchcand != NULL);
511 
512  return branchcand->nexterncands;
513 }
514 
515 /** gets number of external branching candidates with maximal branch priority */
517  SCIP_BRANCHCAND* branchcand /**< branching candidate storage */
518  )
519 {
520  assert(branchcand != NULL);
521 
522  return branchcand->nprioexterncands;
523 }
524 
525 /** gets number of binary external branching candidates with maximal branch priority */
527  SCIP_BRANCHCAND* branchcand /**< branching candidate storage */
528  )
529 {
530  assert(branchcand != NULL);
531 
532  return branchcand->nprioexternbins;
533 }
534 
535 /** gets number of integer external branching candidates with maximal branch priority */
537  SCIP_BRANCHCAND* branchcand /**< branching candidate storage */
538  )
539 {
540  assert(branchcand != NULL);
541 
542  return branchcand->nprioexternints;
543 }
544 
545 /** gets number of implicit integer external branching candidates with maximal branch priority */
547  SCIP_BRANCHCAND* branchcand /**< branching candidate storage */
548  )
549 {
550  assert(branchcand != NULL);
551 
552  return branchcand->nprioexternimpls;
553 }
554 
555 /** gets number of continuous external branching candidates with maximal branch priority */
557  SCIP_BRANCHCAND* branchcand /**< branching candidate storage */
558  )
559 {
560  assert(branchcand != NULL);
561 
562  return branchcand->nprioexterncands - branchcand->nprioexternbins - branchcand->nprioexternints - branchcand->nprioexternimpls;
563 }
564 
565 /** insert variable, its score and its solution value into the external branching candidate storage
566  * the absolute difference of the current lower and upper bounds of the variable must be at least epsilon
567  */
569  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
570  SCIP_SET* set, /**< global SCIP settings */
571  SCIP_VAR* var, /**< variable to insert */
572  SCIP_Real score, /**< score of external candidate, e.g. infeasibility */
573  SCIP_Real solval /**< value of the variable in the current solution */
574  )
575 {
576  SCIP_VARTYPE vartype;
577  int branchpriority;
578  int insertpos;
579 
580  assert(branchcand != NULL);
581  assert(var != NULL);
582  assert(!SCIPsetIsEQ(set, SCIPvarGetLbLocal(var), SCIPvarGetUbLocal(var))); /* the variable should not be fixed yet */
583  assert(SCIPvarGetType(var) == SCIP_VARTYPE_CONTINUOUS || !SCIPsetIsEQ(set, SCIPsetCeil(set, SCIPvarGetLbLocal(var)), SCIPsetFloor(set, SCIPvarGetUbLocal(var)))); /* a discrete variable should also not be fixed, even after rounding bounds to integral values */
584  assert(SCIPvarGetStatus(var) != SCIP_VARSTATUS_MULTAGGR || !SCIPsetIsEQ(set, SCIPvarGetMultaggrLbLocal(var, set), SCIPvarGetMultaggrUbLocal(var, set))); /* also the current bounds of a multi-aggregated variable should not be fixed yet */
585  assert(branchcand->nprioexterncands <= branchcand->nexterncands);
586  assert(branchcand->nexterncands <= branchcand->externcandssize);
587 
588  vartype = SCIPvarGetType(var);
589  branchpriority = SCIPvarGetBranchPriority(var);
590  insertpos = branchcand->nexterncands;
591 
592  SCIP_CALL( ensureExterncandsSize(branchcand, set, branchcand->nexterncands+1) );
593 
594  SCIPsetDebugMsg(set, "inserting external candidate <%s> of type %d and priority %d into candidate set (maxprio: %d), score = %g, solval = %g\n",
595  SCIPvarGetName(var), vartype, branchpriority, branchcand->externmaxpriority, score, solval);
596 
597  /* insert the variable into externcands, making sure, that the highest priority candidates are at the front
598  * and ordered binaries, integers, implicit integers, continuous
599  */
600  if( branchpriority > branchcand->externmaxpriority )
601  {
602  /* candidate has higher priority than the current maximum:
603  * move it to the front and declare it to be the single best candidate
604  */
605  branchcand->externcands[insertpos] = branchcand->externcands[0];
606  branchcand->externcandsscore[insertpos] = branchcand->externcandsscore[0];
607  branchcand->externcandssol[insertpos] = branchcand->externcandssol[0];
608 
609  insertpos = 0;
610 
611  branchcand->nprioexterncands = 1;
612  branchcand->nprioexternbins = (vartype == SCIP_VARTYPE_BINARY ? 1 : 0);
613  branchcand->nprioexternints = (vartype == SCIP_VARTYPE_INTEGER ? 1 : 0);
614  branchcand->nprioexternimpls = (vartype == SCIP_VARTYPE_IMPLINT ? 1 : 0);
615  branchcand->externmaxpriority = branchpriority;
616  }
617  else if( branchpriority == branchcand->externmaxpriority )
618  {
619  /* candidate has equal priority as the current maximum:
620  * move away the first non-maximal priority candidate, move the current candidate to the correct
621  * slot (binaries first, integers next, implicit integers next, continuous last) and increase the number
622  * of maximal priority candidates
623  */
624  if( insertpos != branchcand->nprioexterncands )
625  {
626  branchcand->externcands[insertpos] = branchcand->externcands[branchcand->nprioexterncands];
627  branchcand->externcandsscore[insertpos] = branchcand->externcandsscore[branchcand->nprioexterncands];
628  branchcand->externcandssol[insertpos] = branchcand->externcandssol[branchcand->nprioexterncands];
629 
630  insertpos = branchcand->nprioexterncands;
631  }
632  branchcand->nprioexterncands++;
633  if( vartype == SCIP_VARTYPE_BINARY || vartype == SCIP_VARTYPE_INTEGER || vartype == SCIP_VARTYPE_IMPLINT )
634  {
635  if( insertpos != branchcand->nprioexternbins + branchcand->nprioexternints + branchcand->nprioexternimpls )
636  {
637  branchcand->externcands[insertpos] =
638  branchcand->externcands[branchcand->nprioexternbins + branchcand->nprioexternints + branchcand->nprioexternimpls];
639  branchcand->externcandsscore[insertpos] =
640  branchcand->externcandsscore[branchcand->nprioexternbins + branchcand->nprioexternints + branchcand->nprioexternimpls];
641  branchcand->externcandssol[insertpos] =
642  branchcand->externcandssol[branchcand->nprioexternbins + branchcand->nprioexternints + branchcand->nprioexternimpls];
643 
644  insertpos = branchcand->nprioexternbins + branchcand->nprioexternints + branchcand->nprioexternimpls;
645  }
646  branchcand->nprioexternimpls++;
647 
648 
649  if( vartype == SCIP_VARTYPE_BINARY || vartype == SCIP_VARTYPE_INTEGER )
650  {
651  if( insertpos != branchcand->nprioexternbins + branchcand->nprioexternints )
652  {
653  branchcand->externcands[insertpos] =
654  branchcand->externcands[branchcand->nprioexternbins + branchcand->nprioexternints];
655  branchcand->externcandsscore[insertpos] =
656  branchcand->externcandsscore[branchcand->nprioexternbins + branchcand->nprioexternints];
657  branchcand->externcandssol[insertpos] =
658  branchcand->externcandssol[branchcand->nprioexternbins + branchcand->nprioexternints];
659 
660  insertpos = branchcand->nprioexternbins + branchcand->nprioexternints;
661  }
662  branchcand->nprioexternints++;
663  branchcand->nprioexternimpls--;
664 
665 
666  if( vartype == SCIP_VARTYPE_BINARY )
667  {
668  if( insertpos != branchcand->nprioexternbins )
669  {
670  branchcand->externcands[insertpos] = branchcand->externcands[branchcand->nprioexternbins];
671  branchcand->externcandsscore[insertpos] = branchcand->externcandsscore[branchcand->nprioexternbins];
672  branchcand->externcandssol[insertpos] = branchcand->externcandssol[branchcand->nprioexternbins];
673 
674  insertpos = branchcand->nprioexternbins;
675  }
676  branchcand->nprioexternbins++;
677  branchcand->nprioexternints--;
678  }
679  }
680  }
681  }
682  branchcand->externcands[insertpos] = var;
683  branchcand->externcandsscore[insertpos] = score;
684  branchcand->externcandssol[insertpos] = solval;
685  branchcand->nexterncands++;
686 
687  SCIPsetDebugMsg(set, " -> inserted at position %d (nprioexterncands=%d)\n", insertpos, branchcand->nprioexterncands);
688 
689  assert(0 <= branchcand->nprioexterncands && branchcand->nprioexterncands <= branchcand->nexterncands);
690  assert(0 <= branchcand->nprioexternbins && branchcand->nprioexternbins <= branchcand->nprioexterncands);
691  assert(0 <= branchcand->nprioexternints && branchcand->nprioexternints <= branchcand->nprioexterncands);
692  assert(0 <= branchcand->nprioexternimpls && branchcand->nprioexternimpls <= branchcand->nprioexterncands);
693 
694  return SCIP_OKAY;
695 }
696 
697 /** removes all external candidates from the storage for external branching */
699  SCIP_BRANCHCAND* branchcand /**< branching candidate storage */
700  )
701 {
702  assert(branchcand != NULL);
703 
704  branchcand->nexterncands = 0;
705  branchcand->nprioexterncands = 0;
706  branchcand->nprioexternbins = 0;
707  branchcand->nprioexternints = 0;
708  branchcand->nprioexternimpls = 0;
709  branchcand->externmaxpriority = INT_MIN;
710 }
711 
712 /** checks whether the given variable is contained in the candidate storage for external branching */
714  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
715  SCIP_VAR* var /**< variable to look for */
716  )
717 {
718  int branchpriority;
719  int i;
720 
721  assert(branchcand != NULL);
722  assert(var != NULL);
723  assert(branchcand->nprioexterncands <= branchcand->nexterncands);
724  assert(branchcand->nexterncands <= branchcand->externcandssize);
725 
726  branchpriority = SCIPvarGetBranchPriority(var);
727 
728  /* look for the variable in the externcands, using the fact, that the highest priority candidates are at the front
729  * and ordered binaries, integers, implicit integers, continuous
730  */
731  if( branchpriority > branchcand->externmaxpriority )
732  {
733  /* the branching priority of the variable is higher than the maximal priority contained in the array;
734  * the variable can thus not be contained */
735  return FALSE;
736  }
737  if( branchpriority == branchcand->externmaxpriority )
738  {
739  SCIP_VARTYPE vartype;
740 
741  vartype = SCIPvarGetType(var);
742 
743  /* variable has equal priority as the current maximum:
744  * look for it in the correct slot (binaries first, integers next, implicit integers next, continuous last)
745  */
746  if( vartype == SCIP_VARTYPE_BINARY )
747  {
748  /* the variable is binary, look at the first branchcand->nprioexternbins slots */
749  for( i = 0; i < branchcand->nprioexternbins; i++ )
750  if( branchcand->externcands[i] == var )
751  return TRUE;
752  return FALSE;
753  }
754  if( vartype == SCIP_VARTYPE_INTEGER )
755  {
756  /* the variable is integer, look at the slots containing integers */
757  for( i = 0; i < branchcand->nprioexternints; i++ )
758  if( branchcand->externcands[branchcand->nprioexternbins + i] == var )
759  return TRUE;
760  return FALSE;
761  }
762  if( vartype == SCIP_VARTYPE_IMPLINT )
763  {
764  /* the variable is implicit integer, look at the slots containing implicit integers */
765  for( i = 0; i < branchcand->nprioexternimpls; i++ )
766  if( branchcand->externcands[branchcand->nprioexternbins + branchcand->nprioexternints + i] == var )
767  return TRUE;
768  return FALSE;
769  }
770  /* the variable is continuous, look at the slots containing continuous variables */
771  assert(vartype == SCIP_VARTYPE_CONTINUOUS);
772  for( i = branchcand->nprioexternbins + branchcand->nprioexternints + branchcand->nprioexternimpls;
773  i < branchcand->nprioexterncands; i++ )
774  if( branchcand->externcands[i] == var )
775  return TRUE;
776  return FALSE;
777  }
778  /* the branching priority of the variable is lower than the maximal priority contained in the array;
779  * look for the variable in the candidates which do not have maximal priority */
780  assert(branchpriority < branchcand->externmaxpriority);
781 
782  for( i = branchcand->nprioexterncands; i < branchcand->nexterncands; i++ )
783  if( branchcand->externcands[i] == var )
784  return TRUE;
785  return FALSE;
786 }
787 
788 /** gets branching candidates for pseudo solution branching (non-fixed variables) */
790  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
791  SCIP_SET* set, /**< global SCIP settings */
792  SCIP_PROB* prob, /**< problem data */
793  SCIP_VAR*** pseudocands, /**< pointer to store the array of pseudo branching candidates, or NULL */
794  int* npseudocands, /**< pointer to store the number of pseudo branching candidates, or NULL */
795  int* npriopseudocands /**< pointer to store the number of candidates with maximal priority, or NULL */
796  )
797 {
798  assert(branchcand != NULL);
799 
800 #ifndef NDEBUG
801  /* check, if the current pseudo branching candidate array is correct */
802  {
803  SCIP_VAR* var;
804  int npcs;
805  int v;
806 
807  assert(prob != NULL);
808 
809  /* pseudo branching candidates are non-fixed binary, integer, and implicit integer variables */
810  npcs = 0;
811  for( v = 0; v < prob->nbinvars + prob->nintvars + prob->nimplvars; ++v )
812  {
813  var = prob->vars[v];
814  assert(var != NULL);
816  assert(SCIPvarGetType(var) == SCIP_VARTYPE_BINARY
819  assert(SCIPsetIsFeasIntegral(set, SCIPvarGetLbLocal(var)));
820  assert(SCIPsetIsFeasIntegral(set, SCIPvarGetUbLocal(var)));
821  assert(SCIPsetIsLE(set, SCIPvarGetLbLocal(var), SCIPvarGetUbLocal(var)));
822 
823  if( SCIPsetIsLT(set, SCIPvarGetLbLocal(var), SCIPvarGetUbLocal(var)) )
824  {
825  assert(0 <= var->pseudocandindex && var->pseudocandindex < branchcand->npseudocands);
826  assert(branchcand->pseudocands[var->pseudocandindex] == var);
827  npcs++;
828  }
829  else
830  {
831  assert(var->pseudocandindex == -1);
832  }
833  }
834  assert(branchcand->npseudocands == npcs);
835  for (v = 0; v < branchcand->npriopseudocands; ++v)
836  assert( branchcand->pseudocands[v]->branchpriority == branchcand->pseudomaxpriority );
837  }
838 #endif
839 
840  /* assign return values */
841  if( pseudocands != NULL )
842  *pseudocands = branchcand->pseudocands;
843  if( npseudocands != NULL )
844  *npseudocands = branchcand->npseudocands;
845  if( npriopseudocands != NULL )
846  *npriopseudocands = (set->branch_preferbinary && branchcand->npriopseudobins > 0 ? branchcand->npriopseudobins
847  : branchcand->npriopseudocands);
848 
849  return SCIP_OKAY;
850 }
851 
852 /** gets number of branching candidates for pseudo solution branching (non-fixed variables) */
854  SCIP_BRANCHCAND* branchcand /**< branching candidate storage */
855  )
856 {
857  assert(branchcand != NULL);
858 
859  return branchcand->npseudocands;
860 }
861 
862 /** gets number of branching candidates with maximal branch priority for pseudo solution branching */
864  SCIP_BRANCHCAND* branchcand /**< branching candidate storage */
865  )
866 {
867  assert(branchcand != NULL);
868 
869  return branchcand->npriopseudocands;
870 }
871 
872 /** gets number of binary branching candidates with maximal branch priority for pseudo solution branching */
874  SCIP_BRANCHCAND* branchcand /**< branching candidate storage */
875  )
876 {
877  assert(branchcand != NULL);
878 
879  return branchcand->npriopseudobins;
880 }
881 
882 /** gets number of integer branching candidates with maximal branch priority for pseudo solution branching */
884  SCIP_BRANCHCAND* branchcand /**< branching candidate storage */
885  )
886 {
887  assert(branchcand != NULL);
888 
889  return branchcand->npriopseudoints;
890 }
891 
892 /** gets number of implicit integer branching candidates with maximal branch priority for pseudo solution branching */
894  SCIP_BRANCHCAND* branchcand /**< branching candidate storage */
895  )
896 {
897  assert(branchcand != NULL);
898 
899  return branchcand->npriopseudocands - branchcand->npriopseudobins - branchcand->npriopseudoints;
900 }
901 
902 /** insert pseudocand at given position, or to the first positions of the maximal priority candidates, using the
903  * given position as free slot for the other candidates
904  */
905 static
907  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
908  SCIP_VAR* var, /**< variable to insert */
909  int insertpos /**< free position to insert the variable */
910  )
911 {
912  SCIP_VARTYPE vartype;
913  int branchpriority;
914 
915  assert(branchcand != NULL);
916  assert(var != NULL);
917  assert(branchcand->npriopseudocands <= insertpos && insertpos < branchcand->npseudocands);
918  assert(branchcand->npseudocands <= branchcand->pseudocandssize);
919 
920  vartype = SCIPvarGetType(var);
921  branchpriority = SCIPvarGetBranchPriority(var);
922 
923  SCIPdebugMessage("inserting pseudo candidate <%s> of type %d and priority %d into candidate set at position %d (maxprio: %d)\n",
924  SCIPvarGetName(var), vartype, branchpriority, insertpos, branchcand->pseudomaxpriority);
925 
926  /* insert the variable into pseudocands, making sure, that the highest priority candidates are at the front
927  * and ordered binaries, integers, implicit integers
928  */
929  if( branchpriority > branchcand->pseudomaxpriority )
930  {
931  /* candidate has higher priority than the current maximum:
932  * move it to the front and declare it to be the single best candidate
933  */
934  if( insertpos != 0 )
935  {
936  branchcand->pseudocands[insertpos] = branchcand->pseudocands[0];
937  branchcand->pseudocands[insertpos]->pseudocandindex = insertpos;
938  insertpos = 0;
939  }
940  branchcand->npriopseudocands = 1;
941  branchcand->npriopseudobins = (vartype == SCIP_VARTYPE_BINARY ? 1 : 0);
942  branchcand->npriopseudoints = (vartype == SCIP_VARTYPE_INTEGER ? 1 : 0);
943  branchcand->pseudomaxpriority = branchpriority;
944  }
945  else if( branchpriority == branchcand->pseudomaxpriority )
946  {
947  /* candidate has equal priority as the current maximum:
948  * move away the first non-maximal priority candidate, move the current candidate to the correct
949  * slot (binaries first, integers next, implicit integers last) and increase the number of maximal priority candidates
950  */
951  if( insertpos != branchcand->npriopseudocands )
952  {
953  branchcand->pseudocands[insertpos] = branchcand->pseudocands[branchcand->npriopseudocands];
954  branchcand->pseudocands[insertpos]->pseudocandindex = insertpos;
955  insertpos = branchcand->npriopseudocands;
956  }
957  branchcand->npriopseudocands++;
958  if( vartype == SCIP_VARTYPE_BINARY || vartype == SCIP_VARTYPE_INTEGER )
959  {
960  if( insertpos != branchcand->npriopseudobins + branchcand->npriopseudoints )
961  {
962  branchcand->pseudocands[insertpos] =
963  branchcand->pseudocands[branchcand->npriopseudobins + branchcand->npriopseudoints];
964  branchcand->pseudocands[insertpos]->pseudocandindex = insertpos;
965  insertpos = branchcand->npriopseudobins + branchcand->npriopseudoints;
966  }
967  branchcand->npriopseudoints++;
968 
969  if( vartype == SCIP_VARTYPE_BINARY )
970  {
971  if( insertpos != branchcand->npriopseudobins )
972  {
973  branchcand->pseudocands[insertpos] = branchcand->pseudocands[branchcand->npriopseudobins];
974  branchcand->pseudocands[insertpos]->pseudocandindex = insertpos;
975  insertpos = branchcand->npriopseudobins;
976  }
977  branchcand->npriopseudobins++;
978  branchcand->npriopseudoints--;
979  }
980  }
981  }
982  branchcand->pseudocands[insertpos] = var;
983  var->pseudocandindex = insertpos;
984 
985  SCIPdebugMessage(" -> inserted at position %d (npriopseudocands=%d)\n", insertpos, branchcand->npriopseudocands);
986 
987  assert(0 <= branchcand->npriopseudocands && branchcand->npriopseudocands <= branchcand->npseudocands);
988  assert(0 <= branchcand->npriopseudobins && branchcand->npriopseudobins <= branchcand->npriopseudocands);
989  assert(0 <= branchcand->npriopseudoints && branchcand->npriopseudoints <= branchcand->npriopseudocands);
990 }
991 
992 /** sorts the pseudo branching candidates, such that the candidates of maximal priority are at the front,
993  * ordered by binaries, integers, implicit integers
994  */
995 static
997  SCIP_BRANCHCAND* branchcand /**< branching candidate storage */
998  )
999 {
1000  SCIP_VAR* var;
1001  int i;
1002 
1003  assert(branchcand != NULL);
1004  assert(branchcand->npriopseudocands == 0); /* is only be called after removal of last maximal candidate */
1005  assert(branchcand->npriopseudobins == 0);
1006  assert(branchcand->npriopseudoints == 0);
1007 
1008  SCIPdebugMessage("resorting pseudo candidates\n");
1009 
1010  branchcand->pseudomaxpriority = INT_MIN;
1011 
1012  for( i = 0; i < branchcand->npseudocands; ++i )
1013  {
1014  var = branchcand->pseudocands[i];
1015  assert(var->pseudocandindex == i);
1016 
1017  if( SCIPvarGetBranchPriority(var) >= branchcand->pseudomaxpriority )
1018  branchcandInsertPseudoCand(branchcand, var, i);
1019  }
1020 
1021  assert(0 <= branchcand->npriopseudocands && branchcand->npriopseudocands <= branchcand->npseudocands);
1022  assert(0 <= branchcand->npriopseudobins && branchcand->npriopseudobins <= branchcand->npriopseudocands);
1023  assert(0 <= branchcand->npriopseudoints && branchcand->npriopseudoints <= branchcand->npriopseudocands);
1024 #ifndef NDEBUG
1025  {
1026  for (i = 0; i < branchcand->npriopseudocands; ++i)
1027  assert( branchcand->pseudocands[i]->branchpriority == branchcand->pseudomaxpriority );
1028  }
1029 #endif
1030 }
1031 
1032 /** removes pseudo candidate from pseudocands array
1033  */
1034 static
1036  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
1037  SCIP_VAR* var /**< variable to remove */
1038  )
1039 {
1040  int freepos;
1041 
1042  assert(branchcand != NULL);
1043  assert(var != NULL);
1044  assert(var->pseudocandindex < branchcand->npseudocands);
1045  assert(branchcand->pseudocands[var->pseudocandindex] == var);
1046  assert(branchcand->pseudocands[branchcand->npseudocands-1] != NULL);
1047 
1048  /* Note that the branching priority of the variable to be removed is not necessarily equal to pseudomaxpriority, since
1049  * the status of the variable might have changed, leading to a change in the branching priority. Moreover, if the
1050  * variable was part of an aggregation, even other variables might at this point have different priorities. */
1051  SCIPdebugMessage("removing pseudo candidate <%s> of type %d and priority %d at %d from candidate set (maxprio: %d)\n",
1053  branchcand->pseudomaxpriority);
1054 
1055  /* delete the variable from pseudocands, making sure, that the highest priority candidates are at the front
1056  * and ordered binaries, integers, implicit integers
1057  */
1058  freepos = var->pseudocandindex;
1059  var->pseudocandindex = -1;
1060  assert(0 <= freepos && freepos < branchcand->npseudocands);
1061 
1062  if( freepos < branchcand->npriopseudobins )
1063  {
1064  /* a binary candidate of maximal priority was removed */
1065  assert(SCIPvarGetType(var) == SCIP_VARTYPE_BINARY);
1066  if( freepos != branchcand->npriopseudobins - 1 )
1067  {
1068  branchcand->pseudocands[freepos] = branchcand->pseudocands[branchcand->npriopseudobins - 1];
1069  branchcand->pseudocands[freepos]->pseudocandindex = freepos;
1070  freepos = branchcand->npriopseudobins - 1;
1071  }
1072  branchcand->npriopseudobins--;
1073  branchcand->npriopseudoints++;
1074  }
1075 
1076  if( freepos < branchcand->npriopseudobins + branchcand->npriopseudoints )
1077  {
1078  /* a binary or integer candidate of maximal priority was removed */
1080  if( freepos != branchcand->npriopseudobins + branchcand->npriopseudoints - 1 )
1081  {
1082  branchcand->pseudocands[freepos] =
1083  branchcand->pseudocands[branchcand->npriopseudobins + branchcand->npriopseudoints - 1];
1084  branchcand->pseudocands[freepos]->pseudocandindex = freepos;
1085  freepos = branchcand->npriopseudobins + branchcand->npriopseudoints - 1;
1086  }
1087  branchcand->npriopseudoints--;
1088  }
1089 
1090  if( freepos < branchcand->npriopseudocands )
1091  {
1092  /* a candidate of maximal priority was removed */
1093  if( freepos != branchcand->npriopseudocands - 1 )
1094  {
1095  branchcand->pseudocands[freepos] = branchcand->pseudocands[branchcand->npriopseudocands - 1];
1096  branchcand->pseudocands[freepos]->pseudocandindex = freepos;
1097  freepos = branchcand->npriopseudocands - 1;
1098  }
1099  branchcand->npriopseudocands--;
1100  }
1101  if( freepos != branchcand->npseudocands - 1 )
1102  {
1103  branchcand->pseudocands[freepos] = branchcand->pseudocands[branchcand->npseudocands - 1];
1104  branchcand->pseudocands[freepos]->pseudocandindex = freepos;
1105  }
1106  branchcand->npseudocands--;
1107 
1108  assert(0 <= branchcand->npriopseudocands && branchcand->npriopseudocands <= branchcand->npseudocands);
1109  assert(0 <= branchcand->npriopseudobins && branchcand->npriopseudobins <= branchcand->npriopseudocands);
1110  assert(0 <= branchcand->npriopseudoints && branchcand->npriopseudoints <= branchcand->npriopseudocands);
1111 
1112  /* if all maximal priority candidates were removed, resort the array s.t. the new maximal priority candidates
1113  * are at the front
1114  */
1115  if( branchcand->npriopseudocands == 0 )
1116  branchcandSortPseudoCands(branchcand);
1117 }
1118 
1119 /** removes variable from branching candidate list */
1121  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
1122  SCIP_VAR* var /**< variable that changed its bounds */
1123  )
1124 {
1125  assert(var != NULL);
1126 
1127  /* make sure, variable is not member of the pseudo branching candidate list */
1128  if( var->pseudocandindex >= 0 )
1129  {
1130  branchcandRemovePseudoCand(branchcand, var);
1131  }
1132 
1133  return SCIP_OKAY;
1134 }
1135 
1136 /** updates branching candidate list for a given variable */
1138  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
1139  SCIP_SET* set, /**< global SCIP settings */
1140  SCIP_VAR* var /**< variable that changed its bounds */
1141  )
1142 {
1143  assert(branchcand != NULL);
1144  assert(var != NULL);
1145 
1148  && SCIPsetIsLT(set, SCIPvarGetLbLocal(var), SCIPvarGetUbLocal(var)) )
1149  {
1150  /* variable is neither continuous nor fixed and has non-empty domain: make sure it is member of the pseudo branching candidate list */
1151  if( var->pseudocandindex == -1 )
1152  {
1153  SCIP_CALL( ensurePseudocandsSize(branchcand, set, branchcand->npseudocands+1) );
1154 
1155  branchcand->npseudocands++;
1156  branchcandInsertPseudoCand(branchcand, var, branchcand->npseudocands-1);
1157  }
1158  }
1159  else
1160  {
1167  || SCIPsetIsGE(set, SCIPvarGetLbLocal(var), SCIPvarGetUbLocal(var)));
1168 
1169  /* variable is continuous or fixed or has empty domain: make sure it is not member of the pseudo branching candidate list */
1170  SCIP_CALL( SCIPbranchcandRemoveVar(branchcand, var) );
1171  }
1172 
1173  return SCIP_OKAY;
1174 }
1175 
1176 /** updates branching priority of the given variable and update the pseudo candidate array if needed */
1178  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
1179  SCIP_SET* set, /**< global SCIP settings */
1180  SCIP_VAR* var, /**< variable that changed its bounds */
1181  int branchpriority /**< branch priority of the variable */
1182  )
1183 {
1184  int oldbranchpriority;
1185  int pseudomaxpriority;
1186 
1187  assert(branchcand != NULL);
1188 
1189  oldbranchpriority = SCIPvarGetBranchPriority(var);
1190 
1191  if( oldbranchpriority == branchpriority )
1192  return SCIP_OKAY;
1193 
1194  pseudomaxpriority = branchcand->pseudomaxpriority;
1195 
1196  /* if the variable currently belongs to the priority set or the new branching priority is larger than the current one,
1197  * remove it from the pseudo branch candidate array */
1198  if( oldbranchpriority == pseudomaxpriority || branchpriority > pseudomaxpriority )
1199  {
1200  SCIP_CALL( SCIPbranchcandRemoveVar(branchcand, var) );
1201  assert(var->pseudocandindex == -1);
1202  }
1203 
1204  /* change the branching priority of the variable */
1205  SCIP_CALL( SCIPvarChgBranchPriority(var, branchpriority) );
1206 
1207  /* if the variable is not part of the pseudo branching candidate array, check if it is a pseudo branching candidate
1208  * and add it if so */
1209  SCIP_CALL( SCIPbranchcandUpdateVar(branchcand, set, var) );
1210 
1211  return SCIP_OKAY;
1212 }
1213 
1214 
1215 
1216 /*
1217  * branching rule methods
1218  */
1219 
1220 /** compares two branching rules w. r. to their priority */
1221 SCIP_DECL_SORTPTRCOMP(SCIPbranchruleComp)
1222 { /*lint --e{715}*/
1223  return ((SCIP_BRANCHRULE*)elem2)->priority - ((SCIP_BRANCHRULE*)elem1)->priority;
1224 }
1225 
1226 /** comparison method for sorting branching rules w.r.t. to their name */
1227 SCIP_DECL_SORTPTRCOMP(SCIPbranchruleCompName)
1228 {
1230 }
1231 
1232 /** method to call, when the priority of a branching rule was changed */
1233 static
1234 SCIP_DECL_PARAMCHGD(paramChgdBranchrulePriority)
1235 { /*lint --e{715}*/
1236  SCIP_PARAMDATA* paramdata;
1237 
1238  paramdata = SCIPparamGetData(param);
1239  assert(paramdata != NULL);
1240 
1241  /* use SCIPsetBranchrulePriority() to mark the branchrules unsorted */
1242  SCIP_CALL( SCIPsetBranchrulePriority(scip, (SCIP_BRANCHRULE*)paramdata, SCIPparamGetInt(param)) ); /*lint !e740*/
1243 
1244  return SCIP_OKAY;
1245 }
1246 
1247 /** copies the given branchrule to a new scip */
1249  SCIP_BRANCHRULE* branchrule, /**< branchrule */
1250  SCIP_SET* set /**< SCIP_SET of SCIP to copy to */
1251  )
1252 {
1253  assert(branchrule != NULL);
1254  assert(set != NULL);
1255  assert(set->scip != NULL);
1256 
1257  if( branchrule->branchcopy != NULL )
1258  {
1259  SCIPsetDebugMsg(set, "including branching rule %s in subscip %p\n", SCIPbranchruleGetName(branchrule), (void*)set->scip);
1260  SCIP_CALL( branchrule->branchcopy(set->scip, branchrule) );
1261  }
1262 
1263  return SCIP_OKAY;
1264 }
1265 
1266 /** creates a branching rule */
1268  SCIP_BRANCHRULE** branchrule, /**< pointer to store branching rule */
1269  SCIP_SET* set, /**< global SCIP settings */
1270  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
1271  BMS_BLKMEM* blkmem, /**< block memory for parameter settings */
1272  const char* name, /**< name of branching rule */
1273  const char* desc, /**< description of branching rule */
1274  int priority, /**< priority of the branching rule */
1275  int maxdepth, /**< maximal depth level, up to which this branching rule should be used (or -1) */
1276  SCIP_Real maxbounddist, /**< maximal relative distance from current node's dual bound to primal bound
1277  * compared to best node's dual bound for applying branching rule
1278  * (0.0: only on current best node, 1.0: on all nodes) */
1279  SCIP_DECL_BRANCHCOPY ((*branchcopy)), /**< copy method of branching rule */
1280  SCIP_DECL_BRANCHFREE ((*branchfree)), /**< destructor of branching rule */
1281  SCIP_DECL_BRANCHINIT ((*branchinit)), /**< initialize branching rule */
1282  SCIP_DECL_BRANCHEXIT ((*branchexit)), /**< deinitialize branching rule */
1283  SCIP_DECL_BRANCHINITSOL((*branchinitsol)),/**< solving process initialization method of branching rule */
1284  SCIP_DECL_BRANCHEXITSOL((*branchexitsol)),/**< solving process deinitialization method of branching rule */
1285  SCIP_DECL_BRANCHEXECLP((*branchexeclp)), /**< branching execution method for fractional LP solutions */
1286  SCIP_DECL_BRANCHEXECEXT((*branchexecext)),/**< branching execution method for external solutions */
1287  SCIP_DECL_BRANCHEXECPS((*branchexecps)), /**< branching execution method for not completely fixed pseudo solutions */
1288  SCIP_BRANCHRULEDATA* branchruledata /**< branching rule data */
1289  )
1290 {
1291  char paramname[SCIP_MAXSTRLEN];
1292  char paramdesc[SCIP_MAXSTRLEN];
1293 
1294  assert(branchrule != NULL);
1295  assert(name != NULL);
1296  assert(desc != NULL);
1297 
1298  SCIP_ALLOC( BMSallocMemory(branchrule) );
1299  SCIP_ALLOC( BMSduplicateMemoryArray(&(*branchrule)->name, name, strlen(name)+1) );
1300  SCIP_ALLOC( BMSduplicateMemoryArray(&(*branchrule)->desc, desc, strlen(desc)+1) );
1301  (*branchrule)->priority = priority;
1302  (*branchrule)->maxdepth = maxdepth;
1303  (*branchrule)->maxbounddist = maxbounddist;
1304  (*branchrule)->branchcopy = branchcopy;
1305  (*branchrule)->branchfree = branchfree;
1306  (*branchrule)->branchinit = branchinit;
1307  (*branchrule)->branchexit = branchexit;
1308  (*branchrule)->branchinitsol = branchinitsol;
1309  (*branchrule)->branchexitsol = branchexitsol;
1310  (*branchrule)->branchexeclp = branchexeclp;
1311  (*branchrule)->branchexecext = branchexecext;
1312  (*branchrule)->branchexecps = branchexecps;
1313  (*branchrule)->branchruledata = branchruledata;
1314  SCIP_CALL( SCIPclockCreate(&(*branchrule)->setuptime, SCIP_CLOCKTYPE_DEFAULT) );
1315  SCIP_CALL( SCIPclockCreate(&(*branchrule)->branchclock, SCIP_CLOCKTYPE_DEFAULT) );
1316  (*branchrule)->nlpcalls = 0;
1317  (*branchrule)->nexterncalls = 0;
1318  (*branchrule)->npseudocalls = 0;
1319  (*branchrule)->ncutoffs = 0;
1320  (*branchrule)->ncutsfound = 0;
1321  (*branchrule)->nconssfound = 0;
1322  (*branchrule)->ndomredsfound = 0;
1323  (*branchrule)->nchildren = 0;
1324  (*branchrule)->initialized = FALSE;
1325 
1326  /* add parameters */
1327  (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "branching/%s/priority", name);
1328  (void) SCIPsnprintf(paramdesc, SCIP_MAXSTRLEN, "priority of branching rule <%s>", name);
1329  SCIP_CALL( SCIPsetAddIntParam(set, messagehdlr, blkmem, paramname, paramdesc,
1330  &(*branchrule)->priority, FALSE, priority, INT_MIN/4, INT_MAX/4,
1331  paramChgdBranchrulePriority, (SCIP_PARAMDATA*)(*branchrule)) ); /*lint !e740*/
1332  (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "branching/%s/maxdepth", name);
1333  (void) SCIPsnprintf(paramdesc, SCIP_MAXSTRLEN, "maximal depth level, up to which branching rule <%s> should be used (-1 for no limit)", name);
1334  SCIP_CALL( SCIPsetAddIntParam(set, messagehdlr, blkmem, paramname, paramdesc,
1335  &(*branchrule)->maxdepth, FALSE, maxdepth, -1, SCIP_MAXTREEDEPTH,
1336  NULL, NULL) ); /*lint !e740*/
1337  (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "branching/%s/maxbounddist", name);
1338  (void) SCIPsnprintf(paramdesc, SCIP_MAXSTRLEN, "maximal relative distance from current node's dual bound to primal bound compared to best node's dual bound for applying branching rule (0.0: only on current best node, 1.0: on all nodes)");
1339  SCIP_CALL( SCIPsetAddRealParam(set, messagehdlr, blkmem, paramname, paramdesc,
1340  &(*branchrule)->maxbounddist, FALSE, maxbounddist, 0.0, 1.0,
1341  NULL, NULL) ); /*lint !e740*/
1342 
1343  return SCIP_OKAY;
1344 }
1345 
1346 /** frees memory of branching rule */
1348  SCIP_BRANCHRULE** branchrule, /**< pointer to branching rule data structure */
1349  SCIP_SET* set /**< global SCIP settings */
1350  )
1351 {
1352  assert(branchrule != NULL);
1353  assert(*branchrule != NULL);
1354  assert(!(*branchrule)->initialized);
1355  assert(set != NULL);
1356 
1357  /* call destructor of branching rule */
1358  if( (*branchrule)->branchfree != NULL )
1359  {
1360  SCIP_CALL( (*branchrule)->branchfree(set->scip, *branchrule) );
1361  }
1362 
1363  SCIPclockFree(&(*branchrule)->branchclock);
1364  SCIPclockFree(&(*branchrule)->setuptime);
1365  BMSfreeMemoryArray(&(*branchrule)->name);
1366  BMSfreeMemoryArray(&(*branchrule)->desc);
1367  BMSfreeMemory(branchrule);
1368 
1369  return SCIP_OKAY;
1370 }
1371 
1372 /** initializes branching rule */
1374  SCIP_BRANCHRULE* branchrule, /**< branching rule */
1375  SCIP_SET* set /**< global SCIP settings */
1376  )
1377 {
1378  assert(branchrule != NULL);
1379  assert(set != NULL);
1380 
1381  if( branchrule->initialized )
1382  {
1383  SCIPerrorMessage("branching rule <%s> already initialized\n", branchrule->name);
1384  return SCIP_INVALIDCALL;
1385  }
1386 
1387  if( set->misc_resetstat )
1388  {
1389  SCIPclockReset(branchrule->setuptime);
1390  SCIPclockReset(branchrule->branchclock);
1391  branchrule->nlpcalls = 0;
1392  branchrule->nexterncalls = 0;
1393  branchrule->npseudocalls = 0;
1394  branchrule->ncutoffs = 0;
1395  branchrule->ncutsfound = 0;
1396  branchrule->nconssfound = 0;
1397  branchrule->ndomredsfound = 0;
1398  branchrule->nchildren = 0;
1399  }
1400 
1401  if( branchrule->branchinit != NULL )
1402  {
1403  /* start timing */
1404  SCIPclockStart(branchrule->setuptime, set);
1405 
1406  SCIP_CALL( branchrule->branchinit(set->scip, branchrule) );
1407 
1408  /* stop timing */
1409  SCIPclockStop(branchrule->setuptime, set);
1410  }
1411  branchrule->initialized = TRUE;
1412 
1413  return SCIP_OKAY;
1414 }
1415 
1416 /** deinitializes branching rule */
1418  SCIP_BRANCHRULE* branchrule, /**< branching rule */
1419  SCIP_SET* set /**< global SCIP settings */
1420  )
1421 {
1422  assert(branchrule != NULL);
1423  assert(set != NULL);
1424 
1425  if( !branchrule->initialized )
1426  {
1427  SCIPerrorMessage("branching rule <%s> not initialized\n", branchrule->name);
1428  return SCIP_INVALIDCALL;
1429  }
1430 
1431  if( branchrule->branchexit != NULL )
1432  {
1433  /* start timing */
1434  SCIPclockStart(branchrule->setuptime, set);
1435 
1436  SCIP_CALL( branchrule->branchexit(set->scip, branchrule) );
1437 
1438  /* stop timing */
1439  SCIPclockStop(branchrule->setuptime, set);
1440  }
1441  branchrule->initialized = FALSE;
1442 
1443  return SCIP_OKAY;
1444 }
1445 
1446 /** informs branching rule that the branch and bound process is being started */
1448  SCIP_BRANCHRULE* branchrule, /**< branching rule */
1449  SCIP_SET* set /**< global SCIP settings */
1450  )
1451 {
1452  assert(branchrule != NULL);
1453  assert(set != NULL);
1454 
1455  /* call solving process initialization method of branching rule */
1456  if( branchrule->branchinitsol != NULL )
1457  {
1458  /* start timing */
1459  SCIPclockStart(branchrule->setuptime, set);
1460 
1461  SCIP_CALL( branchrule->branchinitsol(set->scip, branchrule) );
1462 
1463  /* stop timing */
1464  SCIPclockStop(branchrule->setuptime, set);
1465  }
1466 
1467  return SCIP_OKAY;
1468 }
1469 
1470 /** informs branching rule that the branch and bound process data is being freed */
1472  SCIP_BRANCHRULE* branchrule, /**< branching rule */
1473  SCIP_SET* set /**< global SCIP settings */
1474  )
1475 {
1476  assert(branchrule != NULL);
1477  assert(set != NULL);
1478 
1479  /* call solving process deinitialization method of branching rule */
1480  if( branchrule->branchexitsol != NULL )
1481  {
1482  /* start timing */
1483  SCIPclockStart(branchrule->setuptime, set);
1484 
1485  SCIP_CALL( branchrule->branchexitsol(set->scip, branchrule) );
1486 
1487  /* stop timing */
1488  SCIPclockStop(branchrule->setuptime, set);
1489  }
1490 
1491  return SCIP_OKAY;
1492 }
1493 
1494 /** executes branching rule for fractional LP solution */
1496  SCIP_BRANCHRULE* branchrule, /**< branching rule */
1497  SCIP_SET* set, /**< global SCIP settings */
1498  SCIP_STAT* stat, /**< problem statistics */
1499  SCIP_TREE* tree, /**< branch and bound tree */
1500  SCIP_SEPASTORE* sepastore, /**< separation storage */
1501  SCIP_Real cutoffbound, /**< global upper cutoff bound */
1502  SCIP_Bool allowaddcons, /**< should adding constraints be allowed to avoid a branching? */
1503  SCIP_RESULT* result /**< pointer to store the result of the callback method */
1504  )
1505 {
1506  assert(branchrule != NULL);
1507  assert(set != NULL);
1508  assert(tree != NULL);
1509  assert(tree->focusnode != NULL);
1510  assert(tree->nchildren == 0);
1511  assert(result != NULL);
1512 
1513  *result = SCIP_DIDNOTRUN;
1514  if( branchrule->branchexeclp != NULL
1515  && (branchrule->maxdepth == -1 || branchrule->maxdepth >= SCIPtreeGetCurrentDepth(tree)) )
1516  {
1517  SCIP_Real loclowerbound;
1518  SCIP_Real glblowerbound;
1519  SCIP_Bool runbranchrule;
1520 
1521  loclowerbound = SCIPnodeGetLowerbound(tree->focusnode);
1522  glblowerbound = SCIPtreeGetLowerbound(tree, set);
1523 
1524  /* we distinguish between finite and infinite global lower bounds to avoid comparisons between different values > SCIPinfinity() */
1525  if( SCIPsetIsInfinity(set, -glblowerbound) )
1526  runbranchrule = SCIPsetIsInfinity(set, -loclowerbound) || SCIPsetIsGE(set, branchrule->maxbounddist, 1.0);
1527  else
1528  {
1529  assert(!SCIPsetIsInfinity(set, -loclowerbound));
1530  runbranchrule = SCIPsetIsLE(set, loclowerbound - glblowerbound, branchrule->maxbounddist * (cutoffbound - glblowerbound));
1531  }
1532 
1533  if( runbranchrule )
1534  {
1535  SCIP_Longint oldndomchgs;
1536  SCIP_Longint oldnprobdomchgs;
1537  SCIP_Longint oldnactiveconss;
1538  int oldncuts;
1539 
1540  SCIPsetDebugMsg(set, "executing LP branching rule <%s>\n", branchrule->name);
1541 
1542  oldndomchgs = stat->nboundchgs + stat->nholechgs;
1543  oldnprobdomchgs = stat->nprobboundchgs + stat->nprobholechgs;
1544  oldncuts = SCIPsepastoreGetNCuts(sepastore);
1545  oldnactiveconss = stat->nactiveconssadded;
1546 
1547  /* start timing */
1548  SCIPclockStart(branchrule->branchclock, set);
1549 
1550  /* call external method */
1551  SCIP_CALL( branchrule->branchexeclp(set->scip, branchrule, allowaddcons, result) );
1552 
1553  /* stop timing */
1554  SCIPclockStop(branchrule->branchclock, set);
1555 
1556  /* evaluate result */
1557  if( *result != SCIP_CUTOFF
1558  && *result != SCIP_CONSADDED
1559  && *result != SCIP_REDUCEDDOM
1560  && *result != SCIP_SEPARATED
1561  && *result != SCIP_BRANCHED
1562  && *result != SCIP_DIDNOTFIND
1563  && *result != SCIP_DIDNOTRUN )
1564  {
1565  SCIPerrorMessage("branching rule <%s> returned invalid result code <%d> from LP solution branching\n",
1566  branchrule->name, *result);
1567  return SCIP_INVALIDRESULT;
1568  }
1569  if( *result == SCIP_CONSADDED && !allowaddcons )
1570  {
1571  SCIPerrorMessage("branching rule <%s> added a constraint in LP solution branching without permission\n",
1572  branchrule->name);
1573  return SCIP_INVALIDRESULT;
1574  }
1575 
1576  /* update statistics */
1577  if( *result != SCIP_DIDNOTRUN )
1578  branchrule->nlpcalls++;
1579  if( *result == SCIP_CUTOFF )
1580  branchrule->ncutoffs++;
1581  if( *result != SCIP_BRANCHED )
1582  {
1583  assert(tree->nchildren == 0);
1584 
1585  /* update domain reductions; therefore remove the domain
1586  * reduction counts which were generated in probing mode */
1587  branchrule->ndomredsfound += stat->nboundchgs + stat->nholechgs - oldndomchgs;
1588  branchrule->ndomredsfound -= (stat->nprobboundchgs + stat->nprobholechgs - oldnprobdomchgs);
1589 
1590  branchrule->ncutsfound += SCIPsepastoreGetNCuts(sepastore) - oldncuts; /*lint !e776*/
1591  branchrule->nconssfound += stat->nactiveconssadded - oldnactiveconss; /*lint !e776*/
1592  }
1593  else
1594  branchrule->nchildren += tree->nchildren;
1595  }
1596  }
1597 
1598  return SCIP_OKAY;
1599 }
1600 
1601 /** executes branching rule for external branching candidates */
1603  SCIP_BRANCHRULE* branchrule, /**< branching rule */
1604  SCIP_SET* set, /**< global SCIP settings */
1605  SCIP_STAT* stat, /**< problem statistics */
1606  SCIP_TREE* tree, /**< branch and bound tree */
1607  SCIP_SEPASTORE* sepastore, /**< separation storage */
1608  SCIP_Real cutoffbound, /**< global upper cutoff bound */
1609  SCIP_Bool allowaddcons, /**< should adding constraints be allowed to avoid a branching? */
1610  SCIP_RESULT* result /**< pointer to store the result of the callback method */
1611  )
1612 {
1613  assert(branchrule != NULL);
1614  assert(set != NULL);
1615  assert(tree != NULL);
1616  assert(tree->focusnode != NULL);
1617  assert(tree->nchildren == 0);
1618  assert(result != NULL);
1619 
1620  *result = SCIP_DIDNOTRUN;
1621  if( branchrule->branchexecext != NULL
1622  && (branchrule->maxdepth == -1 || branchrule->maxdepth >= SCIPtreeGetCurrentDepth(tree)) )
1623  {
1624  SCIP_Real loclowerbound;
1625  SCIP_Real glblowerbound;
1626  SCIP_Bool runbranchrule;
1627 
1628  loclowerbound = SCIPnodeGetLowerbound(tree->focusnode);
1629  glblowerbound = SCIPtreeGetLowerbound(tree, set);
1630  assert(!SCIPsetIsInfinity(set, loclowerbound));
1631 
1632  /* we distinguish between finite and infinite global lower bounds to avoid comparisons between different values > SCIPinfinity() */
1633  if( SCIPsetIsInfinity(set, -glblowerbound) )
1634  runbranchrule = SCIPsetIsInfinity(set, -loclowerbound) || SCIPsetIsGE(set, branchrule->maxbounddist, 1.0);
1635  else
1636  {
1637  assert(!SCIPsetIsInfinity(set, -loclowerbound));
1638  runbranchrule = SCIPsetIsLE(set, loclowerbound - glblowerbound, branchrule->maxbounddist * (cutoffbound - glblowerbound));
1639  }
1640 
1641  if( runbranchrule )
1642  {
1643  SCIP_Longint oldndomchgs;
1644  SCIP_Longint oldnprobdomchgs;
1645  int oldncuts;
1646  int oldnactiveconss;
1647 
1648  SCIPsetDebugMsg(set, "executing external solution branching rule <%s>\n", branchrule->name);
1649 
1650  oldndomchgs = stat->nboundchgs + stat->nholechgs;
1651  oldnprobdomchgs = stat->nprobboundchgs + stat->nprobholechgs;
1652  oldncuts = SCIPsepastoreGetNCuts(sepastore);
1653  oldnactiveconss = stat->nactiveconss;
1654 
1655  /* start timing */
1656  SCIPclockStart(branchrule->branchclock, set);
1657 
1658  /* call external method */
1659  SCIP_CALL( branchrule->branchexecext(set->scip, branchrule, allowaddcons, result) );
1660 
1661  /* stop timing */
1662  SCIPclockStop(branchrule->branchclock, set);
1663 
1664  /* evaluate result */
1665  if( *result != SCIP_CUTOFF
1666  && *result != SCIP_CONSADDED
1667  && *result != SCIP_REDUCEDDOM
1668  && *result != SCIP_SEPARATED
1669  && *result != SCIP_BRANCHED
1670  && *result != SCIP_DIDNOTFIND
1671  && *result != SCIP_DIDNOTRUN )
1672  {
1673  SCIPerrorMessage("branching rule <%s> returned invalid result code <%d> from external solution branching\n",
1674  branchrule->name, *result);
1675  return SCIP_INVALIDRESULT;
1676  }
1677  if( *result == SCIP_CONSADDED && !allowaddcons )
1678  {
1679  SCIPerrorMessage("branching rule <%s> added a constraint in external solution branching without permission\n",
1680  branchrule->name);
1681  return SCIP_INVALIDRESULT;
1682  }
1683 
1684  /* update statistics */
1685  if( *result != SCIP_DIDNOTRUN )
1686  branchrule->nexterncalls++;
1687  if( *result == SCIP_CUTOFF )
1688  branchrule->ncutoffs++;
1689  if( *result != SCIP_BRANCHED )
1690  {
1691  assert(tree->nchildren == 0);
1692 
1693  /* update domain reductions; therefore remove the domain
1694  * reduction counts which were generated in probing mode */
1695  branchrule->ndomredsfound += stat->nboundchgs + stat->nholechgs - oldndomchgs;
1696  branchrule->ndomredsfound -= (stat->nprobboundchgs + stat->nprobholechgs - oldnprobdomchgs);
1697 
1698  branchrule->ncutsfound += SCIPsepastoreGetNCuts(sepastore) - oldncuts; /*lint !e776*/
1699  branchrule->nconssfound += stat->nactiveconss - oldnactiveconss; /*lint !e776*/
1700  }
1701  else
1702  branchrule->nchildren += tree->nchildren;
1703  }
1704  }
1705  return SCIP_OKAY;
1706 }
1707 
1708 /** executes branching rule for not completely fixed pseudo solution */
1710  SCIP_BRANCHRULE* branchrule, /**< branching rule */
1711  SCIP_SET* set, /**< global SCIP settings */
1712  SCIP_STAT* stat, /**< problem statistics */
1713  SCIP_TREE* tree, /**< branch and bound tree */
1714  SCIP_Real cutoffbound, /**< global upper cutoff bound */
1715  SCIP_Bool allowaddcons, /**< should adding constraints be allowed to avoid a branching? */
1716  SCIP_RESULT* result /**< pointer to store the result of the callback method */
1717  )
1718 {
1719  assert(branchrule != NULL);
1720  assert(set != NULL);
1721  assert(tree != NULL);
1722  assert(tree->nchildren == 0);
1723  assert(result != NULL);
1724 
1725  *result = SCIP_DIDNOTRUN;
1726  if( branchrule->branchexecps != NULL
1727  && (branchrule->maxdepth == -1 || branchrule->maxdepth >= SCIPtreeGetCurrentDepth(tree)) )
1728  {
1729  SCIP_Real loclowerbound;
1730  SCIP_Real glblowerbound;
1731  SCIP_Bool runbranchrule;
1732 
1733  loclowerbound = SCIPnodeGetLowerbound(tree->focusnode);
1734  glblowerbound = SCIPtreeGetLowerbound(tree, set);
1735 
1736  /* we distinguish between finite and infinite global lower bounds to avoid comparisons between different values > SCIPinfinity() */
1737  if( SCIPsetIsInfinity(set, -glblowerbound) )
1738  runbranchrule = SCIPsetIsInfinity(set, -loclowerbound) || SCIPsetIsGE(set, branchrule->maxbounddist, 1.0);
1739  else
1740  {
1741  assert(!SCIPsetIsInfinity(set, -loclowerbound));
1742  runbranchrule = SCIPsetIsLE(set, loclowerbound - glblowerbound, branchrule->maxbounddist * (cutoffbound - glblowerbound));
1743  }
1744 
1745  if( runbranchrule )
1746  {
1747  SCIP_Longint oldndomchgs;
1748  SCIP_Longint oldnprobdomchgs;
1749  SCIP_Longint oldnactiveconss;
1750 
1751  SCIPsetDebugMsg(set, "executing pseudo branching rule <%s>\n", branchrule->name);
1752 
1753  oldndomchgs = stat->nboundchgs + stat->nholechgs;
1754  oldnprobdomchgs = stat->nprobboundchgs + stat->nprobholechgs;
1755  oldnactiveconss = stat->nactiveconss;
1756 
1757  /* start timing */
1758  SCIPclockStart(branchrule->branchclock, set);
1759 
1760  /* call external method */
1761  SCIP_CALL( branchrule->branchexecps(set->scip, branchrule, allowaddcons, result) );
1762 
1763  /* stop timing */
1764  SCIPclockStop(branchrule->branchclock, set);
1765 
1766  /* evaluate result */
1767  if( *result != SCIP_CUTOFF
1768  && *result != SCIP_CONSADDED
1769  && *result != SCIP_REDUCEDDOM
1770  && *result != SCIP_BRANCHED
1771  && *result != SCIP_DIDNOTFIND
1772  && *result != SCIP_DIDNOTRUN )
1773  {
1774  SCIPerrorMessage("branching rule <%s> returned invalid result code <%d> from pseudo solution branching\n",
1775  branchrule->name, *result);
1776  return SCIP_INVALIDRESULT;
1777  }
1778  if( *result == SCIP_CONSADDED && !allowaddcons )
1779  {
1780  SCIPerrorMessage("branching rule <%s> added a constraint in pseudo solution branching without permission\n",
1781  branchrule->name);
1782  return SCIP_INVALIDRESULT;
1783  }
1784 
1785  /* update statistics */
1786  if( *result != SCIP_DIDNOTRUN )
1787  branchrule->npseudocalls++;
1788  if( *result == SCIP_CUTOFF )
1789  branchrule->ncutoffs++;
1790  if( *result != SCIP_BRANCHED )
1791  {
1792  assert(tree->nchildren == 0);
1793 
1794  /* update domain reductions; therefore remove the domain
1795  * reduction counts which were generated in probing mode */
1796  branchrule->ndomredsfound += stat->nboundchgs + stat->nholechgs - oldndomchgs;
1797  branchrule->ndomredsfound -= (stat->nprobboundchgs + stat->nprobholechgs - oldnprobdomchgs);
1798 
1799  branchrule->nconssfound += stat->nactiveconss - oldnactiveconss;
1800  }
1801  else
1802  branchrule->nchildren += tree->nchildren;
1803  }
1804  }
1805 
1806  return SCIP_OKAY;
1807 }
1808 
1809 /** gets user data of branching rule */
1811  SCIP_BRANCHRULE* branchrule /**< branching rule */
1812  )
1813 {
1814  assert(branchrule != NULL);
1815 
1816  return branchrule->branchruledata;
1817 }
1818 
1819 /** sets user data of branching rule; user has to free old data in advance! */
1821  SCIP_BRANCHRULE* branchrule, /**< branching rule */
1822  SCIP_BRANCHRULEDATA* branchruledata /**< new branching rule user data */
1823  )
1824 {
1825  assert(branchrule != NULL);
1826 
1827  branchrule->branchruledata = branchruledata;
1828 }
1829 
1830 /** sets copy method of branching rule */
1832  SCIP_BRANCHRULE* branchrule, /**< branching rule */
1833  SCIP_DECL_BRANCHCOPY ((*branchcopy)) /**< copy method of branching rule or NULL if you don't want to copy your plugin into sub-SCIPs */
1834  )
1835 {
1836  assert(branchrule != NULL);
1837 
1838  branchrule->branchcopy = branchcopy;
1839 }
1840 
1841 /** sets destructor method of branching rule */
1843  SCIP_BRANCHRULE* branchrule, /**< branching rule */
1844  SCIP_DECL_BRANCHFREE ((*branchfree)) /**< destructor of branching rule */
1845  )
1846 {
1847  assert(branchrule != NULL);
1848 
1849  branchrule->branchfree = branchfree;
1850 }
1851 
1852 /** sets initialization method of branching rule */
1854  SCIP_BRANCHRULE* branchrule, /**< branching rule */
1855  SCIP_DECL_BRANCHINIT ((*branchinit)) /**< initialize branching rule */
1856  )
1857 {
1858  assert(branchrule != NULL);
1859 
1860  branchrule->branchinit = branchinit;
1861 }
1862 
1863 /** sets deinitialization method of branching rule */
1865  SCIP_BRANCHRULE* branchrule, /**< branching rule */
1866  SCIP_DECL_BRANCHEXIT ((*branchexit)) /**< deinitialize branching rule */
1867  )
1868 {
1869  assert(branchrule != NULL);
1870 
1871  branchrule->branchexit = branchexit;
1872 }
1873 
1874 /** sets solving process initialization method of branching rule */
1876  SCIP_BRANCHRULE* branchrule, /**< branching rule */
1877  SCIP_DECL_BRANCHINITSOL((*branchinitsol)) /**< solving process initialization method of branching rule */
1878  )
1879 {
1880  assert(branchrule != NULL);
1881 
1882  branchrule->branchinitsol = branchinitsol;
1883 }
1884 
1885 /** sets solving process deinitialization method of branching rule */
1887  SCIP_BRANCHRULE* branchrule, /**< branching rule */
1888  SCIP_DECL_BRANCHEXITSOL((*branchexitsol)) /**< solving process deinitialization method of branching rule */
1889  )
1890 {
1891  assert(branchrule != NULL);
1892 
1893  branchrule->branchexitsol = branchexitsol;
1894 }
1895 
1896 
1897 
1898 /** sets branching execution method for fractional LP solutions */
1900  SCIP_BRANCHRULE* branchrule, /**< branching rule */
1901  SCIP_DECL_BRANCHEXECLP((*branchexeclp)) /**< branching execution method for fractional LP solutions */
1902  )
1903 {
1904  assert(branchrule != NULL);
1905 
1906  branchrule->branchexeclp = branchexeclp;
1907 }
1908 
1909 /** sets branching execution method for external candidates */
1911  SCIP_BRANCHRULE* branchrule, /**< branching rule */
1912  SCIP_DECL_BRANCHEXECEXT((*branchexecext)) /**< branching execution method for external candidates */
1913  )
1914 {
1915  assert(branchrule != NULL);
1916 
1917  branchrule->branchexecext = branchexecext;
1918 }
1919 
1920 /** sets branching execution method for not completely fixed pseudo solutions */
1922  SCIP_BRANCHRULE* branchrule, /**< branching rule */
1923  SCIP_DECL_BRANCHEXECPS((*branchexecps)) /**< branching execution method for not completely fixed pseudo solutions */
1924  )
1925 {
1926  assert(branchrule != NULL);
1927 
1928  branchrule->branchexecps = branchexecps;
1929 }
1930 
1931 /** gets name of branching rule */
1933  SCIP_BRANCHRULE* branchrule /**< branching rule */
1934  )
1935 {
1936  assert(branchrule != NULL);
1937 
1938  return branchrule->name;
1939 }
1940 
1941 /** gets description of branching rule */
1943  SCIP_BRANCHRULE* branchrule /**< branching rule */
1944  )
1945 {
1946  assert(branchrule != NULL);
1947 
1948  return branchrule->desc;
1949 }
1950 
1951 /** gets priority of branching rule */
1953  SCIP_BRANCHRULE* branchrule /**< branching rule */
1954  )
1955 {
1956  assert(branchrule != NULL);
1957 
1958  return branchrule->priority;
1959 }
1960 
1961 /** sets priority of branching rule */
1963  SCIP_BRANCHRULE* branchrule, /**< branching rule */
1964  SCIP_SET* set, /**< global SCIP settings */
1965  int priority /**< new priority of the branching rule */
1966  )
1967 {
1968  assert(branchrule != NULL);
1969  assert(set != NULL);
1970 
1971  branchrule->priority = priority;
1972  set->branchrulessorted = FALSE;
1973 }
1974 
1975 /** gets maximal depth level, up to which this branching rule should be used (-1 for no limit) */
1977  SCIP_BRANCHRULE* branchrule /**< branching rule */
1978  )
1979 {
1980  assert(branchrule != NULL);
1981 
1982  return branchrule->maxdepth;
1983 }
1984 
1985 /** sets maximal depth level, up to which this branching rule should be used (-1 for no limit) */
1987  SCIP_BRANCHRULE* branchrule, /**< branching rule */
1988  int maxdepth /**< new maxdepth of the branching rule */
1989  )
1990 {
1991  assert(branchrule != NULL);
1992  assert(maxdepth >= -1);
1993 
1994  branchrule->maxdepth = maxdepth;
1995 }
1996 
1997 /** gets maximal relative distance from current node's dual bound to primal bound for applying branching rule */
1999  SCIP_BRANCHRULE* branchrule /**< branching rule */
2000  )
2001 {
2002  assert(branchrule != NULL);
2003 
2004  return branchrule->maxbounddist;
2005 }
2006 
2007 /** sets maximal relative distance from current node's dual bound to primal bound for applying branching rule */
2009  SCIP_BRANCHRULE* branchrule, /**< branching rule */
2010  SCIP_Real maxbounddist /**< new maxbounddist of the branching rule */
2011  )
2012 {
2013  assert(branchrule != NULL);
2014  assert(maxbounddist >= -1);
2015 
2016  branchrule->maxbounddist = maxbounddist;
2017 }
2018 
2019 /** enables or disables all clocks of \p branchrule, depending on the value of the flag */
2021  SCIP_BRANCHRULE* branchrule, /**< the branching rule for which all clocks should be enabled or disabled */
2022  SCIP_Bool enable /**< should the clocks of the branching rule be enabled? */
2023  )
2024 {
2025  assert(branchrule != NULL);
2026 
2027  SCIPclockEnableOrDisable(branchrule->setuptime, enable);
2028  SCIPclockEnableOrDisable(branchrule->branchclock, enable);
2029 }
2030 
2031 /** gets time in seconds used in this branching rule for setting up for next stages */
2033  SCIP_BRANCHRULE* branchrule /**< branching rule */
2034  )
2035 {
2036  assert(branchrule != NULL);
2037 
2038  return SCIPclockGetTime(branchrule->setuptime);
2039 }
2040 
2041 /** gets time in seconds used in this branching rule */
2043  SCIP_BRANCHRULE* branchrule /**< branching rule */
2044  )
2045 {
2046  assert(branchrule != NULL);
2047 
2048  return SCIPclockGetTime(branchrule->branchclock);
2049 }
2050 
2051 /** gets the total number of times, the branching rule was called on an LP solution */
2053  SCIP_BRANCHRULE* branchrule /**< branching rule */
2054  )
2055 {
2056  assert(branchrule != NULL);
2057 
2058  return branchrule->nlpcalls;
2059 }
2060 
2061 /** gets the total number of times, the branching rule was called on an external solution */
2063  SCIP_BRANCHRULE* branchrule /**< branching rule */
2064  )
2065 {
2066  assert(branchrule != NULL);
2067 
2068  return branchrule->nexterncalls;
2069 }
2070 
2071 /** gets the total number of times, the branching rule was called on a pseudo solution */
2073  SCIP_BRANCHRULE* branchrule /**< branching rule */
2074  )
2075 {
2076  assert(branchrule != NULL);
2077 
2078  return branchrule->npseudocalls;
2079 }
2080 
2081 /** gets the total number of times, the branching rule detected a cutoff */
2083  SCIP_BRANCHRULE* branchrule /**< branching rule */
2084  )
2085 {
2086  assert(branchrule != NULL);
2087 
2088  return branchrule->ncutoffs;
2089 }
2090 
2091 /** gets the total number of cuts, the branching rule separated */
2093  SCIP_BRANCHRULE* branchrule /**< branching rule */
2094  )
2095 {
2096  assert(branchrule != NULL);
2097 
2098  return branchrule->ncutsfound;
2099 }
2100 
2101 /** gets the total number of constraints, the branching rule added to the respective local nodes (not counting constraints
2102  * that were added to the child nodes as branching decisions)
2103  */
2105  SCIP_BRANCHRULE* branchrule /**< branching rule */
2106  )
2107 {
2108  assert(branchrule != NULL);
2109 
2110  return branchrule->nconssfound;
2111 }
2112 
2113 /** gets the total number of domain reductions, the branching rule found */
2115  SCIP_BRANCHRULE* branchrule /**< branching rule */
2116  )
2117 {
2118  assert(branchrule != NULL);
2119 
2120  return branchrule->ndomredsfound;
2121 }
2122 
2123 /** gets the total number of children, the branching rule created */
2125  SCIP_BRANCHRULE* branchrule /**< branching rule */
2126  )
2127 {
2128  assert(branchrule != NULL);
2129 
2130  return branchrule->nchildren;
2131 }
2132 
2133 /** is branching rule initialized? */
2135  SCIP_BRANCHRULE* branchrule /**< branching rule */
2136  )
2137 {
2138  assert(branchrule != NULL);
2139 
2140  return branchrule->initialized;
2141 }
2142 
2143 
2144 
2145 
2146 /*
2147  * branching methods
2148  */
2149 
2150 /** calculates the branching score out of the gain predictions for a binary branching */
2152  SCIP_SET* set, /**< global SCIP settings */
2153  SCIP_VAR* var, /**< variable, of which the branching factor should be applied, or NULL */
2154  SCIP_Real downgain, /**< prediction of objective gain for rounding downwards */
2155  SCIP_Real upgain /**< prediction of objective gain for rounding upwards */
2156  )
2157 {
2158  SCIP_Real score;
2159  SCIP_Real eps;
2160 
2161  assert(set != NULL);
2162 
2163  /* adjust scores near zero to always yield product score greater than 0 */
2164  eps = SCIPsetSumepsilon(set);
2165  if( set->branch_sumadjustscore )
2166  {
2167  /* adjust scores by adding eps to keep near zero score differences between variables */
2168  downgain = downgain + eps;
2169  upgain = upgain + eps;
2170  }
2171  else
2172  {
2173  /* disregard near zero score differences between variables and consider the branching factor for them */
2174  downgain = MAX(downgain, eps);
2175  upgain = MAX(upgain, eps);
2176  }
2177 
2178  switch( set->branch_scorefunc )
2179  {
2180  case 's': /* linear sum score function */
2181  /* weigh the two child nodes with branchscorefac and 1-branchscorefac */
2182  if( downgain > upgain )
2183  score = set->branch_scorefac * downgain + (1.0-set->branch_scorefac) * upgain;
2184  else
2185  score = set->branch_scorefac * upgain + (1.0-set->branch_scorefac) * downgain;
2186  break;
2187 
2188  case 'p': /* product score function */
2189  score = downgain * upgain;
2190  break;
2191  case 'q': /* quotient score function */
2192  if( downgain > upgain )
2193  score = upgain * upgain / downgain;
2194  else
2195  score = downgain * downgain / upgain;
2196  break;
2197  default:
2198  SCIPerrorMessage("invalid branching score function <%c>\n", set->branch_scorefunc);
2199  SCIPABORT();
2200  score = 0.0;
2201  }
2202 
2203  /* apply the branch factor of the variable */
2204  if( var != NULL )
2205  score *= SCIPvarGetBranchFactor(var);
2206 
2207  return score;
2208 }
2209 
2210 /** calculates the branching score out of the gain predictions for a branching with arbitrary many children */
2212  SCIP_SET* set, /**< global SCIP settings */
2213  SCIP_VAR* var, /**< variable, of which the branching factor should be applied, or NULL */
2214  int nchildren, /**< number of children that the branching will create */
2215  SCIP_Real* gains /**< prediction of objective gain for each child */
2216  )
2217 {
2218  SCIP_Real min1;
2219  SCIP_Real min2;
2220  int c;
2221 
2222  assert(nchildren == 0 || gains != NULL);
2223 
2224  /* search for the two minimal gains in the child list and use these to calculate the branching score */
2225  min1 = SCIPsetInfinity(set);
2226  min2 = SCIPsetInfinity(set);
2227  for( c = 0; c < nchildren; ++c )
2228  {
2229  if( gains[c] < min1 )
2230  {
2231  min2 = min1;
2232  min1 = gains[c];
2233  }
2234  else if( gains[c] < min2 )
2235  min2 = gains[c];
2236  }
2237 
2238  return SCIPbranchGetScore(set, var, min1, min2);
2239 }
2240 
2241 /** computes a branching point for a (not necessarily discrete) variable
2242  * a suggested branching point is first projected onto the box
2243  * if no point is suggested, then the value in the current LP or pseudo solution is used
2244  * if this value is at infinity, then 0.0 projected onto the bounds and then moved inside the interval is used
2245  * for a discrete variable, it is ensured that the returned value is fractional
2246  * for a continuous variable, the parameter branching/clamp defines how far a branching point need to be from the bounds of a variable
2247  * the latter is only applied if no point has been suggested, or the suggested point is not inside the variable's interval
2248  */
2250  SCIP_SET* set, /**< global SCIP settings */
2251  SCIP_TREE* tree, /**< branch and bound tree */
2252  SCIP_VAR* var, /**< variable, of which the branching point should be computed */
2253  SCIP_Real suggestion /**< suggestion for branching point, or SCIP_INVALID if no suggestion */
2254  )
2255 {
2256  SCIP_Real branchpoint;
2257  SCIP_Real lb;
2258  SCIP_Real ub;
2259 
2260  assert(set != NULL);
2261  assert(var != NULL);
2262 
2263  lb = SCIPvarGetLbLocal(var);
2264  ub = SCIPvarGetUbLocal(var);
2265 
2266  /* for a fixed variable, we cannot branch further */
2267  assert(!SCIPsetIsEQ(set, lb, ub));
2268 
2269  if( !SCIPsetIsInfinity(set, REALABS(suggestion)) )
2270  {
2271  /* use user suggested branching point */
2272 
2273  /* first, project it onto the current domain */
2274  branchpoint = MAX(lb, MIN(suggestion, ub));
2275 
2277  {
2278  /* if it is a discrete variable, then round it down and up and accept this choice */
2279  if( SCIPsetIsEQ(set, branchpoint, ub) )
2280  {
2281  /* in the right branch, variable is fixed to its current upper bound */
2282  return SCIPsetFloor(set, branchpoint) - 0.5;
2283  }
2284  else
2285  {
2286  /* in the left branch, variable is fixed to its current lower bound */
2287  return SCIPsetFloor(set, branchpoint) + 0.5;
2288  }
2289  }
2290  else if( (SCIPsetIsInfinity(set, -lb) || SCIPsetIsRelGT(set, branchpoint, lb)) &&
2291  (SCIPsetIsInfinity(set, ub) || SCIPsetIsRelLT(set, branchpoint, ub)) )
2292  {
2293  /* if it is continuous and inside the box, then accept it */
2294  return branchpoint;
2295  }
2296  /* if it is continuous and suggestion is on of the bounds, continue below */
2297  }
2298  else
2299  {
2300  /* if no point is suggested and the value in LP solution is not too big, try the LP or pseudo LP solution
2301  * otherwise, if the value in the LP or pseudosolution is large (here 1e+12), use 0.0
2302  * in both cases, project onto bounds of course
2303  */
2304  branchpoint = SCIPvarGetSol(var, SCIPtreeHasCurrentNodeLP(tree));
2305  if( REALABS(branchpoint) > 1e+12 )
2306  branchpoint = 0.0;
2307  branchpoint = MAX(lb, MIN(branchpoint, ub));
2308  }
2309 
2310  /* if value is at +/- infty, then choose some value a bit off from bounds or 0.0 */
2311  if( SCIPsetIsInfinity(set, branchpoint) )
2312  {
2313  /* if value is at +infty, then the upper bound should be at infinity */
2314  assert(SCIPsetIsInfinity(set, ub));
2315 
2316  /* choose 0.0 or something above lower bound if lower bound > 0 */
2317  if( SCIPsetIsPositive(set, lb) )
2318  branchpoint = lb + 1000.0;
2319  else
2320  branchpoint = 0.0;
2321  }
2322  else if( SCIPsetIsInfinity(set, -branchpoint) )
2323  {
2324  /* if value is at -infty, then the lower bound should be at -infinity */
2325  assert(SCIPsetIsInfinity(set, -lb));
2326 
2327  /* choose 0.0 or something below upper bound if upper bound < 0 */
2328  if( SCIPsetIsNegative(set, ub) )
2329  branchpoint = ub - 1000.0;
2330  else
2331  branchpoint = 0.0;
2332  }
2333 
2334  assert(SCIPsetIsInfinity(set, ub) || SCIPsetIsLE(set, branchpoint, ub));
2335  assert(SCIPsetIsInfinity(set, -lb) || SCIPsetIsGE(set, branchpoint, lb));
2336 
2337  if( SCIPvarGetType(var) >= SCIP_VARTYPE_IMPLINT )
2338  {
2339  if( !SCIPsetIsInfinity(set, -lb) || !SCIPsetIsInfinity(set, ub) )
2340  {
2341  /* if one bound is missing, we are temporarily guessing the other one, so we can apply the clamp below */
2342  if( SCIPsetIsInfinity(set, ub) )
2343  {
2344  ub = lb + MIN(MAX(0.5 * REALABS(lb), 1000), 0.9 * (SCIPsetInfinity(set) - lb)); /*lint !e666*/
2345  }
2346  else if( SCIPsetIsInfinity(set, -lb) )
2347  {
2348  lb = ub - MIN(MAX(0.5 * REALABS(ub), 1000), 0.9 * (SCIPsetInfinity(set) + ub)); /*lint !e666*/
2349  }
2350 
2351  /* if branching point is too close to the bounds, move more into the middle of the interval */
2352  if( SCIPrelDiff(ub, lb) <= 2.02 * SCIPsetEpsilon(set) )
2353  {
2354  /* for very tiny intervals we set it exactly into the middle */
2355  branchpoint = (lb+ub)/2.0;
2356  }
2357  else
2358  {
2359  /* otherwise we project it away from the bounds */
2360  SCIP_Real minbrpoint;
2361  SCIP_Real maxbrpoint;
2362  SCIP_Real scale;
2363  SCIP_Real lbabs;
2364  SCIP_Real ubabs;
2365 
2366  lbabs = REALABS(lb);
2367  ubabs = REALABS(ub);
2368 
2369  scale = MAX3(lbabs, ubabs, 1.0);
2370 
2371  /* the minimal branching point should be
2372  * - set->clamp away from the lower bound - relative to the local domain size
2373  * - SCIPsetEpsilon(set)*scale above the lower bound - in absolute value
2374  */
2375  minbrpoint = (1.0 - set->branch_clamp) * lb + set->branch_clamp * ub;
2376  minbrpoint = MAX(lb + 1.01*SCIPsetEpsilon(set)*scale, minbrpoint); /*lint !e666*/
2377 
2378  /* the maximal branching point should be
2379  * - set->clamp away from the upper bound - relative to the local domain size
2380  * - SCIPsetEpsilon(set)*scale below the upper bound - in absolute value
2381  */
2382  maxbrpoint = set->branch_clamp * lb + (1.0 - set->branch_clamp) * ub;
2383  maxbrpoint = MIN(ub - 1.01*SCIPsetEpsilon(set)*scale, maxbrpoint); /*lint !e666*/
2384 
2385  /* project branchpoint into [minbrpoint, maxbrpoint] */
2386  branchpoint = MAX(minbrpoint, MIN(branchpoint, maxbrpoint));
2387 
2388  /* if selected branching point is close to 0.0 and bounds are away from 0.0, it often makes sense to branch exactly on 0.0 */
2389  if( SCIPsetIsFeasZero(set, branchpoint) && SCIPsetIsFeasNegative(set, lb) && SCIPsetIsFeasPositive(set, ub) )
2390  branchpoint = 0.0;
2391 
2392  assert(SCIPsetIsRelLT(set, SCIPvarGetLbLocal(var), branchpoint));
2393  assert(SCIPsetIsRelLT(set, branchpoint, SCIPvarGetUbLocal(var)));
2394  }
2395  }
2396 
2397  /* ensure fractional branching point for implicit integer variables */
2398  if( SCIPvarGetType(var) == SCIP_VARTYPE_IMPLINT && SCIPsetIsIntegral(set, branchpoint) )
2399  {
2400  /* if branchpoint is integral but not on bounds, then it should be one of the value {lb+1, ..., ub-1} */
2401  assert(SCIPsetIsGE(set, SCIPsetRound(set, branchpoint), lb + 1.0));
2402  assert(SCIPsetIsLE(set, SCIPsetRound(set, branchpoint), ub - 1.0));
2403  /* if branchpoint is integral, create one branch with x <= x'-1 and one with x >= x'
2404  * @todo could in the same way be x <= x' and x >= x'+1; is there some easy way to know which is better?
2405  */
2406  return branchpoint - 0.5;
2407  }
2408 
2409  return branchpoint;
2410  }
2411  else
2412  {
2413  /* discrete variables */
2414  if( branchpoint <= lb + 0.5 )
2415  {
2416  /* if branchpoint is on lower bound, create one branch with x = lb and one with x >= lb+1 */
2417  return lb + 0.5;
2418  }
2419  else if( branchpoint >= ub - 0.5 )
2420  {
2421  /* if branchpoint is on upper bound, create one branch with x = ub and one with x <= ub-1 */
2422  return ub - 0.5;
2423  }
2424  else if( SCIPsetIsIntegral(set, branchpoint) )
2425  {
2426  /* if branchpoint is integral but not on bounds, then it should be one of the value {lb+1, ..., ub-1} */
2427  assert(SCIPsetIsGE(set, SCIPsetRound(set, branchpoint), lb + 1.0));
2428  assert(SCIPsetIsLE(set, SCIPsetRound(set, branchpoint), ub - 1.0));
2429  /* if branchpoint is integral, create one branch with x <= x'-1 and one with x >= x'
2430  * @todo could in the same way be x <= x' and x >= x'+1; is there some easy way to know which is better? */
2431  return branchpoint - 0.5;
2432  }
2433  else
2434  {
2435  /* branchpoint is somewhere between bounds and fractional, so just round down and up */
2436  return branchpoint;
2437  }
2438  }
2439 }
2440 
2441 /** calls branching rules to branch on an LP solution; if no fractional variables exist, the result is SCIP_DIDNOTRUN;
2442  * if the branch priority of an unfixed variable is larger than the maximal branch priority of the fractional
2443  * variables, pseudo solution branching is applied on the unfixed variables with maximal branch priority
2444  */
2446  BMS_BLKMEM* blkmem, /**< block memory for parameter settings */
2447  SCIP_SET* set, /**< global SCIP settings */
2448  SCIP_STAT* stat, /**< problem statistics */
2449  SCIP_PROB* transprob, /**< transformed problem after presolve */
2450  SCIP_PROB* origprob, /**< original problem */
2451  SCIP_TREE* tree, /**< branch and bound tree */
2452  SCIP_REOPT* reopt, /**< reoptimization data structure */
2453  SCIP_LP* lp, /**< current LP data */
2454  SCIP_SEPASTORE* sepastore, /**< separation storage */
2455  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
2456  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
2457  SCIP_Real cutoffbound, /**< global upper cutoff bound */
2458  SCIP_Bool allowaddcons, /**< should adding constraints be allowed to avoid a branching? */
2459  SCIP_RESULT* result /**< pointer to store the result of the branching (s. branch.h) */
2460  )
2461 {
2462  int i;
2463  int nalllpcands; /* sum of binary, integer, and implicit branching candidates */
2464 
2465  assert(branchcand != NULL);
2466  assert(result != NULL);
2467 
2468  *result = SCIP_DIDNOTRUN;
2469 
2470  /* calculate branching candidates */
2471  SCIP_CALL( branchcandCalcLPCands(branchcand, set, stat, lp) );
2472  assert(0 <= branchcand->npriolpcands && branchcand->npriolpcands <= branchcand->nlpcands);
2473  assert((branchcand->npriolpcands == 0) == (branchcand->nlpcands == 0));
2474 
2475  SCIPsetDebugMsg(set, "branching on LP solution with %d (+%d) fractional (+implicit fractional) variables (%d of maximal priority)\n",
2476  branchcand->nlpcands, branchcand->nimpllpfracs, branchcand->npriolpcands);
2477 
2478  nalllpcands = branchcand->nlpcands + branchcand->nimpllpfracs;
2479  /* do nothing, if no fractional variables exist */
2480  if( nalllpcands == 0 )
2481  return SCIP_OKAY;
2482 
2483  /* if there is a non-fixed variable with higher priority than the maximal priority of the fractional candidates,
2484  * use pseudo solution branching instead
2485  */
2486  if( branchcand->pseudomaxpriority > branchcand->lpmaxpriority )
2487  {
2488  SCIP_CALL( SCIPbranchExecPseudo(blkmem, set, stat, transprob, origprob, tree, reopt, lp, branchcand, eventqueue, cutoffbound,
2489  allowaddcons, result) );
2490  assert(*result != SCIP_DIDNOTRUN && *result != SCIP_DIDNOTFIND);
2491  return SCIP_OKAY;
2492  }
2493 
2494  /* sort the branching rules by priority */
2496 
2497  /* try all branching rules until one succeeded to branch */
2498  for( i = 0; i < set->nbranchrules && (*result == SCIP_DIDNOTRUN || *result == SCIP_DIDNOTFIND) && !SCIPsolveIsStopped(set, stat, FALSE); ++i )
2499  {
2500  SCIP_CALL( SCIPbranchruleExecLPSol(set->branchrules[i], set, stat, tree, sepastore, cutoffbound, allowaddcons, result) );
2501  }
2502 
2503  if( *result == SCIP_DIDNOTRUN || *result == SCIP_DIDNOTFIND )
2504  {
2505  SCIP_VAR* var;
2506  SCIP_Real factor;
2507  SCIP_Real bestfactor;
2508  int priority;
2509  int bestpriority;
2510  int bestcand;
2511 
2512  /* no branching method succeeded in choosing a branching: just branch on the first fractional variable with maximal
2513  * priority, and out of these on the one with maximal branch factor
2514  */
2515  bestcand = -1;
2516  bestpriority = INT_MIN;
2517  bestfactor = SCIP_REAL_MIN;
2518  for( i = 0; i < nalllpcands; ++i )
2519  {
2520  priority = SCIPvarGetBranchPriority(branchcand->lpcands[i]);
2521  factor = SCIPvarGetBranchFactor(branchcand->lpcands[i]);
2522  if( priority > bestpriority || (priority == bestpriority && factor > bestfactor) )
2523  {
2524  bestcand = i;
2525  bestpriority = priority;
2526  bestfactor = factor;
2527  }
2528  }
2529  assert(0 <= bestcand && bestcand < nalllpcands);
2530 
2531  var = branchcand->lpcands[bestcand];
2532  assert(SCIPvarGetType(var) != SCIP_VARTYPE_CONTINUOUS);
2533  assert(branchcand->nlpcands == 0 || SCIPvarGetType(var) != SCIP_VARTYPE_IMPLINT);
2534 
2535  assert(!SCIPsetIsEQ(set, SCIPvarGetLbLocal(var), SCIPvarGetUbLocal(var)));
2536 
2537  SCIP_CALL( SCIPtreeBranchVar(tree, reopt, blkmem, set, stat, transprob, origprob, lp, branchcand, eventqueue, var, SCIP_INVALID,
2538  NULL, NULL, NULL) );
2539 
2540  *result = SCIP_BRANCHED;
2541  }
2542 
2543  return SCIP_OKAY;
2544 }
2545 
2546 /** calls branching rules to branch on an external solution; if no external branching candidates exist, the result is SCIP_DIDNOTRUN */
2548  BMS_BLKMEM* blkmem, /**< block memory for parameter settings */
2549  SCIP_SET* set, /**< global SCIP settings */
2550  SCIP_STAT* stat, /**< problem statistics */
2551  SCIP_PROB* transprob, /**< transformed problem after presolve */
2552  SCIP_PROB* origprob, /**< original problem */
2553  SCIP_TREE* tree, /**< branch and bound tree */
2554  SCIP_REOPT* reopt, /**< reoptimization data structure */
2555  SCIP_LP* lp, /**< current LP data */
2556  SCIP_SEPASTORE* sepastore, /**< separation storage */
2557  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
2558  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
2559  SCIP_Real cutoffbound, /**< global upper cutoff bound */
2560  SCIP_Bool allowaddcons, /**< should adding constraints be allowed to avoid a branching? */
2561  SCIP_RESULT* result /**< pointer to store the result of the branching (s. branch.h) */
2562  )
2563 {
2564  int i;
2565 
2566  assert(branchcand != NULL);
2567  assert(result != NULL);
2568  assert(0 <= branchcand->nprioexterncands && branchcand->nprioexterncands <= branchcand->nexterncands);
2569  assert((branchcand->nprioexterncands == 0) == (branchcand->nexterncands == 0));
2570 
2571  *result = SCIP_DIDNOTRUN;
2572 
2573  SCIPsetDebugMsg(set, "branching on external solution with %d branching candidates (%d of maximal priority)\n",
2574  branchcand->nexterncands, branchcand->nprioexterncands);
2575 
2576  /* do nothing, if no external candidates exist */
2577  if( branchcand->nexterncands == 0 )
2578  return SCIP_OKAY;
2579 
2580  /* if there is a non-fixed variable with higher priority than the maximal priority of the external candidates,
2581  * use pseudo solution branching instead
2582  */
2583  if( branchcand->pseudomaxpriority > branchcand->externmaxpriority )
2584  {
2585  /* @todo: adjust this, that also LP branching might be called, if lpmaxpriority != externmaxpriority.
2586  * Therefor, it has to be clear which of both has the higher priority
2587  */
2588  SCIP_CALL( SCIPbranchExecPseudo(blkmem, set, stat, transprob, origprob, tree, reopt, lp, branchcand, eventqueue, cutoffbound,
2589  allowaddcons, result) );
2590  assert(*result != SCIP_DIDNOTRUN && *result != SCIP_DIDNOTFIND);
2591  return SCIP_OKAY;
2592  }
2593 
2594  /* sort the branching rules by priority */
2596 
2597  /* try all branching rules until one succeeded to branch */
2598  for( i = 0; i < set->nbranchrules && (*result == SCIP_DIDNOTRUN || *result == SCIP_DIDNOTFIND); ++i )
2599  {
2600  SCIP_CALL( SCIPbranchruleExecExternSol(set->branchrules[i], set, stat, tree, sepastore, cutoffbound, allowaddcons, result) );
2601  }
2602 
2603  if( *result == SCIP_DIDNOTRUN || *result == SCIP_DIDNOTFIND )
2604  {
2605  SCIP_VAR* var;
2606  SCIP_Real val;
2607  SCIP_Real bestfactor;
2608  SCIP_Real bestdomain;
2609  int bestpriority;
2610  int bestcand;
2611 
2612  /* if all branching rules did nothing, then they should also not have cleared all branching candidates */
2613  assert(branchcand->nexterncands > 0);
2614 
2615  /* no branching method succeeded in choosing a branching: just branch on the first branching candidates with maximal
2616  * priority, and out of these on the one with maximal branch factor, and out of these on the one with largest domain
2617  */
2618  bestcand = -1;
2619  bestpriority = INT_MIN;
2620  bestfactor = SCIP_REAL_MIN;
2621  bestdomain = 0.0;
2622  for( i = 0; i < branchcand->nexterncands; ++i )
2623  {
2624  SCIP_VAR* cand;
2625  SCIP_Real domain;
2626  SCIP_Real factor;
2627  int priority;
2628 
2629  cand = branchcand->externcands[i];
2630  priority = SCIPvarGetBranchPriority(cand);
2631  factor = SCIPvarGetBranchFactor(cand);
2632 
2633  /* the domain size is infinite, iff one of the bounds is infinite */
2635  domain = SCIPsetInfinity(set);
2636  else
2637  domain = SCIPvarGetUbLocal(cand) - SCIPvarGetLbLocal(cand);
2638 
2639  /* choose variable with higher priority, higher factor, larger domain (in that order) */
2640  if( priority > bestpriority || (priority == bestpriority && factor > bestfactor) || (priority == bestpriority && factor == bestfactor && domain > bestdomain) ) /*lint !e777*/
2641  {
2642  bestcand = i;
2643  bestpriority = priority;
2644  bestfactor = factor;
2645  bestdomain = domain;
2646  }
2647  }
2648  assert(0 <= bestcand && bestcand < branchcand->nexterncands);
2649 
2650  var = branchcand->externcands[bestcand];
2651  val = SCIPbranchGetBranchingPoint(set, tree, var, branchcand->externcandssol[bestcand]);
2652  assert(!SCIPsetIsEQ(set, SCIPvarGetLbLocal(var), SCIPvarGetUbLocal(var)));
2653  assert(SCIPrelDiff(SCIPvarGetUbLocal(var), SCIPvarGetLbLocal(var)) <= 2.02 * SCIPsetEpsilon(set)
2654  || SCIPsetIsLT(set, SCIPvarGetLbLocal(var), val));
2655  assert(SCIPrelDiff(SCIPvarGetUbLocal(var), SCIPvarGetLbLocal(var)) <= 2.02 * SCIPsetEpsilon(set)
2656  || SCIPsetIsLT(set, val, SCIPvarGetUbLocal(var)));
2657 
2658  SCIPsetDebugMsg(set, "no branching method succeeded; fallback selected to branch on variable <%s> with bounds [%g, %g] on value %g\n",
2659  SCIPvarGetName(var), SCIPvarGetLbLocal(var), SCIPvarGetUbLocal(var), val);
2660 
2661  SCIP_CALL( SCIPtreeBranchVar(tree, reopt, blkmem, set, stat, transprob, origprob, lp, branchcand, eventqueue, var, val,
2662  NULL, NULL, NULL) );
2663 
2664  if( tree->nchildren >= 1 )
2665  *result = SCIP_BRANCHED;
2666  /* if the bounds are too close, it may happen that we cannot branch but rather fix the variable */
2667  else
2668  {
2669  assert(SCIPsetIsEQ(set, SCIPvarGetLbLocal(var), SCIPvarGetUbLocal(var)));
2670  *result = SCIP_REDUCEDDOM;
2671  }
2672  }
2673 
2674  return SCIP_OKAY;
2675 }
2676 
2677 /** calls branching rules to branch on a pseudo solution; if no unfixed variables exist, the result is SCIP_DIDNOTRUN */
2679  BMS_BLKMEM* blkmem, /**< block memory for parameter settings */
2680  SCIP_SET* set, /**< global SCIP settings */
2681  SCIP_STAT* stat, /**< problem statistics */
2682  SCIP_PROB* transprob, /**< transformed problem after presolve */
2683  SCIP_PROB* origprob, /**< original problem */
2684  SCIP_TREE* tree, /**< branch and bound tree */
2685  SCIP_REOPT* reopt, /**< reoptimization data structure */
2686  SCIP_LP* lp, /**< current LP data */
2687  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
2688  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
2689  SCIP_Real cutoffbound, /**< global upper cutoff bound */
2690  SCIP_Bool allowaddcons, /**< should adding constraints be allowed to avoid a branching? */
2691  SCIP_RESULT* result /**< pointer to store the result of the branching (s. branch.h) */
2692  )
2693 {
2694  int i;
2695 
2696  assert(branchcand != NULL);
2697  assert(result != NULL);
2698 
2699  SCIPsetDebugMsg(set, "branching on pseudo solution with %d unfixed variables\n", branchcand->npseudocands);
2700 
2701  *result = SCIP_DIDNOTRUN;
2702 
2703  /* do nothing, if no unfixed variables exist */
2704  if( branchcand->npseudocands == 0 )
2705  return SCIP_OKAY;
2706 
2707  /* sort the branching rules by priority */
2709 
2710  /* try all branching rules until one succeeded to branch */
2711  for( i = 0; i < set->nbranchrules && (*result == SCIP_DIDNOTRUN || *result == SCIP_DIDNOTFIND); ++i )
2712  {
2713  SCIP_CALL( SCIPbranchruleExecPseudoSol(set->branchrules[i], set, stat, tree, cutoffbound, allowaddcons, result) );
2714  }
2715 
2716  if( *result == SCIP_DIDNOTRUN || *result == SCIP_DIDNOTFIND )
2717  {
2718  SCIP_VAR* var;
2719  SCIP_Real factor;
2720  SCIP_Real bestfactor;
2721  int priority;
2722  int bestpriority;
2723  int bestcand;
2724 
2725  /* no branching method succeeded in choosing a branching: just branch on the first unfixed variable with maximal
2726  * priority, and out of these on the one with maximal branch factor
2727  */
2728  bestcand = -1;
2729  bestpriority = INT_MIN;
2730  bestfactor = SCIP_REAL_MIN;
2731  for( i = 0; i < branchcand->npseudocands; ++i )
2732  {
2733  priority = SCIPvarGetBranchPriority(branchcand->pseudocands[i]);
2734  factor = SCIPvarGetBranchFactor(branchcand->pseudocands[i]);
2735  if( priority > bestpriority || (priority == bestpriority && factor > bestfactor) )
2736  {
2737  bestcand = i;
2738  bestpriority = priority;
2739  bestfactor = factor;
2740  }
2741  }
2742  assert(0 <= bestcand && bestcand < branchcand->npseudocands);
2743 
2744  var = branchcand->pseudocands[bestcand];
2745  assert(SCIPvarGetType(var) != SCIP_VARTYPE_CONTINUOUS);
2746  assert(!SCIPsetIsEQ(set, SCIPvarGetLbLocal(var), SCIPvarGetUbLocal(var)));
2747 
2748  SCIP_CALL( SCIPtreeBranchVar(tree, reopt, blkmem, set, stat, transprob, origprob, lp, branchcand, eventqueue, var, SCIP_INVALID,
2749  NULL, NULL, NULL) );
2750 
2751  *result = SCIP_BRANCHED;
2752  }
2753 
2754  return SCIP_OKAY;
2755 }
2756 
enum SCIP_Result SCIP_RESULT
Definition: type_result.h:52
SCIP_Real * lpcandssol
Definition: struct_branch.h:40
int SCIPbranchcandGetNPrioExternBins(SCIP_BRANCHCAND *branchcand)
Definition: branch.c:526
SCIP_Bool SCIPsolveIsStopped(SCIP_SET *set, SCIP_STAT *stat, SCIP_Bool checknodelimits)
Definition: solve.c:71
SCIP_RETCODE SCIPbranchruleCreate(SCIP_BRANCHRULE **branchrule, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, BMS_BLKMEM *blkmem, const char *name, const char *desc, int priority, int maxdepth, SCIP_Real maxbounddist, SCIP_DECL_BRANCHCOPY((*branchcopy)), SCIP_DECL_BRANCHFREE((*branchfree)), SCIP_DECL_BRANCHINIT((*branchinit)), SCIP_DECL_BRANCHEXIT((*branchexit)), SCIP_DECL_BRANCHINITSOL((*branchinitsol)), SCIP_DECL_BRANCHEXITSOL((*branchexitsol)), SCIP_DECL_BRANCHEXECLP((*branchexeclp)), SCIP_DECL_BRANCHEXECEXT((*branchexecext)), SCIP_DECL_BRANCHEXECPS((*branchexecps)), SCIP_BRANCHRULEDATA *branchruledata)
Definition: branch.c:1267
SCIP_Bool SCIPsetIsInfinity(SCIP_SET *set, SCIP_Real val)
Definition: set.c:5776
SCIP_BRANCHRULEDATA * SCIPbranchruleGetData(SCIP_BRANCHRULE *branchrule)
Definition: branch.c:1810
internal methods for managing events
SCIP_Bool SCIPbranchruleIsInitialized(SCIP_BRANCHRULE *branchrule)
Definition: branch.c:2134
SCIP_Bool SCIPsetIsLE(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:5834
SCIP_RETCODE SCIPtreeBranchVar(SCIP_TREE *tree, SCIP_REOPT *reopt, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, SCIP_VAR *var, SCIP_Real val, SCIP_NODE **downchild, SCIP_NODE **eqchild, SCIP_NODE **upchild)
Definition: tree.c:5341
SCIP_Bool SCIPsetIsFeasZero(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6284
SCIP_DECL_SORTPTRCOMP(SCIPbranchruleComp)
Definition: branch.c:1221
void SCIPbranchruleSetCopy(SCIP_BRANCHRULE *branchrule, SCIP_DECL_BRANCHCOPY((*branchcopy)))
Definition: branch.c:1831
SCIP_Longint ncutsfound
Definition: struct_branch.h:78
#define BMSfreeMemoryArrayNull(ptr)
Definition: memory.h:130
internal methods for branch and bound tree
SCIP_Real SCIPbranchruleGetMaxbounddist(SCIP_BRANCHRULE *branchrule)
Definition: branch.c:1998
SCIP_Real SCIPsetFeastol(SCIP_SET *set)
Definition: set.c:5678
SCIP_Real SCIPvarGetBranchFactor(SCIP_VAR *var)
Definition: var.c:17436
SCIP_Real SCIPsetFloor(SCIP_SET *set, SCIP_Real val)
Definition: set.c:5963
SCIP_RETCODE SCIPbranchruleExitsol(SCIP_BRANCHRULE *branchrule, SCIP_SET *set)
Definition: branch.c:1471
SCIP_Real SCIPnodeGetLowerbound(SCIP_NODE *node)
Definition: tree.c:7360
SCIP_PARAMDATA * SCIPparamGetData(SCIP_PARAM *param)
Definition: paramset.c:661
SCIP_Longint SCIPbranchruleGetNChildren(SCIP_BRANCHRULE *branchrule)
Definition: branch.c:2124
#define SCIP_DECL_BRANCHEXECPS(x)
Definition: type_branch.h:161
#define SCIP_MAXSTRLEN
Definition: def.h:259
SCIP_Longint ndomredsfound
Definition: struct_branch.h:81
internal methods for clocks and timing issues
int SCIPbranchcandGetNPseudoCands(SCIP_BRANCHCAND *branchcand)
Definition: branch.c:853
SCIP_BRANCHRULEDATA * branchruledata
Definition: struct_branch.h:94
SCIP_Bool SCIPsetIsPositive(SCIP_SET *set, SCIP_Real val)
Definition: set.c:5899
struct SCIP_ParamData SCIP_PARAMDATA
Definition: type_paramset.h:76
void SCIPbranchruleSetFree(SCIP_BRANCHRULE *branchrule, SCIP_DECL_BRANCHFREE((*branchfree)))
Definition: branch.c:1842
SCIP_Real SCIPvarGetLbLocal(SCIP_VAR *var)
Definition: var.c:17332
int nintvars
Definition: struct_prob.h:63
struct SCIP_BranchruleData SCIP_BRANCHRULEDATA
Definition: type_branch.h:43
SCIP_RETCODE SCIPbranchcandCreate(SCIP_BRANCHCAND **branchcand)
Definition: branch.c:133
SCIP_Real SCIPsetInfinity(SCIP_SET *set)
Definition: set.c:5636
SCIP_Longint nactiveconssadded
Definition: struct_stat.h:113
SCIP_Real SCIPvarGetSol(SCIP_VAR *var, SCIP_Bool getlpval)
Definition: var.c:12665
int SCIPbranchcandGetNPrioExternCands(SCIP_BRANCHCAND *branchcand)
Definition: branch.c:516
const char * SCIPbranchruleGetDesc(SCIP_BRANCHRULE *branchrule)
Definition: branch.c:1942
SCIP_Real SCIPbranchGetScore(SCIP_SET *set, SCIP_VAR *var, SCIP_Real downgain, SCIP_Real upgain)
Definition: branch.c:2151
#define SCIP_DECL_BRANCHFREE(x)
Definition: type_branch.h:60
SCIP_Longint nholechgs
Definition: struct_stat.h:105
void SCIPclockStop(SCIP_CLOCK *clck, SCIP_SET *set)
Definition: clock.c:350
#define FALSE
Definition: def.h:64
int lppos
Definition: struct_lp.h:163
SCIP_Longint SCIPbranchruleGetNDomredsFound(SCIP_BRANCHRULE *branchrule)
Definition: branch.c:2114
SCIP_Bool SCIPsetIsFeasIntegral(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6317
SCIP_Bool solved
Definition: struct_lp.h:348
SCIP_Real SCIPrelDiff(SCIP_Real val1, SCIP_Real val2)
Definition: misc.c:10289
SCIP_RETCODE SCIPbranchExecPseudo(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_Real cutoffbound, SCIP_Bool allowaddcons, SCIP_RESULT *result)
Definition: branch.c:2678
void SCIPclockStart(SCIP_CLOCK *clck, SCIP_SET *set)
Definition: clock.c:280
int SCIPbranchcandGetNPrioPseudoImpls(SCIP_BRANCHCAND *branchcand)
Definition: branch.c:893
int SCIPsnprintf(char *t, int len, const char *s,...)
Definition: misc.c:10011
#define TRUE
Definition: def.h:63
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
int SCIPtreeGetCurrentDepth(SCIP_TREE *tree)
Definition: tree.c:8300
SCIP_Longint SCIPbranchruleGetNCutoffs(SCIP_BRANCHRULE *branchrule)
Definition: branch.c:2082
internal methods for branching rules and branching candidate storage
void SCIPbranchcandClearExternCands(SCIP_BRANCHCAND *branchcand)
Definition: branch.c:698
int SCIPsetCalcMemGrowSize(SCIP_SET *set, int num)
Definition: set.c:5326
SCIP_Real SCIPsetRound(SCIP_SET *set, SCIP_Real val)
Definition: set.c:5985
#define SCIP_DECL_BRANCHEXECEXT(x)
Definition: type_branch.h:140
SCIP_RETCODE SCIPbranchruleInitsol(SCIP_BRANCHRULE *branchrule, SCIP_SET *set)
Definition: branch.c:1447
#define SCIPdebugMessage
Definition: pub_message.h:77
int nimplvars
Definition: struct_prob.h:64
static SCIP_RETCODE ensureLpcandsSize(SCIP_BRANCHCAND *branchcand, SCIP_SET *set, int num)
Definition: branch.c:55
SCIP_Longint SCIPbranchruleGetNExternCalls(SCIP_BRANCHRULE *branchrule)
Definition: branch.c:2062
internal methods for handling parameter settings
SCIP_Bool SCIPsetIsNegative(SCIP_SET *set, SCIP_Real val)
Definition: set.c:5910
void SCIPclockEnableOrDisable(SCIP_CLOCK *clck, SCIP_Bool enable)
Definition: clock.c:250
#define SCIP_DECL_BRANCHEXITSOL(x)
Definition: type_branch.h:98
#define BMSfreeMemory(ptr)
Definition: memory.h:127
static SCIP_RETCODE ensureExterncandsSize(SCIP_BRANCHCAND *branchcand, SCIP_SET *set, int num)
Definition: branch.c:103
int SCIPbranchcandGetExternMaxPrio(SCIP_BRANCHCAND *branchcand)
Definition: branch.c:496
SCIP_RETCODE SCIPbranchruleExecLPSol(SCIP_BRANCHRULE *branchrule, SCIP_SET *set, SCIP_STAT *stat, SCIP_TREE *tree, SCIP_SEPASTORE *sepastore, SCIP_Real cutoffbound, SCIP_Bool allowaddcons, SCIP_RESULT *result)
Definition: branch.c:1495
int SCIPbranchcandGetNPrioExternInts(SCIP_BRANCHCAND *branchcand)
Definition: branch.c:536
SCIP_LPSOLSTAT SCIPlpGetSolstat(SCIP_LP *lp)
Definition: lp.c:12612
SCIP_Real SCIPsetCeil(SCIP_SET *set, SCIP_Real val)
Definition: set.c:5974
internal methods for LP management
SCIP_Bool SCIPsetIsFeasFracIntegral(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6328
int SCIPbranchcandGetNPrioPseudoCands(SCIP_BRANCHCAND *branchcand)
Definition: branch.c:863
real eps
int branchpriority
Definition: struct_var.h:259
SCIP_RETCODE SCIPbranchruleExecPseudoSol(SCIP_BRANCHRULE *branchrule, SCIP_SET *set, SCIP_STAT *stat, SCIP_TREE *tree, SCIP_Real cutoffbound, SCIP_Bool allowaddcons, SCIP_RESULT *result)
Definition: branch.c:1709
int SCIPlpGetNCols(SCIP_LP *lp)
Definition: lp.c:16744
SCIP_Longint nexterncalls
Definition: struct_branch.h:75
SCIP_Bool SCIPsetIsGE(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:5870
SCIP_RETCODE SCIPbranchExecLP(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_SEPASTORE *sepastore, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, SCIP_Real cutoffbound, SCIP_Bool allowaddcons, SCIP_RESULT *result)
Definition: branch.c:2445
int pseudocandindex
Definition: struct_var.h:250
int SCIPbranchcandGetNExternCands(SCIP_BRANCHCAND *branchcand)
Definition: branch.c:506
SCIP_Bool SCIPsetIsLT(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:5816
SCIP_RETCODE SCIPbranchcandAddExternCand(SCIP_BRANCHCAND *branchcand, SCIP_SET *set, SCIP_VAR *var, SCIP_Real score, SCIP_Real solval)
Definition: branch.c:568
#define SCIP_DECL_BRANCHINIT(x)
Definition: type_branch.h:68
SCIP_Real lb
Definition: struct_lp.h:129
SCIP_RETCODE SCIPvarChgBranchPriority(SCIP_VAR *var, int branchpriority)
Definition: var.c:11100
SCIP_Real SCIPcolGetPrimsol(SCIP_COL *col)
Definition: lp.c:16205
#define SCIP_DECL_BRANCHCOPY(x)
Definition: type_branch.h:52
SCIP_RETCODE SCIPbranchcandGetExternCands(SCIP_BRANCHCAND *branchcand, SCIP_VAR ***externcands, SCIP_Real **externcandssol, SCIP_Real **externcandsscore, int *nexterncands, int *nprioexterncands, int *nprioexternbins, int *nprioexternints, int *nprioexternimpls)
Definition: branch.c:439
#define BMSfreeMemoryArray(ptr)
Definition: memory.h:129
internal methods for storing and manipulating the main problem
#define SCIPerrorMessage
Definition: pub_message.h:45
SCIP_VAR ** lpcands
Definition: struct_branch.h:39
SCIP_Real maxbounddist
Definition: struct_branch.h:71
SCIP_Real SCIPbranchruleGetSetupTime(SCIP_BRANCHRULE *branchrule)
Definition: branch.c:2032
SCIP_Real SCIPbranchGetBranchingPoint(SCIP_SET *set, SCIP_TREE *tree, SCIP_VAR *var, SCIP_Real suggestion)
Definition: branch.c:2249
SCIP_Longint lpcount
Definition: struct_stat.h:171
void SCIPclockReset(SCIP_CLOCK *clck)
Definition: clock.c:199
SCIP_COL ** SCIPlpGetCols(SCIP_LP *lp)
Definition: lp.c:16734
#define SCIP_DECL_BRANCHINITSOL(x)
Definition: type_branch.h:87
SCIP_RETCODE SCIPbranchruleExit(SCIP_BRANCHRULE *branchrule, SCIP_SET *set)
Definition: branch.c:1417
int SCIPsepastoreGetNCuts(SCIP_SEPASTORE *sepastore)
Definition: sepastore.c:1237
#define SCIP_DECL_BRANCHEXECLP(x)
Definition: type_branch.h:119
const char * SCIPvarGetName(SCIP_VAR *var)
Definition: var.c:16662
SCIP_RETCODE SCIPbranchcandGetPseudoCands(SCIP_BRANCHCAND *branchcand, SCIP_SET *set, SCIP_PROB *prob, SCIP_VAR ***pseudocands, int *npseudocands, int *npriopseudocands)
Definition: branch.c:789
SCIP_Real SCIPclockGetTime(SCIP_CLOCK *clck)
Definition: clock.c:428
void SCIPbranchruleSetInit(SCIP_BRANCHRULE *branchrule, SCIP_DECL_BRANCHINIT((*branchinit)))
Definition: branch.c:1853
SCIP_Real * externcandsscore
Definition: struct_branch.h:43
SCIP_RETCODE SCIPbranchcandGetLPCands(SCIP_BRANCHCAND *branchcand, SCIP_SET *set, SCIP_STAT *stat, SCIP_LP *lp, SCIP_VAR ***lpcands, SCIP_Real **lpcandssol, SCIP_Real **lpcandsfrac, int *nlpcands, int *npriolpcands, int *nfracimplvars)
Definition: branch.c:404
int SCIPbranchcandGetNPrioLPCands(SCIP_BRANCHCAND *branchcand)
Definition: branch.c:486
SCIP_Real * externcandssol
Definition: struct_branch.h:44
SCIP_Longint SCIPbranchruleGetNConssFound(SCIP_BRANCHRULE *branchrule)
Definition: branch.c:2104
#define REALABS(x)
Definition: def.h:173
SCIP_Bool SCIPsetIsRelGT(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6727
SCIP_RETCODE SCIPsetBranchrulePriority(SCIP *scip, SCIP_BRANCHRULE *branchrule, int priority)
Definition: scip.c:9306
static SCIP_RETCODE branchcandCalcLPCands(SCIP_BRANCHCAND *branchcand, SCIP_SET *set, SCIP_STAT *stat, SCIP_LP *lp)
Definition: branch.c:203
internal methods for global SCIP settings
#define SCIP_CALL(x)
Definition: def.h:350
SCIP_Longint SCIPbranchruleGetNLPCalls(SCIP_BRANCHRULE *branchrule)
Definition: branch.c:2052
SCIP_Bool SCIPsetIsFeasGE(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6262
SCIP_Real SCIPbranchruleGetTime(SCIP_BRANCHRULE *branchrule)
Definition: branch.c:2042
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:2813
SCIP_Bool SCIPsetIsEQ(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:5798
SCIP_Bool SCIPbranchcandContainsExternCand(SCIP_BRANCHCAND *branchcand, SCIP_VAR *var)
Definition: branch.c:713
internal methods for storing separated cuts
int SCIPbranchcandGetLPMaxPrio(SCIP_BRANCHCAND *branchcand)
Definition: branch.c:476
SCIP_Bool SCIPsetIsFeasLE(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6218
#define BMSduplicateMemoryArray(ptr, source, num)
Definition: memory.h:125
SCIP_Longint nprobboundchgs
Definition: struct_stat.h:106
SCIP_RETCODE SCIPclockCreate(SCIP_CLOCK **clck, SCIP_CLOCKTYPE clocktype)
Definition: clock.c:160
void SCIPbranchruleSetMaxdepth(SCIP_BRANCHRULE *branchrule, int maxdepth)
Definition: branch.c:1986
SCIP_Longint SCIPbranchruleGetNCutsFound(SCIP_BRANCHRULE *branchrule)
Definition: branch.c:2092
internal methods for problem variables
void SCIPbranchruleSetExecLp(SCIP_BRANCHRULE *branchrule, SCIP_DECL_BRANCHEXECLP((*branchexeclp)))
Definition: branch.c:1899
void SCIPbranchruleSetPriority(SCIP_BRANCHRULE *branchrule, SCIP_SET *set, int priority)
Definition: branch.c:1962
SCIP_Bool SCIPsetIsIntegral(SCIP_SET *set, SCIP_Real val)
Definition: set.c:5921
#define SCIP_Bool
Definition: def.h:61
SCIP_Longint npseudocalls
Definition: struct_branch.h:76
SCIP_Real SCIPsetSumepsilon(SCIP_SET *set)
Definition: set.c:5668
int SCIPbranchcandGetNPrioExternConts(SCIP_BRANCHCAND *branchcand)
Definition: branch.c:556
int nbinvars
Definition: struct_prob.h:62
int SCIPvarGetBranchPriority(SCIP_VAR *var)
Definition: var.c:17448
void SCIPclockFree(SCIP_CLOCK **clck)
Definition: clock.c:175
void SCIPbranchruleSetData(SCIP_BRANCHRULE *branchrule, SCIP_BRANCHRULEDATA *branchruledata)
Definition: branch.c:1820
#define MAX(x, y)
Definition: tclique_def.h:75
void SCIPbranchruleEnableOrDisableClocks(SCIP_BRANCHRULE *branchrule, SCIP_Bool enable)
Definition: branch.c:2020
#define SCIPsetDebugMsg
Definition: set.h:1913
SCIP_CLOCK * branchclock
Definition: struct_branch.h:96
SCIP_Bool SCIPsetIsRelLT(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6683
static SCIP_DECL_PARAMCHGD(paramChgdBranchrulePriority)
Definition: branch.c:1234
SCIP_Bool SCIPtreeHasCurrentNodeLP(SCIP_TREE *tree)
Definition: tree.c:8317
SCIP_COL * SCIPvarGetCol(SCIP_VAR *var)
Definition: var.c:16990
SCIP_Real SCIPbranchGetScoreMultiple(SCIP_SET *set, SCIP_VAR *var, int nchildren, SCIP_Real *gains)
Definition: branch.c:2211
SCIP_RETCODE SCIPbranchcandUpdateVar(SCIP_BRANCHCAND *branchcand, SCIP_SET *set, SCIP_VAR *var)
Definition: branch.c:1137
void SCIPbranchruleSetExecPs(SCIP_BRANCHRULE *branchrule, SCIP_DECL_BRANCHEXECPS((*branchexecps)))
Definition: branch.c:1921
SCIP_RETCODE SCIPbranchruleExecExternSol(SCIP_BRANCHRULE *branchrule, SCIP_SET *set, SCIP_STAT *stat, SCIP_TREE *tree, SCIP_SEPASTORE *sepastore, SCIP_Real cutoffbound, SCIP_Bool allowaddcons, SCIP_RESULT *result)
Definition: branch.c:1602
SCIP_Real ub
Definition: struct_lp.h:130
void SCIPbranchcandInvalidate(SCIP_BRANCHCAND *branchcand)
Definition: branch.c:192
#define SCIP_MAXTREEDEPTH
Definition: def.h:286
SCIP_RETCODE SCIPbranchcandFree(SCIP_BRANCHCAND **branchcand)
Definition: branch.c:173
void SCIPbranchruleSetInitsol(SCIP_BRANCHRULE *branchrule, SCIP_DECL_BRANCHINITSOL((*branchinitsol)))
Definition: branch.c:1875
int SCIPbranchruleGetMaxdepth(SCIP_BRANCHRULE *branchrule)
Definition: branch.c:1976
SCIP_Real SCIPsetFeasFrac(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6374
int SCIPparamGetInt(SCIP_PARAM *param)
Definition: paramset.c:716
#define SCIP_REAL_MIN
Definition: def.h:151
void SCIPbranchruleSetExecExt(SCIP_BRANCHRULE *branchrule, SCIP_DECL_BRANCHEXECEXT((*branchexecext)))
Definition: branch.c:1910
void SCIPsetSortBranchrules(SCIP_SET *set)
Definition: set.c:4605
int nactiveconss
Definition: struct_stat.h:220
int lpipos
Definition: struct_lp.h:164
SCIP_Longint SCIPbranchruleGetNPseudoCalls(SCIP_BRANCHRULE *branchrule)
Definition: branch.c:2072
internal methods for main solving loop and node processing
SCIP_Longint nchildren
Definition: struct_branch.h:82
SCIP_CLOCK * setuptime
Definition: struct_branch.h:95
void SCIPbranchruleSetExitsol(SCIP_BRANCHRULE *branchrule, SCIP_DECL_BRANCHEXITSOL((*branchexitsol)))
Definition: branch.c:1886
SCIP_RETCODE SCIPbranchruleInit(SCIP_BRANCHRULE *branchrule, SCIP_SET *set)
Definition: branch.c:1373
SCIP_RETCODE SCIPbranchruleCopyInclude(SCIP_BRANCHRULE *branchrule, SCIP_SET *set)
Definition: branch.c:1248
int SCIPbranchcandGetNPrioPseudoBins(SCIP_BRANCHCAND *branchcand)
Definition: branch.c:873
SCIP_Longint nconssfound
Definition: struct_branch.h:79
SCIP_Longint validlpcandslp
Definition: struct_branch.h:46
SCIP_Longint nboundchgs
Definition: struct_stat.h:104
SCIP_VARSTATUS SCIPvarGetStatus(SCIP_VAR *var)
Definition: var.c:16781
static void branchcandSortPseudoCands(SCIP_BRANCHCAND *branchcand)
Definition: branch.c:996
#define SCIP_Real
Definition: def.h:149
internal methods for problem statistics
const char * SCIPbranchruleGetName(SCIP_BRANCHRULE *branchrule)
Definition: branch.c:1932
SCIP_VAR ** vars
Definition: struct_prob.h:55
datastructures for branching rules and branching candidate storage
SCIP_RETCODE SCIPbranchruleFree(SCIP_BRANCHRULE **branchrule, SCIP_SET *set)
Definition: branch.c:1347
SCIP_VAR ** pseudocands
Definition: struct_branch.h:45
SCIP_Bool SCIPsetIsFeasPositive(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6295
#define BMSallocMemory(ptr)
Definition: memory.h:101
#define SCIP_INVALID
Definition: def.h:169
#define BMSreallocMemoryArray(ptr, num)
Definition: memory.h:109
SCIP_Bool initialized
Definition: struct_branch.h:99
void SCIPbranchruleSetMaxbounddist(SCIP_BRANCHRULE *branchrule, SCIP_Real maxbounddist)
Definition: branch.c:2008
#define SCIP_Longint
Definition: def.h:134
void SCIPbranchruleSetExit(SCIP_BRANCHRULE *branchrule, SCIP_DECL_BRANCHEXIT((*branchexit)))
Definition: branch.c:1864
static void branchcandRemovePseudoCand(SCIP_BRANCHCAND *branchcand, SCIP_VAR *var)
Definition: branch.c:1035
static void branchcandInsertPseudoCand(SCIP_BRANCHCAND *branchcand, SCIP_VAR *var, int insertpos)
Definition: branch.c:906
SCIP_VAR * var
Definition: struct_lp.h:151
SCIP_RETCODE SCIPbranchcandRemoveVar(SCIP_BRANCHCAND *branchcand, SCIP_VAR *var)
Definition: branch.c:1120
SCIP_VARTYPE SCIPvarGetType(SCIP_VAR *var)
Definition: var.c:16827
SCIP_Real SCIPvarGetMultaggrUbLocal(SCIP_VAR *var, SCIP_SET *set)
Definition: var.c:8133
SCIP_Real SCIPsetEpsilon(SCIP_SET *set)
Definition: set.c:5658
int SCIPbranchcandGetNPrioPseudoInts(SCIP_BRANCHCAND *branchcand)
Definition: branch.c:883
enum SCIP_Vartype SCIP_VARTYPE
Definition: type_var.h:60
int nchildren
Definition: struct_tree.h:210
SCIP_Real SCIPvarGetUbLocal(SCIP_VAR *var)
Definition: var.c:17342
SCIP_Real SCIPtreeGetLowerbound(SCIP_TREE *tree, SCIP_SET *set)
Definition: tree.c:7153
common defines and data types used in all packages of SCIP
SCIP_Longint ncutoffs
Definition: struct_branch.h:77
struct BMS_BlkMem BMS_BLKMEM
Definition: memory.h:419
SCIP_RETCODE SCIPsetAddRealParam(SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, BMS_BLKMEM *blkmem, const char *name, const char *desc, SCIP_Real *valueptr, SCIP_Bool isadvanced, SCIP_Real defaultvalue, SCIP_Real minvalue, SCIP_Real maxvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
Definition: set.c:2861
SCIP_Longint nlpcalls
Definition: struct_branch.h:74
#define SCIP_ALLOC(x)
Definition: def.h:361
SCIP_RETCODE SCIPbranchExecExtern(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_SEPASTORE *sepastore, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, SCIP_Real cutoffbound, SCIP_Bool allowaddcons, SCIP_RESULT *result)
Definition: branch.c:2547
#define SCIPABORT()
Definition: def.h:322
SCIP_Longint nprobholechgs
Definition: struct_stat.h:107
SCIP_Real SCIPvarGetMultaggrLbLocal(SCIP_VAR *var, SCIP_SET *set)
Definition: var.c:8067
SCIP_Real * lpcandsfrac
Definition: struct_branch.h:41
#define SCIP_DECL_BRANCHEXIT(x)
Definition: type_branch.h:76
SCIP_VAR ** externcands
Definition: struct_branch.h:42
SCIP callable library.
SCIP_Bool SCIPsetIsFeasNegative(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6306
SCIP_RETCODE SCIPbranchcandUpdateVarBranchPriority(SCIP_BRANCHCAND *branchcand, SCIP_SET *set, SCIP_VAR *var, int branchpriority)
Definition: branch.c:1177
SCIP_NODE * focusnode
Definition: struct_tree.h:180
int SCIPbranchcandGetNPrioExternImpls(SCIP_BRANCHCAND *branchcand)
Definition: branch.c:546
int SCIPbranchruleGetPriority(SCIP_BRANCHRULE *branchrule)
Definition: branch.c:1952
static SCIP_RETCODE ensurePseudocandsSize(SCIP_BRANCHCAND *branchcand, SCIP_SET *set, int num)
Definition: branch.c:80
memory allocation routines