Page 1 of 1

How to get the last value of an auxiliary variable ?

Posted: Mon Aug 28, 2017 3:44 pm
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

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

Posted: Mon Aug 28, 2017 4:01 pm
by tomfid

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

Posted: Mon Aug 28, 2017 4:56 pm
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

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

Posted: Mon Aug 28, 2017 5:22 pm
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.

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

Posted: Mon Aug 28, 2017 5:23 pm
by tomfid
You might also check this:
http://vensim.com/discrete-stochastic/

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

Posted: Tue Aug 29, 2017 9:16 am
by oOLauraOo
Oh yes now I understand what you meant, and it works ! Thank you a lot !
Laura