A real-valued genetic algorithm (GA) encodes each chromosome with real numbers rather than binary or Gray-coded strings. It suits continuous variables and real-valued parameters such as curve coefficients, PID controller settings, function inputs, and neural-network weights. Direct real-valued encoding preserves search-space smoothness, improves precision, and can reduce encoding complexity. section 8.2
Use genetic operators that exploit continuous values directly:
- Apply single arithmetic crossover by choosing one gene and replacing it with a weighted average of the parents. section 8.2.1
- Apply simple arithmetic crossover by averaging genes after a crossover point, or whole arithmetic crossover by averaging every gene. section 8.2.1
- Use simulated binary crossover (SBX) to generate offspring near their parents while balancing exploration and exploitation. section 8.2.1
- Mutate genes with Gaussian, Cauchy, boundary, or polynomial perturbations; adjust standard deviation or distribution index to control search distance. section 8.2.2
Curve fitting with four real-valued genes
Fit the third-order polynomial y = ax³ + bx² + cx + d by treating a, b, c, and d as a chromosome. Evaluate each candidate with mean squared error against the points x = 0, 1.25, 2.5, 3.75, 5 and y = 1, 5.22, 23.5, 79.28, 196. A demonstrated best fit uses a = 2, b = −3, c = 4, and d = 1. A Python implementation can define the problem with four variables bounded from −10 to 10, use float sampling, SBX, polynomial mutation, a population of 50, and 100 generations in pymoo. section 8.2.2
| Child1Genei = α × Parent1Genei + (1 – α) × Parent2Genei Child2Genei = α × Parent2Genei + (1 – α) × Parent1Genei |
Use the arithmetic-crossover equations to see how a random weight α combines corresponding parent genes into two children. section 8.2.1
