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