4.0 Genotype Representation: Encoding Solutions for Evolution
The choice of how to represent a solution is one of the most critical steps in designing a successful Genetic Algorithm. An improper representation can severely hinder the GA’s performance, making it difficult for the genetic operators to explore the search space effectively. The representation defines the mapping between the real-world problem (phenotype) and the computational encoding (genotype) and must be tailored to the specific problem being solved.
4.1 Binary Representation
This is the simplest and one of the most widely used representations, where the genotype consists of a string of bits (0s and 1s). It is the natural choice for problems involving Boolean decision variables.
- Best Suited For: Problems like the 0/1 Knapsack Problem, where for each item, the decision is a simple “yes” (1) or “no” (0).
- Potential Pitfall: When encoding numerical values, a single bit-flip mutation can have an outsized effect on the number’s value (e.g., flipping the most significant bit). This can be mitigated by using Gray Coding, an alternative binary encoding where adjacent numbers differ by only a single bit, leading to more gradual changes.
4.2 Real-Valued Representation
For problems where the decision variables are continuous, a real-valued (or floating-point) representation is the most natural choice. Each gene in the chromosome is a real number.
- Best Suited For: Problems involving tuning continuous parameters, such as in engineering design or function optimization.
- Limitation: The precision of the solution is inherently limited by the computer’s floating-point representation.
4.3 Integer Representation
This scheme is used when genes can take on one of a discrete set of values that are not simply binary.
- Best Suited For: Problems where variables can be chosen from a finite set. For example, if a variable represents a direction, it could be encoded with integers: North {0}, South {1}, East {2}, and West {3}.
4.4 Permutation Representation
For many problems, the solution itself is an ordering of a set of elements. In these cases, a permutation representation is the most appropriate. The chromosome is a list of elements where the order is significant.
- Best Suited For: Ordering and scheduling problems. A classic example is the Traveling Salesman 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 (e.g., [City 3, City 1, City 4, City 2]), where the order defines the path the salesman takes. This direct mapping makes it easy for problem-specific genetic operators to manipulate and evaluate potential tours.
Having explored how to represent individual solutions, we now turn our attention to the management of the entire collection of these solutions—the population.