Quintiq file version 2.0
#parent: #root
Method RunOptimizer (
  structured[ProductInStockingPointInPeriodPlanning] smartplanpispips,
  Boolean hastotalsupplyuser,
  Boolean isonlyplanonestepupstream,
  Boolean isoverwritemanual
) id:Method_DialogSmartPlan_RunOptimizer
{
  #keys: '[122872.1.872833979]'
  Body:
  [*
    // runs the optimizer based on last selected options
    
    isUsingSelectedUnits := CheckBoxIsSelectedUnits.Checked();
    units := DataHolderSelectedUnitsForSmartPlan.Data()
    run := MacroPlan.GetLastAlgorithmRun();
    issmartplan := true;
    issmartplanforperiodtask := false;
    isupstreamsmartplan := RadioButtonGroupUpstreamDownstream.BoundValue() = SmartPlanSetting::Upstream();
    ismiddleoutsmartplan := RadioButtonGroupUpstreamDownstream.BoundValue() = SmartPlanSetting::MiddleOut();
    totalsupplyuser := 0.0;
    if( hastotalsupplyuser )
    {
      totalsupplyuser := ApplicationLibMacroPlanner.FormatStringToReal( EditorTotalSupply.Text() );
    }
    strategy := SelectionStrategy.Data();
    
    periodstart := MacroPlan.FirstPlanningPeriod();
    periodend := MacroPlan.LastPlanningPeriod();
    AlgorithmRun::GetLastOptimizationHorizon( run, MacroPlan, periodstart, periodend );
    
    MacroPlan.RunSmartPlan( issmartplan,
                            issmartplanforperiodtask,
                            smartplanpispips,
                            hastotalsupplyuser,
                            totalsupplyuser,
                            isupstreamsmartplan,
                            ismiddleoutsmartplan,
                            isonlyplanonestepupstream,
                            strategy,
                            isoverwritemanual,
                            periodstart,
                            periodend,
                            isUsingSelectedUnits,
                            units,
                            null( Process_MP ), 
                            false );
    
    if ( not MacroPlan.GlobalParameters_MP().RunSmartPlanSynchronously() ) 
    {
      Application.RemoveHistory();
    }
  *]
}
