R/powmut.R

Defines functions powmut

Documented in powmut

# Power mutation
powmut = function(y, lb, ub, mutpow, ...){
  m = length(y)
  if(missing(lb) | missing(ub)) 
    stop("powmut requires lb and ub !")
  if(missing(mutpow)) mutpow = 2
  v = sample(1:m, 1)
  r = runif(1)
  p = runif(1)^mutpow
  t = (y[v]-lb[v])/(ub[v]-y[v])
  y[v] = y[v] + ifelse(r>t, -p*(y[v]-lb[v]), +p*(ub[v]-y[v]))
  return(list(mutant=y, mutgen=v))
}

Try the adana package in your browser

Any scripts or data that you put into this service are public.

adana documentation built on March 18, 2022, 6:03 p.m.