| 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; | 
|   *] | 
| } |