Skip to content

Commit 528f2a4

Browse files
committed
Merge remote-tracking branch 'origin/v10-minor'
2 parents 655c6b1 + 8122a47 commit 528f2a4

File tree

3 files changed

+67
-24
lines changed

3 files changed

+67
-24
lines changed

src/scip/branch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2982,7 +2982,7 @@ SCIP_RETCODE SCIPbranchExecLPExact(
29822982
#endif
29832983

29842984
SCIP_CALL( SCIPtreeBranchVarExact(tree, reopt, blkmem, set, stat, transprob, origprob, lp,
2985-
branchcand, eventqueue, eventfilter, branchvar, NULL, NULL, NULL) );
2985+
branchcand, eventqueue, eventfilter, branchvar, NULL, NULL) );
29862986
*result = SCIP_BRANCHED;
29872987
}
29882988
/* reset the validlpcandslp to recalculate the branchcands for normal branching */

src/scip/tree.c

Lines changed: 66 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6330,18 +6330,64 @@ SCIP_RETCODE SCIPtreeBranchVar(
63306330
uplb = MAX(val, SCIPvarGetLbLocal(var) + SCIPsetEpsilon(set)); /*lint !e666*/
63316331
}
63326332
}
6333-
else if( SCIPsetIsFeasIntegral(set, val) && !set->exact_enable )
6333+
else if( set->exact_enable && EPSISINT(val, 0.0) ) /*lint !e835*/
63346334
{
63356335
SCIP_Real lb;
63366336
SCIP_Real ub;
63376337

63386338
lb = SCIPvarGetLbLocal(var);
63396339
ub = SCIPvarGetUbLocal(var);
63406340

6341-
/* if there was no explicit value given for branching, the variable has a finite domain and the current LP/pseudo
6341+
/* if there was no explicit value given for branching, the variable has a finite domain, and the current LP/pseudo
6342+
* solution is one of the bounds, we branch in the center of the domain */
6343+
if( !validval && !SCIPsetIsInfinity(set, -lb) && !SCIPsetIsInfinity(set, ub) && ( val == lb || val == ub ) ) /*lint !e777*/
6344+
{
6345+
SCIP_Real center;
6346+
6347+
/* create child nodes with x <= x", and x >= x"+1 with x" = floor((lb + ub)/2);
6348+
* if x" is integral, make the interval smaller in the child in which the current solution x'
6349+
* is still feasible
6350+
*/
6351+
center = (ub + lb) / 2.0;
6352+
if( val <= center )
6353+
{
6354+
downub = floor(center);
6355+
uplb = downub + 1.0;
6356+
}
6357+
else
6358+
{
6359+
uplb = ceil(center);
6360+
downub = uplb - 1.0;
6361+
}
6362+
}
6363+
else
6364+
{
6365+
/* create child nodes with x <= x'-1, x = x', and x >= x'+1 */
6366+
fixval = val;
6367+
6368+
/* create child node with x <= x'-1, if this would be feasible */
6369+
if( fixval - 1.0 >= lb )
6370+
downub = fixval - 1.0;
6371+
6372+
/* create child node with x >= x'+1, if this would be feasible */
6373+
if( fixval + 1.0 <= ub )
6374+
uplb = fixval + 1.0;
6375+
}
6376+
SCIPsetDebugMsg(set, "integral branch on variable <%s> with value %g, priority %d (current lower bound: %g)\n",
6377+
SCIPvarGetName(var), val, SCIPvarGetBranchPriority(var), SCIPnodeGetLowerbound(tree->focusnode));
6378+
}
6379+
else if( !set->exact_enable && SCIPsetIsFeasIntegral(set, val) )
6380+
{
6381+
SCIP_Real lb;
6382+
SCIP_Real ub;
6383+
6384+
lb = SCIPvarGetLbLocal(var);
6385+
ub = SCIPvarGetUbLocal(var);
6386+
6387+
/* if there was no explicit value given for branching, the variable has a finite domain, and the current LP/pseudo
63426388
* solution is one of the bounds, we branch in the center of the domain */
63436389
if( !validval && !SCIPsetIsInfinity(set, -lb) && !SCIPsetIsInfinity(set, ub)
6344-
&& (SCIPsetIsFeasEQ(set, val, lb) || SCIPsetIsFeasEQ(set, val, ub)) )
6390+
&& ( SCIPsetIsFeasEQ(set, val, lb) || SCIPsetIsFeasEQ(set, val, ub) ) )
63456391
{
63466392
SCIP_Real center;
63476393

@@ -6364,16 +6410,14 @@ SCIP_RETCODE SCIPtreeBranchVar(
63646410
else
63656411
{
63666412
/* create child nodes with x <= x'-1, x = x', and x >= x'+1 */
6367-
assert(SCIPsetIsEQ(set, SCIPsetFeasCeil(set, val), SCIPsetFeasFloor(set, val)));
6368-
6369-
fixval = SCIPsetFeasCeil(set, val); /* get rid of numerical issues */
6413+
fixval = round(val);
63706414

63716415
/* create child node with x <= x'-1, if this would be feasible */
6372-
if( SCIPsetIsFeasGE(set, fixval-1.0, lb) )
6416+
if( SCIPsetIsFeasGE(set, fixval - 1.0, lb) )
63736417
downub = fixval - 1.0;
63746418

63756419
/* create child node with x >= x'+1, if this would be feasible */
6376-
if( SCIPsetIsFeasLE(set, fixval+1.0, ub) )
6420+
if( SCIPsetIsFeasLE(set, fixval + 1.0, ub) )
63776421
uplb = fixval + 1.0;
63786422
}
63796423
SCIPsetDebugMsg(set, "integral branch on variable <%s> with value %g, priority %d (current lower bound: %g)\n",
@@ -6384,8 +6428,10 @@ SCIP_RETCODE SCIPtreeBranchVar(
63846428
/* create child nodes with x <= floor(x'), and x >= ceil(x') */
63856429
if( set->exact_enable )
63866430
{
6431+
assert(val < SCIPvarGetUbLocal(var));
63876432
downub = floor(val);
63886433
uplb = downub + 1.0;
6434+
assert(uplb == ceil(val)); /*lint !e777*/
63896435
}
63906436
else
63916437
{
@@ -6498,7 +6544,6 @@ SCIP_RETCODE SCIPtreeBranchVar(
64986544
/** branches on a variable x; unlike the fp-version this will also branch x <= floor(x'), x >= ceil(x')
64996545
* if x' is very close to being integral at one of its bounds;
65006546
* in the fp version this case would be branched in the middle of the domain;
6501-
* if x' is almost integral but not at a bound, this will branch (x <= x'-1, x == x', x >= x'+1);
65026547
* not meant for branching on a continuous variables
65036548
*/
65046549
SCIP_RETCODE SCIPtreeBranchVarExact(
@@ -6515,7 +6560,6 @@ SCIP_RETCODE SCIPtreeBranchVarExact(
65156560
SCIP_EVENTFILTER* eventfilter, /**< global event filter */
65166561
SCIP_VAR* var, /**< variable to branch on */
65176562
SCIP_NODE** downchild, /**< pointer to return the left child with variable rounded down, or NULL */
6518-
SCIP_NODE** eqchild, /**< pointer to return the middle child with variable fixed, or NULL */
65196563
SCIP_NODE** upchild /**< pointer to return the right child with variable rounded up, or NULL */
65206564
)
65216565
{
@@ -6530,12 +6574,11 @@ SCIP_RETCODE SCIPtreeBranchVarExact(
65306574
assert(tree != NULL);
65316575
assert(set != NULL);
65326576
assert(var != NULL);
6577+
assert(set->exact_enable);
65336578

65346579
/* initialize children pointer */
65356580
if( downchild != NULL )
65366581
*downchild = NULL;
6537-
if( eqchild != NULL )
6538-
*eqchild = NULL;
65396582
if( upchild != NULL )
65406583
*upchild = NULL;
65416584

@@ -6559,9 +6602,9 @@ SCIP_RETCODE SCIPtreeBranchVarExact(
65596602
assert(SCIPvarIsActive(var));
65606603
assert(SCIPvarGetProbindex(var) >= 0);
65616604
assert(SCIPvarGetStatus(var) == SCIP_VARSTATUS_LOOSE || SCIPvarGetStatus(var) == SCIP_VARSTATUS_COLUMN);
6562-
assert(SCIPsetIsFeasIntegral(set, SCIPvarGetLbLocal(var)));
6563-
assert(SCIPsetIsFeasIntegral(set, SCIPvarGetUbLocal(var)));
6564-
assert(SCIPsetIsLT(set, SCIPvarGetLbLocal(var), SCIPvarGetUbLocal(var)));
6605+
assert(SCIPvarGetLbLocal(var) == round(SCIPvarGetLbLocal(var))); /*lint !e777*/
6606+
assert(SCIPvarGetUbLocal(var) == round(SCIPvarGetUbLocal(var))); /*lint !e777*/
6607+
assert(SCIPvarGetLbLocal(var) < SCIPvarGetUbLocal(var));
65656608

65666609
/* update the information for the focus node before creating children */
65676610
SCIP_CALL( SCIPvisualUpdateChild(stat->visual, set, stat, tree->focusnode) );
@@ -6583,15 +6626,17 @@ SCIP_RETCODE SCIPtreeBranchVarExact(
65836626
}
65846627
}
65856628

6586-
assert(SCIPsetIsFeasGE(set, val, SCIPvarGetLbLocal(var)));
6587-
assert(SCIPsetIsFeasLE(set, val, SCIPvarGetUbLocal(var)));
6588-
/* see comment in SCIPbranchVarVal */
6589-
assert(SCIPvarIsIntegral(var));
6590-
65916629
/* create child nodes with x <= floor(x'), and x >= ceil(x') */
6630+
assert(val >= SCIPvarGetLbLocal(var));
6631+
assert(val <= SCIPvarGetUbLocal(var));
65926632
downub = floor(val);
6633+
if( val == SCIPvarGetUbLocal(var) ) /*lint !e777*/
6634+
downub -= 1.0;
65936635
uplb = downub + 1.0;
6594-
SCIPsetDebugMsg(set, "fractional branch on variable <%s> with value %g, root value %g, priority %d (current lower bound: %g)\n",
6636+
assert(downub < uplb);
6637+
assert(downub >= SCIPvarGetLbLocal(var));
6638+
assert(uplb <= SCIPvarGetUbLocal(var));
6639+
SCIPsetDebugMsg(set, "exact branch on variable <%s> with value %g, root value %g, priority %d (current lower bound: %g)\n",
65956640
SCIPvarGetName(var), val, SCIPvarGetRootSol(var), SCIPvarGetBranchPriority(var), SCIPnodeGetLowerbound(tree->focusnode));
65966641

65976642
/* perform the branching;

src/scip/tree.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,6 @@ SCIP_RETCODE SCIPtreeBranchVar(
647647
/** branches on a variable x; unlike the fp-version this will also branch x <= floor(x'), x >= ceil(x')
648648
* if x' is very close to being integral at one of its bounds;
649649
* in the fp version this case would be branched in the middle of the domain;
650-
* if x' is almost integral but not at a bound, this will branch (x <= x'-1, x == x', x >= x'+1);
651650
* not meant for branching on a continuous variables
652651
*/
653652
SCIP_RETCODE SCIPtreeBranchVarExact(
@@ -664,7 +663,6 @@ SCIP_RETCODE SCIPtreeBranchVarExact(
664663
SCIP_EVENTFILTER* eventfilter, /**< global event filter */
665664
SCIP_VAR* var, /**< variable to branch on */
666665
SCIP_NODE** downchild, /**< pointer to return the left child with variable rounded down, or NULL */
667-
SCIP_NODE** eqchild, /**< pointer to return the middle child with variable fixed, or NULL */
668666
SCIP_NODE** upchild /**< pointer to return the right child with variable rounded up, or NULL */
669667
);
670668

0 commit comments

Comments
 (0)