Binary representation encodes each solution component as 0 or 1. In a selection problem, 0 means excluded and 1 means included, turning a complete candidate into a fixed-length bit string. section 4.4 section 4.5
Use binary representation when:
- The decision for each component is naturally yes/no or on/off, such as selecting items for a knapsack. section 4.4 section 4.5
- You want compact chromosomes and potentially fast computation using primitive values. section 4.5
- Choose another encoding when solutions require precise decimal values, item quantities, or ordered sequences. section 4.5 section 5.6
A knapsack chromosome
For 26 available items, create a 26-character chromosome. At each position, write 0 to leave the corresponding item out or 1 to include it. A mutation then selects a gene and flips its value: 1 becomes 0, while 0 becomes 1. section 4.5 section 4.15
Figure 4.11 Binary-encoding the Knapsack Problem
A visual mapping between knapsack items and their binary gene positions makes the fixed-length representation easy to inspect. section 4.4





