gena.constr | R Documentation |
Impose constraints on chromosomes.
gena.constr(population, method = "bounds", par, iter)
population |
numeric matrix which rows are chromosomes i.e. vectors of parameters values. |
method |
method used to impose constraints. |
par |
additional parameters to be passed depending on the |
iter |
iteration number of the genetic algorithm. |
If method = "bounds"
then chromosomes will be bounded
between par$lower
and par$upper
.
The function returns a list with the following elements:
population
- matrix which rows are chromosomes after
constraints have been imposed.
constr.ind
- matrix of logical values which (i, j)-th
elements equals TRUE
(FALSE
otherwise) if j-th jene of
i-th chromosome is a subject to constraint.
# Randomly initialize population set.seed(123) population <- gena.population(pop.n = 10, lower = c(-5, -5), upper = c(5, 5)) # Impose lower and upper bounds constraints pop.constr <- gena.constr(population, method = "bounds", par = list(lower = c(-1, 2), upper = c(1, 5))) print(pop.constr)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.