Skip to content

Commit 8c17cf4

Browse files
committed
Merge remote-tracking branch 'origin/v92-bugfix' into v9-minor
2 parents 55a5356 + c071230 commit 8c17cf4

File tree

1 file changed

+16
-21
lines changed

1 file changed

+16
-21
lines changed

src/scip/cons_setppc.c

+16-21
Original file line numberDiff line numberDiff line change
@@ -5561,41 +5561,35 @@ SCIP_RETCODE multiAggregateBinvar(
55615561

55625562
assert(scip != NULL);
55635563
assert(vars != NULL);
5564-
assert(nvars > 1);
5565-
assert(0 <= pos && pos < nvars);
5564+
assert(nvars >= 1);
5565+
assert(pos >= 0);
5566+
assert(pos < nvars);
55665567
assert(infeasible != NULL);
55675568
assert(aggregated != NULL);
55685569

5569-
if( nvars == 2 )
5570-
{
5571-
SCIP_Bool redundant;
5572-
5573-
/* perform aggregation on variables resulting from a set-packing constraint */
5574-
SCIP_CALL( SCIPaggregateVars(scip, vars[pos], vars[nvars - pos - 1], 1.0, 1.0, 1.0, infeasible, &redundant, aggregated) );
5575-
5576-
if( *aggregated )
5577-
SCIPdebugMsg(scip, "aggregated %s = 1 - %s\n", SCIPvarGetName(vars[pos]), SCIPvarGetName(vars[nvars - pos - 1]));
5578-
5579-
return SCIP_OKAY;
5580-
}
5581-
5582-
if( !linearconshdlrexist )
5570+
if( !linearconshdlrexist && nvars > 2 )
55835571
{
55845572
*infeasible = FALSE;
5573+
*aggregated = FALSE;
5574+
55855575
return SCIP_OKAY;
55865576
}
55875577

5578+
/* if the first variable will be multi-aggregated, we do not need to copy the variables */
5579+
if( pos == 0 )
5580+
tmpvars = vars + 1;
55885581
/* if the last variable will be multi-aggregated, we do not need to copy the variables */
5589-
if( pos == nvars - 1 )
5582+
else if( pos == nvars - 1 )
55905583
tmpvars = vars;
5584+
/* copy variables for aggregation */
55915585
else
55925586
{
5593-
/* copy variables for aggregation */
5594-
SCIP_CALL( SCIPduplicateBufferArray(scip, &tmpvars, vars, nvars) );
5595-
tmpvars[pos] = tmpvars[nvars - 1];
5587+
SCIP_CALL( SCIPduplicateBufferArray(scip, &tmpvars, vars, nvars - 1) );
5588+
tmpvars[pos] = vars[nvars - 1];
55965589
}
55975590

55985591
SCIP_CALL( SCIPallocBufferArray(scip, &scalars, nvars - 1) );
5592+
55995593
/* initialize scalars */
56005594
for( v = nvars - 2; v >= 0; --v )
56015595
scalars[v] = -1.0;
@@ -5610,9 +5604,10 @@ SCIP_RETCODE multiAggregateBinvar(
56105604

56115605
SCIPfreeBufferArray(scip, &scalars);
56125606

5613-
if( pos < nvars - 1 )
5607+
if( pos != 0 && pos != nvars - 1 )
56145608
{
56155609
assert(tmpvars != vars);
5610+
assert(tmpvars != vars + 1);
56165611
SCIPfreeBufferArray(scip, &tmpvars);
56175612
}
56185613

0 commit comments

Comments
 (0)