Evolutionary algorithm: Difference between revisions
Content deleted Content added
Line 5,551: | Line 5,551: | ||
# Mutate function |
# Mutate function |
||
mutate= function(x, rate= 0.1){ |
mutate= function(x, rate= 0.1){ |
||
idx= runif(length(target)) <= rate |
idx= which(runif(length(target)) <= rate) |
||
x[idx] = sample(x= chars, size= 1, replace= T) |
x[idx]= replicate(n= length(idx), expr= sample(x= chars, size= 1, replace= T)) |
||
x |
x |
||
} |
} |