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' } 
 | 
} 
 |