CMAEvolutionStrategy.jl
CMAEvolutionStrategy.jl copied to clipboard
ask-tell interface
Hello,
we are currently using the python-cma and are thinking about switching to julia. In Python, we use especially the functions es.stop(), es.ask(), es.tell() to controll the optimization as well as es.disp(), es.logger.add(), es.best.f, es.best.x, es.best.x.tolist, es.result_pretty().
Is there a way to use stop, ask and tell in your package in a similar way and can you expand the documentation a bit on how logging is done?
Thanks in advance Patrick
If I'm just using the minimize-function in this package I am wondering how I can pass additional (keyword)-arguments to the function that I want to optimize - that might be a possibility in our case to not use stop/ask/tell
Sorry to reach out to you via this issue in multiple comments. I'm facing problems to get the CMA to work even with a very simple setup. My function to minimize looks like transformation_path(::Array{Float64}; swi_write_results, swi_write_jahresordner, swi_random_wetter), but the minimize-function doesn't send an Array, but something else, so I'm getting a MethodError no method matching transformation_path(::SubArray{Float64, 1, Matrix{Float64}, Tuple{Base.Slice{Base.OneTo{Int64}}, Int64}, true})
Also setting the constraints with constraints=[0.,1.] leads to the error no method matching backtransform!(::Vector{Float64}, ::Vector{Float64}) - which looks a little bit strange to me ;-) in which forms do I need to put the constraints?
transformation_path(::Array{Float64}; kwargs...) is rather restrictive (maybe too restrictive?). If necessary, I could check for this case and adapt the code accordingly. Currently, transformation_path(::AbstractArray{Float64}; kwargs...) should work.
To handle keyword-arguments I usually use anonymous closures, e.g. I would pass the function x -> transformation_path(x, swi_write_results = some_value) to minimize.
If you have just box constraints, you could use the lower and upper keyword arguments. I should better document this.
Regarding ask-tell interface, I would have to think a bit more, but I don't have the time this week. I'll come back to it asap.
Thank you for the fast reply! Switching to transformation_path(::AbstractArray{Float64}; kwargs...) helped indeed and it seems like not being a big performance problem. And thanks for the tip with the anonymous closures, I have to test that at a later stage, as our code is a little bit confusing there ;-)
Setting lower and upper now also works. My mistake was that I wanted to set one lower/upper boundary for all values via minimize(..., lower=0.0, upper=1.0) or minimize(..., constraints=(0.0, 1.0) - which would actually be a nice feature instead of needing to pass an array (but of course works like that as well).
And thanks for looking into an ask-tell interface. There's no need to rush from our side :) Maybe we can also adapt our code or use a workaround with stopping the optimizer like you explained in #6