Skip to content

Commit 289921b

Browse files
committed
Merge branch 'fix-vartype-statistics' into 'v91-bugfix'
Fix vartype statistics See merge request integer/scip!3509
2 parents dfcdddc + 9092a53 commit 289921b

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

Diff for: CHANGELOG

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Fixed bugs
2828
- fixed reading of very long lines (>78000 characters) in FlatZinc reader
2929
- fixed write of strings with at least 1024 characters when compiling with MSVS 2015 (14.0) or later (still an issue with earlier MSVS, which will not be fixed)
3030
- keep epsilon coefficients in applyFixings() of cons_linear.c until multiples are merged to avoid loss of relevant contributions
31+
- fixed that some variable type changes were not accounted correctly in presolve of linear constraints
3132

3233
Performance improvements
3334
------------------------

Diff for: src/scip/cons_linear.c

+18-9
Original file line numberDiff line numberDiff line change
@@ -9623,7 +9623,8 @@ SCIP_RETCODE convertLongEquality(
96239623
SCIP_CONS* cons, /**< linear constraint */
96249624
SCIP_Bool* cutoff, /**< pointer to store TRUE, if a cutoff was found */
96259625
int* naggrvars, /**< pointer to count number of aggregated variables */
9626-
int* ndelconss /**< pointer to count number of deleted constraints */
9626+
int* ndelconss, /**< pointer to count number of deleted constraints */
9627+
int* nchgvartypes /**< pointer to count number of changed variable types */
96279628
)
96289629
{
96299630
SCIP_CONSDATA* consdata;
@@ -9761,6 +9762,7 @@ SCIP_RETCODE convertLongEquality(
97619762
if( absval > maxabsval )
97629763
maxabsval = absval;
97639764

9765+
/*TODO: why exit here when implied integrality can still be derived?!*/
97649766
/* do not try to multi aggregate, when numerical bad */
97659767
if( maxabsval / minabsval > conshdlrdata->maxmultaggrquot )
97669768
return SCIP_OKAY;
@@ -9942,6 +9944,7 @@ SCIP_RETCODE convertLongEquality(
99429944
}
99439945
assert(!samevar || (supinf > 0 && infinf > 0));
99449946

9947+
/*TODO: implint detection again terminates early here*/
99459948
/* If the infimum and the supremum of a multi-aggregation are both infinite, then the multi-aggregation might not be resolvable.
99469949
* E.g., consider the equality z = x-y. If x and y are both fixed to +infinity, the value for z is not determined */
99479950
if( (samevar && (supinf > 1 || infinf > 1)) || (!samevar && supinf > 0 && infinf > 0) )
@@ -10049,6 +10052,7 @@ SCIP_RETCODE convertLongEquality(
1004910052
SCIPdebugMsg(scip, "linear constraint <%s>: converting continuous variable <%s> to implicit integer variable\n",
1005010053
SCIPconsGetName(cons), SCIPvarGetName(var));
1005110054
SCIP_CALL( SCIPchgVarType(scip, var, SCIP_VARTYPE_IMPLINT, &infeasible) );
10055+
(*nchgvartypes)++;
1005210056
if( infeasible )
1005310057
{
1005410058
SCIPdebugMsg(scip, "infeasible upgrade of variable <%s> to integral type, domain is empty\n", SCIPvarGetName(var));
@@ -10143,6 +10147,7 @@ SCIP_RETCODE convertLongEquality(
1014310147
SCIPdebugMsg(scip, "linear constraint <%s>: converting integer variable <%s> to implicit integer variable\n",
1014410148
SCIPconsGetName(cons), SCIPvarGetName(var));
1014510149
SCIP_CALL( SCIPchgVarType(scip, var, SCIP_VARTYPE_IMPLINT, &infeasible) );
10150+
(*nchgvartypes)++;
1014610151
if( infeasible )
1014710152
{
1014810153
SCIPdebugMsg(scip, "infeasible upgrade of variable <%s> to integral type, domain is empty\n", SCIPvarGetName(var));
@@ -10487,7 +10492,8 @@ SCIP_RETCODE convertEquality(
1048710492
SCIP_Bool* cutoff, /**< pointer to store TRUE, if a cutoff was found */
1048810493
int* nfixedvars, /**< pointer to count number of fixed variables */
1048910494
int* naggrvars, /**< pointer to count number of aggregated variables */
10490-
int* ndelconss /**< pointer to count number of deleted constraints */
10495+
int* ndelconss, /**< pointer to count number of deleted constraints */
10496+
int* nchgvartypes /**< pointer to count number of changed variable types */
1049110497
)
1049210498
{
1049310499
SCIP_CONSDATA* consdata;
@@ -10525,7 +10531,7 @@ SCIP_RETCODE convertEquality(
1052510531
SCIP_CALL( checkPartialObjective(scip, cons, conshdlrdata) );
1052610532

1052710533
/* try to multi-aggregate one of the variables */
10528-
SCIP_CALL( convertLongEquality(scip, conshdlrdata, cons, cutoff, naggrvars, ndelconss) );
10534+
SCIP_CALL( convertLongEquality(scip, conshdlrdata, cons, cutoff, naggrvars, ndelconss, nchgvartypes) );
1052910535
}
1053010536

1053110537
return SCIP_OKAY;
@@ -10613,7 +10619,8 @@ SCIP_RETCODE dualPresolve(
1061310619
SCIP_Bool* cutoff, /**< pointer to store TRUE, if a cutoff was found */
1061410620
int* nfixedvars, /**< pointer to count number of fixed variables */
1061510621
int* naggrvars, /**< pointer to count number of aggregated variables */
10616-
int* ndelconss /**< pointer to count number of deleted constraints */
10622+
int* ndelconss, /**< pointer to count number of deleted constraints */
10623+
int* nchgvartypes /**< pointer to count number of changed variable types */
1061710624
)
1061810625
{
1061910626
SCIP_CONSDATA* consdata;
@@ -11040,6 +11047,7 @@ SCIP_RETCODE dualPresolve(
1104011047
if( SCIPvarGetType(aggrvars[j]) == SCIP_VARTYPE_IMPLINT )
1104111048
{
1104211049
SCIP_CALL( SCIPchgVarType(scip, aggrvars[j], SCIP_VARTYPE_INTEGER, &infeasiblevartypechg) );
11050+
(*nchgvartypes)++;
1104311051
assert(!infeasiblevartypechg);
1104411052
}
1104511053
}
@@ -14597,7 +14605,8 @@ SCIP_RETCODE fullDualPresolve(
1459714605
SCIP_CONS** conss, /**< constraint set */
1459814606
int nconss, /**< number of constraints */
1459914607
SCIP_Bool* cutoff, /**< pointer to store TRUE, if a cutoff was found */
14600-
int* nchgbds /**< pointer to count the number of bound changes */
14608+
int* nchgbds, /**< pointer to count the number of bound changes */
14609+
int* nchgvartypes /**< pointer to count the number of variable type changes */
1460114610
)
1460214611
{
1460314612
SCIP_Real* redlb;
@@ -15032,7 +15041,7 @@ SCIP_RETCODE fullDualPresolve(
1503215041
{
1503315042
/* since we locally copied the variable array we can change the variable type immediately */
1503415043
SCIP_CALL( SCIPchgVarType(scip, var, SCIP_VARTYPE_IMPLINT, &infeasible) );
15035-
15044+
(*nchgvartypes)++;
1503615045
if( infeasible )
1503715046
{
1503815047
SCIPdebugMsg(scip, "infeasible upgrade of variable <%s> to integral type, domain is empty\n", SCIPvarGetName(var));
@@ -16592,13 +16601,13 @@ SCIP_DECL_CONSPRESOL(consPresolLinear)
1659216601
/* convert special equalities */
1659316602
if( !cutoff && SCIPconsIsActive(cons) )
1659416603
{
16595-
SCIP_CALL( convertEquality(scip, cons, conshdlrdata, &cutoff, nfixedvars, naggrvars, ndelconss) );
16604+
SCIP_CALL( convertEquality(scip, cons, conshdlrdata, &cutoff, nfixedvars, naggrvars, ndelconss, nchgvartypes) );
1659616605
}
1659716606

1659816607
/* apply dual presolving for variables that appear in only one constraint */
1659916608
if( !cutoff && SCIPconsIsActive(cons) && conshdlrdata->dualpresolving && SCIPallowStrongDualReds(scip) )
1660016609
{
16601-
SCIP_CALL( dualPresolve(scip, conshdlrdata, cons, &cutoff, nfixedvars, naggrvars, ndelconss) );
16610+
SCIP_CALL( dualPresolve(scip, conshdlrdata, cons, &cutoff, nfixedvars, naggrvars, ndelconss, nchgvartypes) );
1660216611
}
1660316612

1660416613
/* check if an inequality is parallel to the objective function */
@@ -16732,7 +16741,7 @@ SCIP_DECL_CONSPRESOL(consPresolLinear)
1673216741
{
1673316742
if( conshdlrdata->dualpresolving && SCIPallowStrongDualReds(scip) && !SCIPisStopped(scip) )
1673416743
{
16735-
SCIP_CALL( fullDualPresolve(scip, conss, nconss, &cutoff, nchgbds) );
16744+
SCIP_CALL( fullDualPresolve(scip, conss, nconss, &cutoff, nchgbds, nchgvartypes) );
1673616745
}
1673716746
}
1673816747

0 commit comments

Comments
 (0)