calculating number of weeks on the model's results

Use this forum to post Vensim related questions.
Post Reply
adjie
Member
Posts: 22
Joined: Tue May 10, 2011 4:59 am

calculating number of weeks on the model's results

Post 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,
Attachments
sample.mdl
(1.19 KiB) Downloaded 532 times
Administrator
Super Administrator
Posts: 4842
Joined: Wed Mar 05, 2003 3:10 am

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

Post by Administrator »

Use the Integ function, see the attached model.
Attachments
sample.mdl
(1.91 KiB) Downloaded 649 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
tomfid
Administrator
Posts: 3999
Joined: Wed May 24, 2006 4:54 am

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

Post 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:
adjie
Member
Posts: 22
Joined: Tue May 10, 2011 4:59 am

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

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

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

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