ForecastSimulateMethod7

Forecast Simulate Method 7

Major Business Rule

Object Name: B3400855

Parent DLL: CMFG

Location: Client/Server

Language: C

1.Functional Description

1.1Purpose
This function will generate the forecast numbers for Method 7, Second Order Approximation, 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 7 - Simulate 2nd Order Approximation
If NumberOfBuckets is less than (MonthsBestFit + 3 times 

2ndDegreeApproxNoMonths)

Move '1 to DataError

End Function

End


Divide MonthsBestFit by 2ndDegreeApproxNoMonths to get $Y

If the remainder is greater than 0

Add 1 to $Y

Move the remainder to $R

End


Move zero to $$SIM

Move zero to $ABS

Do $Y times incrementing $Z

Multiply 2ndDegreeApproxNoMonths * ($Y - 1) to get $M

Subtract (MonthsBestFit - $M) from LastBucketPosition to get $X
Move zeroes to Period1, Period2, and Period3
Do 2ndDegreeApproxNoMonths times

If ForecastAmounts is not set to '1'

Add PtrToActualSales,$X to Period3

Add PtrToActualSales,($X - 2ndDegreeApproxNoMonths) to Period2
Add PtrToActualSales,($X - 2 * 2ndDegreeApproxNoMonths) to 

Period1

Else

Add PtrToActualAmounts,$X to Period3

Add PtrToActualAmounts,($X - 2ndDegreeApproxNoMonths) to Period2

Add PtrToActualAmounts,($X - 2 * 2ndDegreeApproxNoMonths) to 
Period1

End

Subtract 1 from $X

End

Multiply Period2 by -2 to get $$C
Add Period3 to $$C 

Add Perio1 to $$C

Divide $$C by 2

Multiple $$C by -3 to get $$B
Add Period2 to $$B 

Subtract Period1 from $$B


Subtract $$B from Period1 to get $$A

Subtract $$C from $$A

Multiply $$C by 16 to get $3

Multiply $$B by 4 to get $2

Add $2 to $$A to get Result

Add $3 to Result


If $Z is equal to $Y

If $R is not equal to 0

Divide Result by 2ndDegreeApproxNoMonths

Multiply Result by $R
End

End

Add Result to $$SIM


If MeanAbsoluteDeviation is equal to '1'

Divide $$SIM by 2ndDegreeApproxNoMonths

Subtract (MonthsBestFit - $M - 1) from LastBucketPosition to get 
$X

Do 2ndDegreeApproxNoMonths times incrementing $X

If ForecastAmounts is not equal to '1'

Subtract $$SIM from PtrToActualSales,$X to get 

$DIFF

Else

Subtract $$SIM from PtrToActualAmounts,$X to get 

$DIFF

End
Add the absolute value of $DIFF to $ABS

End Do

Move zero to $$SIM

End

End Do


If MeanAbsoluteDeviation is not equal to '1'

If ForecastAmounts is not equal to '1'

Divide $$SIM by QtyBestFit to get MethodYield

Else

Divide $$SIM 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 7 to Method

End

Else

Divide $ABS by MonthsBestFit to get Method Yield


Decide if this method is the Best Fit Method

If MethodYield is less than BestFit

Move MethodYield to BestFit

Move 7 to Method

End

End


^

Data Structure

D3400855 - Forecast Simulate Method 7

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.

cForecastAmountsEV02charNONENONE

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.

mnMonthsBestFitMATH02MATH_NUMERICNONENONE

- - - Good Performance High Value. 

mnLastBucketPositionMATH03MATH_NUMERICNONENONE

- - - Bad Performance Low Value. 

idPtrToActualValuesGENLNGIDNONENONE

General purpose ID variable.

cMeanAbsoluteDeviationEV01charNONENONE

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

mn2ndDegreeApproxNoMonthsMATH01MATH_NUMERICNONENONE

- - - Good Performance Low Value. 

Related Functions

B3401050 Forecast Accumulate Actuals

Related Tables

None