Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/v90-bugfix'
Browse files Browse the repository at this point in the history
  • Loading branch information
scip-ci committed Feb 8, 2024
2 parents ff30eb4 + ee9947f commit 2b9a68d
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ Fixed bugs
- fixed make install when SHARED=no and make uninstall
- check absolute coefficients relative to extremal average to avoid invalid unifications in normalizeCons()
- enforce and check symmetry-based constraints to take their locks (in dual reductions) into account
- fixed bug in detection of double lex matrices due to wrong memory allocation

Miscellaneous
-------------
Expand Down
43 changes: 35 additions & 8 deletions src/scip/symmetry.c
Original file line number Diff line number Diff line change
Expand Up @@ -1795,6 +1795,7 @@ SCIP_RETCODE detectOrbitopalSymmetries(
static
SCIP_RETCODE isDoublelLexSym(
SCIP* scip, /**< SCIP pointer */
int nsymvars, /**< number of variables on which symmetries act */
int*** matrices1, /**< first list of matrices associated with orbitopal symmetries */
int nrows1, /**< number of rows of first family of matrices */
int* ncols1, /**< for each matrix in the first family, its number of columns */
Expand Down Expand Up @@ -1831,6 +1832,7 @@ SCIP_RETCODE isDoublelLexSym(
int j;

assert( scip != NULL );
assert( nsymvars >= 0 );
assert( matrices1 != NULL );
assert( nrows1 > 0 );
assert( ncols1 != NULL );
Expand Down Expand Up @@ -1877,6 +1879,20 @@ SCIP_RETCODE isDoublelLexSym(
SCIP_CALL( SCIPallocBufferArray(scip, &idxtocol1, nidx) );
SCIP_CALL( SCIPallocBufferArray(scip, &idxtocol2, nidx) );

/* use separate loops for efficiency reasons */
for (i = 0; i < nsymvars; ++i)
idxtomatrix1[i] = -1;
for (i = 0; i < nsymvars; ++i)
idxtomatrix2[i] = -1;
for (i = 0; i < nsymvars; ++i)
idxtorow1[i] = -1;
for (i = 0; i < nsymvars; ++i)
idxtorow2[i] = -1;
for (i = 0; i < nsymvars; ++i)
idxtocol1[i] = -1;
for (i = 0; i < nsymvars; ++i)
idxtocol2[i] = -1;

for (c = 0; c < nmatrices1; ++c)
{
for (i = 0; i < nrows1; ++i)
Expand All @@ -1902,6 +1918,16 @@ SCIP_RETCODE isDoublelLexSym(
}
}

/* check whether the variables of the two orbitopes coincide */
for (i = 0; i < nsymvars; ++i)
{
if ( (idxtomatrix1[i] == -1) != (idxtomatrix2[i] == -1) )
{
*success = FALSE;
goto FREEINITMEMORY;
}
}

/* Find a big matrix such that the columns of this matrix correspond to the columns of matrices in matrices1
* and the rows of this matrix correspond to the columns of matrices in matrices2. In total, this leads to
* a matrix of block shape
Expand Down Expand Up @@ -1991,13 +2017,6 @@ SCIP_RETCODE isDoublelLexSym(
FREEMEMORY:
SCIPfreeBufferArray(scip, &sortvals);

SCIPfreeBufferArray(scip, &idxtocol2);
SCIPfreeBufferArray(scip, &idxtocol1);
SCIPfreeBufferArray(scip, &idxtorow2);
SCIPfreeBufferArray(scip, &idxtorow1);
SCIPfreeBufferArray(scip, &idxtomatrix2);
SCIPfreeBufferArray(scip, &idxtomatrix1);

if ( !(*success) )
{
for (i = *nrows - 1; i >= 0; --i)
Expand All @@ -2012,6 +2031,14 @@ SCIP_RETCODE isDoublelLexSym(
*colsbegin = NULL;
}

FREEINITMEMORY:
SCIPfreeBufferArray(scip, &idxtocol2);
SCIPfreeBufferArray(scip, &idxtocol1);
SCIPfreeBufferArray(scip, &idxtorow2);
SCIPfreeBufferArray(scip, &idxtorow1);
SCIPfreeBufferArray(scip, &idxtomatrix2);
SCIPfreeBufferArray(scip, &idxtomatrix1);

return SCIP_OKAY;
}

Expand Down Expand Up @@ -2124,7 +2151,7 @@ SCIP_RETCODE SCIPdetectSingleOrDoubleLexMatrices(
{
assert( ncycs1 > 0 );

SCIP_CALL( isDoublelLexSym(scip, matricestype1, ncycs1, ncolstype1, nmatricestype1,
SCIP_CALL( isDoublelLexSym(scip, permlen, matricestype1, ncycs1, ncolstype1, nmatricestype1,
matricestype2, ncycs2, ncolstype2, nmatricestype2,
lexmatrix, nrows, ncols, lexrowsbegin, lexcolsbegin, success) );

Expand Down

0 comments on commit 2b9a68d

Please sign in to comment.