gena.constr {gena} | R Documentation |
Constraints
Description
Impose constraints on chromosomes.
Usage
gena.constr(population, method = "bounds", par, iter)
Arguments
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. |
Details
If method = "bounds"
then chromosomes will be bounded
between par$lower
and par$upper
.
Value
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 equalsTRUE
(FALSE
otherwise) if j-th jene of i-th chromosome is a subject to constraint.
Examples
# 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)
[Package gena version 1.0.0 Index]