Skip to content

Commit

Permalink
Merge branch 'fix_symmetry_on_bugfix' into 'v80-bugfix'
Browse files Browse the repository at this point in the history
Bugfix: fix symmetry fail with sassy on bugfix

See merge request integer/scip!3244
  • Loading branch information
svigerske committed Nov 18, 2023
2 parents 7d11bb0 + 42be648 commit bbc8cb5
Showing 1 changed file with 36 additions and 5 deletions.
41 changes: 36 additions & 5 deletions src/symmetry/compute_symmetry_sassy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,9 @@ SCIP_RETCODE determineGraphSize(
{
SCIP_EXPR* rootexpr;
SCIP_EXPR* expr;
#ifndef NDEBUG
int currentlevel = 0;
#endif

rootexpr = SCIPgetExprNonlinear(conss[i]);

Expand Down Expand Up @@ -589,7 +591,7 @@ SCIP_RETCODE determineGraphSize(

/* add node */
internode = (*nnodes)++;
++(nnonlinearnodes);
++(*nnonlinearnodes);

/* ensure size of degrees */
SCIP_CALL( SCIPensureBlockMemoryArray(scip, degrees, maxdegrees, *nnodes) );
Expand Down Expand Up @@ -630,7 +632,9 @@ SCIP_RETCODE determineGraphSize(

visitednodes[numvisitednodes++] = *nnodes;
ischildofsum[numischildofsum++] = FALSE;
#ifndef NDEBUG
++currentlevel;
#endif

break;
}
Expand Down Expand Up @@ -730,15 +734,19 @@ SCIP_RETCODE determineGraphSize(
}
}

#ifndef NDEBUG
++currentlevel;
#endif
break;
}
/* when leaving an expression, the nodes that are not needed anymore are erased from the respective arrays */
case SCIP_EXPRITER_LEAVEEXPR:
{
--numvisitednodes;
--numischildofsum;
#ifndef NDEBUG
currentlevel--;
#endif

/* When leaving the child of a sum expression, we have to pop again to get rid of the intermediate nodes
* used for the coefficients of summands
Expand Down Expand Up @@ -860,10 +868,10 @@ SCIP_RETCODE fillGraphByConss(
int varssize;
#ifndef NDEBUG
SCIP_Real oldcoef = SCIP_INVALID;
int m = 0;
#endif
int firstcolornodenumber = -1;
int n = 0;
int m = 0;
int i;
int j;

Expand Down Expand Up @@ -948,7 +956,9 @@ SCIP_RETCODE fillGraphByConss(
G->add_edge((unsigned) rhsnode, (unsigned) varnode);
else
G->add_edge((unsigned) varnode, (unsigned) rhsnode);
#ifndef NDEBUG
++m;
#endif
}
else
{
Expand Down Expand Up @@ -990,20 +1000,28 @@ SCIP_RETCODE fillGraphByConss(
if ( newinternode )
{
G->add_edge((unsigned) rhsnode, (unsigned) internode);
#ifndef NDEBUG
++m;
#endif
}
G->add_edge((unsigned) varnode, (unsigned) internode);
#ifndef NDEBUG
++m;
#endif
}
else
{
if ( newinternode )
{
G->add_edge((unsigned) varnode, (unsigned) internode);
#ifndef NDEBUG
++m;
#endif
}
G->add_edge((unsigned) rhsnode, (unsigned) internode);
#ifndef NDEBUG
++m;
#endif
}
}
}
Expand Down Expand Up @@ -1124,6 +1142,7 @@ SCIP_RETCODE fillGraphByConss(
assert( requiredsize <= varssize );

assert( numvisitednodes > 0 );

parentnode = visitednodes[numvisitednodes-1];
assert( parentnode < nnodes );

Expand Down Expand Up @@ -1156,16 +1175,20 @@ SCIP_RETCODE fillGraphByConss(

assert( internode < nnodes );

G->add_edge((unsigned) internode, (unsigned) parentnode);
G->add_edge((unsigned) parentnode, (unsigned) internode);
#ifndef NDEBUG
++m;
#endif
assert( m <= nedges );

/* connect the intermediate node to its corresponding variable node */
node = SCIPvarGetProbindex(vars[k]);
assert( node < nnodes );

G->add_edge((unsigned) internode, (unsigned) node);
G->add_edge((unsigned) node, (unsigned) internode);
#ifndef NDEBUG
++m;
#endif
assert( m <= nedges );
}

Expand All @@ -1175,7 +1198,7 @@ SCIP_RETCODE fillGraphByConss(
SYM_CONSTTYPE* ct;

/* check whether we have to resize */
SCIP_CALL( SCIPensureBlockMemoryArray(scip, &uniquerhsarray, &constarraysize, nuniqueconsts+1) );
SCIP_CALL( SCIPensureBlockMemoryArray(scip, &uniqueconstarray, &constarraysize, nuniqueconsts+1) );
assert( nuniqueconsts < constarraysize );

ct = &uniqueconstarray[nuniqueconsts];
Expand All @@ -1198,7 +1221,9 @@ SCIP_RETCODE fillGraphByConss(
assert( node < nnodes );

G->add_edge((unsigned) parentnode, (unsigned) node);
#ifndef NDEBUG
++m;
#endif
assert( m <= nedges );
}

Expand Down Expand Up @@ -1317,7 +1342,9 @@ SCIP_RETCODE fillGraphByConss(
G->add_edge((unsigned) parentnode, (unsigned) node);
else
G->add_edge((unsigned) node, (unsigned) parentnode);
#ifndef NDEBUG
++m;
#endif
assert( m <= nedges );

/* for sum expression, also add intermediate nodes for the coefficients */
Expand Down Expand Up @@ -1362,7 +1389,9 @@ SCIP_RETCODE fillGraphByConss(
assert( internode < nnodes );

G->add_edge((unsigned) node, (unsigned) internode);
#ifndef NDEBUG
++m;
#endif
assert( m <= nedges );
}

Expand Down Expand Up @@ -1396,7 +1425,9 @@ SCIP_RETCODE fillGraphByConss(
assert( node < nnodes );

G->add_edge((unsigned) node, (unsigned) internode);
#ifndef NDEBUG
++m;
#endif
assert( m <= nedges );
}
}
Expand Down

0 comments on commit bbc8cb5

Please sign in to comment.