Skip to content

Commit

Permalink
Merge branch 'fix-strong-branching' into 'v91-bugfix'
Browse files Browse the repository at this point in the history
Fix strongbranching cutoffs

See merge request integer/scip!3534
  • Loading branch information
svigerske committed Oct 10, 2024
2 parents 16e5da5 + 40f77c4 commit 36c553d
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 34 deletions.
14 changes: 3 additions & 11 deletions src/scip/branch_allfullstrong.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,6 @@ SCIP_RETCODE branch(
int npseudocands;
int npriopseudocands;
int bestpseudocand;
#ifndef NDEBUG
SCIP_Real cutoffbound;
cutoffbound = SCIPgetCutoffbound(scip);
#endif

assert(branchrule != NULL);
assert(strcmp(SCIPbranchruleGetName(branchrule), BRANCHRULE_NAME) == 0);
Expand Down Expand Up @@ -165,7 +161,7 @@ SCIP_RETCODE branch(

assert(*result == SCIP_DIDNOTRUN);
assert(0 <= bestpseudocand && bestpseudocand < npseudocands);
assert(SCIPisLT(scip, provedbound, cutoffbound));
assert(SCIPisLT(scip, provedbound, SCIPgetCutoffbound(scip)));

var = pseudocandscopy[bestpseudocand];

Expand Down Expand Up @@ -316,10 +312,6 @@ SCIP_RETCODE SCIPselectVarPseudoStrongBranching(
SCIP_Real lpobjval;
SCIP_Bool allcolsinlp;
SCIP_Bool exactsolve;
#ifndef NDEBUG
SCIP_Real cutoffbound;
cutoffbound = SCIPgetCutoffbound(scip);
#endif

assert(scip != NULL);
assert(pseudocands != NULL);
Expand Down Expand Up @@ -442,8 +434,8 @@ SCIP_RETCODE SCIPselectVarPseudoStrongBranching(
up = MAX(up, lpobjval);
downgain = down - lpobjval;
upgain = up - lpobjval;
assert(!allcolsinlp || exactsolve || !downvalid || downinf == SCIPisGE(scip, down, cutoffbound));
assert(!allcolsinlp || exactsolve || !upvalid || upinf == SCIPisGE(scip, up, cutoffbound));
assert(!allcolsinlp || exactsolve || !downvalid || downinf == SCIPisGE(scip, down, SCIPgetCutoffbound(scip)));
assert(!allcolsinlp || exactsolve || !upvalid || upinf == SCIPisGE(scip, up, SCIPgetCutoffbound(scip)));
assert(downinf || !downconflict);
assert(upinf || !upconflict);

Expand Down
8 changes: 6 additions & 2 deletions src/scip/scip_prob.c
Original file line number Diff line number Diff line change
Expand Up @@ -3724,7 +3724,9 @@ SCIP_RETCODE SCIPupdateLocalLowerbound(
}

/** if given value is tighter (higher for minimization, lower for maximization) than the node's dual bound, sets the
* node's dual bound to the new value. Only applicable to non-leafs because the node priority queue remains untouched.
* node's dual bound to the new value.
*
* @note must not be used on a leaf because the node priority queue remains untouched
*
* @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
* SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
Expand All @@ -3746,7 +3748,9 @@ SCIP_RETCODE SCIPupdateNodeDualbound(
}

/** if given value is higher than the node's lower bound (in transformed problem), sets the node's lower bound to the
* new value. Only applicable to non-leafs because the node priority queue remains untouched.
* new value.
*
* @note must not be used on a leaf because the node priority queue remains untouched
*
* @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
* SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
Expand Down
2 changes: 2 additions & 0 deletions src/scip/scip_tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,8 @@ SCIP_RETCODE SCIPgetOpenNodesData(
}

/** cuts off node and whole sub tree from branch and bound tree
*
* @note must not be used on a leaf because the node priority queue remains untouched
*
* @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
* SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
Expand Down
35 changes: 16 additions & 19 deletions src/scip/scip_var.c
Original file line number Diff line number Diff line change
Expand Up @@ -2946,7 +2946,7 @@ SCIP_RETCODE SCIPgetVarStrongbranchFrac(

assert(var != NULL);
assert(lperror != NULL);
assert(!SCIPtreeProbing(scip->tree)); /* we should not be in strong branching with propagation mode */
assert(!SCIPinProbing(scip)); /* we should not be in strong branching with propagation mode */
assert(var->scip == scip);

SCIP_CALL( SCIPcheckStage(scip, "SCIPgetVarStrongbranchFrac", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
Expand Down Expand Up @@ -3044,15 +3044,13 @@ SCIP_RETCODE SCIPgetVarStrongbranchFrac(
{
if( !idempotent ) /*lint !e774*/
{
SCIP_CALL( analyzeStrongbranch(scip, var, downinf, upinf, downconflict, upconflict) );
}
else
{
if( downinf != NULL )
*downinf = localdownvalid && SCIPsetIsGE(scip->set, localdown, scip->lp->cutoffbound);
if( upinf != NULL )
*upinf = localupvalid && SCIPsetIsGE(scip->set, localup, scip->lp->cutoffbound);
SCIP_CALL( analyzeStrongbranch(scip, var, NULL, NULL, downconflict, upconflict) );
}

if( downinf != NULL )
*downinf = localdownvalid && SCIPsetIsGE(scip->set, localdown, scip->lp->cutoffbound);
if( upinf != NULL )
*upinf = localupvalid && SCIPsetIsGE(scip->set, localup, scip->lp->cutoffbound);
}

if( down != NULL )
Expand Down Expand Up @@ -3766,11 +3764,12 @@ SCIP_RETCODE SCIPgetVarStrongbranchInt(
SCIP_Bool localdownvalid;
SCIP_Bool localupvalid;

SCIP_CALL( SCIPcheckStage(scip, "SCIPgetVarStrongbranchInt", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );

assert(var != NULL);
assert(lperror != NULL);
assert(var->scip == scip);

SCIP_CALL( SCIPcheckStage(scip, "SCIPgetVarStrongbranchInt", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );

lpobjval = SCIPgetLPObjval(scip);
if( downvalid != NULL )
*downvalid = FALSE;
Expand Down Expand Up @@ -3864,15 +3863,13 @@ SCIP_RETCODE SCIPgetVarStrongbranchInt(
{
if( !idempotent ) /*lint !e774*/
{
SCIP_CALL( analyzeStrongbranch(scip, var, downinf, upinf, downconflict, upconflict) );
}
else
{
if( downinf != NULL )
*downinf = localdownvalid && SCIPsetIsGE(scip->set, localdown, scip->lp->cutoffbound);
if( upinf != NULL )
*upinf = localupvalid && SCIPsetIsGE(scip->set, localup, scip->lp->cutoffbound);
SCIP_CALL( analyzeStrongbranch(scip, var, NULL, NULL, downconflict, upconflict) );
}

if( downinf != NULL )
*downinf = localdownvalid && SCIPsetIsGE(scip->set, localdown, scip->lp->cutoffbound);
if( upinf != NULL )
*upinf = localupvalid && SCIPsetIsGE(scip->set, localup, scip->lp->cutoffbound);
}

if( down != NULL )
Expand Down
10 changes: 8 additions & 2 deletions src/scip/tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -1231,7 +1231,10 @@ SCIP_RETCODE SCIPnodeFree(
return SCIP_OKAY;
}

/** cuts off node and whole sub tree from branch and bound tree */
/** cuts off node and whole sub tree from branch and bound tree
*
* @note must not be used on a leaf because the node priority queue remains untouched
*/
SCIP_RETCODE SCIPnodeCutoff(
SCIP_NODE* node, /**< node that should be cut off */
SCIP_SET* set, /**< global SCIP settings */
Expand Down Expand Up @@ -2377,7 +2380,10 @@ SCIP_RETCODE treeApplyPendingBdchgs(
return SCIP_OKAY;
}

/** if given value is larger than the node's lower bound, sets the node's lower bound to the new value */
/** if given value is larger than the node's lower bound, sets the node's lower bound to the new value
*
* @note must not be used on a leaf because the node priority queue remains untouched
*/
void SCIPnodeUpdateLowerbound(
SCIP_NODE* node, /**< node to update lower bound for */
SCIP_STAT* stat, /**< problem statistics */
Expand Down

0 comments on commit 36c553d

Please sign in to comment.