Vensim Equations

Use this forum to post Vensim related questions.
Post Reply
ahmadi2010
Senior Member
Posts: 77
Joined: Thu Aug 19, 2010 3:34 pm

Vensim Equations

Post 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]
Administrator
Super Administrator
Posts: 4590
Joined: Wed Mar 05, 2003 3:10 am

Post by Administrator »

The following should work ok for you.

IF THEN ELSE ( TIME >= 25 :AND: TIME <=35
, equation 1
, equation 2)
ahmadi2010
Senior Member
Posts: 77
Joined: Thu Aug 19, 2010 3:34 pm

Post 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]
Administrator
Super Administrator
Posts: 4590
Joined: Wed Mar 05, 2003 3:10 am

Post by Administrator »

Can you post the model? There may be a really simple way of doing it.

Tony.
ahmadi2010
Senior Member
Posts: 77
Joined: Thu Aug 19, 2010 3:34 pm

Post by ahmadi2010 »

I sent an email for you Tony.

Thanks again.
tomfid
Administrator
Posts: 3811
Joined: Wed May 24, 2006 4:54 am

Post 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
Administrator
Super Administrator
Posts: 4590
Joined: Wed Mar 05, 2003 3:10 am

Post 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.
tomfid
Administrator
Posts: 3811
Joined: Wed May 24, 2006 4:54 am

Post 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.
Administrator
Super Administrator
Posts: 4590
Joined: Wed Mar 05, 2003 3:10 am

Post by Administrator »

I think it might just be a time series data Tom, either coming in as a VDF or lookup.
tomfid
Administrator
Posts: 3811
Joined: Wed May 24, 2006 4:54 am

Post 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
Post Reply