View source: R/11-grafos-NPdif.R
mutate_binary_sequence | R Documentation |
Mutation of binary sequences for use in the genetic algorithm
mutate_binary_sequence(s, p = 0.1)
s |
Sequence consisting of 0 and 1 |
p |
Mutation probability. Defaults to 0.1 |
This routine takes a binary sequence and it flips ("mutates") each bit with a fixed probability. In the genetic algorithm context, this operation randomly explores regions of configuration space which are far away from the starting point, thus trying to avoid local optima. The fitting function values of mutated individuals are generically very poor, and this behavior is to be expected. Thus, mutation is not an optimization procedure per se.
A mutated binary sequence
Cesar Asensio
search_cut_genetic genetic cut-searching algorithm, crossover_sequences crossover operation
set.seed(1)
s <- sample(0:1, 10, replace = TRUE) # 0 0 1 1 0 1 1 1 1 0
mutate_binary_sequence(s, p = 0.5) # 1 1 1 0 0 0 1 1 0 0
mutate_binary_sequence(s, p = 1) # 1 1 0 0 1 0 0 0 0 1
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.