I have a problem I want to solve using genetic algorithms (GA). You can simplify it to the following problem:
I want to optimize the car pool of a company, which means, the number of cars and car models. I already have a fitness function calcFitness(carList)
which evaluates given setups like 'business car, transporter' or 'business car, business car, transporter'. Now, the question is, how do I solve this variable length problem using GA.
I have four ideas how you could tackle these problems generally:
What do you think about these general approaches? Any other ideas or perhaps alternatives to GA for these variable length cases?
Variable length is certainly possible, and the most natural representation of this problem, it seems. Why would it be an issue? The only substantial difference will be in the crossover operation. While a single-point is trivial (you just pick a point within a
, a point within b
, and automatically get a variable-length offspring), it is often better to have continuous crossover which requires some more intuition with variable lengths. But that can be implemented later following a thorough separate testing.
Be prepared that your algorithm may find out that the better the chromosome the better results (under some combination of circumstances) it can produce. You don't get exponential bloat like in genetic programming (where the genotypes are trees rather than linear sequences) but still the chromosome length may start growing uncomfortably. You may need to account for that in the fitness function, or you may model a solution like #2 by rejecting candidates surpassing some limit right away.