Closed ndgnuh closed 3 years ago
Yep, it's a bug. The initialization of the NonDifferentiable
should be done better. Currently, the result of the objective function must have the same type as an element of the individual of the population. Otherwise, multiple functions has to be overridden to make it work. That is wrong.
zero
valueThanks, this workds for me (and shouldn't break the API)
function initialize_objective(f, x::AbstractArray{T}, S = typeof(f(x))) where T
NonDifferentiable{S,typeof(x)}(f, zero(S), zeros(T, length(x)), [0,])
end
initialize_objective(f, first(individual))
I met this issue while trying to use GA to solve the travelling salesman problem. The code to reproduce this issue is fairly simple, so I'll just paste it here: