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
Quintiq file version 2.0
#parent: #root
Method SetTargets
{
  TextBody:
  [*
    
    
    // we use 10000 as a big number to give sufficient supply in upstream locations
    // leaf locations have target 0 to start with
    // this is used to initiate the calculations so that after this we find suitable target to leaf locations and can be sure that we have sufficient supply in upstream
    
    // we need to set pispip.MEIO_Target according to beloew R code 
    
    target_max := this.MEIO_Parameters().InitialLargeValueParentResupply(); 
    
    // Set all targets to max value on non-leafs
    // Set targets to 0 at leafs
    nodes := this.GetAllTreePISP();
    traverse( nodes, Elements, pisp )
    {
      for ( p := pisp.MEIO_Leadtime() + 1; p <= this.LastPeriodNumber(); p++ ) 
      {
        if ( pisp.MEIO_IsLeaf() ) 
        {
          pisp.GetPISPIPFromPeriodNumber( p ).MEIO_Target( 0 ); 
        }
        else
        {
          pisp.GetPISPIPFromPeriodNumber( p ).MEIO_Target( target_max );
        }
      }
      
      for ( p := 1; p <= pisp.MEIO_Leadtime(); p++ )  // copy from MP current value
      {
        pispip := pisp.GetPISPIPFromPeriodNumber( p  ); 
        pispip.MEIO_Target( pispip.TargetInQuantity() );
      }
    }
  *]
}