Quintiq file version 2.0 
 | 
#parent: #root 
 | 
Method RunSmartPlanForPeriodTask ( 
 | 
  ProductInStockingPointInPeriodPlanning smartplanpispip, 
 | 
  Real userqty, 
 | 
  Units units, 
 | 
  ScenarioManager scenariomanager, 
 | 
  Process_MP process 
 | 
) 
 | 
{ 
 | 
  Description: 'For smart plan on specific routing / leg. Will call the RunSmalPlan with some default parameters' 
 | 
  TextBody: 
 | 
  [* 
 | 
    //Pre-set smart plan parameters 
 | 
    issmartplanforperiodtask := true;  
 | 
    run := this.Optimization().GetLastSmartPlanAlgorithmRun( issmartplanforperiodtask ); 
 | 
    hastotalsupplyuser := true;  
 | 
    newsupplyfromprocess := 0.0;  
 | 
    if ( process.istype( Operation ) )  
 | 
    { 
 | 
      routing := process.astype( Operation ).RoutingStep().Routing();  
 | 
      newsupplyfromprocess := sum( smartplanpispip,  
 | 
                                   Supply_MP.astype( NewSupply ),  
 | 
                                   ns,  
 | 
                                   guard( ns.Process_MP().astype( Operation ).RoutingStep().Routing() = routing, false),  
 | 
                                   ns.Quantity() );  
 | 
    } 
 | 
    else if ( process.istype( LaneLeg ) )  
 | 
    { 
 | 
      newsupplyfromprocess := sum( smartplanpispip,  
 | 
                                   Supply_MP.astype( NewSupply ),  
 | 
                                   ns,  
 | 
                                   ns.Process_MP() = process,  
 | 
                                   ns.Quantity() ) 
 | 
    } 
 | 
    else  
 | 
    { 
 | 
      error( 'unsupported type in RunSmartPlanForPeriodTask' );  
 | 
    } 
 | 
     
 | 
     
 | 
     
 | 
    diff := newsupplyfromprocess - userqty;  
 | 
    totalsupplyuser := smartplanpispip.SupplyQuantity() - diff;  
 | 
     
 | 
    //this flag is to overwrite user value on smart plan pispip level. Smart plan on period task is a level lower. 
 | 
    //so we will set this to false here and only choose to reset the "other period task" supplying to the pispip. 
 | 
    //say R1,R2 are supply to PISPIP X.  
 | 
    //We're setting the period task qty for R1. In this case, R2 is the "other period task" 
 | 
    isoverwritemanual := false; 
 | 
    isupstreamsmartplan := true; 
 | 
    ismiddleoutsmartplan := false;  
 | 
    isonlyplanonestepupstream := true;  
 | 
    isusingselectedunits := true; 
 | 
     
 | 
    strategy := AlgorithmRun::GetLastStrategyUsed( this.GlobalParameters_MP(), run, scenariomanager, true, true ); 
 | 
    periodstart := this.FirstPlanningPeriod(); 
 | 
    periodend := this.LastPlanningPeriod(); 
 | 
    AlgorithmRun::GetLastOptimizationHorizon( run, this, periodstart, periodend ); 
 | 
     
 | 
    smartplanpispips := construct( ProductInStockingPointInPeriodPlannings ); 
 | 
    smartplanpispips.Add( smartplanpispip );  
 | 
     
 | 
    ProductInStockingPointInPeriod::ResetSuppliesBeforeSmartPlan( smartplanpispips, process );  
 | 
     
 | 
    this.RunSmartPlan( true /*issmartplan*/, 
 | 
                       issmartplanforperiodtask,  
 | 
                       smartplanpispips, 
 | 
                       hastotalsupplyuser, 
 | 
                       totalsupplyuser,  
 | 
                       isupstreamsmartplan, 
 | 
                       ismiddleoutsmartplan, 
 | 
                       isonlyplanonestepupstream, 
 | 
                       strategy, 
 | 
                       isoverwritemanual, 
 | 
                       periodstart, 
 | 
                       periodend, 
 | 
                       isusingselectedunits, 
 | 
                       units, 
 | 
                       process,  
 | 
                       false ); // not re-using StrategyMacroPlan 
 | 
  *] 
 | 
} 
 |