Problems with an aging chain using conveyors

Use this forum to post Vensim related questions.
gwr
Senior Member
Posts: 209
Joined: Sun Oct 04, 2009 8:40 pm
Vensim version: DSS

Problems with an aging chain using conveyors

Post by gwr »

Hi,

I am experimenting with different formulations for an aging chain for vehicles (or other assets for that) where it is somewhat important to correctly report the age distribution. Since the usual coflow formulation will assume average attributes to be passed along it is imo not appropriate when aging takes place. I have worked with the SHIFT IF TRUE and a coflow aging chain using conveyors where the aging is modeled as a negative leakrate for the cowflow tracking the sum of the vehicle ages (tricky...).

While I like the precision of the SHIFT IF TRUE I find the absence of flows between the cohorts unfortunate as I wanted to aggregate the vehicles in broader stocks (young, mediumage, old) to have a simpler structure for coflows tracking different attributes so one has the advantage of age precision plus the ease of an aggregated coflow model. In order to achieve this I have now tried to achieve something similar to the discrete shifted-model by working with an aging chain using conveyor delays with a conveyance time of one year (cf. my model).

In the structure of the model included the cohorts are organized using subscript ranges:

Code: Select all

AgeGroup : (J0-J20) ~~|
AgeGroupOlder : (J1-J20) ~~|
AgeGroupYounger : (J0-J19) -> AgeGroupOlder ~~|
The "heart" of the model is then the conveyor based aging chain:

Code: Select all

VehiclesAging[J0]= 
	DELAY CONVEYOR( 
	
		{inflow} 	         VehiclesPurchased, 
		{conveytime} 	 OneYear, 
		{leakrate} 	         leakrate[J0], 
		{initprofile} 	 FlatAgeDistribution , 
		{inittotal} 	         VehiclesInitial[J0] , 
		{initconveytime} OneYear
	
	 ) ~~|

VehiclesAging[AgeGroupOlder]= 
	DELAY CONVEYOR( 
	
		{inflow} 	         VehiclesAging[AgeGroupYounger],
		{conveytime} 	 OneYear, 
		{leakrate} 	         leakrate[AgeGroupOlder],
		{initprofile} 	 FlatAgeDistribution , 
		{inittotal} 	         VehiclesInitial[AgeGroupOlder], 
		{initconveytime} OneYear
	
	 )~~|
The leakrate would simply be the exogenous Vehicle Sales divided by the number of Vehicles in that age group using a ZIDZ function.

Using this mapping should reduce the aging chain quite nicely - so I thought. But unfortunately it does not work. In the model enclosed I have simply given one vehicle for the age group J0 to start with - all other slots being zero. The number of vehicles will increase and the behavior of the model is rather strange. Where is the problem?

Kind regards,

Guido
Attachments
DataRepository.xlsx
... in case the inclusion in the package did not work out.
(9.88 KiB) Downloaded 933 times
VehicleAgingChain.vpm
Packaged model (hopefully including the data repository.xlsx)
(50.22 KiB) Downloaded 1027 times
Administrator
Super Administrator
Posts: 4590
Joined: Wed Mar 05, 2003 3:10 am

Re: Problems with an aging chain using conveyors

Post by Administrator »

Can you upload the model in MDL format please? The VPM will not load.

Tony.
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
gwr
Senior Member
Posts: 209
Joined: Sun Oct 04, 2009 8:40 pm
Vensim version: DSS

Re: Problems with an aging chain using conveyors

Post by gwr »

I have enclosed the model here.

Guido
Attachments
VehicleAgingChain.mdl
(6.21 KiB) Downloaded 979 times
Administrator
Super Administrator
Posts: 4590
Joined: Wed Mar 05, 2003 3:10 am

Re: Problems with an aging chain using conveyors

Post by Administrator »

In the 2nd equation for Vehicles, change

Code: Select all

Vehiclesaging[agegroupyounger] - VEHICLESSOLD[agegroupolder] - VEHICLESSOLD[agegroupolder]
to

Code: Select all

Vehiclesaging[agegroupyounger] - VEHICLESSOLD[agegroupolder] - Vehiclesaging[agegroupolder]
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
gwr
Senior Member
Posts: 209
Joined: Sun Oct 04, 2009 8:40 pm
Vensim version: DSS

Re: Problems with an aging chain using conveyors

Post by gwr »

Duh!!! :D

Thank you, Tony.

- That leaves the problem of getting the 1 to walk across, instead of two fractions....
tomfid
Administrator
Posts: 3811
Joined: Wed May 24, 2006 4:54 am

Re: Problems with an aging chain using conveyors

Post by tomfid »

Another option to look at is the QUEUE ATTRIBUTE functions.
gwr
Senior Member
Posts: 209
Joined: Sun Oct 04, 2009 8:40 pm
Vensim version: DSS

Re: Problems with an aging chain using conveyors

Post by gwr »

Tom & Tony,

thanks for putting me on the right track - I have simply not been able to spot the error in the equation after looking and looking.

But there remains a problem that I am not able to solve: I have enclosed the (corrected) and modified aging chain model using conveyors. In the model I have now changed the leakage rate to be fractional as indicated in the Model Guide chapter 9. The FractionalSalesRate in the model thus now gives a fractional leakrate with correction for the look-ahead-issue:

Code: Select all

VehiclesSold[J0]=( Vehicles[J0] + (VehiclesPurchased - VehiclesAging[J0]) * TIME STEP ) * FractionalSalesRate[J0] ~~|
VehiclesSold[AgeGroupOlder]= ( Vehicles[AgeGroupOlder] + (VehiclesAging[AgeGroupYounger] - VehiclesAging[AgeGroupOlder])*TIME STEP )*FractionalSalesRate[AgeGroupOlder] ~~|
In order to test the model, I initialized the fleet to consists of just one vehicle in the age group [J0]; vehicles is thus a vector of the form (1,0,...,0). FractionalSalesRates will be 0 for all AgeGroups but the 10-year-group. The FractionalSaleRate for the 10-year-group is set to 1 (100%).

Simulating the model shows that the aging process now works fine until the 10-year-group is reached. For some reason around 0.34 vehicles continue to age and reach the end of the chain when Time Step is set to be 0.125 even though 100% leakage should take place in between. Decreasing the Time Step will actually increase the error. I have tried other values like 80% for the fractional sales rate as well and also found implausible values for the number of vehicles leaving the chain.

What is the issue here and what can be done about it?

Kind regards,

Guido
Attachments
VehicleAgingChain.mdl
The corrected model using a fractional "leakrate" (=sales rate) as indicated in the Model Guide chapter 9.
(7.32 KiB) Downloaded 938 times
DataRepository.xlsx
Data for the model initializing the fleet to (1,0,...,0).
(9.88 KiB) Downloaded 1047 times
gwr
Senior Member
Posts: 209
Joined: Sun Oct 04, 2009 8:40 pm
Vensim version: DSS

Re: Problems with an aging chain using conveyors

Post by gwr »

While I am waiting for further answers regarding my problem with a conveyor based aging chain I have been trying to get some more hold upon the problem at hand.

I have enclosed a simple model of a one stage conveyor delay that pretty much uses the standard formulations as provided in chapter 9 of the modeling guide. I have added two stocks, Material leaked and Material out of conveyor, in order to keep track of what has leaked and what has come out of the conveyor. Also I have introduced a further variable, TimeToLeak, that will modulate the leak rate, so the equation for the leak will be:

Code: Select all

leak= ( Material in Conveyor + (Inflow - Outflow) * TIME STEP ) * FractionLeaking/TimeToLeak
~ Widgets/Year
~ |

In the BaseRun with the Time Step set to 0.125 and an inflow consisting just of a one periode pulse at 1 Widget/Year I notice that with 100 % Fraction Leaking and TimeToLeak at 1 Year - which represents the setting equivalent to the chapter 9 model in the modeling guide - only around 66% of the material will have leaked in total.

That is not what I would intuitively associate with a leak rate of 100% per year. Obviously the time needed to leak plays into it and experimenting with the model soon shows that the TimeToLeak must be equal to the TimeStep to achieve 100% leakage. But this will not hold for say 50% leakage where the TimeToLeak will have to be 0.75 Years in order to have the total Material that has leaked be 0.5.

The TimeToLeak needs to be 0.58 yrs to achieve a 75% leakage, 0.75 yrs for 50% and 0.88 yrs for 25%. So the correct TimeToLeak is a function of the intended fractional leakage (and the conveyor time). Looking at a plot of these values shows that it can be linearized by applying Power(x, 13/5) then linear regression can be applied which leads to the following macro to calculate the corrected TimeToLeak:

Code: Select all

TimeToLeak = ( 212.084 - 2.11176 * FractionLeaking * 100 ) ^ (5/13) * 0.125 * ConveyanceTime
I have enclosed the model using the thus corrected TimeToLeak which is - with some rounding error - robust for Time Steps <= 0.25.

Maybe there is more to this or there is a better way to internally implement this in Vensim? I would suggest that a fractional leak rate of 100% - should in any case show no material coming out of the conveyor (what else is 100% leaking to mean?). If this is be driven further then a more advanced conveyor might work with the leak being a conveyor itself thus the fraction to leak would enter the leaking conveyor with every time step and then leave the leak conveyor after TimeToLeak has passed.

Any other suggestions?

Guido
Attachments
SimpleConveyorModelCorrectedLeakTimes.mdl
The same model with an endogenously corrected TimeToLeak
(6.01 KiB) Downloaded 968 times
SimpleConveyorModel.mdl
Simple Conveyor Model showing the problem
(5.49 KiB) Downloaded 1013 times
tomfid
Administrator
Posts: 3811
Joined: Wed May 24, 2006 4:54 am

Re: Problems with an aging chain using conveyors

Post by tomfid »

I think the short answer here is that 1yr is the mean time to leak, but some material leaks much sooner, and some much later. Hence the standard 1st-order time constant result, that 2/3 has leaked at t = 1 time constant, applies. This is obviously much different from the discrete case, where exactly 100% would have leaked.

I'll take a look at the model.
gwr
Senior Member
Posts: 209
Joined: Sun Oct 04, 2009 8:40 pm
Vensim version: DSS

Re: Problems with an aging chain using conveyors

Post by gwr »

Thank you, Tom.

The leakrate as it is implemented in Vensim's Conveyor Delay in its present form is misleading.

In a conveyor the inflow is pushed through the conveyor stock as it is so the profile of the inflow in time remains the same. If the fraction leaking is 100% (independent from the rate of leakage!) then nothing should come out - anything else imo is not an approximation but plainly wrong. In its present form the error is also dependent on the conveyance time, so a leak rate of 0.5 per year will mean a different amount of leakage given different conveyance times.

What should probably happen in a model with a leaking conveyor delay is that whenever something enters the conveyor at a given time step that amount should instantaneously be split into the leakage and what remains in that same time step. So the leakage should be flushed out into anouther stock in the same time step the material enters the conveyor (temorary stock of leaked material).

Then the material being in the temporary stock of leaked material might leak out in a first order delay which would then be an approximation given a time constant like TimeToLeak. The more appropriate discrete behavior might be that the outflow from the temporary stock of leaked material is a conveyor itself having a conveyance time equal to the TimeToLeak.

Kind regards,

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

Re: Problems with an aging chain using conveyors

Post by gwr »

Since this thread has been viewed very often I will relay the information given to me by Tony Kennedy (Vensim Support) as I consider it relevant to others:
I've raised this as a bug that needs fixing. There is little I can do for now about it, but it is in our system now so hopefully will get looked at very soon.

Kind regards,

Tony.
Maybe someone might in the meantime still work out a better mathematical fix to the problem than the one I have provided in my post above? After all I tend to find the discrete alternative to a conveyor-based aging chain (e.g. Vensim's SHIFT IF TRUE - formulation) not very satisfying to a rather continuous mindset of SD-modelers. :wink:

Guido
tomfid
Administrator
Posts: 3811
Joined: Wed May 24, 2006 4:54 am

Re: Problems with an aging chain using conveyors

Post by tomfid »

I haven't had a chance to work through it in detail, but I'm not convinced that this is a bug. The leakage fraction is not the fraction of material that leaks out over the duration of the delay (one minus the fraction that makes it through), but the fraction of the contents that leaks out per unit time. Therefore you'd expect some material to escape, even with a leakage fraction = 1.
tomfid
Administrator
Posts: 3811
Joined: Wed May 24, 2006 4:54 am

Re: Problems with an aging chain using conveyors

Post by tomfid »

Here's an alternate version of the model, with an interpretation of leakage that's consistent with the behavior.
SimpleConveyorModelCorrTF1.mdl
(6.06 KiB) Downloaded 1025 times
gwr
Senior Member
Posts: 209
Joined: Sun Oct 04, 2009 8:40 pm
Vensim version: DSS

Re: Problems with an aging chain using conveyors

Post by gwr »

Thanks a lot, Tom!

That solution works out fine and it does look a lot more elegant than my crude regression attempt. While I have not figured the logic behind your solution completely it looks very much like using the equivalent rate given (conveyance time / time step) - periods of compounding?

It would still - imho - be benefitial if the time to leak could be separated from the fraction eventually leaking so that the leak and the conveyor are decoupled as I had suggested in my previous post. One should start thinking in continuous terms (e.g. a first order draining process) only after the correct amount has leaked out of the discrete process thus introducing the time to leak as a separate parameter. If that kind of exactness is not needed one might very well not use conveyors at all and just use conventional structures like regular aging chains.

Kind regards,

Guido
tomfid
Administrator
Posts: 3811
Joined: Wed May 24, 2006 4:54 am

Re: Problems with an aging chain using conveyors

Post by tomfid »

Correct - the leak rate is calculated to yield the desired survival through the chain, with discrete compounding. If TIME STEP << conveyance time, the continuous version could probably be used with sufficient accuracy, though it's main virtue is that it's easier to read, so perhaps best to stick with discrete.

I think the challenge here is that there are several different real-world situations that one might want to represent. For example, there could be material in transit, and 10% of that per time is subject to theft. That's well represented by the current formulation. On the other hand, perhaps we're talking about pharmaceuticals, and some % is subject to expiration, which might be a discrete event at the end of the conveyor, rather than a discrete process.

We probably need to leave DELAY CONVEYOR alone for compatibility, but an additional function is an option if there's something it can't represent.
gwr
Senior Member
Posts: 209
Joined: Sun Oct 04, 2009 8:40 pm
Vensim version: DSS

Re: Problems with an aging chain using conveyors

Post by gwr »

Just for completeness with this post:

I have just now found some time to work with the aging chain model and I have started to implement Tom's formula to get the leaking work right in the way the model should work out. There are some numerical intricacies here though as can be seen running Tom's model (cf. his post above):

While the model will show proper behavior for pretty much any fractional leak rate entered it will not do so for a leak rate of 100% !

If the fractional leak rate is set to say 50% it will take exactly the timespan of conveyor time to do so (e.g. the conveyor time thus equals the time it takes to leak). Not so for a fractional leakrate of 100% here the leaking will take just one single time step making a big difference in the model (giving me ringing behavior for example). The cure should be to work with anumber arbitrarily close to one ( 0.9999...) which will show proper behavior taking its time to leak. And then maybe have a 100% leak rate later in the aging chain where it will not matter anymore to take care of the little numerical amounts that have passed through.

I certainly hope there will be some alternative for the DELAY CONVEYOR that will not have these kinds of problems.
tomfid
Administrator
Posts: 3811
Joined: Wed May 24, 2006 4:54 am

Re: Problems with an aging chain using conveyors

Post by tomfid »

What parameters are you using in the model (including TIME STEP)? For me, the linked SimpleConveyorModelCorrTF1.mdl works fine with FractionEventuallyLeaking = 1. Extremely high leak rates do beg the question, why bother with a stock or conveyor, but I agree that the tool should be robust to such extremes.
gwr
Senior Member
Posts: 209
Joined: Sun Oct 04, 2009 8:40 pm
Vensim version: DSS

Re: Problems with an aging chain using conveyors

Post by gwr »

tomfid wrote:What parameters are you using in the model (including TIME STEP)? For me, the linked SimpleConveyorModelCorrTF1.mdl works fine with FractionEventuallyLeaking = 1. Extremely high leak rates do beg the question, why bother with a stock or conveyor, but I agree that the tool should be robust to such extremes.
Tom,

I have been running the SimpleConveyorModelCorrTF1.mdl as given with time step of 0.0625. You can see the abrupt behavior change in the synthesim though (e.g. from leakrate just below 1 to exactly 1.0). In my latest model I am using half of that time stept and using your formula my age cohorts will be drained in one single time step!

You asked: "why bother with stocks or conveyors?" I would greatly appreciate any suggestion giving me a better suited appraoch. My goal was - and is - to build an aging chain for some assets using one-year-cohorts in order to report exact average ages. Since aging is an exact process where things put in do not overtake things that were put in before, the conveyor still seems the natural tool for this since using the shift if true with coflows tends to be rather tedious as opposed to "regular" flows.

In the model the age chain may have 20 cohorts in it (for flexibility) but the maximum age policy may have the assets be scrapped maybe at age 13 years. Next to this more old assets will be sold if the number of assets required is lowered (this should be a policy variable as well). So then you need to use the leak rates for selling/scrapping assets in a dynamic and adaptive way. How else can I build this without using the shif if true and its "unnatural behavior"? -- And if you need to flexibly sell or drain cohorts the need for 100% leak rates should become obvious.

Am I missing something - or is there a better alternative to do this?
tomfid
Administrator
Posts: 3811
Joined: Wed May 24, 2006 4:54 am

Re: Problems with an aging chain using conveyors

Post by tomfid »

OK - now I understand the problem - I'll have to ponder a bit. We have a nice solution for this in future Vensim, but it won't be available for a while.
gwr
Senior Member
Posts: 209
Joined: Sun Oct 04, 2009 8:40 pm
Vensim version: DSS

Re: Problems with an aging chain using conveyors

Post by gwr »

tomfid wrote:OK - now I understand the problem - I'll have to ponder a bit. We have a nice solution for this in future Vensim, but it won't be available for a while.
Great, Tom, and I am really, really looking forward to the "big release"!

... but what best advise can you offer to keep me a patient and loyal customer in the meantime :wink: ?

Solution 1:

If detailled keeping track of aging stocks is needed (e.g. to have a more precise average age etc.) then turn to the Shift-if-true with the downside of abrupt step-behavior next to a somewhat very different modeling philosophy so a shift-if-true model might not be easily modified maybe?

Solution 2:

Work with the patched up conveyor solution(as provided in your model - which is what I have been doing until now) which gives rise to some rounding issues and forfeits the possibility to model the time it takes for assets to be scrapped?

Solution 3:

Keep to System Dynamics dogma (?) of aggregation and use larger cohorts with a normal flow used for aging (best modeled with a higher degree delay in order to have less variation in the time it takes to age) while keeping cohorts small enough for the error in the average age to be small?

Solution 4:

Model each asset as an agent with a continuous aging process and another stock (=agent attribute) to keep track of entering and leaving the "fleet" and then aggregate these for the main model (hybrid approach)?


I sometimes wonder if solution 4 is not actually easier to model and understand than solution 1 and 2 once you have come up with the need to keep track of small entities while the focus in (most) other parts of the model is rather on the big picture (= System Dynamics)?
gwr
Senior Member
Posts: 209
Joined: Sun Oct 04, 2009 8:40 pm
Vensim version: DSS

Rebuilding the Conveyor with Fixed Delays

Post by gwr »

Tom,

I have enclosed a model that shows what I would like to have as regular "Conveyor Behavior". I have rebuilt a Conveyor using the DelayFixed. In Synthesim one can switch the Initial Material in the Conveyor between 0 and 1 widget. If there is 1 widget in the conveyor then that will be drained - thus assuming an intial flat distribution (using a lookup one might essentially achieve the same flexibility as in the conveyor structure).

For both, initial material and later inflow, the ConveyanceTime and the TimeToLeak can be chosen independently. There will be roundoff-error but that may be neglectable.

Am I missing something in your opinion or would such a structure be a feasible substitute for a conveyor, e.g. for usage in an aging chain under (stock)-management?

Kind regards,

Guido
Attachments
ConveyorModelPipelineDelay.vpm
Rebuilding the Conveyor with Pipeline-Delays
(30.98 KiB) Downloaded 875 times
tomfid
Administrator
Posts: 3811
Joined: Wed May 24, 2006 4:54 am

Re: Problems with an aging chain using conveyors

Post by tomfid »

I think there's a 5th option, which is using the QUEUE ATTRIB functions, where (one of) the attributes is the time of entry into the chain. That only works if the process is really FIFO, which isn't the case for conveyor leakage unfortunately. Otherwise, I tend to favor the SHIFT IF TRUE approach - the weird sawtooth tends to remain confined within the stock chain. Failing that, the quasi-agent approach works, if you can manage with a modest number of elements.

I'm still a bit puzzled about the instability issue with the simpleConveyorModel - it works fine for me with 100% leakage; the only issue is slight numerical inaccuracy in DP Vensim (final result = 2e-8 rather than 0).
gwr
Senior Member
Posts: 209
Joined: Sun Oct 04, 2009 8:40 pm
Vensim version: DSS

Re: Problems with an aging chain using conveyors

Post by gwr »

Unfortunately I tend to always use DouplePrecision Vensim DSS - so cheers to puzzlement.

I will have to check out the QUEUE ATTRIB functions more deeply now.

Regarding the SHIF IF TRUE:

I do not like that I have to copy that mechanism down to every attribute of the stocks (which I would have to do, dont I?). With a flow - even if it is a conveyor - I can build regular coflow structures wich makes it a bit easier.

ALso, while I may not have thought it through enough, I do find the modeling of the continuous management policy of the aging chain (e.g. getting rid of over capacity, building new capacity) more complex to built as you have to take care of when exactly the decision is taken. That in my opinion gives additional complexity.
gwr
Senior Member
Posts: 209
Joined: Sun Oct 04, 2009 8:40 pm
Vensim version: DSS

A general, generic solution to the conveyor problem?

Post by gwr »

@Tom and others:

I believe I have found what I am looking for: A rather general model structure (rather like a molecule) to represent a delayed process where some kind of leakage or draining takes place. The model is enclosed with this post.

Description of the model:
The material that arrives at some process is flushed in one time step into two separate stocks - one for the material to leak and one for the material that continues to be processed - governed by the fraction to leak. With this decoupling of the material in place one can then choose between any type of delay for the further flows out of the process (e.g. leakage/finished material). Should the order of the delay for the processed material be infinite a conveyor-like behavior could be achieved.

I would be grateful for further helpful suggestions or reports on any errors found.

Guido
Attachments
ProcessWithLeakageBasicModel.vpm
Delayed Process with Leakage
(32.8 KiB) Downloaded 917 times
gwr
Senior Member
Posts: 209
Joined: Sun Oct 04, 2009 8:40 pm
Vensim version: DSS

Re: Problems with an aging chain using conveyors

Post by gwr »

Dear Vensim - Support:

With great interest I do notice that exactly those issues that are touched in this thread have been addressed in more detail by a paper written by Bob Eberlein and James Thompson:

Eberlein, R. L. and Thompson, J. P. (2013), Precise modeling of aging populations. Syst. Dyn. Rev., 29: 87–101

http://onlinelibrary.wiley.com/doi/10.1 ... .1497/full

In that article an external function is mentioned, COHORT CONTROL. I am a bit surprised to find this mentioned as a function developed and supposedly documented in guess what: Vensim.

While that spreads some hope regarding the issue, it also raises a couple of questions I do find worthy of putting forward here:

Why is it that I do not find its documentation searching the reference?
Why is it that I do have to read the SDR while nobody here on this thread and in this forum has given any hints regarding that Vensim functionality and how to apply it?
(That paper has been received by the SDR on May 30th, 2012 - so such a function should have been known all the time that I have been asking about the issue!)
Where can I find it and how can it best be employed?

Kind regards,

Guido
Last edited by gwr on Wed Dec 04, 2013 4:19 pm, edited 1 time in total.
Post Reply