Potential bug in constant elasticity priority profile

Use this forum to post Vensim related questions.
Post Reply
eneko
Junior Member
Posts: 4
Joined: Tue Jun 28, 2022 12:38 pm
Vensim version: DSS

Potential bug in constant elasticity priority profile

Post by eneko »

Hi Vensim developers and users,

I may have found a bug in the implementation of constant elasticity priority profile functions in Vensim.

I have been working with the ALLOCATE AVAILABLE function. I have seen that when the priority profile is a constant elasticity function (numeric value 5), there could be some discontinuities. The example below:

Code: Select all

allocation[branch]= 
	ALLOCATE AVAILABLE(demand[branch], priority[branch,ptype], available) 
	~	 
	~		| 

available= 
	20*Time 
	~	 
	~		| 

branch: 
	Boston, Dayton, Fresno 
	~	 
	~		| 

demand[branch]= 
	500, 300, 750 
	~	 
	~		| 

pprofile: 
	ptype, ppriority, pwidth, pextra 
	~	 
	~		| 

priority[branch,pprofile]= 
	5,5,2,1; 
	5,7,4,2; 
	5,3,4,3; 
	~	 
	~		| 


Produces the following output:
allocation
allocation
c_e1.png (18.83 KiB) Viewed 782 times
This happens also when the constant elasticity function is mixed with other profiles:

Code: Select all

allocation 0[branch]= 
	ALLOCATE AVAILABLE(demand[branch], priority 0[branch,ptype], available) 
	~	 	
	~		| 

priority 0[branch,pprofile]= 
	3,5,1,0; 
	3,7,2,0; 
	5,3,2,3; 
	~	 
	~		| 
allocation 0
allocation 0
c_e2.png (18.17 KiB) Viewed 782 times
I suppose that this happens because the image of this profile function, against the others, is not totally contained in the range [0, request] when pwidth != ppriority (i.e. image(priority_func(x)) != [0, request]);
q(x) = q0 * (x/ppriority)^(-pextra) if x > pwidth
q(x) = q0 * (pwidth/ppriority)^(-pextra)if x <= pwidth


This could easily be solved with a transposition for x and a redefinition for the second equation:
q(x) = q0 * ((x-pwidth+ppriority)/ppriority)^(-pextra) if x > pwidth
q(x) = q0 if x <= pwidth
See some examples for both definitions below:
Constant elasticity functions
Constant elasticity functions
cons_elas.png (43.3 KiB) Viewed 782 times


I suppose that a similar problem may happen with the constant elasticity supply function when using the many-to-many allocation.

I hope my explanation was clear.

Cheers,
Eneko
eneko
Junior Member
Posts: 4
Joined: Tue Jun 28, 2022 12:38 pm
Vensim version: DSS

Re: Potential bug in constant elasticity priority profile

Post by eneko »

I forgot to say that I am using Vensim DSS 9.2.4 x64 in Windows.
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Re: Potential bug in constant elasticity priority profile

Post by tomfid »

Can you post your sample model?
eneko
Junior Member
Posts: 4
Joined: Tue Jun 28, 2022 12:38 pm
Vensim version: DSS

Re: Potential bug in constant elasticity priority profile

Post by eneko »

Yes. Please, find the sample model below:
test_allocate_available.mdl
(2.7 KiB) Downloaded 92 times
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Re: Potential bug in constant elasticity priority profile

Post by tomfid »

It took me a while to get into this, but I think you've identified a bug in the behavior for large allocations. I haven't found the particular line of code, but I think the algorithm is limiting the range of priorities considered in some cases, and that leads to the discontinuity.

I don't think we want to change the definition of the curves however. The range consideration you identify indicates that there's an unstated constraint on the pwidth priority, which is that pwidth should be >= ppriority in order to realize sensible behavior where q0 is a possible output. Instead we'll note this in the documentation.

The bug will obviously be fixed though.
Post Reply