Page 1 of 1

calculating number of weeks on the model's results

Posted: Fri Sep 16, 2011 3:31 am
by adjie
Dear All,

i have a question about how can i calculate the result of simulation by numbers of week. for example, in sample model (as attached), i simulate the model resulting rainfall pattern over 1000 weeks. what i want to do is to calculate the number of weeks for the rainfall which has more than 0.02. i expect that it should be some weeks out of 1000 weeks (total weeks on simulation).

is there any mechanism on the model to get this result? or do i have to do it manually? let's say, i export the result to the excel and calculate it in excel rather than in vensim.

thanks,

Re: calculating number of weeks on the model's results

Posted: Fri Sep 16, 2011 10:08 am
by Administrator
Use the Integ function, see the attached model.

Re: calculating number of weeks on the model's results

Posted: Fri Sep 16, 2011 10:04 pm
by tomfid
Note that INTEG lags by one TIME STEP, so if there's a (rainfall>threshold) event in the last time step, it won't be counted. Normally this is not a problem. However, if you need to count the last time step too, you can modify the model to report the stock, plus the current value of the flag.

It may be convenient to put this in a macro, e.g.

:MACRO: COUNTEVENTS( flag )

cumCount = INTEG(flag/TIME STEP$,0) ~flag~|

COUNTEVENTS = cumCount+flag ~flag~|

:END OF MACRO:

Re: calculating number of weeks on the model's results

Posted: Sat Sep 17, 2011 3:49 am
by adjie
Thanks tony and tom for your suggestion.

i apply tony's mechanism in my model. it is working. and i think, the mechanism also count the last time step.
But, i still have no idea in applying tom's suggestion in my model. i tried to look for :MACRO: function in vensim, but i did not find it. can you give me more explanation?

many thanks,

Re: calculating number of weeks on the model's results

Posted: Sat Sep 17, 2011 5:12 pm
by tomfid
Macros are defined in the text editor - see the help system, e.g. http://www.vensim.com/documentation/ind ... ?22145.htm

No macros in PLE.

Tom