3.0 Step 1: Designing the Genotype – Representing Solutions
The choice of genotype is arguably the most critical design decision in any GA implementation; it dictates the very structure of the search space and the efficacy of the genetic operators. This choice is highly problem-specific and has a direct and profound impact on the GA’s performance. An effective representation facilitates the generation of meaningful and improved offspring, while a poor one can severely hinder the algorithm’s ability to converge on a high-quality solution.
3.2.1. Binary Representation
This is one of the simplest and most common representations, where the genotype is a string of bits (0s and 1s). It is the natural choice for problems involving Boolean decision variables.
- Suitable Application: The 0/1 Knapsack Problem is a classic example. If there are n items, a solution can be represented by a binary string of length n, where the bit at each position indicates whether the corresponding item is included (1) or not (0). For numerical problems, standard binary encoding can be problematic due to the “Hamming cliff,” where a small change in a number (e.g., from 7 to 8) requires flipping many bits (0111 to 1000). This can disrupt the search. This issue is mitigated by using Gray Coding, where adjacent numerical values differ by only a single bit flip.
3.2.2. Real-Valued Representation
For problems where the decision variables are continuous, a real-valued (or floating-point) representation is the most natural fit.
- Suitable Application: Optimizing functions with continuous parameters, such as tuning the weights in a neural network or solving engineering design problems where dimensions or temperatures can vary continuously.
3.2.3. Integer Representation
This representation is useful when genes can take on a discrete set of values that are not simply binary.
- Suitable Application: Problems where variables are discrete integers. For instance, if a problem required encoding the four cardinal directions, they could be represented as integers {0, 1, 2, 3} for North, South, East, and West.
3.2.4. Permutation Representation
For problems where the solution is defined by a specific ordering or sequence of elements, a permutation representation is essential.
- Suitable Application: Ordering problems like the Travelling Salesperson Problem (TSP), where the goal is to find the shortest tour that visits a set of cities exactly once. The solution is naturally represented as a permutation of the cities.
Once a representation for a single solution (chromosome) has been established, the next logical step is to create and manage a collection of them in the population.