haorenhui
2023-10-30 6d6cc10d9e8e242661da7fd655dec155a09d676c
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
Quintiq file version 2.0
#parent: #root
Method SetOptimizerPuzzle (
  OptimizerPuzzle optpuzzle,
  Period_MPs periods
)
{
  TextBody:
  [*
    verify( not isnull( optpuzzle ),  Translations::Algorithm_MP_NoOptimizerPuzzleAvailableError() ); 
    
    macroplan := this.MacroPlan(); 
    traverse( macroplan, Period_MP, period ) 
    {
      period.IsInOptimizerPuzzle( false ); 
    }
    
    traverse( periods, Elements, period ) 
    {
      period.IsInOptimizerPuzzle( true ); 
    }
    
    // set is included flags on product. Only used within this method to make selection of PISPs more efficient. 
    traverse(  macroplan, Product_MP, product ) 
    {
      product.IsInOptimizerPuzzle( false ); // clear flags on all
    }
    traverse(  optpuzzle.GetIncludedProducts(), Elements, product ) 
    {
      product.IsInOptimizerPuzzle( true ); // set according to puzzle
    }
    
    units := optpuzzle.GetIncludedUnits();  
    sps := optpuzzle.GetIncludedStockingPoints( units );
    
    traverse( macroplan, StockingPoint_MP, sp ) 
    {
      sp.isInOptimizerPuzzle( false ); 
    }
    traverse(  sps, Elements, sp ) 
    {
      sp.isInOptimizerPuzzle( true ); 
    }
    
    traverse( macroplan, Unit, unit ) 
    {
      unit.IsInOptimizerPuzzle( false ); 
    }
    
    traverse( units, Elements, unit )
    {
      unit.IsInOptimizerPuzzle( true ); 
      unit.OptimizerFullRunAddedOperationOrTrip( false ); 
    }
    
    if ( this.DebugMode() ) // write back values to check we adhere to the sub puzzle
    {
      traverse( macroplan, Unit.UnitPeriod, up ) 
      {
        up.DebugSubPuzzleQuantityToProcessPrior( up.QuantityToProcess() ); 
      }
      
      traverse( macroplan, StockingPoint_MP.ProductInStockingPoint_MP.ProductInStockingPointInPeriodPlanning, p ) 
      {
        p.DebugSubPuzzleInventoryEndPrior( p.InventoryLevelEnd() );   
      }
    }
  *]
  InterfaceProperties { Accessibility: 'Module' }
}