Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/v9-minor'
Browse files Browse the repository at this point in the history
  • Loading branch information
scip-ci committed Apr 1, 2024
2 parents 3fe72b2 + 081569e commit 8cbff9e
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 56 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ Fixed bugs
- set probing LP to be a relaxation only when objective has not been changed
- declare contradicting infinities in getMinActivity() and getMaxActivity() as non-tight
- reject farkas solution with large values to bound magnification of errors in SCIPgetFarkasProof()
- if all variables are fixed, apply relative feasibility tolerance to avoid invalid infeasibility in applyFixings() of cons_linear.c

Miscellaneous
-------------
Expand Down
1 change: 1 addition & 0 deletions check/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,7 @@ set(pairs_Issue
"instances/Issue/3633.lp\;0\;default"
"instances/Issue/3662_1.cip\;0\;default"
"instances/Issue/3662_2.cip\;0\;default"
"instances/Issue/3681.cip\;0\;default"
)

#
Expand Down
12 changes: 12 additions & 0 deletions check/instances/Issue/3681.cip
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
STATISTICS
Problem name : PyomoModel
Variables : 1 (0 binary, 0 integer, 0 implicit integer, 1 continuous)
Constraints : 0 initial, 2 maximal
OBJECTIVE
Sense : maximize
VARIABLES
[continuous] <x6207>: obj=0, original bounds=[-inf,+inf]
CONSTRAINTS
[linear] <c_u_x7720_>: +3.68<x6207>[C] == 1334.96018242414;
[linear] <c_u_x8265_>: -50000000<x6207>[C] == -18138045956.8497;
END
144 changes: 88 additions & 56 deletions src/scip/cons_linear.c
Original file line number Diff line number Diff line change
Expand Up @@ -3472,21 +3472,23 @@ SCIP_RETCODE chgLhs(

assert(scip != NULL);
assert(cons != NULL);
assert(!SCIPisInfinity(scip, lhs));

/* adjust value to not be smaller than -inf */
if ( SCIPisInfinity(scip, -lhs) )
/* adjust value to be not beyond infinity */
if( SCIPisInfinity(scip, -lhs) )
lhs = -SCIPinfinity(scip);
else if( SCIPisInfinity(scip, lhs) )
lhs = SCIPinfinity(scip);

consdata = SCIPconsGetData(cons);
assert(consdata != NULL);
assert(consdata->nvars == 0 || (consdata->vars != NULL && consdata->vals != NULL));
assert(!SCIPisInfinity(scip, consdata->lhs));

/* check whether the side is not changed */
if( SCIPisEQ(scip, consdata->lhs, lhs) )
return SCIP_OKAY;

assert(!SCIPisInfinity(scip, ABS(consdata->lhs)) || !SCIPisInfinity(scip, ABS(lhs)));

/* ensure that rhs >= lhs is satisfied without numerical tolerance */
if( SCIPisEQ(scip, lhs, consdata->rhs) )
{
Expand Down Expand Up @@ -3554,7 +3556,7 @@ SCIP_RETCODE chgLhs(
}

/* check whether the left hand side is increased, if and only if that's the case we maybe can propagate, tighten and add more cliques */
if( !SCIPisInfinity(scip, -lhs) && SCIPisGT(scip, lhs, consdata->lhs) )
if( !SCIPisInfinity(scip, ABS(lhs)) && SCIPisGT(scip, lhs, consdata->lhs) )
{
consdata->boundstightened = 0;
consdata->presolved = FALSE;
Expand Down Expand Up @@ -3598,21 +3600,23 @@ SCIP_RETCODE chgRhs(

assert(scip != NULL);
assert(cons != NULL);
assert(!SCIPisInfinity(scip, -rhs));

/* adjust value to not be larger than inf */
if ( SCIPisInfinity(scip, rhs) )
/* adjust value to be not beyond infinity */
if( SCIPisInfinity(scip, rhs) )
rhs = SCIPinfinity(scip);
else if( SCIPisInfinity(scip, -rhs) )
rhs = -SCIPinfinity(scip);

consdata = SCIPconsGetData(cons);
assert(consdata != NULL);
assert(consdata->nvars == 0 || (consdata->vars != NULL && consdata->vals != NULL));
assert(!SCIPisInfinity(scip, -consdata->rhs));

/* check whether the side is not changed */
if( SCIPisEQ(scip, consdata->rhs, rhs) )
return SCIP_OKAY;

assert(!SCIPisInfinity(scip, ABS(consdata->rhs)) || !SCIPisInfinity(scip, ABS(rhs)));

/* ensure that rhs >= lhs is satisfied without numerical tolerance */
if( SCIPisEQ(scip, rhs, consdata->lhs) )
{
Expand Down Expand Up @@ -3682,7 +3686,7 @@ SCIP_RETCODE chgRhs(
}

/* check whether the right hand side is decreased, if and only if that's the case we maybe can propagate, tighten and add more cliques */
if( !SCIPisInfinity(scip, rhs) && SCIPisLT(scip, rhs, consdata->rhs) )
if( !SCIPisInfinity(scip, ABS(rhs)) && SCIPisLT(scip, rhs, consdata->rhs) )
{
consdata->boundstightened = 0;
consdata->presolved = FALSE;
Expand Down Expand Up @@ -4707,22 +4711,20 @@ SCIP_RETCODE applyFixings(
{
if( SCIPisInfinity(scip, ABS(fixedval)) )
{
if( val * fixedval > 0.0 )
{
SCIP_CALL( chgLhs(scip, cons, -SCIPinfinity(scip)) );
}
else
/* if lhs gets infinity it means that the problem is infeasible */
if( ( val > 0.0 ) != ( fixedval > 0.0 ) )
{
SCIP_CALL( chgLhs(scip, cons, SCIPinfinity(scip)) );

if( infeasible != NULL )
{
/* if lhs gets infinity it means that the problem is infeasible */
*infeasible = TRUE;
return SCIP_OKAY;
}
else
{
SCIP_CALL( chgLhs(scip, cons, SCIPinfinity(scip)) );
}
}
else
{
SCIP_CALL( chgLhs(scip, cons, -SCIPinfinity(scip)) );
}
}
else
Expand All @@ -4732,18 +4734,16 @@ SCIP_RETCODE applyFixings(
{
if( SCIPisInfinity(scip, ABS(fixedval)) )
{
if( val * fixedval > 0.0 )
/* if rhs gets -infinity it means that the problem is infeasible */
if( ( val > 0.0 ) == ( fixedval > 0.0 ) )
{
SCIP_CALL( chgRhs(scip, cons, -SCIPinfinity(scip)) );

if( infeasible != NULL )
{
/* if rhs gets -infinity it means that the problem is infeasible */
*infeasible = TRUE;
return SCIP_OKAY;
}
else
{
SCIP_CALL( chgRhs(scip, cons, -SCIPinfinity(scip)) );
}
}
else
{
Expand All @@ -4757,31 +4757,31 @@ SCIP_RETCODE applyFixings(
break;

case SCIP_VARSTATUS_AGGREGATED:
{
SCIP_VAR* activevar = SCIPvarGetAggrVar(var);
SCIP_Real activescalar = val * SCIPvarGetAggrScalar(var);
SCIP_Real activeconstant = val * SCIPvarGetAggrConstant(var);
{
SCIP_VAR* activevar = SCIPvarGetAggrVar(var);
SCIP_Real activescalar = val * SCIPvarGetAggrScalar(var);
SCIP_Real activeconstant = val * SCIPvarGetAggrConstant(var);

assert(activevar != NULL);
SCIP_CALL( SCIPgetProbvarSum(scip, &activevar, &activescalar, &activeconstant) );
assert(activevar != NULL);
assert(activevar != NULL);
SCIP_CALL( SCIPgetProbvarSum(scip, &activevar, &activescalar, &activeconstant) );
assert(activevar != NULL);

if( !SCIPisZero(scip, activescalar) )
{
SCIP_CALL( addCoef(scip, cons, activevar, activescalar) );
}
if( !SCIPisZero(scip, activescalar) )
{
SCIP_CALL( addCoef(scip, cons, activevar, activescalar) );
}

if( !SCIPisZero(scip, activeconstant) )
{
if( !SCIPisInfinity(scip, -consdata->lhs) )
lhssubtrahend += activeconstant;
if( !SCIPisInfinity(scip, consdata->rhs) )
rhssubtrahend += activeconstant;
}
if( !SCIPisZero(scip, activeconstant) )
{
if( !SCIPisInfinity(scip, -consdata->lhs) )
lhssubtrahend += activeconstant;
if( !SCIPisInfinity(scip, consdata->rhs) )
rhssubtrahend += activeconstant;
}

SCIP_CALL( delCoefPos(scip, cons, v) );
break;
}
}
case SCIP_VARSTATUS_MULTAGGR:
SCIP_CALL( SCIPflattenVarAggregationGraph(scip, var) );
naggrvars = SCIPvarGetMultaggrNVars(var);
Expand Down Expand Up @@ -4822,12 +4822,28 @@ SCIP_RETCODE applyFixings(

if( !SCIPisInfinity(scip, -consdata->lhs) && !SCIPisInfinity(scip, consdata->lhs) )
{
/* for large numbers that are relatively equal, substraction can lead to cancellation,
* causing wrong fixings of other variables --> better use a real zero here;
* for small numbers, polishing the difference might lead to wrong results -->
* better use the exact difference in this case
/* check left hand side of unmodifiable empty constraint with former feasibility tolerance */
if( !SCIPconsIsModifiable(cons) && consdata->nvars == 0 )
{
if( SCIPisFeasLT(scip, lhssubtrahend, consdata->lhs) )
{
SCIP_CALL( chgLhs(scip, cons, SCIPinfinity(scip)) );

if( infeasible != NULL )
{
*infeasible = TRUE;
return SCIP_OKAY;
}
}
else
{
SCIP_CALL( chgLhs(scip, cons, -SCIPinfinity(scip)) );
}
}
/* for large numbers that are relatively equal, subtraction can lead to cancellation,
* causing wrong fixings of other variables --> better use a real zero here
*/
if( SCIPisEQ(scip, lhssubtrahend, consdata->lhs) && SCIPisFeasGE(scip, REALABS(lhssubtrahend), 1.0) )
else if( SCIPisEQ(scip, lhssubtrahend, consdata->lhs) )
{
SCIP_CALL( chgLhs(scip, cons, 0.0) );
}
Expand All @@ -4836,14 +4852,30 @@ SCIP_RETCODE applyFixings(
SCIP_CALL( chgLhs(scip, cons, consdata->lhs - lhssubtrahend) );
}
}
if( !SCIPisInfinity(scip, consdata->rhs) && !SCIPisInfinity(scip, -consdata->rhs))
if( !SCIPisInfinity(scip, consdata->rhs) && !SCIPisInfinity(scip, -consdata->rhs) )
{
/* check right hand side of unmodifiable empty constraint with former feasibility tolerance */
if( !SCIPconsIsModifiable(cons) && consdata->nvars == 0 )
{
if( SCIPisFeasGT(scip, rhssubtrahend, consdata->rhs) )
{
SCIP_CALL( chgRhs(scip, cons, -SCIPinfinity(scip)) );

if( infeasible != NULL )
{
*infeasible = TRUE;
return SCIP_OKAY;
}
}
else
{
SCIP_CALL( chgRhs(scip, cons, SCIPinfinity(scip)) );
}
}
/* for large numbers that are relatively equal, substraction can lead to cancellation,
* causing wrong fixings of other variables --> better use a real zero here;
* for small numbers, polishing the difference might lead to wrong results -->
* better use the exact difference in this case
* causing wrong fixings of other variables --> better use a real zero here
*/
if( SCIPisEQ(scip, rhssubtrahend, consdata->rhs ) && SCIPisFeasGE(scip, REALABS(rhssubtrahend), 1.0) )
else if( SCIPisEQ(scip, rhssubtrahend, consdata->rhs) )
{
SCIP_CALL( chgRhs(scip, cons, 0.0) );
}
Expand Down Expand Up @@ -11347,7 +11379,7 @@ SCIP_RETCODE aggregateVariables(
}
}
}
while( success );
while( success && consdata->nvars >= 1 );

return SCIP_OKAY;
}
Expand Down

0 comments on commit 8cbff9e

Please sign in to comment.