I'm simulating a multi-agent system. Each agent has a chromosome. The genotypes represent 5 parameters that are various floating-point numbers between 0 and 100. My mutation operator simply modifies the original gene with a new random number (according to the constant mutation rate). Is that the best approach or could you advise another way? For instance, is that possible to mutate the parameters in a bit digit level to provide more precision?
Do you mean you'd like to modify the gene value based on its current value, rather than simply replacing it? Maybe this will work for you:
globals [ genome ]
to setup
ca
set genome n-values 5 [ random 101 / 100 ]
print word "Original genome: " genome
reset-ticks
end
to mutate
set genome map [
i ->
ifelse-value ( random-float 1 < 0.2 )
[ precision ( i + one-of [ 0.01 -0.01 ] ) 2 ]
[ i ]
] genome
print word "Mutated genome: " genome
end
Here, the genome is randomly created in setup
, and then every time you call mutate
, each gene has a chance of being either increased or decreased by 0.01. Output:
Original genome: [0.09 0.77 0.41 0.97 0.8]
Mutated genome: [0.08 0.77 0.41 0.96 0.8]
Mutated genome: [0.08 0.76 0.41 0.97 0.8]
Mutated genome: [0.08 0.75 0.41 0.97 0.8]
Mutated genome: [0.09 0.75 0.42 0.97 0.8]