chenqinghong
2024-05-07 3ec06a830367465068963156dcc1d8e522571c13
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
Quintiq file version 2.0
#parent: #root
Method VerifyCapacitySmoothing (
  MacroPlan macroplan
)
{
  TextBody:
  [*
    epsilon := 1e-4; 
    units := selectset( macroplan, Unit, u, u.ID() = 'Supplier UBC scrap (Asia)' or u.ID() = 'Melting furnace (Qi-Ying)' ); 
    
    traverse( units, Elements, unit ) 
    {
      unitperiod := selectsortedset( unit, PlanningUnitPeriod, p, not p.Period_MP().IsHistorical(), p.Start() ); 
      i := 0; 
      while ( i < unitperiod.Size() ) 
      {
        max_value := Real::MinReal(); 
        min_value := Real::MaxReal(); 
        for ( j := 0; j < unit.CapacitySmoothingLength() and i + j < unitperiod.Size(); j++ ) 
        {
          up1 := unitperiod.Element( i + j ).UtilizationPercentage();
          max_value := maxvalue( max_value, up1 ); 
          min_value := minvalue( min_value , up1 ); 
        } 
    
        diff := max_value - min_value; 
        // Verify there are 9 sanity check number of message count.
        this.Run().AssertLess( unit.CapacitySmoothingPercentageDelta() + epsilon, diff, 'Verify capacity smoothing [Planning issue] is correct' +  unit.Name() +  'first period=' + [String] unitperiod.Element( i ).Start() );
    
        i := i + ifexpr( unit.IsOverlapCapacitySmoothing(), 1,  unit.CapacitySmoothingLength() - 1 ); 
      }
    }
  *]
  InterfaceProperties { Accessibility: 'Module' }
}