Help for 'if then else'

Use this forum to post Vensim related questions.
Post Reply
hasbito
Junior Member
Posts: 4
Joined: Mon Apr 10, 2017 6:15 pm
Vensim version: PLE

Help for 'if then else'

Post by hasbito »

Hi guys,

I need to write a specific condition but couldn't figure out .Here it is;
I want Y is equal to X if R becomes less than 0 once, otherwise Z.

For my project, I could only do this one:
Nominal exchange rate:IF THEN ELSE(Reserves<=0,Shadow Exchange Rate,3)
but it didn't work because whenever R>0, it again comes back to 3. I want nominal exchange rate to be equal to shadow one, once R<0 and indifferent of whether in some point of time R again becomes greater than 0.

Can you guys help me?
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Re: Help for 'if then else'

Post by tomfid »

You can use a stock to create a persistent state, or check out the SAMPLE IF TRUE function.
hasbito
Junior Member
Posts: 4
Joined: Mon Apr 10, 2017 6:15 pm
Vensim version: PLE

Re: Help for 'if then else'

Post by hasbito »

Hi,
Thank you for the reply. Can you elaborate on creating stock for persistent state? I want the condition work for once, and constantly change the variable's value without affected by condition again.
I don't have the full version, I don't have SAMPLE TRUE function, unfortunately.
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Help for 'if then else'

Post by Administrator »

I've attached a model showing how to do it using a level. It's probably more complicated than you need, but I'm sure you can simplify it so suit your needs.
Attachments
forum demo.mdl
(2.63 KiB) Downloaded 165 times
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
hasbito
Junior Member
Posts: 4
Joined: Mon Apr 10, 2017 6:15 pm
Vensim version: PLE

Re: Help for 'if then else'

Post by hasbito »

I can't tell how I'm grateful for your help right now. Thank you very much. It worked. Many thanks.
With love,
Melih
Post Reply