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