Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for multidimensional individuals #35

Closed
aahaselgrove opened this issue Sep 15, 2019 · 5 comments
Closed

Support for multidimensional individuals #35

aahaselgrove opened this issue Sep 15, 2019 · 5 comments

Comments

@aahaselgrove
Copy link
Contributor

I'm currently looking at a problem I'm trying to apply GA to which has 2D individuals. This implementation only supports 1D individuals but I don't see any reason not to support individuals of arbitrary dimension.

Major changes required are to getIndividual and population generation. The easy way to do this would probably be to change the dimensionality parameter N to instead specify the type of an individual.

What are your thoughts?

@phelipe
Copy link

phelipe commented Sep 16, 2019

If you are working with 2D arrays, you just need to write the fitness function to get a vector, the rest would look the same.

using Evolutionary
using Base.Iterators 
# Matrix 2x2
function eval_data(t::Matrix)
    ...
end

# x vector 4
function fitness(x::Vector)
    input = collect( partition(x, 2) )
    return eval_data( hcat(input...) )
end

es(fitness, 4)

@aahaselgrove
Copy link
Contributor Author

I considered this, but looking at the code, the restriction forcing inputs to be 1D vectors seems to be arbitrary and the only impact is on interpreting the initPopulation parameter - hence, my suggestion to widen support. I'm currently investigating this on a local fork.

@phelipe
Copy link

phelipe commented Sep 17, 2019

For me it makes no sense to use 2D arrays, you will have to modify the whole package, besides GA and DE consider vectors in their theoretical definition. As with convex optimization problems, you need to rewrite your problem before the solver can solve it.

@wildart
Copy link
Owner

wildart commented Sep 24, 2019

Majority of mutation and recombination operations work on vectors only. You'll need to write your own for 2D transfomations.

@wildart
Copy link
Owner

wildart commented May 2, 2020

Implemented in new api, see Docs/Dev/Population

@wildart wildart closed this as completed May 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants