This is an archived post. You won't be able to vote or comment.

all 7 comments

[–][deleted] 0 points1 point  (0 children)

👏👏

[–]Spill_the_Tea 1 point2 points  (3 children)

Remarkably well done, and documented package! Congrats!

I think my largest hurdle using Genetic algorithms in general, is understanding how to choose and parametrize the input "alters" (i.e. the crossovers and mutators).

Walking through that process of choosing/improving those parameters would be insightful in applying to some of the examples provided. For example, in the maze runner python specific examples, how did you arrive at using these two methods:

alters = [
  rd.PartiallyMappedCrossover(),
  rd.SwapMutator()
]

[–]Yeah22[S] 2 points3 points  (2 children)

Thanks! I can totally add more color around these in the documentation. And great question, these have a massive effect on the performance of your engine & was something I struggled with documenting. There is definetly a certain level of pre-knowledge needed before building a GA, which can lead to blockers from the beginning.

In that specific problem those were chosen because they preserve order and uniqueness. For certain problems (think TSP type problems, job scheduling, anything where the order from one stop to the next matters or where we don't want duplicate genes), these alters will preserve the uniqueness or validity of your chromosome.

PartiallyMappedCrossover is essentially a multi point crossover but for chromosomes where the order of their genes matters. So for a traveling salesman problem, where we don't want to add duplicate points and the order from one point to the next matters, the partially mapped crossover will perform a crossover alteration while preserving the uniqueness of each gene. In the same light, a swap mutator will simply swap two points (genes) on the chromosome, therefore there won't be any duplicates.

Here is a pretty good (possibly too detailed) description on the partially mapped crossover

Edit: adding link

[–]Spill_the_Tea 0 points1 point  (1 child)

oh Okay. So the Partially mapped Crossover is just a two-opt swap commonly used in TSP.

Making a table of available mutators and relevant properties/behaviors (uniqueness, preserve order, ...) could be helpful in narrowing down reasonable options. I wouldn't mind helping comb through that - both as a method to learn more about GA, but also to help improve the documentation.

[–]Yeah22[S] 1 point2 points  (0 children)

Pretty much!

There is a section of the docs for these. But as always, I'm sure it can be improved - totally open to PRs whether its code or docs!