Skip to content

Trait based impl. of OrderOneCrossover and PartiallyMappedCrossover#12

Open
pka wants to merge 1 commit intoinnoave:masterfrom
pka:trait-based-order
Open

Trait based impl. of OrderOneCrossover and PartiallyMappedCrossover#12
pka wants to merge 1 commit intoinnoave:masterfrom
pka:trait-based-order

Conversation

@pka
Copy link

@pka pka commented Nov 5, 2017

Hi,
I've changed OrderOneCrossover and PartiallyMappedCossover to a trait based implemenation, because I wanted to have my permutation encoding in something different than Vec<usize>. Since I'm an absolute beginner in the field of GAs, I don't know whether my approach makes sense though.
Thanks for your great work!
Pirmin

@codecov
Copy link

codecov bot commented Nov 5, 2017

Codecov Report

Merging #12 into master will increase coverage by 0.98%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #12      +/-   ##
==========================================
+ Coverage   65.85%   66.83%   +0.98%     
==========================================
  Files          21       21              
  Lines         940      968      +28     
==========================================
+ Hits          619      647      +28     
  Misses        321      321
Impacted Files Coverage Δ
src/recombination/order.rs 93.33% <100%> (+1.22%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a0af2e3...66c6c1a. Read the comment docs.

@haraldmaida
Copy link
Member

haraldmaida commented Nov 6, 2017

Can you please eleborate on your use case/example? It would help to think about, whether the generic implementation makes sense.

My thoughts on why a chose Vec are the following:

For example think about the travalling salesperson problem (TSP), which is a famous example for permutation encoded genomes. We have a Vec<City>. Now we want to find the shortest route that includes all cities once. The crossover and mutation operators change the order of the cities but do not change the cities itself. Therefore I would encode the order in the genome. The order of the cities can be represented by a Vec of indexes into the Vec<City>. Indexes in Rust are of type usize, hence the Vec<usize>. If I'm not mistaken any permutation encoding problem can make use of this pattern. But maybe its due to my lack of experience with GA and a generic implementation would make more sense.

That is also the reason why I differentiate between phenotype and genotype in this lib. phenotype is the representation of one solution to the world, e.g. Vec<City> in the TSP example. The genotype defines the properties (or genes) that are relevant to evolve one generation to the next and which cause the change of the fitness value, e.g. the order (Vec<usize>) in which the cities are visited determine the total length of the route, which in fact is the fitness of the route.

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

Successfully merging this pull request may close these issues.

2 participants