dietmarwo / fast-cma-es

A Python 3 gradient-free optimization library
MIT License
122 stars 18 forks source link

Stall iterations in BiteOpt #15

Closed avaneev closed 2 years ago

avaneev commented 2 years ago

I've checked your fix to stall iterations handling. If stall_iterations is a value 0,1,2,3 (in documentation), you have to multiply it by 64. Please fix this. This applies to Java version as well, not only Python. Orig:

            if (stall_iterations > 0 && stallCount > stall_iterations*dim) {
                stop = 2;
                break;
            }

Fixed:

            if (stall_iterations > 0 && stallCount > stall_iterations*64*dim) {
                stop = 2;
                break;
            }
avaneev commented 2 years ago

It would even be better this way: if (stall_iterations > 0 && stallCount > stall_iterations128dim) { stop = 2; break; }

dietmarwo commented 2 years ago

Your proposed change should be consistent with the documentation:

stall_iterations : int, optional 
    Terminate if stall_iterations stalled, Not used if <= 0

I agree that the parameter should be consistent between your C++ version and the Python wrapper.

If stall_iterations is a value 0,1,2,3 (in documentation),

To which documentation do you refer exactly?

stallcount is incremented for each function evaluation. So one possibility to clarify things would be to rename the parameter and remove any factor:

if (stall_evaluations > 0 && stallCount > stall_evaluations) {

Or, if the term "iteration" is defined for BiteOpt somewhere. and it includes 64dim evaluations, then your proposal would fit. Or is it 128dim evaluations?

Anyway, the default is that it is not used at all (stall_iterations = 0) and we have to make sure, that the user understands, what a configured value means.

avaneev commented 2 years ago

It will be better to rename "stall_evaluations" to "stall_criterion" and use stallCount > stall_criterion*128*dim expression. The reason for defining it as a value from 0, 1, 2, 3 is that a direct stalling multiplier (128 or 64) depends on the method version. Previously, 64dims was adequate. Now 128dims is adequate. It will be easier for the user to just define e.g. stall_criterion=1 or stall_criterion=2. In biteopt_minimize function it's defined the same way (see stopc variable).

dietmarwo commented 2 years ago

Thanks for the clarification. Will update both the java and the python version as suggested (version 1.3.32 will contain the fix).

avaneev commented 2 years ago

Thanks!