Page 1 of 1

Vensim Equations

Posted: Fri Dec 03, 2010 4:39 pm
by ahmadi2010
I have a question about vensim equations.

I have to define 2 equations for a variable.For example I have 50 time steps in my model. for time=25 to 35 I have to define an equation and for other times another equation. How can I define it with IF THEN ELSE ?

[Edited on 12-3-2010 by ahmadi2010]

Posted: Fri Dec 03, 2010 5:11 pm
by Administrator
The following should work ok for you.

IF THEN ELSE ( TIME >= 25 :AND: TIME <=35
, equation 1
, equation 2)

Posted: Fri Dec 03, 2010 5:24 pm
by ahmadi2010
Thank you Tony.

And if I have to define equation2 like this:
I have some constant (c26,c27,c28.......c34)

if time=26 then c26*equation2
if time=27 then c27*equation2
.
.
.
if time=34 then c34*equation2

Can you help me please?
Is there any way that I'm not forced to use IF THEN ELSE for each of time step?

I do't like to use this form:
IF THEN ELSE(Time=35,c35*equation2 , IF THEN ELSE(Time=36,c36*equation2 ,IF THEN ELSE(Time=37,c37*equation2 , IF THEN ELSE(Time=38,c38*equation2 , IF THEN ELSE(Time=39, c39*equation2 ...........

[Edited on 12-3-2010 by ahmadi2010]

Posted: Fri Dec 03, 2010 5:48 pm
by Administrator
Can you post the model? There may be a really simple way of doing it.

Tony.

Posted: Fri Dec 03, 2010 6:41 pm
by ahmadi2010
I sent an email for you Tony.

Thanks again.

Posted: Fri Dec 03, 2010 6:59 pm
by tomfid
This could be accomplished with subscripting, where the equations reside in an array and VECTOR SELECT is used to pick the active element.

However, why would you want to do this? It sounds very cumbersome.

T

Posted: Fri Dec 03, 2010 7:42 pm
by Administrator
I've got the sample model.

Are these values going to be constants or variables? Using nested "IF THEN ELSE" is not the solution.

Posted: Fri Dec 03, 2010 7:48 pm
by tomfid
Using a different equation for every time step implies that either (a) different data is brought to bear at each time, in which case there should be a solution (like VECTOR SELECT) or (b) the system structure changes at every time step, in which case it would be far better to have a generic structure that applies at all time steps, changing only through parameter variations.

Posted: Fri Dec 03, 2010 7:49 pm
by Administrator
I think it might just be a time series data Tom, either coming in as a VDF or lookup.

Posted: Fri Dec 03, 2010 7:57 pm
by tomfid
In that case the structure I built in Model3/4 of this thread does what's needed.
http://www.ventanasystems.co.uk/forum/v ... php?t=4272

Tom