rao_genetic_max | R Documentation |
Uses a genetic algorithm to find the optimum permutation of p to maximize Rao(p,D).
rao_genetic_max(
p,
D,
swap_freq,
term_cycles=10,
maxiters=400,
popsize_perm=150,
popsize_swap=150,
keep=25,
cross=0,
prc=0.001
)
p |
numeric vector of length n. A species weights vector. |
D |
numeric vector of length n(n-1)/2. i.e. a dist object representing the lower triangle of an nxn matrix. |
swap_freq |
integer vector - distribution of swaps per generation. For a constant swap rate, set to a constant value (recommend 1). If set to c(1,1,2,3), for example, one swap per generation will occur about half the time, and two swaps per generation will occur one quarter of the time, etc. |
term_cycles |
integer, number of cycles with no improvement to trigger termination (default: 10). |
maxiters |
integer, maximum number of iterations to run algorithm (default: 400). |
popsize_perm |
integer, population size for genetic algorithm that is initialized using random permutations of p. Total population size is equal to popsize_perm+popsize_swap+1, and all mutation post initialization is performed using swaps (default: 150). |
popsize_swap |
integer, population size for genetic algorithm that is initialized using random swaps of p. The numbers of swaps are drawn from swap_freq (default: 150). |
keep |
integer, number of individuals to keep during each iteration (default: 25). |
cross |
integer, number of items in pop mutated via PMX instead of by swap each generation (default: 0). |
prc |
double, precision for calculating termination with term_cycles (default: 0.001). |
List object containing results of genetic algorithm:
Maximum Rao value found.
Max Rao value for each iteration. If termination condition was met, rest of values after final iteration are NA.
Iteration numbers, corresponding to iter_raos.
The best permutation of p found (corresponds to best_rao).
John L. Darcy
# library(specificity)
# set.seed(12345)
# p <- runif(100)
# D <- dist(sample(p))
# a <- rao_genetic_max(p,D,c(1,1,2,3))
# plot(a$iter_raos ~ a$iterations)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.