Is there an equation for counter in Vensim?

Use this forum to post Vensim related questions.
Post Reply
kong17
Senior Member
Posts: 60
Joined: Wed May 30, 2018 1:12 pm
Vensim version: PRO

Is there an equation for counter in Vensim?

Post by kong17 »

Dear all

I want to achieve the function in Figure Image
The time step is month.
I was wondering how to achieve it in vensim? If the time boundaries is 120.
I try to use IF THEN ELSE and LEVEL. Each time step, the price will be accumulated.
IF THEN ELSE=12, price/12,0
IF THEN ELSE=60, price/60,0
But, it only works one time.
So, I was wondering is there an equation similar to the counter in Vensim that help accumlate data for a certain period of time.
Thank you very much

Kind regards
Attachments
Capture.JPG
Capture.JPG (33.72 KiB) Viewed 1732 times
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Re: Is there an equation for counter in Vensim?

Post by tomfid »

An extremely simple implementation would be

A = PR/SMOOTH(PR,smoothing time)
smoothing time = 3

The SMOOTH function gives you an exponentially-weighted moving average of its input, which is often a good model of perception. A fixed window is typically not as good a model of perception, unless there's some reporting process that enforces it.
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Re: Is there an equation for counter in Vensim?

Post by tomfid »

If you need a fixed window, you can use something like:

avg input = x in window/tau
x in window = INTEG( input - outflow, input*tau )
outflow = DELAY FIXED( input, tau, input )
tau = 3

The time scale tau needs to be an integer multiple of the time step for this to initialize correctly, though you could adjust for that if needed.
Post Reply