A genotype is the chromosome-based encoding of an organism in a genetic algorithm. For a 0–1 knapsack, each bit records whether an item stays on Earth or enters the Mars-bound crate. The encoded solution is the phenotype: the goods selected by the chromosome. section 18.1.2
Use the representation deliberately:
- A binary genotype provides one position per item; 0 excludes the item and 1 includes it. section 18.1.2
- Different genotypes can encode different phenotypes, while identical genotypes produce the same solution and fitness in this knapsack model. section 18.1.2
- Nonbinary genotypes require operators that preserve valid value constraints, and genotype changes can alter phenotype features. section 18.1.2 section 18.1.5
Knapsack encoding
Two chromosome strings can select different cargo sets: one takes wheat flour and tomatoes; another takes wheat flour, rice, and beans. The latter represents the best solution for the illustrated instance. section 18.1.2
Figure 18.4 Examples of encoding chromosomes for the knapsack problem (the specific instance described in section 1.4). Two figures are shown: the differences in the genotypes (the two strings) are reflected in the phenotypes (the goods taken to Mars: wheat flour and tomatoes versus wheat flour, rice, and beans). The latter chromosome encodes the best solution for the instance of the problem summed up in table 18.1.
Compare chromosome strings directly with the cargo they encode; the figure makes genotype–phenotype differences visible. section 18.1.2

