ForecastSimulateMethod6

Forecast Simulate Method 6

Major Business Rule

Object Name: B3400895

Parent DLL: CMFG

Location: Client/Server

Language: C

1.Functional Description

1.1Purpose
This function will generate the forecast numbers for Method 6, Least Squares Regression, if the 
processing option is set to do so.  It will also decide if this method is the Best Fit forecast.


1.2Setup Notes and Prerequisites


1.3Special Logic



2.Technical Specifications

Method 6 - Simulate Least Squares Regression

This method uses the following equations for forecast calculation:

Y(demand) = $$SIM = a + bX

where X represents time,

a is the Y-intercept,

b is the slope of the regression line.

'e5XY - nX`Y`

b =  -------------------------

'e5X2 - nX`2

a = Y` - bX`

X` is the average X values,
Y` is the average Y values,

and n is the LSRNumberMonths.


If NumberOfBuckets is less than (MonthsBestFit + LSRNumberMonths)

Move '1' to DataError

End Function

Else

Subtract MonthsBestFit from LastBucketPostion to get $J

Move 0 to $TOT


Do MonthsBestFit times

Subtract (LSRNumberMonths - 1) from $J


Calculate 'e5XY, Y`, X`, and 'e5X2

Move 0 to SumXY

Move 0 to AvgY

Move 0 to AvgX

Move 0 to SumXSquared

Move 1 to $X

Do LSRNumberMonths times incrementing $X and $J

If ForecastAmounts is not equal to '1'

Multiply PntrActualSales,$J by $X to get $Z

Add PntrActualSales,$J to AvgY

Else

Multiply PntrActualAmounts,$J by $X to get $Z

Add PntrActualAmounts,$J to AvgY

End

Add $Z to SumXY

Add X to AvgX

Multiply X by X to get XSquared

Add Xsquared to SumXSquared

EndSubtract 1 from $X

Divide AvgX by $X

Divide AvgY by $X


Calculate values for A and B

Multiply AvgX by AvgY to get $1

Multiply $1 by LSRNumberMonths to get $2

Subtract $2 from SumXY to get $NUM

Multiply AvgX by AvgX to get $1

Multiply $1 by LSRNumberMonths to get $2

Subtract $2 from SumXSquared to get $DENOM

Divide $NUM by $DENOM to get B


Multiply B by AvgX to get $1

Subtract $1 from AvgY to get A


Calculate a simulated forecast value for this month of the best fit 

period

Add 1 to LSRNumberMonths to get $X

Multiply B by $X to get $$SIM

Add A to $$SIM


If MeanAbsoluteDeviation is not equal to '1'

Add $$SIM to $TOT

Else

If ForecastAmounts is not equal to '1'

Subtract $$SIM from PntrActualSales,$J to get $DIFF

Else

Subtract $$SIM from PntrActualAmounts,$J to get $DIFF

End

Add the absolute value of $DIFF to $TOT

End

End

If MeanAbsoluteDeviation is not equal to '1'

If ForecastAmounts is not equal to '1'

Divide $TOT by QtyBestFit to get MethodYield

Else

Divide $TOT by AmtBestFit to get MethodYield

End


Decide if this method is the Best Fit Method

If MethodYield is greater than 1

Subtract 1 from MethodYield to get $SPER

Else

Subtract MethodYield from 1 to get $SPER

End

If $SPER is less than BestFit

Move $SPER to BestFit

Move 6 to Method

End

Else

Divide $TOT by MonthsBestFit to get MethodYield

Decide if this method is the Best Fit Method

If MethodYield is less than BestFit

Move MethodYield to BestFit

Move 6 to Method

End

End

End



^

Data Structure

D3400895 - Forecast Simulate Method 6

Parameter NameData ItemData TypeReq/OptI/O/Both
mnNumberOfBucketsMATH01MATH_NUMERICNONENONE

- - - Good Performance Low Value. 

mnQtyBestFitMN29D9MATH_NUMERICNONENONE

This is a generic field used as a work field in Everest.

mnAmtBestFitMN29D9MATH_NUMERICNONENONE

This is a generic field used as a work field in Everest.

cMethodEV01charNONENONE

An option that specifies the type of processing for an event.

cDataErrorERRcharNONENONE

The Data Field Error Code field is simply a generic data field to pass an error condition flag.  This field is one of the fields that make up the 
external parameter data structure of the Data Dictionary Server.

cForecastAmountsEV01charNONENONE

An option that specifies the type of processing for an event.

mnMethodYieldMN29D9MATH_NUMERICNONENONE

This is a generic field used as a work field in Everest.

mnBestFitMN29D9MATH_NUMERICNONENONE

This is a generic field used as a work field in Everest.

mnLastBucketPositionMATH01MATH_NUMERICNONENONE

- - - Good Performance Low Value. 

idPtrToActualValuesGENLNGIDNONENONE

General purpose ID variable.

mnMonthsBestFitMATH01MATH_NUMERICNONENONE

- - - Good Performance Low Value. 

mnLSRNumberMonthsMATH01MATH_NUMERICNONENONE

- - - Good Performance Low Value. 

cMeanAbsoluteDeviationEV01charNONENONE

An option that specifies the type of processing for an event.

Related Functions

B3401050 Forecast Accumulate Actuals

Related Tables

None