1

I'm trying to write a genetic algorithm for pieces of ride track, and thinking about how to implement mutation/crossover. The goal is to evolve a) a complete loop and b) an exciting ride (I have criteria for this).

I have about sixty pieces to choose from but not all of them are compatible with each other. For example, a track piece may be banked left and another track piece may be banked right.

When allowing mutations, I could make an effort to only allow track pieces to mutate to other pieces with compatible angles. Or, I could only crossover two tracks at points that share the same angle. However this may limit the ability to do advanced explorations that may be fruitful down the line.

A parallel for the popular "Hello World" example would be, you are trying to generate any valid word, or any valid sentence. English has a rule (made up for this example, no idea if it's true) that a consonant can never follow a Z. Should you only allow vowels to mutate after a Z?

Does that make any sense? Or should you just allow every type of mutation and discard the bad ones?

Amar Syla
  • 3,523
  • 3
  • 29
  • 69
Kevin Burke
  • 61,194
  • 76
  • 188
  • 305

2 Answers2

2

Two approaches you could try:

  • manage the "piece compatibility requirement" as a constraint and use a bi-dimensional vector as fitness value.

    The first element would be the result of a penalty function applied to a track (measuring the amount of constraint violation, e.g. the sum of deviations of a track-piece from the maximum allowed angles)

    The second element the standard, base objective function.

    When comparing two fitness values:

    1. any feasible solution is preferred to any infeasible solution
    2. among feasible solutions, the one having better objective function value is preferred
    3. among infeasible solutions, the one having smaller constraint violation is preferred

    In this way you'd apply a selective pressure for infeasible solutions to come closer and inside the feasible region (but infeasible solution are allowed for exploration).

    This is the approach described in An Efficient Constraint Handling Method for Genetic Algorithms - Kalyanmoy Deb

  • try an approach similar to the automated synthesis of analog electrical circuits by means of genetic programming.

    Program trees have to be mapped to tracks via a growth process that begins with a simple "embryonic track". The track circuit is progressively developed by applying various functions in a track-constructing program tree.

    Probably the functions in the circuit-constructing program trees can be grouped by compatible signatures and strongly typed genetic programming approach could be viable.

manlio
  • 18,345
  • 14
  • 76
  • 126
0

A different way to what manlio answered is the use of an indirect encoding. You can design such encoding that ensures validity of all solutions. Look at Grammatical Evolution and the way the solutions are encoded or even use it directly with a grammar that describes your solutions.

zegkljan
  • 8,051
  • 5
  • 34
  • 49