EDA.norm | R Documentation |
Implements an EDA with normal distribution.
EDA.norm(fun,
lower,
upper,
n = 30,
maxiter,
k = 2,
k0= 10,
tolerance = 0.01,
...)
fun |
A function to be minimized, with first argument the vector of parameters over which minimization is to take place. |
lower |
Lower limits of the parameters. |
upper |
Upper bounds on the parameters. |
n |
Number of individuals per generation |
maxiter |
Maximum number of iterations. |
k |
The minimum number of consecutive generations using the same search distribution. |
k0 |
The minimum number of consecutive generations using the uniform distribution. |
tolerance |
Criterion for determining whether the distribution has changed. |
... |
Additional arguments of the objective function. |
Implements an EDA with normal distribution that uses the proposal presented in Salinas-Gutiérrez and Zavala, 2023 before changing the model.
Returns a list with the following entries:
sol |
The best solution found. |
par |
The n best individuals generated by the last model. |
value |
The best value of the objective function. |
historical |
The best fitness value in each generatio. |
Salinas-Gutiérrez, R., & Zavala, A. E. M. (2023).An explicit exploration strategy for evolutionary algorithms. Applied Soft Computing, 140. https://doi.org/10.1016/j.asoc.2023.110230
EDA.ecdf
, EDA.hist
, EDA.mnorm
,
ExplicitExploration
#Example happy cat
fun <- function(X){
D <- length(X)
f <- abs(sum(X^2) - D)^(1/4) + (0.5 * sum(X^2) + sum(X))/D + 0.5
return(f)
}
n <- 30
k <- 2
tolerance <- 0.01
lower <- rep(-5,2)
upper <- rep(5,2)
res <- EDA.norm(fun, lower = lower,
upper = upper,n = n,
k = k, tolerance = tolerance,
maxiter = 200)
z <- outer(X = seq(-5, 5, 0.05), Y = seq(-5, 5, 0.05),
FUN = Vectorize(function(X, Y) { fun(c(X, Y)) }))
contour(seq(-5, 5, 0.05),seq(-5, 5, 0.05),z,
nlevels = 20, cex.axis = .8)
points(res$sol[1],res$sol[2],
col = "blue", pch = 19)
#Multiple regression example
set.seed(pi)
x1 <- rnorm(n = 100, mean = 10, sd = 5)
x2 <- rnorm(n = 100, mean = 8, sd = 2)
y <- 7 + 4 * x1 - 6 * x2 + rnorm(n = 100, mean = 0, sd = 3)
ec <- function(par,y,x1,x2){
b0 <- par[1]
b1 <- par[2]
b2 <- par[3]
y_hat <- b0 + b1 * x1 + b2 * x2
value <- sum((y - y_hat)^2)
return(value)
}
opt <- EDA.norm(fun = ec, lower = c(-20,-20,-20),
upper = c(20,20,20), maxiter = 150,
y = y, x1 = x1, x2 = x2)
opt$sol
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.