Analytic lookups? (Functions)

Use this forum to post Vensim related questions.
Post Reply
Travis
Senior Member
Posts: 181
Joined: Tue Jul 15, 2008 8:42 pm

Analytic lookups? (Functions)

Post by Travis »

In order to make some diagrams look "pretty", I'm wondering if there is a way to define analytic functions like we can define lookup tables. For instance, it is rather easy to:

TableFunction1 = [set of points defined by user in Vensim Equation Editor]
TableFunction2 = [set of points defined by user in Vensim Equation Editor]

Variable1 = IF THEN ELSE (switch = 1, TableFunction1(input), TableFunction2(input))

Note: Variable1 only has three arrows coming into it. Clean diagram.

Is there away to have to substitute analytic functions in place of the Table functions? I tried Macros but I would like to use SyntheSim on some of the function parameters.

Example (if this exists, it might like):
Function1 (input)= Input * param1 + param2^param3
Function2 (input)= Input * param1 + param4^param5

Variable1 = IF THEN ELSE (switch = 1, Function1(input), Function2(input))

The key would be that param1, param2, could be manipulated in a Sketch view. And Variable1 still only has three arrows coming into it because the Functions are defined in a sketch elsewhere. I think PowerSim can do this easily. Can Vensim?
Administrator
Super Administrator
Posts: 4838
Joined: Wed Mar 05, 2003 3:10 am

Post by Administrator »

The only way I can think of that you can do what you want to is to just hide the arrows (magic wand tool).

Hope this helps.

Tony.
bob@vensim.com
Senior Member
Posts: 1107
Joined: Wed Mar 12, 2003 2:46 pm

Post by bob@vensim.com »

Actually what you are describing is precisely a macro. If your purpose is to hide the connection between shape parameters and the places the function is used then use global macro variables.
Travis
Senior Member
Posts: 181
Joined: Tue Jul 15, 2008 8:42 pm

Post by Travis »

I created a little test model and wasn't able to get the functionality I wanted. Maybe I am doing it wrong. What I did (with liberal syntax):

:MACRO:
Function1 (input)= Input * param1 + param2^param3

Now, if I want to change Param3 in Synthesim so that it changes the macro value, param3 needs to be in a sketch and it needs to be passed a parameter in the macro. The macro call now becomes "Function1(input, param3)". I tried leaving it out of the declaration and (of course) got an error about param3 being an unknown local variable.

If the macro becomes "Function1(input, param3)", then the sketch has more arrows and I'm back to the same problem as before.

Maybe hiding arrows is the easiest, or am I missing something?

[Edited on 7-16-2008 by Travis]
bob@vensim.com
Senior Member
Posts: 1107
Joined: Wed Mar 12, 2003 2:46 pm

Post by bob@vensim.com »

From the docs: The one exception to the local nature of macro variables is that you may specify a model variable by following its name with a dollar sign $. For example you can use TIME STEP$ inside of a macro to refer to the model variable TIME STEP. Only unsubscripted variables may be referred to in this manner.
Travis
Senior Member
Posts: 181
Joined: Tue Jul 15, 2008 8:42 pm

Post by Travis »

RTM -- Grrrrr... Sorry. I did read some of the entries but must have missed that one. Thank you for directing me to it.
Post Reply