@@ -9614,13 +9614,6 @@ SCIP_RETCODE convertLongEquality(
9614
9614
SCIP_Bool coefsintegral;
9615
9615
SCIP_Bool varsintegral;
9616
9616
SCIP_Bool infeasible;
9617
- SCIP_Bool samevar;
9618
- int supinf; /* counter for infinite contributions to the supremum of a possible
9619
- * multi-aggregation
9620
- */
9621
- int infinf; /* counter for infinite contributions to the infimum of a possible
9622
- * multi-aggregation
9623
- */
9624
9617
int maxnlocksstay;
9625
9618
int maxnlocksremove;
9626
9619
int bestslackpos;
@@ -9851,17 +9844,19 @@ SCIP_RETCODE convertLongEquality(
9851
9844
if( conshdlrdata->multaggrremove && !removescons )
9852
9845
continue;
9853
9846
9854
- /* prefer variables that make the constraints redundant */
9855
- if( bestremovescons && !removescons )
9856
- continue;
9857
-
9858
9847
/* if the constraint does not become redundant, only accept the variable if it does not appear in
9859
9848
* other constraints
9860
9849
*/
9861
9850
if( !removescons && nlocks > maxnlocksstay )
9862
9851
continue;
9863
9852
9864
- better = better || (!bestremovescons && removescons);
9853
+ /* prefer variables that make the constraints redundant
9854
+ * unless there is a continuous better slack
9855
+ */
9856
+ if( !bestremovescons && removescons )
9857
+ better = TRUE;
9858
+ else if( bestremovescons && !removescons && (bestslacktype > SCIP_VARTYPE_INTEGER || slacktype <= SCIP_VARTYPE_INTEGER) )
9859
+ better = FALSE;
9865
9860
if( better )
9866
9861
{
9867
9862
bestslackpos = v;
@@ -9883,56 +9878,6 @@ SCIP_RETCODE convertLongEquality(
9883
9878
return SCIP_OKAY;
9884
9879
}
9885
9880
9886
- supinf = 0;
9887
- infinf = 0;
9888
- samevar = FALSE;
9889
-
9890
- /* check whether the the infimum and the supremum of the multi-aggregation can be get infinite */
9891
- for( v = 0; v < consdata->nvars; ++v )
9892
- {
9893
- if( v != bestslackpos )
9894
- {
9895
- if( SCIPisPositive(scip, consdata->vals[v]) )
9896
- {
9897
- if( SCIPisInfinity(scip, SCIPvarGetUbGlobal(consdata->vars[v])) )
9898
- {
9899
- ++supinf;
9900
- if( SCIPisInfinity(scip, -SCIPvarGetLbGlobal(consdata->vars[v])) )
9901
- {
9902
- ++infinf;
9903
- samevar = TRUE;
9904
- }
9905
- }
9906
- else if( SCIPisInfinity(scip, -SCIPvarGetLbGlobal(consdata->vars[v])) )
9907
- ++infinf;
9908
- }
9909
- else if( SCIPisNegative(scip, consdata->vals[v]) )
9910
- {
9911
- if( SCIPisInfinity(scip, -SCIPvarGetLbGlobal(consdata->vars[v])) )
9912
- {
9913
- ++supinf;
9914
- if( SCIPisInfinity(scip, SCIPvarGetUbGlobal(consdata->vars[v])) )
9915
- {
9916
- ++infinf;
9917
- samevar = TRUE;
9918
- }
9919
- }
9920
- else if( SCIPisInfinity(scip, SCIPvarGetUbGlobal(consdata->vars[v])) )
9921
- ++infinf;
9922
- }
9923
- }
9924
- }
9925
- assert(!samevar || (supinf > 0 && infinf > 0));
9926
-
9927
- /** @todo Do not exit here, but continue if we may still detect implied integrality. */
9928
- /* If the infimum and the supremum of a multi-aggregation are both infinite, then the multi-aggregation might not be resolvable.
9929
- * E.g., consider the equality z = x-y. If x and y are both fixed to +infinity, the value for z is not determined */
9930
- if( (samevar && (supinf > 1 || infinf > 1)) || (!samevar && supinf > 0 && infinf > 0) )
9931
- {
9932
- SCIPdebugMsg(scip, "do not perform multi-aggregation: infimum and supremum are both infinite\n");
9933
- return SCIP_OKAY;
9934
- }
9935
-
9936
9881
/* if the slack variable is of integer type, and the constraint itself may take fractional values,
9937
9882
* we cannot aggregate the variable, because the integrality condition would get lost
9938
9883
* Similarly, if there are implied integral variables, we cannot aggregate since we might
@@ -9942,6 +9887,7 @@ SCIP_RETCODE convertLongEquality(
9942
9887
&& (bestslacktype == SCIP_VARTYPE_CONTINUOUS || bestslacktype == SCIP_DEPRECATED_VARTYPE_IMPLINT
9943
9888
|| (coefsintegral && varsintegral && nimplvars == 0)) )
9944
9889
{
9890
+ SCIP_VAR** aggrvars;
9945
9891
SCIP_VAR* slackvar;
9946
9892
SCIP_Real* scalars;
9947
9893
SCIP_Real slackcoef;
@@ -9967,33 +9913,37 @@ SCIP_RETCODE convertLongEquality(
9967
9913
assert(!SCIPisZero(scip, slackcoef));
9968
9914
aggrconst = consdata->rhs/slackcoef;
9969
9915
9970
- getNewSidesAfterAggregation(scip, consdata, slackvar, slackcoef, &newlhs, &newrhs);
9971
- assert(SCIPisLE(scip, newlhs, newrhs));
9972
- SCIP_CALL( chgLhs(scip, cons, newlhs) );
9973
- SCIP_CALL( chgRhs(scip, cons, newrhs) );
9974
- SCIP_CALL( delCoefPos(scip, cons, bestslackpos) );
9975
-
9976
9916
/* allocate temporary memory */
9977
- SCIP_CALL( SCIPallocBufferArray(scip, &scalars, consdata->nvars) );
9917
+ SCIP_CALL( SCIPallocBufferArray(scip, &aggrvars, consdata->nvars - 1) );
9918
+ SCIP_CALL( SCIPallocBufferArray(scip, &scalars, consdata->nvars - 1) );
9978
9919
9979
9920
/* set up the multi-aggregation */
9980
9921
SCIPdebugMsg(scip, "linear constraint <%s>: multi-aggregate <%s> ==", SCIPconsGetName(cons), SCIPvarGetName(slackvar));
9981
- for( v = 0; v < consdata->nvars; ++v )
9922
+ for( v = 0; v < consdata->nvars - 1 ; ++v )
9982
9923
{
9983
- scalars[v] = -consdata->vals[v]/slackcoef;
9984
- SCIPdebugMsgPrint(scip, " %+.15g<%s>", scalars[v], SCIPvarGetName(vars[v]));
9924
+ if( v == bestslackpos )
9925
+ {
9926
+ aggrvars[v] = vars[consdata->nvars - 1];
9927
+ scalars[v] = -consdata->vals[consdata->nvars - 1] / slackcoef;
9928
+ }
9929
+ else
9930
+ {
9931
+ aggrvars[v] = vars[v];
9932
+ scalars[v] = -consdata->vals[v] / slackcoef;
9933
+ }
9934
+ SCIPdebugMsgPrint(scip, " %+.15g<%s>", scalars[v], SCIPvarGetName(aggrvars[v]));
9985
9935
}
9986
9936
SCIPdebugMsgPrint(scip, " %+.15g, bounds of <%s>: [%.15g,%.15g], nlocks=%d, maxnlocks=%d, removescons=%u\n",
9987
9937
aggrconst, SCIPvarGetName(slackvar), SCIPvarGetLbGlobal(slackvar), SCIPvarGetUbGlobal(slackvar),
9988
9938
bestnlocks, bestremovescons ? maxnlocksremove : maxnlocksstay, bestremovescons);
9989
9939
9990
9940
/* perform the multi-aggregation */
9991
- SCIP_CALL( SCIPmultiaggregateVar(scip, slackvar, consdata->nvars, vars , scalars, aggrconst,
9941
+ SCIP_CALL( SCIPmultiaggregateVar(scip, slackvar, consdata->nvars - 1, aggrvars , scalars, aggrconst,
9992
9942
&infeasible, &aggregated) );
9993
- assert(aggregated);
9994
9943
9995
9944
/* free temporary memory */
9996
9945
SCIPfreeBufferArray(scip, &scalars);
9946
+ SCIPfreeBufferArray(scip, &aggrvars);
9997
9947
9998
9948
/* check for infeasible aggregation */
9999
9949
if( infeasible )
@@ -10003,7 +9953,20 @@ SCIP_RETCODE convertLongEquality(
10003
9953
return SCIP_OKAY;
10004
9954
}
10005
9955
10006
- (*naggrvars)++;
9956
+ /* check for applied aggregation */
9957
+ if( !aggregated )
9958
+ {
9959
+ SCIPdebugMsg(scip, "linear constraint <%s>: multi-aggregation not applicable\n", SCIPconsGetName(cons));
9960
+ return SCIP_OKAY;
9961
+ }
9962
+
9963
+ ++(*naggrvars);
9964
+
9965
+ getNewSidesAfterAggregation(scip, consdata, slackvar, slackcoef, &newlhs, &newrhs);
9966
+ assert(SCIPisLE(scip, newlhs, newrhs));
9967
+ SCIP_CALL( chgLhs(scip, cons, newlhs) );
9968
+ SCIP_CALL( chgRhs(scip, cons, newrhs) );
9969
+ SCIP_CALL( delCoefPos(scip, cons, bestslackpos) );
10007
9970
10008
9971
/* delete the constraint if it became redundant */
10009
9972
if( bestremovescons )
@@ -10897,13 +10860,6 @@ SCIP_RETCODE dualPresolve(
10897
10860
int j;
10898
10861
SCIP_Bool infeasible;
10899
10862
SCIP_Bool aggregated;
10900
- SCIP_Bool samevar;
10901
- int supinf; /* counter for infinite contributions to the supremum of a possible
10902
- * multi-aggregation
10903
- */
10904
- int infinf; /* counter for infinite contributions to the infimum of a possible
10905
- * multi-aggregation
10906
- */
10907
10863
10908
10864
assert(!bestislhs || lhsexists);
10909
10865
assert(bestislhs || rhsexists);
@@ -10920,9 +10876,6 @@ SCIP_RETCODE dualPresolve(
10920
10876
SCIPdebugPrintCons(scip, cons, NULL);
10921
10877
SCIPdebugMsg(scip, "linear constraint <%s> (dual): multi-aggregate <%s> ==", SCIPconsGetName(cons), SCIPvarGetName(bestvar));
10922
10878
naggrs = 0;
10923
- supinf = 0;
10924
- infinf = 0;
10925
- samevar = FALSE;
10926
10879
10927
10880
for( j = 0; j < consdata->nvars; ++j )
10928
10881
{
@@ -10952,39 +10905,9 @@ SCIP_RETCODE dualPresolve(
10952
10905
aggrcoefs[naggrs] = SCIPfloor(scip, aggrcoefs[naggrs]+0.5);
10953
10906
}
10954
10907
10955
- if( SCIPisPositive(scip, aggrcoefs[naggrs]) )
10956
- {
10957
- if( SCIPisInfinity(scip, SCIPvarGetUbGlobal(consdata->vars[j])) )
10958
- {
10959
- ++supinf;
10960
- if( SCIPisInfinity(scip, -SCIPvarGetLbGlobal(consdata->vars[j])) )
10961
- {
10962
- ++infinf;
10963
- samevar = TRUE;
10964
- }
10965
- }
10966
- else if( SCIPisInfinity(scip, -SCIPvarGetLbGlobal(consdata->vars[j])) )
10967
- ++infinf;
10968
- }
10969
- else if( SCIPisNegative(scip, aggrcoefs[naggrs]) )
10970
- {
10971
- if( SCIPisInfinity(scip, -SCIPvarGetLbGlobal(consdata->vars[j])) )
10972
- {
10973
- ++supinf;
10974
- if( SCIPisInfinity(scip, SCIPvarGetUbGlobal(consdata->vars[j])) )
10975
- {
10976
- ++infinf;
10977
- samevar = TRUE;
10978
- }
10979
- }
10980
- else if( SCIPisInfinity(scip, SCIPvarGetUbGlobal(consdata->vars[j])) )
10981
- ++infinf;
10982
- }
10983
-
10984
10908
naggrs++;
10985
10909
}
10986
10910
}
10987
- assert(!samevar || (supinf > 0 && infinf > 0));
10988
10911
10989
10912
aggrconst = (bestislhs ? consdata->lhs/bestval : consdata->rhs/bestval);
10990
10913
SCIPdebugMsgPrint(scip, " %+.15g, bounds of <%s>: [%.15g,%.15g]\n", aggrconst, SCIPvarGetName(bestvar),
@@ -11002,43 +10925,35 @@ SCIP_RETCODE dualPresolve(
11002
10925
infeasible = FALSE;
11003
10926
11004
10927
/* perform the multi-aggregation */
11005
- if( (samevar && supinf == 1 && infinf == 1) || (!samevar && (supinf == 0 || infinf == 0)) )
10928
+ SCIP_CALL( SCIPmultiaggregateVar(scip, bestvar, naggrs, aggrvars, aggrcoefs, aggrconst, &infeasible, &aggregated) );
10929
+
10930
+ /** @todo handle this case properly with weak and strong implied integrality */
10931
+ /* if the multi-aggregated bestvar is enforced but not strongly implied integral, we need to convert implied
10932
+ * integral to integer variables because integrality of the multi-aggregated variable must hold
10933
+ */
10934
+ if( !infeasible && aggregated && SCIPvarGetType(bestvar) != SCIP_VARTYPE_CONTINUOUS && SCIPvarGetImplType(bestvar) != SCIP_IMPLINTTYPE_STRONG )
11006
10935
{
11007
- SCIP_CALL( SCIPmultiaggregateVar(scip, bestvar, naggrs, aggrvars, aggrcoefs, aggrconst, &infeasible, &aggregated) ) ;
10936
+ SCIP_Bool infeasiblevartypechg = FALSE ;
11008
10937
11009
- /** @todo handle this case properly with weak and strong implied integrality */
11010
- /* if the multi-aggregated bestvar is enforced but not strongly implied integral, we need to convert implied
11011
- * integral to integer variables because integrality of the multi-aggregated variable must hold
11012
- */
11013
- if( !infeasible && aggregated && SCIPvarGetType(bestvar) != SCIP_VARTYPE_CONTINUOUS && SCIPvarGetImplType(bestvar) != SCIP_IMPLINTTYPE_STRONG )
10938
+ for( j = 0; j < naggrs; ++j )
11014
10939
{
11015
- SCIP_Bool infeasiblevartypechg = FALSE;
11016
-
11017
- for( j = 0; j < naggrs; ++j)
10940
+ /* if the multi-aggregation was not infeasible, then setting implied integral to integer should not
10941
+ * lead to infeasibility
10942
+ */
10943
+ if( SCIPvarGetType(aggrvars[j]) == SCIP_VARTYPE_CONTINUOUS || SCIPvarGetImplType(aggrvars[j]) != SCIP_IMPLINTTYPE_NONE )
11018
10944
{
11019
- /* if the multi-aggregation was not infeasible, then setting implied integral to integer should not
11020
- * lead to infeasibility
11021
- */
11022
- if( SCIPvarGetType(aggrvars[j]) == SCIP_VARTYPE_CONTINUOUS || SCIPvarGetImplType(aggrvars[j]) != SCIP_IMPLINTTYPE_NONE )
10945
+ if( SCIPvarGetType(aggrvars[j]) == SCIP_VARTYPE_CONTINUOUS )
11023
10946
{
11024
- if( SCIPvarGetType(aggrvars[j]) == SCIP_VARTYPE_CONTINUOUS )
11025
- {
11026
- SCIP_CALL( SCIPchgVarType(scip, aggrvars[j], SCIP_VARTYPE_INTEGER, &infeasiblevartypechg) );
11027
- assert(!infeasiblevartypechg);
11028
- }
11029
- SCIP_CALL( SCIPchgVarImplType(scip, aggrvars[j], SCIP_IMPLINTTYPE_NONE, &infeasiblevartypechg) );
10947
+ SCIP_CALL( SCIPchgVarType(scip, aggrvars[j], SCIP_VARTYPE_INTEGER, &infeasiblevartypechg) );
11030
10948
assert(!infeasiblevartypechg);
11031
- (*nchgvartypes)++;
11032
10949
}
10950
+ SCIP_CALL( SCIPchgVarImplType(scip, aggrvars[j], SCIP_IMPLINTTYPE_NONE, &infeasiblevartypechg) );
10951
+ assert(!infeasiblevartypechg);
10952
+ (*nchgvartypes)++;
11033
10953
}
11034
10954
}
11035
10955
}
11036
- else
11037
- {
11038
- /* If the infimum and the supremum of a multi-aggregation are both infinite, then the multi-aggregation might not be resolvable.
11039
- * E.g., consider the equality z = x-y. If x and y are both fixed to +infinity, the value for z is not determined */
11040
- SCIPdebugMsg(scip, "do not perform multi-aggregation: infimum and supremum are both infinite\n");
11041
- }
10956
+
11042
10957
/* free temporary memory */
11043
10958
SCIPfreeBufferArray(scip, &aggrcoefs);
11044
10959
SCIPfreeBufferArray(scip, &aggrvars);
0 commit comments