Skip to content

Commit ca427b6

Browse files
author
Christopher Hojny
committed
Merge branch '3912-list-total-number-of-symmetric-variables' into 'master'
Resolve "List total number of symmetric variables" Closes #3912 See merge request integer/scip!3851
2 parents dbba347 + 6b437b6 commit ca427b6

File tree

2 files changed

+66
-60
lines changed

2 files changed

+66
-60
lines changed

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Features
3434
the SCIP shell dialog "display statistics" now also prints the statistics from solving the Benders' decomposition in the relaxator
3535
- added a dynamic max-lookahead criterion for strong branching. Fits a probability distribution to the observed candidate gains and
3636
stop evaluating further candidates once the expected tree-size reduction no longer justifies the LP evaluation cost.
37+
- extended the statistics to also include information about the number of variables (per type) affected by symmetry
3738

3839
Performance improvements
3940
------------------------

src/scip/prop_symmetry.c

Lines changed: 65 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,65 @@ SCIP_RETCODE printSyminfoGroupAction(
674674
return SCIP_OKAY;
675675
}
676676

677+
678+
/** ensures that movedpermvarscounts is initialized */
679+
static
680+
SCIP_RETCODE ensureSymmetryMovedPermvarsCountsComputed(
681+
SCIP* scip, /**< SCIP instance */
682+
SCIP_PROPDATA* propdata /**< propagator data */
683+
)
684+
{
685+
int v;
686+
int p;
687+
688+
assert( scip != NULL );
689+
assert( propdata != NULL );
690+
691+
/* symmetries must have been determined */
692+
assert( propdata->nperms >= 0 );
693+
694+
/* stop if already computed */
695+
if ( propdata->nmovedpermvars >= 0 )
696+
return SCIP_OKAY;
697+
assert( propdata->nmovedpermvars == -1 );
698+
699+
propdata->nmovedpermvars = 0;
700+
propdata->nmovedbinpermvars = 0;
701+
propdata->nmovedintpermvars = 0;
702+
propdata->nmovedcontpermvars = 0;
703+
704+
for (v = 0; v < propdata->npermvars; ++v)
705+
{
706+
for (p = 0; p < propdata->nperms; ++p)
707+
{
708+
if ( propdata->perms[p][v] != v )
709+
{
710+
++propdata->nmovedpermvars;
711+
712+
switch ( SCIPgetSymInferredVarType(propdata->permvars[v]) )
713+
{
714+
case SCIP_VARTYPE_BINARY:
715+
++propdata->nmovedbinpermvars;
716+
break;
717+
case SCIP_VARTYPE_INTEGER:
718+
++propdata->nmovedintpermvars;
719+
break;
720+
case SCIP_VARTYPE_CONTINUOUS:
721+
++propdata->nmovedcontpermvars;
722+
break;
723+
default:
724+
SCIPerrorMessage("unknown variable type\n");
725+
return SCIP_INVALIDDATA;
726+
} /*lint !e788*/
727+
break;
728+
}
729+
}
730+
}
731+
732+
return SCIP_OKAY;
733+
}
734+
735+
677736
/*
678737
* Table callback methods
679738
*/
@@ -701,10 +760,14 @@ SCIP_DECL_TABLEOUTPUT(tableOutputSymmetry)
701760
assert( tabledata != NULL );
702761
assert( tabledata->propdata != NULL );
703762

704-
if ( tabledata->propdata->orbitopalreddata || tabledata->propdata->orbitalreddata
705-
|| tabledata->propdata->lexreddata )
763+
/* print information only if symmetries are present */
764+
if ( tabledata->propdata->nperms > 0 )
706765
{
707766
SCIPverbMessage(scip, SCIP_VERBLEVEL_MINIMAL, file, "Symmetry :\n");
767+
SCIP_CALL( ensureSymmetryMovedPermvarsCountsComputed(scip, tabledata->propdata) );
768+
SCIPverbMessage(scip, SCIP_VERBLEVEL_MINIMAL, file, " #affected vars : %10d (%d bin, %d int, %d cont)\n",
769+
tabledata->propdata->nmovedpermvars, tabledata->propdata->nmovedbinpermvars,
770+
tabledata->propdata->nmovedintpermvars, tabledata->propdata->nmovedcontpermvars) ;
708771
if ( tabledata->propdata->orbitopalreddata )
709772
{
710773
SCIP_CALL( SCIPorbitopalReductionGetStatistics(scip, tabledata->propdata->orbitopalreddata, &nred, &ncutoff) );
@@ -2168,64 +2231,6 @@ SCIP_RETCODE ensureSymmetryPermstransComputed(
21682231
}
21692232

21702233

2171-
/** ensures that movedpermvarscounts is initialized */
2172-
static
2173-
SCIP_RETCODE ensureSymmetryMovedPermvarsCountsComputed(
2174-
SCIP* scip, /**< SCIP instance */
2175-
SCIP_PROPDATA* propdata /**< propagator data */
2176-
)
2177-
{
2178-
int v;
2179-
int p;
2180-
2181-
assert( scip != NULL );
2182-
assert( propdata != NULL );
2183-
2184-
/* symmetries must have been determined */
2185-
assert( propdata->nperms >= 0 );
2186-
2187-
/* stop if already computed */
2188-
if ( propdata->nmovedpermvars >= 0 )
2189-
return SCIP_OKAY;
2190-
assert( propdata->nmovedpermvars == -1 );
2191-
2192-
propdata->nmovedpermvars = 0;
2193-
propdata->nmovedbinpermvars = 0;
2194-
propdata->nmovedintpermvars = 0;
2195-
propdata->nmovedcontpermvars = 0;
2196-
2197-
for (v = 0; v < propdata->npermvars; ++v)
2198-
{
2199-
for (p = 0; p < propdata->nperms; ++p)
2200-
{
2201-
if ( propdata->perms[p][v] != v )
2202-
{
2203-
++propdata->nmovedpermvars;
2204-
2205-
switch ( SCIPgetSymInferredVarType(propdata->permvars[v]) )
2206-
{
2207-
case SCIP_VARTYPE_BINARY:
2208-
++propdata->nmovedbinpermvars;
2209-
break;
2210-
case SCIP_VARTYPE_INTEGER:
2211-
++propdata->nmovedintpermvars;
2212-
break;
2213-
case SCIP_VARTYPE_CONTINUOUS:
2214-
++propdata->nmovedcontpermvars;
2215-
break;
2216-
default:
2217-
SCIPerrorMessage("unknown variable type\n");
2218-
return SCIP_INVALIDDATA;
2219-
} /*lint !e788*/
2220-
break;
2221-
}
2222-
}
2223-
}
2224-
2225-
return SCIP_OKAY;
2226-
}
2227-
2228-
22292234
/** returns whether a SCIP instance has an active inferred binary variable */
22302235
static
22312236
SCIP_Bool hasInferredBinVar(

0 commit comments

Comments
 (0)