Genetic Algorithm Maximization
1. **Problem Statement:**
We want to maximize the function $$f(x) = x^2 + 3x$$ where $$x$$ is an integer in the interval $$[0,31]$$ using a Genetic Algorithm (GA).
2. **Basic Structure of Genetic Algorithm:**
- **Initialization:** Start with a randomly generated population of candidate solutions (chromosomes), here representing values of $$x$$.
- **Selection:** Choose individuals based on their fitness (value of $$f(x)$$) to reproduce.
- **Crossover:** Combine pairs of selected individuals to create offspring.
- **Mutation:** Introduce small random changes to offspring to maintain genetic diversity.
- **Evaluation:** Calculate fitness of new individuals.
- **Replacement:** Form a new population from offspring.
- **Termination:** Repeat until a stopping criterion is met (e.g., max generations or convergence).
3. **Applying GA to maximize $$f(x) = x^2 + 3x$$:**
- **Encoding:** Represent $$x$$ as a 5-bit binary string since $$31_{10} = 11111_2$$.
- **Fitness Function:** $$fitness(x) = x^2 + 3x$$.
- **Population:** Initialize with random 5-bit strings.
- **Selection:** Use roulette wheel or tournament selection based on fitness.
- **Crossover and Mutation:** Apply standard GA operators.
4. **Mathematical Analysis:**
- The function is a parabola opening upwards.
- Vertex formula for $$f(x) = ax^2 + bx + c$$ is $$x = -\frac{b}{2a}$$.
- Here, $$a=1$$, $$b=3$$, so vertex at $$x = -\frac{3}{2} = -1.5$$ (outside domain).
- Since parabola opens upwards and vertex is negative, function increases over $$[0,31]$$.
- Maximum at $$x=31$$ with $$f(31) = 31^2 + 3\times31 = 961 + 93 = 1054$$.
5. **Summary:**
- GA will evolve populations towards $$x=31$$.
- The maximum value of $$f(x)$$ in the domain is $$1054$$ at $$x=31$$.
**Graph Description:**
- The graph is a parabola opening upwards.
- X-axis: values from 0 to 31.
- Y-axis: function values $$f(x)$$.
- The curve rises as $$x$$ increases from 0 to 31.
Final answer: The maximum value of $$f(x)$$ on $$[0,31]$$ is $$1054$$ at $$x=31$$.