Quintiq file version 2.0
|
#parent: #root
|
Method RemoveUnusedTripsAfterSmartPlan (
|
LibOpt_Task task
|
)
|
{
|
Description: 'Remove the unused trips and product in trips after running optimizer, to reduce memory consumption'
|
TextBody:
|
[*
|
if ( not isnull( task.TaskContext() ) )
|
{
|
tripsInOptimizerScope := construct( Trips );
|
unusedpits := construct( ProductInTrips );
|
nrofunusedtrip :=0;
|
|
macroplan := this.Optimization().astype( Optimization ).MacroPlan();
|
taskcontext := task.TaskContext().astype( TaskContextSmartPlan );
|
taskcontext.GetUnusedPIT( &unusedpits, nrofunusedtrip );
|
|
alltripsinrun := selectset( taskcontext, ProductInTrip.Trip, trip, true, true );
|
totaltripinrun := alltripsinrun.Size();
|
|
usedpercentage := guard( ( ( totaltripinrun - nrofunusedtrip )/ totaltripinrun * 100 ), 0 );
|
|
minpercentage := macroplan.GlobalParameters_MP().MinToKeepTripInUsedPercentage();
|
|
debuginfo( 'total trips in run = ', totaltripinrun, 'used % = ', usedpercentage, 'unused pit=', unusedpits.Size() );
|
// delete if use percentage < minimum percentage
|
if ( usedpercentage < minpercentage )
|
{
|
// Delete the productintrips that were part of the optimizer run, that have an optimizer quantity of 0,
|
// that are not manual planning and that do not have feedback
|
ProductInTrip::Delete( unusedpits );
|
|
tripsInOptimizerScope := selectset( alltripsinrun, Elements, trip,
|
trip.ProductInTrip( relsize ) = 0 );
|
}
|
|
tripsOutOfScope := selectset( macroplan, Unit.Lane.LaneLeg.Trip, trip,
|
not ( trip.HasValidArrival() and trip.HasValidDeparture() ) );
|
|
tripsToDelete := tripsInOptimizerScope.Union( tripsOutOfScope ).Unique();
|
Trip::Delete( tripsToDelete );
|
}
|
*]
|
InterfaceProperties { Accessibility: 'Module' }
|
}
|