andim / noisyopt

Python library for optimizing noisy functions.
http://noisyopt.readthedocs.io/
MIT License
89 stars 15 forks source link

minimizeCompass is increasing N to early? #22

Closed dsmic closed 8 months ago

dsmic commented 8 months ago

I do a noisy optimization, as I have a Monte-Carlo Integral, which is very expensive.

minimizeCompass increases N before it knows, that there are directions, which could be optimized with the actual N. This seems unnecessary expensive to me?

minimization starting
args ()
errorcontrol True
paired False
nit 1, Delta 0.3
H tensor(-1.3065) [ 3.25   0.342  5.695 11.8    0.39   1.6    0.75 ]
H tensor(-1.3144) [ 3.25   0.342  5.695 11.8    0.39   1.6    0.75 ]
H tensor(-1.2994) [ 3.25   0.342  5.695 11.8    0.39   1.6    0.75 ]
H tensor(-1.3032) [ 3.25   0.342  5.695 11.8    0.39   1.6    0.75 ]
H tensor(-1.3019) [ 3.25   0.342  5.695 11.8    0.39   1.6    0.75 ]
H tensor(-1.3019) [ 3.25   0.342  5.695 11.8    0.39   1.6    0.75 ]
H tensor(-1.2964) [ 3.25   0.342  5.695 11.8    0.39   1.6    0.75 ]
H tensor(-1.3056) [ 3.25   0.342  5.695 11.8    0.39   1.6    0.75 ]
H tensor(-1.3201) [ 3.25   0.342  5.695 11.8    0.39   1.6    0.75 ]
H tensor(-1.3013) [ 3.25   0.342  5.695 11.8    0.39   1.6    0.75 ]
H tensor(-1.3062) [ 3.25   0.342  5.695 11.8    0.3    1.6    0.75 ]
H tensor(-1.3010) [ 3.25   0.342  5.695 11.8    0.3    1.6    0.75 ]
H tensor(-1.3157) [ 3.25   0.342  5.695 11.8    0.3    1.6    0.75 ]
H tensor(-1.3123) [ 3.25   0.342  5.695 11.8    0.3    1.6    0.75 ]
H tensor(-1.2936) [ 3.25   0.342  5.695 11.8    0.3    1.6    0.75 ]
H tensor(-1.3023) [ 3.25   0.342  5.695 11.8    0.3    1.6    0.75 ]
H tensor(-1.3068) [ 3.25   0.342  5.695 11.8    0.3    1.6    0.75 ]
H tensor(-1.2945) [ 3.25   0.342  5.695 11.8    0.3    1.6    0.75 ]
H tensor(-1.2959) [ 3.25   0.342  5.695 11.8    0.3    1.6    0.75 ]
H tensor(-1.3060) [ 3.25   0.342  5.695 11.8    0.3    1.6    0.75 ]
H tensor(-1.3160) [ 3.25   0.342  5.695 11.8    0.345  1.6    0.75 ]
H tensor(-1.3140) [ 3.25   0.342  5.695 11.8    0.345  1.6    0.75 ]
H tensor(-1.3091) [ 3.25   0.342  5.695 11.8    0.345  1.6    0.75 ]
H tensor(-1.3068) [ 3.25   0.342  5.695 11.8    0.345  1.6    0.75 ]
H tensor(-1.2994) [ 3.25   0.342  5.695 11.8    0.345  1.6    0.75 ]
H tensor(-1.3195) [ 3.25   0.342  5.695 11.8    0.345  1.6    0.75 ]
H tensor(-1.3068) [ 3.25   0.342  5.695 11.8    0.345  1.6    0.75 ]
H tensor(-1.3004) [ 3.25   0.342  5.695 11.8    0.345  1.6    0.75 ]
H tensor(-1.3170) [ 3.25   0.342  5.695 11.8    0.345  1.6    0.75 ]
H tensor(-1.3108) [ 3.25   0.342  5.695 11.8    0.345  1.6    0.75 ]
new N 20
andim commented 8 months ago

Noisyopt will increase N if the evaluation of the function is so noisy that it believes there is too much statistical uncertainty to pick a direction for optimization.

Maybe you can reduce noise by using paired evaluation of your Monte Carlo integral using shared seeds?

Hope that helps, Andreas

dsmic commented 8 months ago

Yes, thanks. minimizeCompass seems to be very bad if one does not have good "scaling", and in this case it immediately increases the N. It would make more sense to increase it after the iteration is done, as it is increased after the direction with problems, so it does not help in the actual iteration anyway. But my main problem is, I do not know the response to the parameters before, so I can not set good scaling...

With minimizeSPSA I get two orders of magnitude faster results if one chooses a c as suggested.

And yes, I started using paired (I was avoiding it, as I do VEGAS and was trying to reuse the map and even changing the integration volume depending on the parameters)

Thanks a lot Detlef