Problems with "Find zero" convergence

Use this forum to post Vensim related questions.
Post Reply
sosorior
Junior Member
Posts: 16
Joined: Mon Oct 28, 2013 8:11 pm
Vensim version: DSS

Problems with "Find zero" convergence

Post by sosorior »

Hello, I'm having problems with the function "find zero". I have an error when running. It says "FIND_ZERO did not sufficiently zero" at several times and I have serious problems of convergence (differences up to 50000).
I'm using find zero in order to find a price at which some amounts of supply and demand equal. Then, the find zero function depend on the allocation functions "demand at price" and "supply at price".
Do you know what can I do to improve function convergence?
Tom, If you need I can email you my model with all the attachments, could you please give an email?
Administrator
Super Administrator
Posts: 4592
Joined: Wed Mar 05, 2003 3:10 am

Re: Problems with "Find zero" convergence

Post by Administrator »

That warning usually appears when it cannot find a solution. Have you verified that there is a solution when the warning appears?
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
tomfid
Administrator
Posts: 3811
Joined: Wed May 24, 2006 4:54 am

Re: Problems with "Find zero" convergence

Post by tomfid »

Have you scaled your input vectors to order of magnitude 1? There may be numerical precision issues if not.
sosorior
Junior Member
Posts: 16
Joined: Mon Oct 28, 2013 8:11 pm
Vensim version: DSS

Re: Problems with "Find zero" convergence

Post by sosorior »

I use zs=one such as the example of the vensim help. What do you mean exactly with "scaling the vector"?. I'm going to explain you briefly what I'm doing: It is about energy arbitrage. I use FIND ZERO to find a bid price. This is the price at which they bid at certain hours and with this price, I calculate the maximum price at which they buy energy. Then, the energy bought should equal the energy sold. My formulation is as follows. I'd be grateful you can help me.

Bid price=
find zero(one,Assessment pumping equality,one,Init value bid price,1,0,1,1e+007,1)

Bid price per hour[Hour]=
Bid price*Control pumping endogenous

Max purchase price for PSP[Hour]=
Bid price per hour[Hour]*PSP efficiency

Assessment availability per PDC[Hour,PDCaux]=
supply AT PRICE(Assessment residual supply after exports[Hour,PDCaux],Assessment Residual supply profile[Hour,PDCaux,ptype],Max purchase price for PSP[Hour])

Assessment allocability per PDC[Hour,PDCaux]=
DEMAND AT PRICE(Assessment total supply[Hour,PDCaux],Assessment dispatch profile[Hour,PDCaux,ptype],Bid price per hour[Hour])

Assessment allocability per hour[Hour]=
sum(Assessment allocability per PDC[Hour,PDCaux!])

PSP demand[Hour]=
Min(Pumping capacity*Pump availability,sum(Assessment availability per PDC[Hour,PDCaux!]))

Water pumped=
sum(PSP demand[Hour!])

Water needed for PSP generation=
sum(Assessment allocability per hour[Hour!])/PSP efficiency

Assessment pumping equality=
(Water needed for PSP generation-Water pumped)^1
Administrator
Super Administrator
Posts: 4592
Joined: Wed Mar 05, 2003 3:10 am

Re: Problems with "Find zero" convergence

Post by Administrator »

If you can post the model we can take a look.
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
sosorior
Junior Member
Posts: 16
Joined: Mon Oct 28, 2013 8:11 pm
Vensim version: DSS

Re: Problems with "Find zero" convergence

Post by sosorior »

Can you give an email?
Administrator
Super Administrator
Posts: 4592
Joined: Wed Mar 05, 2003 3:10 am

Re: Problems with "Find zero" convergence

Post by Administrator »

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
tomfid
Administrator
Posts: 3811
Joined: Wed May 24, 2006 4:54 am

Re: Problems with "Find zero" convergence

Post by tomfid »

In this case, the scaling factors should not be 1:
zs is a scaling vector for z. After multiplying z by this vector the results should all be of the order of magnitude of 1. zs must be a vector of the same length as x and will often be a vector of ones.
http://www.vensim.com/documentation/fn_find_zero.htm

Since X and Z are on the order of 100 to 10000, the scaling factors should be order of .01 to .0001.
tomfid
Administrator
Posts: 3811
Joined: Wed May 24, 2006 4:54 am

Re: Problems with "Find zero" convergence

Post by tomfid »

An implicit assumption in the FIND ZERO function is that the response of the vector to be zeroed to the control vector to be set meets some reality checks. For example, it needs to be continuous and have a gradient everywhere. Otherwise the algorithm can easily get stuck on flat spots, local minima or discontinuities that are barriers to finding a solution.
sosorior
Junior Member
Posts: 16
Joined: Mon Oct 28, 2013 8:11 pm
Vensim version: DSS

Re: Problems with "Find zero" convergence

Post by sosorior »

Thank you Tom
As this is an electricity market model, i have some discontinuities in the supply curve. I understand the limitations that this create on the find zero function and I'm working on a different way to solve it, and thanks to your help know I understand better the nature of my problem (zero might not exist). I will tell you if the new idea works.
Thanks for your fast responses
sosorior
Junior Member
Posts: 16
Joined: Mon Oct 28, 2013 8:11 pm
Vensim version: DSS

Re: Problems with "Find zero" convergence

Post by sosorior »

Hello Vensim team again
Since the last time I advanced significantly on my model. Now I'm trying to implement a different exports dispatch and I need to use simultaneous equations and find zero so as to price to converge. However, vectors sizes of x and z are different and I have not been able to find a find zero formulation that works. I'm not working on the big model as I preferred to try on a very simple one. I'm trying to allocate an amount A between two countries, which demand depends on a function Q(P), which in turn depends on the price. Since in the big model, Q will depend on other variables, as well, I cannot use the allocate functions. That is why I tried to implement a find zero function in which the amount available must equal the sum of quantities exported. However, I cannot get any results because of floating point errors, which I guess are caused by the dimensions of the scale vectors. Could you please give a look at it?
Also, is it possible to include two variables that should be zero, i.e., two z's, in order to find the x?
Thank you
Attachments
Simultaneous find zero several exports.mdl
(7.03 KiB) Downloaded 168 times
tomfid
Administrator
Posts: 3811
Joined: Wed May 24, 2006 4:54 am

Re: Problems with "Find zero" convergence

Post by tomfid »

I'm happy to look at it after the SD conference.
tomfid
Administrator
Posts: 3811
Joined: Wed May 24, 2006 4:54 am

Re: Problems with "Find zero" convergence

Post by tomfid »

I think the issue is that Difference Quantity isn't a vector. The first four arguments all need to have the same dimension. It should be possible to reformulate this problem to work, perhaps by computing a single shadow price and deriving exports from that. I'll have to think about it.
tomfid
Administrator
Posts: 3811
Joined: Wed May 24, 2006 4:54 am

Re: Problems with "Find zero" convergence

Post by tomfid »

FIND ZERO dispatch.mdl
(7.02 KiB) Downloaded 181 times
The above setup might work. It needs demand/supply curves and parameters, but hopefully you can guess the intent from the units & names.

The purpose of the "unserved" item is to permit convergence even in extreme conditions (low supply and inelastic high demand) by dispatching brownouts.

Since FIND ZERO requires dimensionless x & z, I tend to make scale those to ~1 and use multipliers (ref price and supply scale) to convert to/from real units separately. Same result, but clearer.
Post Reply