<p>I guess you can go a lot of different ways and that it depends on your particular use case.</p>

<p>Your randomisation of a gene doesn't seem particularly wrong to me. Although a more subtle approach could be to only add or remove a pre-defined <code>n</code> (or range of) instead of a changing it to a completely new random number.</p>

<p>In this paper here they mutate like you suggest though, using a random generator: <a href="https://arxiv.org/abs/1308.4675" rel="nofollow noreferrer"><em>Genetic Algorithm for Solving Simple Mathematical Equality Problem</em></a>.</p>
How can genetic algorithms evolve solutions with numerical data?
<p>I'm familiar with GA within the context of strings or text but not with numerical data.</p>

<p>For strings, I understand how crossover and mutation would apply:</p>

<pre><code>ParentA = abcdef
ParentB = uvwxyz

Using one-point crossover:
ChildA = abwxyz (pivot after 2nd gene)
ChildB = uvcdef

Using random gene mutation (after crossover):
ChildA = abwgyz (4th gene mutated)
ChildB = uvcdef (no genes mutated)
</code></pre>

<p>For strings, I have a discrete alphabet to go off of, but how would these operators apply to continuous numerical data?</p>

<p>For example, chromosomes represented as points in 4-space (each axes is a gene):</p>

<pre><code>ParentA = [19, 58, 21, 54]
ParentB = [65, 21, 59, 11]
</code></pre>

<p>Would it be appropriate to apply crossover by switching axes of both parents for offspring?</p>

<pre><code>ChildA = [19, 58, 59, 11] (pivot after 2nd gene)
ChildB = [65, 21, 21, 54]
</code></pre>

<p>I have a feeling this seems alright, but my naive notion of mutation, randomizing a gene, doesn't seem correct:</p>

<pre><code>ChildA = [12, 58, 59, 11] (1st gene mutated)
ChildB = [65, 89, 34, 54] (2nd and 3rd genes mutated)
</code></pre>

<p>I'm just unsure how genetic algorithms can be applied to numeric data like this. I know what I need for GA but not how to apply the operators. For example, consider the problem being minimizing the Rastrigin function in 4-dimensions: the search space is <code>[-512, 512]</code> in each dimension and the fitness function is the Rastrigin function. I don't know how the operators as I've described here can help find a more fit chromosome.</p>

<p>For what it's worth, elite selection and population initialization seems straightforward, my only confusion comes with crossover and mutation operators.</p>

<h3>Update for Bounty</h3>

<p>I did an implementation of a GA for continuous numerical data using the mutation and crossover rates as I have described here. The optimization problem is the Styblinski-Tang function in two dimensions because it is easy to graph. I'm also using standard elite and tournament selection strategies.</p>

<p>I find that the population best fitness does converge nicely to a solution, the average fitness doesn't really.</p>

<p>Here I've plotted the search space over ten generations: a black dot is a candidate solution and the red 'x' is the global optimum:</p>

<p><a href="https://i.stack.imgur.com/S52xa.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/S52xa.gif" alt="enter image description here"></a></p>

<p>The crossover operator as I've described seems to work well but the mutation operator (randomizing both, either, or neither of the x or y positions of a chromosome) seems to create crosshair and crosshatch patterns.</p>

<p>I did a run in 50 dimensions to prolong convergence (since in two dimensions it converges in one generation) and plotted it:</p>

<p><a href="https://i.stack.imgur.com/AeY3P.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AeY3P.png" alt="enter image description here"></a></p>

<p>Here the y-axis represents how close a solution was to global optimum (since the optimum is known), it's just a fraction <code>actual output / expected output</code>. It's a percentage. Green line is population best (approx 96-97% target), blue is population average (fluctuates 65-85% target).</p>

<p>This verifies what I thought: the mutation operator doesn't really affect the population best but does mean the population average never converges and it fluctuates up and down.</p>

<p>So my question for the bounty is what mutation operators can be used other than randomization of a gene?</p>

<p><strong>Just to add:</strong> I ask this question because I'm interested in using GA to optimize neural network weights to train a network in lieu of backpropagation. If you know anything about that, any source detailing that would also answer my question.</p>