Skip to content

Commit

Permalink
Merge branch '3632-fix-stricter-redundancy-check-leads-to-suboptimal-…
Browse files Browse the repository at this point in the history
…solution' into 'v80-bugfix'

Resolve "Stricter redundancy check leads to suboptimal solution" better

See merge request integer/scip!3217
  • Loading branch information
sbolusani committed Oct 29, 2023
2 parents 738df7f + 9a9ff61 commit ddeeb02
Showing 1 changed file with 18 additions and 23 deletions.
41 changes: 18 additions & 23 deletions src/scip/cons_linear.c
Original file line number Diff line number Diff line change
Expand Up @@ -11466,8 +11466,8 @@ SCIP_RETCODE rangedRowSimplify(
assert(!SCIPisInfinity(scip, rhs));
assert(!SCIPisNegative(scip, rhs));

/* sides must be positive to detect set partition */
if( !SCIPisPositive(scip, lhs) || !SCIPisPositive(scip, rhs) )
/* sides must be positive and different to detect set partition */
if( !SCIPisPositive(scip, lhs) || !SCIPisLT(scip, lhs, rhs) )
return SCIP_OKAY;

vals = consdata->vals;
Expand Down Expand Up @@ -11498,36 +11498,31 @@ SCIP_RETCODE rangedRowSimplify(
break;
}

/* check if all variables are binary */
if( v == -1 )
/* check if all variables are binary, we can choose one, and need to choose at most one */
if( v == -1 && SCIPisGE(scip, minval, lhs) && SCIPisLE(scip, maxval, rhs)
&& SCIPisGT(scip, minval + secondminval, rhs) )
{
if( SCIPisEQ(scip, minval, maxval) && SCIPisEQ(scip, lhs, rhs) )
return SCIP_OKAY;

/* check if we can choose one and need to choose at most one binary variable */
if( SCIPisGE(scip, minval, lhs) && SCIPisLE(scip, maxval, rhs) && SCIPisGT(scip, minval + secondminval, rhs) )
/* change all coefficients to 1.0 */
for( v = nvars - 1; v >= 0; --v )
{
/* change all coefficients to 1.0 */
for( v = nvars - 1; v >= 0; --v )
{
SCIP_CALL( chgCoefPos(scip, cons, v, 1.0) );
}
(*nchgcoefs) += nvars;

/* replace old right and left hand side with 1.0 */
SCIP_CALL( chgRhs(scip, cons, 1.0) );
SCIP_CALL( chgLhs(scip, cons, 1.0) );
(*nchgsides) += 2;
SCIP_CALL( chgCoefPos(scip, cons, v, 1.0) );
}
(*nchgcoefs) += nvars;

/* replace old right and left hand side with 1.0 */
SCIP_CALL( chgRhs(scip, cons, 1.0) );
SCIP_CALL( chgLhs(scip, cons, 1.0) );
(*nchgsides) += 2;
}

return SCIP_OKAY;
}

/** tries to simplify coefficients and delete variables in constraints of the form lhs <= a^Tx <= rhs
* for equations @see rangedRowSimplify() will be called
*
* there are several different coefficient reduction steps which will be applied
* for both-sided constraints only @see rangedRowSimplify() will be called
*
* for one-sided constraints there are several different coefficient reduction steps which will be applied
*
* 1. We try to determine parts of the constraint which will not change anything on (in-)feasibility of the constraint
*
Expand Down Expand Up @@ -11661,7 +11656,7 @@ SCIP_RETCODE simplifyInequalities(
SCIPdebug( oldnchgcoefs = *nchgcoefs; )
SCIPdebug( oldnchgsides = *nchgsides; )

/* @todo also work on ranged rows */
/* @todo extend both-sided simplification */
if( haslhs && hasrhs )
{
SCIP_CALL( rangedRowSimplify(scip, cons, nchgcoefs, nchgsides ) );
Expand Down

0 comments on commit ddeeb02

Please sign in to comment.