Skip to content

Commit 0a7952a

Browse files
committed
Merge remote-tracking branch 'origin/v10-minor'
2 parents 56dff56 + b9d3ecf commit 0a7952a

File tree

6 files changed

+298
-0
lines changed

6 files changed

+298
-0
lines changed

CHANGELOG

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ Features
6767
- added writing support for AMPL NL writer: currently only general and specialized linear and nonlinear constraints can be written
6868
- implemented columnwise Jacobian sparsity computation in the NLP oracle
6969
- implemented method to compute new permutations from a given list of symmetry group generators
70+
- cons_orbisack, cons_orbitope_full, cons_orbitope_pp and cons_symresack now try to replace aggregated variables by active ones at the
71+
end of presolving. This should reduce the size of copies of the presolved problem
7072

7173
Performance improvements
7274
------------------------

src/scip/cons_logicor.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4171,6 +4171,7 @@ SCIP_DECL_CONSINITPRE(consInitpreLogicor)
41714171

41724172
return SCIP_OKAY;
41734173
}
4174+
41744175
/** presolving deinitialization method of constraint handler (called after presolving has been finished) */
41754176
static
41764177
SCIP_DECL_CONSEXITPRE(consExitpreLogicor)

src/scip/cons_orbisack.c

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,6 +1019,70 @@ SCIP_RETCODE separateInequalities(
10191019
}
10201020

10211021

1022+
/** replace aggregated variables by active variables */
1023+
static
1024+
SCIP_RETCODE replaceAggregatedVarsOrbisack(
1025+
SCIP* scip, /**< SCIP data structure */
1026+
SCIP_CONS* cons /**< constraint to be processed */
1027+
)
1028+
{
1029+
SCIP_CONSDATA* consdata;
1030+
SCIP_VAR** vars1;
1031+
SCIP_VAR** vars2;
1032+
int i;
1033+
int nrows;
1034+
1035+
assert( scip != NULL );
1036+
assert( cons != NULL );
1037+
1038+
/* get data of constraint */
1039+
consdata = SCIPconsGetData(cons);
1040+
assert( consdata != NULL );
1041+
assert( consdata->vars1 != NULL );
1042+
assert( consdata->vars2 != NULL );
1043+
assert( consdata->nrows > 0 );
1044+
1045+
nrows = consdata->nrows;
1046+
vars1 = consdata->vars1;
1047+
vars2 = consdata->vars2;
1048+
1049+
/* loop through all variables */
1050+
for (i = 0; i < nrows; ++i)
1051+
{
1052+
SCIP_VAR* var;
1053+
SCIP_Bool negated;
1054+
1055+
/* treat first column */
1056+
assert( SCIPvarGetStatus(vars1[i]) != SCIP_VARSTATUS_MULTAGGR ); /* variables are marked as not to be multi-aggregated */
1057+
1058+
SCIP_CALL( SCIPgetBinvarRepresentative(scip, vars1[i], &var, &negated) );
1059+
SCIP_UNUSED( negated );
1060+
assert( SCIPvarIsActive(var) || SCIPvarGetStatus(var) == SCIP_VARSTATUS_NEGATED || SCIPvarGetStatus(var) == SCIP_VARSTATUS_FIXED );
1061+
if ( var != vars1[i] )
1062+
{
1063+
SCIP_CALL( SCIPreleaseVar(scip, &vars1[i]) );
1064+
vars1[i] = var;
1065+
SCIP_CALL( SCIPcaptureVar(scip, var) );
1066+
}
1067+
1068+
/* treat second column */
1069+
assert( SCIPvarGetStatus(vars2[i]) != SCIP_VARSTATUS_MULTAGGR ); /* variables are marked as not to be multi-aggregated */
1070+
1071+
SCIP_CALL( SCIPgetBinvarRepresentative(scip, vars2[i], &var, &negated) );
1072+
SCIP_UNUSED( negated );
1073+
assert( SCIPvarIsActive(var) || SCIPvarGetStatus(var) == SCIP_VARSTATUS_NEGATED || SCIPvarGetStatus(var) == SCIP_VARSTATUS_FIXED );
1074+
if ( var != vars2[i] )
1075+
{
1076+
SCIP_CALL( SCIPreleaseVar(scip, &vars2[i]) );
1077+
vars2[i] = var;
1078+
SCIP_CALL( SCIPcaptureVar(scip, var) );
1079+
}
1080+
}
1081+
1082+
return SCIP_OKAY;
1083+
}
1084+
1085+
10221086
/*--------------------------------------------------------------------------------------------
10231087
*--------------------------------- SCIP functions -------------------------------------------
10241088
*--------------------------------------------------------------------------------------------*/
@@ -1753,6 +1817,25 @@ SCIP_DECL_CONSRESPROP(consRespropOrbisack)
17531817
}
17541818

17551819

1820+
/** presolving deinitialization method of constraint handler (called after presolving has been finished) */
1821+
static
1822+
SCIP_DECL_CONSEXITPRE(consExitpreOrbisack)
1823+
{
1824+
int c;
1825+
1826+
assert( scip != NULL );
1827+
assert( conshdlr != NULL );
1828+
assert( strcmp(SCIPconshdlrGetName(conshdlr), CONSHDLR_NAME) == 0 );
1829+
1830+
for (c = 0; c < nconss; ++c)
1831+
{
1832+
/* replace aggregated variables by active variables */
1833+
SCIP_CALL( replaceAggregatedVarsOrbisack(scip, conss[c]) );
1834+
}
1835+
return SCIP_OKAY;
1836+
}
1837+
1838+
17561839
/** Lock variables
17571840
*
17581841
* We assume we have only one global (void) constraint and lock all variables.
@@ -2182,6 +2265,7 @@ SCIP_RETCODE SCIPincludeConshdlrOrbisack(
21822265
SCIP_CALL( SCIPsetConshdlrPrint(scip, conshdlr, consPrintOrbisack) );
21832266
SCIP_CALL( SCIPsetConshdlrProp(scip, conshdlr, consPropOrbisack, CONSHDLR_PROPFREQ, CONSHDLR_DELAYPROP, CONSHDLR_PROP_TIMING) );
21842267
SCIP_CALL( SCIPsetConshdlrResprop(scip, conshdlr, consRespropOrbisack) );
2268+
SCIP_CALL( SCIPsetConshdlrExitpre(scip, conshdlr, consExitpreOrbisack) );
21852269
SCIP_CALL( SCIPsetConshdlrSepa(scip, conshdlr, consSepalpOrbisack, consSepasolOrbisack, CONSHDLR_SEPAFREQ, CONSHDLR_SEPAPRIORITY, CONSHDLR_DELAYSEPA) );
21862270
SCIP_CALL( SCIPsetConshdlrTrans(scip, conshdlr, consTransOrbisack) );
21872271
SCIP_CALL( SCIPsetConshdlrInitlp(scip, conshdlr, consInitlpOrbisack) );

src/scip/cons_orbitope_full.c

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,6 +1002,59 @@ SCIP_RETCODE checkRedundantCons(
10021002
}
10031003

10041004

1005+
/** replace aggregated variables by active variables */
1006+
static
1007+
SCIP_RETCODE replaceAggregatedVarsOrbitopeFull(
1008+
SCIP* scip, /**< SCIP data structure */
1009+
SCIP_CONS* cons /**< constraint to be processed */
1010+
)
1011+
{
1012+
SCIP_CONSDATA* consdata;
1013+
SCIP_VAR*** vars;
1014+
int i;
1015+
int j;
1016+
int nrows;
1017+
int ncols;
1018+
1019+
assert( scip != NULL );
1020+
assert( cons != NULL );
1021+
1022+
consdata = SCIPconsGetData(cons);
1023+
assert( consdata != NULL );
1024+
assert( consdata->vars != NULL );
1025+
assert( consdata->nrows > 0 );
1026+
assert( consdata->ncols > 0 );
1027+
1028+
vars = consdata->vars;
1029+
nrows = consdata->nrows;
1030+
ncols = consdata->ncols;
1031+
1032+
/* check whether there exists an aggregated variable in the orbitope */
1033+
for (i = 0; i < nrows; ++i)
1034+
{
1035+
for (j = 0; j < ncols; ++j)
1036+
{
1037+
SCIP_VAR* var;
1038+
SCIP_Bool negated;
1039+
1040+
assert( SCIPvarGetStatus(vars[i][j]) != SCIP_VARSTATUS_MULTAGGR ); /* variables are marked as not to be multi-aggregated */
1041+
1042+
SCIP_CALL( SCIPgetBinvarRepresentative(scip, vars[i][j], &var, &negated) );
1043+
SCIP_UNUSED( negated );
1044+
assert( SCIPvarIsActive(var) || SCIPvarGetStatus(var) == SCIP_VARSTATUS_NEGATED || SCIPvarGetStatus(var) == SCIP_VARSTATUS_FIXED );
1045+
if ( var != vars[i][j] )
1046+
{
1047+
SCIP_CALL( SCIPreleaseVar(scip, &vars[i][j]) );
1048+
vars[i][j] = var;
1049+
SCIP_CALL( SCIPcaptureVar(scip, var) );
1050+
}
1051+
}
1052+
}
1053+
1054+
return SCIP_OKAY;
1055+
}
1056+
1057+
10051058
/*
10061059
* Callback methods of constraint handler
10071060
*/
@@ -1382,6 +1435,25 @@ SCIP_DECL_CONSRESPROP(consRespropOrbitopeFull)
13821435
}
13831436

13841437

1438+
/** presolving deinitialization method of constraint handler (called after presolving has been finished) */
1439+
static
1440+
SCIP_DECL_CONSEXITPRE(consExitpreOrbitopeFull)
1441+
{
1442+
int c;
1443+
1444+
assert( scip != NULL );
1445+
assert( conshdlr != NULL );
1446+
assert( strcmp(SCIPconshdlrGetName(conshdlr), CONSHDLR_NAME) == 0 );
1447+
1448+
for (c = 0; c < nconss; ++c)
1449+
{
1450+
/* replace aggregated variables by active variables */
1451+
SCIP_CALL( replaceAggregatedVarsOrbitopeFull(scip, conss[c]) );
1452+
}
1453+
return SCIP_OKAY;
1454+
}
1455+
1456+
13851457
/** variable rounding lock method of constraint handler */
13861458
static
13871459
SCIP_DECL_CONSLOCK(consLockOrbitopeFull)
@@ -1767,6 +1839,7 @@ SCIP_RETCODE SCIPincludeConshdlrOrbitopeFull(
17671839
SCIP_CALL( SCIPsetConshdlrProp(scip, conshdlr, consPropOrbitopeFull, CONSHDLR_PROPFREQ, CONSHDLR_DELAYPROP,
17681840
CONSHDLR_PROP_TIMING) );
17691841
SCIP_CALL( SCIPsetConshdlrResprop(scip, conshdlr, consRespropOrbitopeFull) );
1842+
SCIP_CALL( SCIPsetConshdlrExitpre(scip, conshdlr, consExitpreOrbitopeFull) );
17701843
SCIP_CALL( SCIPsetConshdlrSepa(scip, conshdlr, consSepalpOrbitopeFull, consSepasolOrbitopeFull, CONSHDLR_SEPAFREQ,
17711844
CONSHDLR_SEPAPRIORITY, CONSHDLR_DELAYSEPA) );
17721845
SCIP_CALL( SCIPsetConshdlrTrans(scip, conshdlr, consTransOrbitopeFull) );

src/scip/cons_orbitope_pp.c

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1815,6 +1815,58 @@ SCIP_RETCODE checkRedundantCons(
18151815
return SCIP_OKAY;
18161816
}
18171817

1818+
/** replace aggregated variables by active variables */
1819+
static
1820+
SCIP_RETCODE replaceAggregatedVarsOrbitopePP(
1821+
SCIP* scip, /**< SCIP data structure */
1822+
SCIP_CONS* cons /**< constraint to be processed */
1823+
)
1824+
{
1825+
SCIP_CONSDATA* consdata;
1826+
SCIP_VAR*** vars;
1827+
int i;
1828+
int j;
1829+
int nrows;
1830+
int ncols;
1831+
1832+
assert( scip != NULL );
1833+
assert( cons != NULL );
1834+
1835+
consdata = SCIPconsGetData(cons);
1836+
assert( consdata != NULL );
1837+
assert( consdata->vars != NULL );
1838+
assert( consdata->nrows > 0 );
1839+
assert( consdata->ncols > 0 );
1840+
1841+
vars = consdata->vars;
1842+
nrows = consdata->nrows;
1843+
ncols = consdata->ncols;
1844+
1845+
/* check whether there exists an aggregated variable in the orbitope */
1846+
for (i = 0; i < nrows; ++i)
1847+
{
1848+
for (j = 0; j < ncols; ++j)
1849+
{
1850+
SCIP_VAR* var;
1851+
SCIP_Bool negated;
1852+
1853+
assert( SCIPvarGetStatus(vars[i][j]) != SCIP_VARSTATUS_MULTAGGR ); /* variables are marked as not to be multi-aggregated */
1854+
1855+
SCIP_CALL( SCIPgetBinvarRepresentative(scip, vars[i][j], &var, &negated) );
1856+
SCIP_UNUSED( negated );
1857+
assert( SCIPvarIsActive(var) || SCIPvarGetStatus(var) == SCIP_VARSTATUS_NEGATED || SCIPvarGetStatus(var) == SCIP_VARSTATUS_FIXED );
1858+
if ( var != vars[i][j] )
1859+
{
1860+
SCIP_CALL( SCIPreleaseVar(scip, &vars[i][j]) );
1861+
vars[i][j] = var;
1862+
SCIP_CALL( SCIPcaptureVar(scip, var) );
1863+
}
1864+
}
1865+
}
1866+
1867+
return SCIP_OKAY;
1868+
}
1869+
18181870

18191871
/*
18201872
* Callback methods of constraint handler
@@ -2202,6 +2254,25 @@ SCIP_DECL_CONSRESPROP(consRespropOrbitopePP)
22022254
}
22032255

22042256

2257+
/** presolving deinitialization method of constraint handler (called after presolving has been finished) */
2258+
static
2259+
SCIP_DECL_CONSEXITPRE(consExitpreOrbitopePP)
2260+
{
2261+
int c;
2262+
2263+
assert( scip != NULL );
2264+
assert( conshdlr != NULL );
2265+
assert( strcmp(SCIPconshdlrGetName(conshdlr), CONSHDLR_NAME) == 0 );
2266+
2267+
for (c = 0; c < nconss; ++c)
2268+
{
2269+
/* replace aggregated variables by active variables */
2270+
SCIP_CALL( replaceAggregatedVarsOrbitopePP(scip, conss[c]) );
2271+
}
2272+
return SCIP_OKAY;
2273+
}
2274+
2275+
22052276
/** variable rounding lock method of constraint handler */
22062277
static
22072278
SCIP_DECL_CONSLOCK(consLockOrbitopePP)
@@ -2600,6 +2671,7 @@ SCIP_RETCODE SCIPincludeConshdlrOrbitopePP(
26002671
SCIP_CALL( SCIPsetConshdlrGetNVars(scip, conshdlr, consGetNVarsOrbitopePP) );
26012672
SCIP_CALL( SCIPsetConshdlrParse(scip, conshdlr, consParseOrbitopePP) );
26022673
SCIP_CALL( SCIPsetConshdlrPresol(scip, conshdlr, consPresolOrbitopePP, CONSHDLR_MAXPREROUNDS, CONSHDLR_PRESOLTIMING) );
2674+
SCIP_CALL( SCIPsetConshdlrExitpre(scip, conshdlr, consExitpreOrbitopePP) );
26032675
SCIP_CALL( SCIPsetConshdlrPrint(scip, conshdlr, consPrintOrbitopePP) );
26042676
SCIP_CALL( SCIPsetConshdlrProp(scip, conshdlr, consPropOrbitopePP, CONSHDLR_PROPFREQ, CONSHDLR_DELAYPROP,
26052677
CONSHDLR_PROP_TIMING) );

src/scip/cons_symresack.c

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1783,6 +1783,52 @@ SCIP_RETCODE SCIPcreateSymbreakCons(
17831783
}
17841784

17851785

1786+
/** replace aggregated variables by active variables */
1787+
static
1788+
SCIP_RETCODE replaceAggregatedVarsSymresack(
1789+
SCIP* scip, /**< SCIP data structure */
1790+
SCIP_CONS* cons /**< constraint to be processed */
1791+
)
1792+
{
1793+
SCIP_CONSDATA* consdata;
1794+
SCIP_VAR** vars;
1795+
int nvars;
1796+
int i;
1797+
1798+
assert( scip != NULL );
1799+
assert( cons != NULL );
1800+
1801+
/* get data of constraint */
1802+
consdata = SCIPconsGetData(cons);
1803+
assert( consdata != NULL );
1804+
assert( consdata->vars != NULL );
1805+
1806+
nvars = consdata->nvars;
1807+
vars = consdata->vars;
1808+
1809+
/* loop through all variables */
1810+
for (i = 0; i < nvars; ++i)
1811+
{
1812+
SCIP_VAR* var;
1813+
SCIP_Bool negated;
1814+
1815+
assert( SCIPvarGetStatus(vars[i]) != SCIP_VARSTATUS_MULTAGGR ); /* variables are marked as not to be multi-aggregated */
1816+
1817+
SCIP_CALL( SCIPgetBinvarRepresentative(scip, vars[i], &var, &negated) );
1818+
SCIP_UNUSED( negated );
1819+
assert( SCIPvarIsActive(var) || SCIPvarGetStatus(var) == SCIP_VARSTATUS_NEGATED || SCIPvarGetStatus(var) == SCIP_VARSTATUS_FIXED );
1820+
if ( var != vars[i] )
1821+
{
1822+
SCIP_CALL( SCIPreleaseVar(scip, &vars[i]) );
1823+
vars[i] = var;
1824+
SCIP_CALL( SCIPcaptureVar(scip, var) );
1825+
}
1826+
}
1827+
1828+
return SCIP_OKAY;
1829+
}
1830+
1831+
17861832
/*--------------------------------------------------------------------------------------------
17871833
*--------------------------------- SCIP functions -------------------------------------------
17881834
*--------------------------------------------------------------------------------------------*/
@@ -2670,6 +2716,25 @@ SCIP_DECL_CONSRESPROP(consRespropSymresack)
26702716
}
26712717

26722718

2719+
/** presolving deinitialization method of constraint handler (called after presolving has been finished) */
2720+
static
2721+
SCIP_DECL_CONSEXITPRE(consExitpreSymresack)
2722+
{
2723+
int c;
2724+
2725+
assert( scip != NULL );
2726+
assert( conshdlr != NULL );
2727+
assert( strcmp(SCIPconshdlrGetName(conshdlr), CONSHDLR_NAME) == 0 );
2728+
2729+
for (c = 0; c < nconss; ++c)
2730+
{
2731+
/* replace aggregated variables by active variables */
2732+
SCIP_CALL( replaceAggregatedVarsSymresack(scip, conss[c]) );
2733+
}
2734+
return SCIP_OKAY;
2735+
}
2736+
2737+
26732738
/** lock variables
26742739
*
26752740
* We assume we have only one global (void) constraint and lock all binary variables
@@ -3108,6 +3173,7 @@ SCIP_RETCODE SCIPincludeConshdlrSymresack(
31083173
SCIP_CALL( SCIPsetConshdlrPrint(scip, conshdlr, consPrintSymresack) );
31093174
SCIP_CALL( SCIPsetConshdlrProp(scip, conshdlr, consPropSymresack, CONSHDLR_PROPFREQ, CONSHDLR_DELAYPROP, CONSHDLR_PROP_TIMING) );
31103175
SCIP_CALL( SCIPsetConshdlrResprop(scip, conshdlr, consRespropSymresack) );
3176+
SCIP_CALL( SCIPsetConshdlrExitpre(scip, conshdlr, consExitpreSymresack) );
31113177
SCIP_CALL( SCIPsetConshdlrSepa(scip, conshdlr, consSepalpSymresack, consSepasolSymresack, CONSHDLR_SEPAFREQ, CONSHDLR_SEPAPRIORITY, CONSHDLR_DELAYSEPA) );
31123178
SCIP_CALL( SCIPsetConshdlrTrans(scip, conshdlr, consTransSymresack) );
31133179
SCIP_CALL( SCIPsetConshdlrInitlp(scip, conshdlr, consInitlpSymresack) );

0 commit comments

Comments
 (0)