how to perform a convolution in vensim

Use this forum to post Vensim related questions.
Post Reply
rolf_w
Junior Member
Posts: 8
Joined: Fri Jan 21, 2011 3:32 pm

how to perform a convolution in vensim

Post by rolf_w »

I'd like to perform a convolution f(t)*g(t) in Vensim (see e.g. http://en.wikipedia.org/wiki/Convolution). I played around with the DELAY PROFILE function as it looks close to what I need but I couldn't figure out what it actually calculates. Could anyone point me to some help on how to construct a convolution and is there a site where the various DELAY functions are explained in math terms? thx rw
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Re: how to perform a convolution in vensim

Post by tomfid »

A general convolution is acausal, i.e. values at a point in time may use information from the future. We don't generally support acausal modeling, though there are technical tricks for accomplishing it in some cases.

If you say more about your problem we might have a solution.
rolf_w
Junior Member
Posts: 8
Joined: Fri Jan 21, 2011 3:32 pm

Re: how to perform a convolution in vensim

Post by rolf_w »

thx for the swift reply. My applications are strictly physical and thus causal. Currently I'd like to model end of life behaviour of large numbers of electrical appliances and use various probability density functions (pdf) to shape failure rates (e.g. Weibull distribution). The system behaviour could be described as a delay where appliances exit the stock according to this pdf. Hence I construct a SISO LTI system with the pdf as the transfer function - the outflow of the stock is then the convolution of the inflow with the pdf and the stock is the cumulated netflow.
rw
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Re: how to perform a convolution in vensim

Post by tomfid »

Got it.

The simple way to do this is with DELAY PROFILE (see the example in Ch. 4 of the Reference Guide). The lookup argument to DELAY PROFILE is the distribution of the wait or residence time of the material (scaled by the delay time parameter).

Unfortunately there isn't any easy way to parametrically set the profile to some known distribution like a Weibull (other than the exponential and Erlang distributions, which can be expressed with Nth order delays), though many can be approximated by series/parallel combinations of simpler delays.

You might also check out http://models.metasd.com/delay-sandbox/

Tom
rolf_w
Junior Member
Posts: 8
Joined: Fri Jan 21, 2011 3:32 pm

Re: how to perform a convolution in vensim

Post by rolf_w »

this is what I tried but got confused with the parameters 'delay time','init' and 'init grow' - referring to the Vensim Help it seems straight forward ...The delay response is the response that the output will show when given a pulse as an input... = transfer function of an LTI system...
Also this seems a nice feature ...Vensim will automatically scale this to a probability distribution so that the input is a conserved quantity... = no headache scaling my Weibull shape...
However, continue reading the Help only increased my confusion. What could that mean ...Since the DELAY PROFILE distributes values over time when it is initialized you can specify an initial growth rate... ?

I tried to leave away the 3 paramters (which is not allowed) then I set them to 0 which did not produce excpected results...

thx for pointing me to the sandbox - I will explore it, rw
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Re: how to perform a convolution in vensim

Post by tomfid »

The initial growth rate parameter specifies the trajectory of your appliance installation rate f(t) prior to the start of the model (INITIAL TIME).

I'll see if I can cook up an example.
rolf_w
Junior Member
Posts: 8
Joined: Fri Jan 21, 2011 3:32 pm

Re: how to perform a convolution in vensim

Post by rolf_w »

thx for all your help Tom,
what would be a great help would be a mathmatical description of the algorithm - 'the formula' . From there it will be easy to figure out the use and setting of the parameters
rolf
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Re: how to perform a convolution in vensim

Post by tomfid »

OK, here's an example, based on the one in the help system:
DELAY PROFILE+.mdl
(4.77 KiB) Downloaded 291 times
I created an arbitrary Weibull-ish profile in the lookup.

If you set the 'pulse install rate' and 'historic install rate' to 0, and the 'constant install rate' to some value, you can see that you get the expected Little's Law result with residence time = shipping time and average stock = shipping time*inflow. (I should have renamed 'shipping time' as 'failure time' or something like that.)

In the default, 'historic install rate' is nonzero, so that you can see the effect of the initialization. It turns out that there's a pitfall here. Unlike the first order case, where the initial contents of the stock has a simple expression (see the Initial Value field for 'appliances operating'), the initial value of the contents of the delay is a convolution of the historic inflow with the delay profile. That makes it tough to get an analytic expression with which to initialize the accounting stock. If you only care about the failure rate, not the operating stock, or can live with 0 initial trend, or initialize the stock to data, that might not be a problem. Otherwise I'd have to think a bit more about how to make a good init val setting.

Tom
rolf_w
Junior Member
Posts: 8
Joined: Fri Jan 21, 2011 3:32 pm

Re: how to perform a convolution in vensim

Post by rolf_w »

thx for the example, Tom
A while ago I have built a very simple model to test my case. It should illustrate the pulse response (Dirac) of the delay function (lookup of a weibull pdf), thus convolving 'in' with the 'pdf'!
I have to admit that after playing around with it for a while I still do not understand what the 3 paramaters 'delay time','init' and 'init grow' in the DELAY PROFILE actually do:
I thought 'delay time' would simply time shift 'in' i.e. same shape just later - but it also affects its shape!!?
As my weibull pdf already includes a delay I wanted to set 'delay time' to 0 which does not produce expected results.
I have no use for 'init' and 'init grow' -the entire system behaviour is set by the 'pdf'. Just set them 0?
The stock is building up properly: it fills up instantly with the pulse then stays constant (no further inflow, no outflow) and with the onset of weibull shaped outflow starts to empty. And as both the pulse and weibull pdf area are 1 it empties to 0.

I'd wish you could show me the DELAY PROFILE formulas!!
rw
CRT_disposal_(weibull).mdl
(2.36 KiB) Downloaded 234 times
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Re: how to perform a convolution in vensim

Post by tomfid »

I'll take a look.

If you don't need 'init' and 'init grow' you can set them to 0.

The profile and delay time parameters work together. The profile gives the shape of the distribution. It's then scaled so that (a) the area under the curve is 1 and (b) the mean arrival time is equal to the delay time parameter.
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Re: how to perform a convolution in vensim

Post by tomfid »

Incidentally, if there's some other software you use that does things differently/better, we're always interested to hear about it.
karankhosla
Senior Member
Posts: 107
Joined: Wed Nov 26, 2008 6:12 am

Re: how to perform a convolution in vensim

Post by karankhosla »

Hi Rolf, this is very interesting; I'm curious, what happens to the results of the outflow with regard to your expectations, if you put the Delay Time value = the mean delay of your pdf?
rolf_w
Junior Member
Posts: 8
Joined: Fri Jan 21, 2011 3:32 pm

Re: how to perform a convolution in vensim

Post by rolf_w »

karankhosla wrote:...what happens to the results of the outflow with regard to your expectations, if you put the Delay Time value = the mean delay of your pdf?
In the screenshot example below, my 'pdf' peaks at time=11 (unit = 1/4year) . If I set 'delay time' to 11 the results look quite ok. Nevertheless it seems strange to me that 'time delay' manipulates others than just delay time and in an incomprehensible manner. my pdf is already scaled (i.e. integral = 1), it has the delay I want, it has the shape I want, thus I would like to set 'time delay' to a value, which idles its functionality.
overview1.JPG
overview1.JPG (102.06 KiB) Viewed 12421 times
rolf
rolf_w
Junior Member
Posts: 8
Joined: Fri Jan 21, 2011 3:32 pm

Re: how to perform a convolution in vensim

Post by rolf_w »

tomfid wrote:...It's then scaled so that (a) the area under the curve is 1 and (b) the mean arrival time is equal to the delay time parameter.
how does 'delay time' do both a) and b) at the same time? what's the math behind it? r
rolf_w
Junior Member
Posts: 8
Joined: Fri Jan 21, 2011 3:32 pm

Re: how to perform a convolution in vensim

Post by rolf_w »

tomfid wrote:...there's some other software you use that does things differently/better...
what I would like to see in Vensim is the possibility to use transfer functions for LTI systems i.e. the possibility to convolve an input with the system's pulse response. (I guess Vensim operates in the time domain only, thus will not calculate Laplacians?). I think there are many ways to calculate a convolution (Mathlab, Maple, Scilab, ... I even use Excel for simple systems).
r
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Re: how to perform a convolution in vensim

Post by tomfid »

It's using the profile and the delay time together to normalize the pdf and establish the mean time.

Off the top of my head, I believe that the procedure is (a) integrate x*lookup(x) over the range of the lookup, and divide by the range, to determine the mean arrival time in the lookup (b) rescale the x axis in order to make the mean arrival time match the 'delay time' parameter (c) integrate with the rescaled x-axis to normalize the area to 1 for a proper pdf.

So, if your lookup already embodies the arrival time, if you set 'delay time' to the mean arrival time, step (b) won't make any difference, and you should get what you want.
Ulrich
Newbie
Posts: 1
Joined: Fri May 05, 2017 1:45 pm
Vensim version: DSS

Re: how to perform a convolution in vensim

Post by Ulrich »

I am new to Vensim and want to follow up on the discussion regarding convoluation. As Rolf, I am interested in dynamic modelling of material flow systems. Lifetimefunctions (e.g. based on Weibull distributions) are used the link the inputs to the stock with the outputs from the stock. As far as I understand the built-in delay functions, they are not suitable to adress this type of delay. I went through the previous forum discussion and tried to set up and run a vensim modell, but I did not came up with a sound solution an I am wondering if there is one available.

To support finding a solution, I have created a simple example in MS Excel (attached) and based on that a Vensim modell (attached). The Vensim modell delivers the right results, but the modelling approch is rather impractical, expecially if more, different and other types of lifetimefunctions are used and if the paramters of the lifetimefunction should be adopted. It would be nice to have a reduced set of variables in the modell and I am looking forward getting any feedbacks and recommendations.

Thank you for your support.
Attachments
delay manuell.mdl
(3.15 KiB) Downloaded 213 times
delay_manuell.xlsx
(31.22 KiB) Downloaded 205 times
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Re: how to perform a convolution in vensim

Post by tomfid »

At least your simple example should be easily accomplished with DELAY PROFILE. https://www.vensim.com/documentation/in ... rofile.htm

You could put a table of any distribution into the profile lookup, though this would still be somewhat inconvenient for cases where the parameters change the shape of the distribution rather than merely scaling it.

Another option would be to use optimization to estimate a series of exponentials that approximate your desired distribution, though that is also potentially cumbersome.
Post Reply