| Quintiq file version 2.0 | 
| #parent: #root | 
| Method GenerateDemandRealization | 
| { | 
|   Description: 'Generates a random demand realization based on the expected demand and the demand uncertainty' | 
|   TextBody: | 
|   [* | 
|     // Martijn Nov-8-2016 (created) | 
|      | 
|      | 
|     expectedqty := this.ExpectedQuantity(); | 
|     demanduncertaintypercentage := this.DemandUncertaintyPercentage() / 100; | 
|     // The NormSInv method is much faster. However, it is very inaccurate <3% or >97% | 
|     // this.Quantity( MacroPlan::RandNormal( expectedqty, demanduncertaintypercentage * expectedqty ) ); | 
|     // Please see Rescue 32832  or SCP 8783. Normal random variate generation will be enabled in the upcoming releases. Please update the code when it is implemented - updated. | 
|     // The demand realization is equal to the expected sales demand quantity  | 
|     // plus the randomly generated factor times the demand uncertainty percentage times the expected sales demand quantity | 
|      | 
|     normal := NormalDistribution::Construct( expectedqty, demanduncertaintypercentage * expectedqty );  | 
|     value := normal.Random();  | 
|     // The sales demand quantity cannot be negative | 
|     value := maxvalue( 0.0, value ); | 
|     this.Quantity( value ); | 
|   *] | 
|   InterfaceProperties { Accessibility: 'Module' } | 
| } |