Page 1 of 1

Smooth and initial value

Posted: Fri Mar 02, 2018 12:52 pm
by Sandra
Hi,
I have an auxiliary variable in my Vensim (DSS 7.2.) model named demand product.
My aim was to generate following variable:

smooth demand product = SMOOTH(demand product, 1)

I also tried:

smooth demand product = INTEG((demand product - smooth demand product), demand product)

The problem with both expressions is, that the initial value of smooth demand product is different from demand product (see figure).
vensimproblem.png
vensimproblem.png (20.98 KiB) Viewed 3370 times

Why does the level variable smooth demand product not use the initial value?

I hope you can help me.
Thanks!

Re: Smooth and initial value

Posted: Fri Mar 02, 2018 1:01 pm
by Administrator
Can you upload an example? My quick test here works exactly as I expect it to.

Re: Smooth and initial value

Posted: Fri Mar 02, 2018 1:14 pm
by Sandra
Small examples like the attached one works also fine. But when doing the same in my huge simulation model, the wrong calculations occur.
SmallExample.mdl
(3.58 KiB) Downloaded 235 times

Re: Smooth and initial value

Posted: Fri Mar 02, 2018 1:44 pm
by Administrator
I need an example that doesn't work in order to help you.

Re: Smooth and initial value

Posted: Fri Mar 02, 2018 1:52 pm
by Sandra
Oh, I think I found the problematic variable.
In the huge model, I used "demand per capita" as an auxiliary with initial.
I did the same now in the small example (attached). Indicated demand and desired demand show the problem described in the first post.
SmallExampleProblemFound.mdl
(4.25 KiB) Downloaded 242 times

Re: Smooth and initial value

Posted: Fri Mar 02, 2018 2:49 pm
by Administrator
ok. The active initial is causing the smooth to initialize with the "1", which is working correctly but very misleading.I'll raise this as a bug.

If you use the following, does it give you the answers you need?

Code: Select all

demand per capita = if then else ( Time = INITIAL TIME  , 1 , 
MIN( max per capita demand , 

   constant term * 
   power( GDP,income elasticity )  * 
   power( price, price elasticity )
) )

Re: Smooth and initial value

Posted: Fri Mar 02, 2018 3:35 pm
by tomfid
This doesn't seem like a bug to me; it's just that ACTIVE INITIAL is potentially treacherous. A fix would have to defeat the purpose of the function.

One thing you can do to debug things like this is to switch to the Diff integration method, which stores the initialization step. Then you can see the discontinuity:

Code: Select all

Time (Month)	0	0.03125	0.0625	0.09375	0.125	
"demand per capita" and its causes Runs:	Current	
demand per capita	1	.05419	.05413	.05407	.05402	
constant term	.01871	
GDP	--	4442	4443	4444	4444	
income elasticity	.2145	
max per capita demand	.06	
price	--	200	201.6	203.1	204.7	
price elasticity	-.1393	
Also, be sure to show warnings (Tools>Options>Settings>Show Warnings). The issue is being flagged here:

Code: Select all

WARNING:     ACTIVE INITIAL differences found.  Use Options>Setting to control reporting.    
WARNING:     -demand per capita- Initial=1 Active=0.0541873 has changed in value.    
WARNING:     -indicated demand- Initial=1.62e+08 Active=8.77834e+06 has changed in value.