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
Quintiq file version 2.0
#parent: #root
Method ReDistOfWealth (
  ProductInStockingPoint_MP pisp,
  Number periodNumber
) as Real
{
  TextBody:
  [*
    //timestepping
    // top, calculate re and s for all periods on top
    // children, 
    // this is not taking into account the targets in the child, so in the resupplies distribtuion the actual demands will be prefered over the targets in the child!!!!
    
    
    // this calculates the expected demands of children of stockingpoint, from the periods that are exacty reachable from period
    //# example: two child nodes A and B, leadtimes 1 and 2 periods, demands are calculated from period + 1 of A, and period + 2 of B
    
    total := 0.0; 
    if (not pisp.MEIO_IsLeaf() ) 
    {
      listofnodes := MEIO_Engine::GetTreePISP( pisp ); 
      lastperiod := max( this, MacroPlan.PlanningPeriod, p, true, p.MEIO_PeriodNumber() ); 
      traverse( listofnodes, Elements, child, not child = pisp ) 
      {
        d := 0.0
        future_period := periodNumber + this.GetLeadTime( child, pisp );  
        lastperiod := this.LastPeriodNumber();  
        if( lastperiod >= future_period ) 
        {
          d := MEIO_Engine::GetDemandExpectedValue( child, future_period ); 
        }
        else 
        {
          d := MEIO_Engine::GetDemandExpectedValue( child, lastperiod ); 
        }
        total := total + d;
      }
    }
    return total;
  *]
}