Evolutionary.jl icon indicating copy to clipboard operation
Evolutionary.jl copied to clipboard

can't store iters, fitness, and best minimizer via callback

Open jpp46 opened this issue 5 years ago • 1 comments

I have been trying to store

  1. the current number of iterations
  2. the best fitness found so far
  3. the genome of the individual with that value Through a callback function and have been trying to work with trace to get there right information into the callback.

When I don't override the trace function can call I get: fieldnames(typeof(oc)) = (:iteration, :value, :metadata) for the value of os

If I override the trace! function and set store_trace to true, no matter what I add to the dictionary I get fieldnames(typeof(tr)) = () for the value of tr that I can see gets passed in in this case

I feel like this should be possible.

Maybe one solution would be to give the callback function an intermediate state of the results such that this would work:

function callback(intermediate_res) items = Evolutionary.iterations(intermediate_res) best_indv = Evolutionary.minimizer(intermediate_res) best_fit = minimum(intermediate_res) . .

Code to save values

. return false end

jpp46 avatar Jul 10 '20 23:07 jpp46

Here is a docs page about traces: Look here: https://wildart.github.io/Evolutionary.jl/dev/tutorial/#Trace-1

This is an example of using it https://github.com/wildart/Evolutionary.jl/blob/30d677fcfc19d517f2a974a00bafda34656c468c/test/onemax.jl#L7-L10

wildart avatar Jul 13 '20 23:07 wildart