How to get the last value of an auxiliary variable ?

Use this forum to post Vensim related questions.
Post Reply
oOLauraOo
Member
Posts: 41
Joined: Wed Mar 22, 2017 5:05 pm
Vensim version: PRO

How to get the last value of an auxiliary variable ?

Post by oOLauraOo »

Hi,
I found similar topics on the forum but couldn't apply the solutions provided to my own issue...
My model aims to calculate the energy performance of a building and compare this energy performance before/after the building refurbishment (TIME STEP = 1 month).
With a lookup, I "scored" the yearly building energy performance from 4 to 0 (worst to best) depending on the amount of yearly energy consumptions (as a sum of consumptions over the past 12 months of the year). So this variable only gets a value every 12 time steps.
I wish to compare the "current energy class" scored at MODULO(Time,12)=0 with the "last known energy class" computed at [Time-12] in order to obtain the distance between previous and current scores.
I tried to use the DELAY FIXED equation, but couldn't get what I need, as :
1) the first value for the variable "current energy class" appears at [Time=12], so I would expect the variable "last known energy class" to be calculated at [Time=24] for the first time... yet "last known energy class" appears earlier than expected at [Time=13] ;
2) I would expect the variable "last known energy class" to appear at the same yearly time as "current energy class" (meaning at Times 24, 36, 48, ...) in order to measure the distance between previous and current values... but instead the "last known energy class" is calculated with a shift in time, and I get the values at Times 13, 25, 37, 49, ... .

Can you please help me find a way to put it right ? What am I missing here ?
Thank you a lot !
Best regards,

Laura
oOLauraOo
Member
Posts: 41
Joined: Wed Mar 22, 2017 5:05 pm
Vensim version: PRO

Re: How to get the last value of an auxiliary variable ?

Post by oOLauraOo »

Hi,
Thanks for your answer ! This solution is okay to get the values at the same time. But I don't understand how to get the value of the "current energy class" variable at Time-12, as DELAY FIXED must directly follow the equal sign ?
Best regards,
Laura
tomfid
Administrator
Posts: 3804
Joined: Wed May 24, 2006 4:54 am

Re: How to get the last value of an auxiliary variable ?

Post by tomfid »

Keep the delayed value in a separate variable.

If you're doing this a lot, you can encapsulate DELAY FIXED in a macro - then it can be used directly on the RHS.
tomfid
Administrator
Posts: 3804
Joined: Wed May 24, 2006 4:54 am

Re: How to get the last value of an auxiliary variable ?

Post by tomfid »

You might also check this:
http://vensim.com/discrete-stochastic/
oOLauraOo
Member
Posts: 41
Joined: Wed Mar 22, 2017 5:05 pm
Vensim version: PRO

Re: How to get the last value of an auxiliary variable ?

Post by oOLauraOo »

Oh yes now I understand what you meant, and it works ! Thank you a lot !
Laura
Post Reply