| Applying science to business management |
  
Dynamic Functions
It is often useful to treat an entire branch in a tree as
though it were a single function that allows you to supply input
arguments. This can be done using Dynamic Functions.
Assume that you want to modify the following tree to calculate
how much Profit increases if Sales go up by 1000.
If Profit were a function of Sales, you could
simply add a node such as
Difference:=Profit(4000)-Profit(3000)
However, Profit is a constant rather than a function,
so this definition will not work. However, you can still perform
this calculation if you refer to Profit as a Dynamic
Function as follows:
Difference:=Profit(Sales:=4000)-Profit(Sales:=3000)
When DScript evaluates the formula
Profit(Sales:=4000)
it realizes that Profit is not a function, so it
assumes you want to treat the entire branch beginning at Profit
as a Dynamic Function. To do this, DScript first evaluates the
expression inside the parentheses; then it recalculates the Profit
branch; and finally, it removes all definitions created while
evaluating the parentheses expression.
The expression inside the parentheses can perform any
operation including completely redefining key parts of the
branch. For example, the following expression not only sets Sales
to a new value, it also redefines the node Variable:
Profit(Sales:=4000,Variable:=Sales*50%)
In using a Dynamic Function, you are asking DScript to
evaluate a branch with a list of temporary changes. This is a
great way to embed scenario testing in your applications.
|