@@ -5566,41 +5566,35 @@ SCIP_RETCODE multiAggregateBinvar(
5566
5566
5567
5567
assert (scip != NULL );
5568
5568
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 );
5571
5572
assert (infeasible != NULL );
5572
5573
assert (aggregated != NULL );
5573
5574
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 )
5588
5576
{
5589
5577
* infeasible = FALSE;
5578
+ * aggregated = FALSE;
5579
+
5590
5580
return SCIP_OKAY ;
5591
5581
}
5592
5582
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 ;
5593
5586
/* 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 )
5595
5588
tmpvars = vars ;
5589
+ /* copy variables for aggregation */
5596
5590
else
5597
5591
{
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 ];
5601
5594
}
5602
5595
5603
5596
SCIP_CALL ( SCIPallocBufferArray (scip , & scalars , nvars - 1 ) );
5597
+
5604
5598
/* initialize scalars */
5605
5599
for ( v = nvars - 2 ; v >= 0 ; -- v )
5606
5600
scalars [v ] = -1.0 ;
@@ -5615,9 +5609,10 @@ SCIP_RETCODE multiAggregateBinvar(
5615
5609
5616
5610
SCIPfreeBufferArray (scip , & scalars );
5617
5611
5618
- if ( pos < nvars - 1 )
5612
+ if ( pos != 0 && pos != nvars - 1 )
5619
5613
{
5620
5614
assert (tmpvars != vars );
5615
+ assert (tmpvars != vars + 1 );
5621
5616
SCIPfreeBufferArray (scip , & tmpvars );
5622
5617
}
5623
5618
0 commit comments