caRamel is a multiobjective evolutionary algorithm combining the MEAS algorithm and the NGSA-II algorithm.
Download the package from CRAN or GitHub and then install and load it.
library(caRamel)
This example will use the pbdMPI package in order to use several processes of caRamel. Download the package from CRAN and then install and load it. Make also sure that you have an MPI distribution installed on your system, see for instance Open MPI if necessary.
library(pbdMPI)
Kursawe test function has two objectives of three variables.
kursawe <- function(i) {
k1 <- -10 * exp(-0.2 * sqrt(x[i,1]^2 + x[i,2]^2)) - 10 * exp(-0.2 * sqrt(x[i,2]^2 + x[i,3]^2))
k2 <- abs(x[i,1])^0.8 + 5 * sin(x[i,1]^3) + abs(x[i,2])^0.8 + 5 * sin(x[i,2]^3) + abs(x[i,3])^0.8 + 5 * sin(x[i,3]^3)
return(c(k1, k2))
}
The variables lie in the range [-5, 5]:
nvar <- 3 # number of variables
bounds <- matrix(data = 1, nrow = nvar, ncol = 2) # upper and lower bounds
bounds[, 1] <- -5 * bounds[, 1]
bounds[, 2] <- 5 * bounds[, 2]
Both functions are to be minimized:
nobj <- 2 # number of objectives
minmax <- c(FALSE, FALSE) # minimization for both functions
Set algorithmic parameters for caRamel:
popsize <- 100 # size of the genetic population
archsize <- 100 # size of the archive for the Pareto front
maxrun <- 1000 # maximum number of calls
prec <- matrix(1.e-3, nrow = 1, ncol = nobj) # accuracy for the convergence phase