Skip to content

Commit e2237d4

Browse files
committed
Merge remote-tracking branch 'origin/v9-minor'
2 parents 5160b25 + 8c17cf4 commit e2237d4

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
@@ -5566,41 +5566,35 @@ SCIP_RETCODE multiAggregateBinvar(
55665566

55675567
assert(scip != NULL);
55685568
assert(vars != NULL);
5569-
assert(nvars > 1);
5570-
assert(0 <= pos && pos < nvars);
5569+
assert(nvars >= 1);
5570+
assert(pos >= 0);
5571+
assert(pos < nvars);
55715572
assert(infeasible != NULL);
55725573
assert(aggregated != NULL);
55735574

5574-
if( nvars == 2 )
5575-
{
5576-
SCIP_Bool redundant;
5577-
5578-
/* perform aggregation on variables resulting from a set-packing constraint */
5579-
SCIP_CALL( SCIPaggregateVars(scip, vars[pos], vars[nvars - pos - 1], 1.0, 1.0, 1.0, infeasible, &redundant, aggregated) );
5580-
5581-
if( *aggregated )
5582-
SCIPdebugMsg(scip, "aggregated %s = 1 - %s\n", SCIPvarGetName(vars[pos]), SCIPvarGetName(vars[nvars - pos - 1]));
5583-
5584-
return SCIP_OKAY;
5585-
}
5586-
5587-
if( !linearconshdlrexist )
5575+
if( !linearconshdlrexist && nvars > 2 )
55885576
{
55895577
*infeasible = FALSE;
5578+
*aggregated = FALSE;
5579+
55905580
return SCIP_OKAY;
55915581
}
55925582

5583+
/* if the first variable will be multi-aggregated, we do not need to copy the variables */
5584+
if( pos == 0 )
5585+
tmpvars = vars + 1;
55935586
/* if the last variable will be multi-aggregated, we do not need to copy the variables */
5594-
if( pos == nvars - 1 )
5587+
else if( pos == nvars - 1 )
55955588
tmpvars = vars;
5589+
/* copy variables for aggregation */
55965590
else
55975591
{
5598-
/* copy variables for aggregation */
5599-
SCIP_CALL( SCIPduplicateBufferArray(scip, &tmpvars, vars, nvars) );
5600-
tmpvars[pos] = tmpvars[nvars - 1];
5592+
SCIP_CALL( SCIPduplicateBufferArray(scip, &tmpvars, vars, nvars - 1) );
5593+
tmpvars[pos] = vars[nvars - 1];
56015594
}
56025595

56035596
SCIP_CALL( SCIPallocBufferArray(scip, &scalars, nvars - 1) );
5597+
56045598
/* initialize scalars */
56055599
for( v = nvars - 2; v >= 0; --v )
56065600
scalars[v] = -1.0;
@@ -5615,9 +5609,10 @@ SCIP_RETCODE multiAggregateBinvar(
56155609

56165610
SCIPfreeBufferArray(scip, &scalars);
56175611

5618-
if( pos < nvars - 1 )
5612+
if( pos != 0 && pos != nvars - 1 )
56195613
{
56205614
assert(tmpvars != vars);
5615+
assert(tmpvars != vars + 1);
56215616
SCIPfreeBufferArray(scip, &tmpvars);
56225617
}
56235618

0 commit comments

Comments
 (0)