# How to choose a mutant solution with a genetic algorithm in a localization problem?

I am new to genetic algorithm but I understand the concept of mutations when taking continuous parameters for an evolutionary algorithm. But I can't get it with a discrete one.

For isntance, let's say I have a grid of a city in zones of one square kilometer with how many interventions I had here. I want to find a solution to this problem using an evolutionary algorithm. I made a loss function but now I want to create a mutation of two parent solutions into a child solution.

Here are the names of interventions according to the locations:

interventions_number_locations = [[5, 2, 4, 8, 9, 0, 3, 3, 8, 7],
[5, 5, 3, 4, 4, 6, 4, 1, 9, 1],
[4, 1, 2, 1, 3, 8, 7, 8, 9, 1],
[1, 7, 1, 6, 9, 3, 1, 9, 6, 9],
[4, 7, 4, 9, 9, 8, 6, 5, 4, 2],
[7, 5, 8, 2, 5, 2, 3, 9, 8, 2],
[1, 4, 0, 6, 8, 4, 0, 1, 2, 1],
[1, 5, 2, 1, 2, 8, 3, 3, 6, 2],
[4, 5, 9, 6, 3, 9, 7, 6, 5, 10],
[0, 6, 2, 8, 7, 1, 2, 1, 5, 3]]


I made a function to get a random solution:

import random

i = random.randint(0, len(interventions_number_locations)-1)
j = random.randint(0, len(interventions_number_locations)-1)
random_individual = (i,j)


And a loss function. I thought of summing the interventions of all the surrounding squares weighted by the distance to the center:

$$loss(i,j) = \sum_{\forall k,l\in A,O\ i\neq k, j\neq l}\frac{1}{distance((i,j),(k,l))}.interventions(k,l)$$

Here is the Python function:

def distance(individual, other):
return math.sqrt(abs(other-i) + abs(other-j))

def loss_function(individual):
loss = 0
for k in range(0, len(interventions_number_locations)-1):
for l in range(0, len(interventions_number_locations)-1):
if k != individual and l != individual:
loss += 1/(distance(individual, (k,l)))*interventions_number_locations[k][l]
return loss


So I can obtain the cost function for each randomly generated solution. However, I do not know how to generate a mutant solution from two randomly chosen solutions .....

I am a noob in this field, don't hesitate to explain it to me like if I wa a 15yo :)