Setting maximum number of function calls in GA Metaheuristics

Probably a stupid question, but I cannot manage to pass the maximum number of function calls f_calls_limit to the optimizer since the following does not seem to have any effect

using Metaheuristics


function gogo() 

c = randn(10);

 A = randn(10, 10);

    function f(x)
        if issorted(x)
            
            return  c'*x, -999*ones(size(x)), [0.0]
        else
            
            return 2*c'*x, 999*ones(size(x)), [0.0]
        end
    end

bounds = repeat([0,100], 1, 10)
#information = Information(f_optimum = 0.0)
options = Options(f_calls_limit = 900000, f_tol = 1e-5, seed=1)
    @show options
 ga = GA(;crossover=SBX(;bounds),
                mutation=PolynomialMutation(;bounds),
                information=information,
                options=options,
                environmental_selection=GenerationalReplacement()
            );
 @show ga
 result = optimize(f, bounds, ga)
     @show minimizer(result)
    @show result
end
gogo()
1 Like

This seems like a question for @jmejia8 :smile:

Hey! Try to increase the number of iterations as well:

options = Options(f_calls_limit = 900000, iterations=10000, f_tol = 1e-5, seed=1)

Iterations and function calls should be automatically handled by the package when some is provided. Next release will solve this malfunction.

3 Likes