3. Making It Real: Representing a Problem
Before a Genetic Algorithm can solve a problem, the potential solutions must be encoded in a format the algorithm can understand—the Chromosome. The choice of representation is crucial and depends entirely on the nature of the problem.
- Binary Representation: This is ideal for problems that involve a series of “yes” or “no” decisions.
- Example: 0/1 Knapsack Problem. The goal is to choose which items to put in a knapsack to maximize value without exceeding a weight limit. A solution can be represented as a string of bits (0s and 1s), where a 1 at a certain position means an item is picked, and a 0 means it is not.
- Permutation Representation: This is perfect for problems where the order of things is the solution.
- Example: Travelling Salesperson Problem (TSP). The goal is to find the shortest possible route that visits a set of cities exactly once. A solution is naturally represented as a permutation—an ordered list—of the cities.
By combining a suitable representation with the evolutionary cycle, Genetic Algorithms become a flexible and powerful tool.