admin
2025-01-22 7e31442f0e9b07764e9c6a9680d3d4aeba5fe1de
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
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
  *]
}