Page 1 of 1
Vensim Compare Help
Posted: Tue Apr 27, 2010 5:26 pm
by Jin
Im trying to use a range of numbers in an IF THEN ELSE type of situation. so at 100 the number would be say 5 but at 20 the number would be 3. Im running into problems trying to implement this and could use a little help.
Posted: Tue Apr 27, 2010 5:56 pm
by tomfid
One possibility:
output = IF THEN ELSE( input = 100, 5, IF THEN ELSE( input = 20, 3, ... ))
If you have more than one or two states, this is likely to get confusing. You might consider a lookup instead.
Check the User's Guide, Chapter 8, "building a function with lookups"
Tom
Posted: Tue Apr 27, 2010 5:58 pm
by Jin
ok, how do i create a look up and use it in this situation. Im very new to using this software so im a little lost.
Posted: Tue Apr 27, 2010 6:23 pm
by tomfid
Again, Help>Vensim Manuals>Contents - Chapter 8 is your best bet.
Alternatively, take a look at some sample models, which are typically in your Vensim directory. For example, C:\Program Files\Vensim\models\guide\CHAP08\COMPLETE\RABBIT3 has an example lookup, "effect of rabbit crowding on deaths".
Tom
Posted: Tue Apr 27, 2010 7:00 pm
by Administrator
Would this work
value = IF THEN ELSE ( time = 10, 5 , 0 )
+ IF THEN ELSE ( time = 20, 6 , 0 )
+ IF THEN ELSE ( time = 30, 7 , 0 )
+ IF THEN ELSE ( time = 40, 8 , 0 )
+ IF THEN ELSE ( time = 50, 9 , 0 )