Delay fixed

Use this forum to post Vensim related questions.
Post Reply
irene
Member
Posts: 22
Joined: Wed Aug 24, 2011 3:07 pm

Delay fixed

Post by irene »

Hello,
I have a question about delay fixed. i have an outflow from a level that is outflow = delay fixed(input, delay time, 0). the outflow is the inflow delayed by delay time (say 5 days). I make the assumption that delay time increases in time=10 by 2 days(delta time = 5+step(2,10)).. I was expecting that output would be now delayed by the new delta time (7 days) but it still is delayed by 5 days. Is there another way to show that after day 10 the outflow is delayed by 7 and not 5 days?
thank you very much.
irene
tomfid
Administrator
Posts: 3811
Joined: Wed May 24, 2006 4:54 am

Re: Delay fixed

Post by tomfid »

The "fixed" in DELAY FIXED means fixed duration of the delay, so you can't change it after initialization. You need DELAY MATERIAL or DELAY INFORMATION (see Help system for examples).
LAUJJL
Senior Member
Posts: 1427
Joined: Fri May 23, 2003 10:09 am
Vensim version: DSS

Re: Delay fixed

Post by LAUJJL »

Hi Irene

You can still do it using delay fixed. You must change the value of your variable with an if then else, saying that your variable is equal to delay fixed 7 days after time 10 and delay fixed 5 days before time 10. var = if then else (time<10,delay fixed(y,5),delay fixed(y,7)). You may have to intialize the delays accordingly. Of course you cannot make the new delay time dependant on some variable whose
value change during the simulation as the value of the new delay will be computed at the start of the simulation and be kept constant. So you must know the value of the delay or be able to compute it at the start of the simulation otherwise you need to use other delay types.
Regards.
JJ
gwr
Senior Member
Posts: 209
Joined: Sun Oct 04, 2009 8:40 pm
Vensim version: DSS

Re: Delay fixed

Post by gwr »

Hi Irene,

what JJ has suggested will only work, if you make the two different DELAY FIXED functions separate variables and then use them in the equation for the delayed flow. Vensim gives an error if you mix IF THEN ELSE with the DELAY FIXED in one equation -- at least my instance of it ;-)

I would seriously doubt that the IF THEN ELSE formulation gives anything that you want: It will not show a change in the outflows as both delays will be calculated from the start of the simulation and that probably is not what you want. You ned to ask yourself what the change of the delay time means (this essentially is the difference between a conveyor and the delay material for example). If the new delay time affect things that are already in the previous delay then you need the conveyor as then you would have slowed done the sped of everything on the conveyor belt. If the new delay time will affect only the things entering the delay from time 10 on then you would need the DELAY MATERIAL as Tom has suggested.

This is nicely explained here:

http://www.vensim.com/documentation/index.html

Kind regards,

Guido
LAUJJL
Senior Member
Posts: 1427
Joined: Fri May 23, 2003 10:09 am
Vensim version: DSS

Re: Delay fixed

Post by LAUJJL »

Hi Guido

When I used the formulation var = if then else (time<10,delay fixed(y,5),delay fixed(y,7)) it was a simplification. It is of course mandatory to use a delay fixed after the = sign.
One has then to use y = if then else (time < 10,y1,y2) with y1 = delay fixed (x,5,x) and y2 = delay fixed (x,7,x). It works very well. See the model joined where one can see that before time 10, the y equal x delayed with 5 time step, and at time 10, y equal x delayed with 7 time step.

Regards.
JJ
Attachments
delaifixe.mdl
(2.5 KiB) Downloaded 325 times
tomfid
Administrator
Posts: 3811
Joined: Wed May 24, 2006 4:54 am

Re: Delay fixed

Post by tomfid »

This is a clever workaround.

There's one caveat, though. The switched-delay-fixed strategy works like DELAY INFORMATION. In some cases, when dealing with a physical process, you'd like the behavior to be like DELAY MATERIAL, for conservation of a material flow a the time of the switch.

Tom
gwr
Senior Member
Posts: 209
Joined: Sun Oct 04, 2009 8:40 pm
Vensim version: DSS

Re: Delay fixed

Post by gwr »

JJ,

I do see how your model works, but I fail to see why you seem to be quite found of using TIME STEP in equations (cf. your post re the World 3 in the SD section). Whatever x = Time/Time Step means in a simulation (once again: TIME STEP is nothing to be "seen" anywhere in the reality to be modeled so preventing its appearance in an equation IMHO is advisable, when there is not much to be gained) - the equation:

DELAY FIXED ( x, 5 * TIME STEP, x)

does not mean that x will be delayed 5 months, so the naming of the variable is misleading in my opinion. The delay time fo the DELAY FIXED will have the same unit as the TIME STEP (e.g. months). So a delay time of simply 5 means 5 months -- there seems to be no need to add anything to make this more robust.

Kind regards,

Guido
LAUJJL
Senior Member
Posts: 1427
Joined: Fri May 23, 2003 10:09 am
Vensim version: DSS

Re: Delay fixed

Post by LAUJJL »

Hi Guido

You are right. I should have used instead of time step, a constant equal to one month. I do my models quite quickly, and as I am using strictest unit testing, I need to be careful with the units.
With the world model, it is totally different, and the time step is mandatory. I know that time step should not be used in models, but sometimes it is necessary, especially when one wants to use RC or build a mass balance. See the model I joins in my next post.
Best regards.
JJ
LAUJJL
Senior Member
Posts: 1427
Joined: Fri May 23, 2003 10:09 am
Vensim version: DSS

Re: Delay fixed

Post by LAUJJL »

Hi Tom

It is possible to avoid the caveat with a slightly more complex model, by computing the loss or gain of quantity when switching from one delay to the other to add it again to the material to be delayed.
Joined the model with the mass balance.
Of course it may be preferable to switch to a material delay, although the material delay is too rather tricky, particularly to verify its results.

Best regards.
JJ
Attachments
delaifixe3.mdl
(6.13 KiB) Downloaded 286 times
LAUJJL
Senior Member
Posts: 1427
Joined: Fri May 23, 2003 10:09 am
Vensim version: DSS

Re: Delay fixed

Post by LAUJJL »

Hi Guido

Joined a modified version of the preceding model without time step, and the x properly dimensionned with a flow (widgets/month). The resuting model makes more sense being properly dimensionned.
Regards.
JJ
Attachments
delaifixe4.mdl
(6.74 KiB) Downloaded 279 times
irene
Member
Posts: 22
Joined: Wed Aug 24, 2011 3:07 pm

Re: Delay fixed

Post by irene »

Many thanks to all of you, i will do my homework since i must admit i am not so familiar with all the things you kindly proposed me. with you help i think i'll do it.
thank you very very much...
irene
LAUJJL
Senior Member
Posts: 1427
Joined: Fri May 23, 2003 10:09 am
Vensim version: DSS

Re: Delay fixed

Post by LAUJJL »

Here are joined two other versions, one equivalent to the version4, but with a much clearer mass balance (the mass balance in the version 4 is rather tricky), and the other one with no delay for the gain. It is of course possible to use an exponential delay for the gain or loss or to split it into parts and to allocate the parts one after the other to make the delayed flow more fluid.
Regards.
JJ
Attachments
delaifixe6.mdl
(7.43 KiB) Downloaded 277 times
delaifixe5.mdl
(6.5 KiB) Downloaded 266 times
gwr
Senior Member
Posts: 209
Joined: Sun Oct 04, 2009 8:40 pm
Vensim version: DSS

Re: Delay fixed

Post by gwr »

Hi JJ,

while I indeed have to admire the intricacies of your formulations in order to correctly capture losses and gains fulfilling the postulate of mass balance I would still say that this is in vain. If you take a look at the modified model of yours that I have enclosed the comparision with the DELAY MATERIAL and the DELAY CONVEYOR shows, that the "true" discrete phyisical process (widgets are being transported) is not met. a fixed delay of 5 that is swtichted to 7 must by necessity lead to a zero flow for two periods if the delay only affects the new material entering the delay process (e.g. the DELAY MATERIAL) - else one would have the conveyor.

In the context of the World 3 model you strongly urge to use a formulation using the time step to correct the original continuous time formulation. (As I will post) using a Max-Min formulation with the easier to understand continuous formulation (a proportional split) should result in marginal error only so the benefit might lie in the better to understand euqations while having marginal numerical error. The formulations in your delayfixe4 are tricky and difficult to understand and the error compared to the discrete functions provided by Vensim are larger. I fail to see the principle you are following?

Kind regards,

Guido
Attachments
delaifixe4mod.mdl
Comparing the switched delay with discrete delays.
(10.66 KiB) Downloaded 258 times
LAUJJL
Senior Member
Posts: 1427
Joined: Fri May 23, 2003 10:09 am
Vensim version: DSS

Re: Delay fixed

Post by LAUJJL »

Hi Guido

I do not pretend that the use of my delay fixed should be used systematically, it is much to complicated. My intention was to correct the loss of material generated by the previous model. the way that loss is allocated will vary and will be certainly different than other discrete Vensim fonctions. The objective was not to lose any matererial as Tom suggested. And I think that my model does it and after a time the switched delay works fully.
If one wants to control fully the way that things are delayed one can use arrays too.
Anyhow, all these things are not important al least to me.
To caary on this discussion, it would be necessary to really model something real, as this is a pure academic discussion.
Regards.
JJ
irene
Member
Posts: 22
Joined: Wed Aug 24, 2011 3:07 pm

Re: Delay fixed

Post by irene »

hello,
i have used delay material, but could you please clarify me this: in DELAY MATERIAL ( unit , time, unit, units) what does "units" represent? i cannot find it in "help" and i want to be sure what it means.
many thanks
irene
tomfid
Administrator
Posts: 3811
Joined: Wed May 24, 2006 4:54 am

Re: Delay fixed

Post by tomfid »

This is just the units of measures of the inputs ('units' is just a typo and should be the same as 'unit'). The arguments are DELAY MATERIAL( {in} , {dtime} , {init} , {missval} ) where 'in' is the inflow, dtime is the delay duration, 'init' is the initial condition (as a flow), and 'missval' is the flow value to assign when missing (due to a change in the delay duration; normally 0). See the sample model linked to the help system (if you have a recent version).
irene
Member
Posts: 22
Joined: Wed Aug 24, 2011 3:07 pm

Re: Delay fixed

Post by irene »

thank you, confirmation is always a good thing to have!!!
irene
Post Reply