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.
It is possible to compute the first order derivatives of the Pareto front with caRamel by setting the logical parameter sensitivity to TRUE.
Schaffer test function has two objectives with one variable.
schaffer <- function(i) {
s1 <- x[i,1] * x[i,1]
s2 <- (x[i,1] - 2) * (x[i,1] - 2)
return(c(s1, s2))
}
Note that :
For instance, the variable will lie in the range [-10, 10]:
nvar <- 1 # number of variables
bounds <- matrix(data = 1, nrow = nvar, ncol = 2) # upper and lower bounds
bounds[, 1] <- -10 * bounds[, 1]
bounds[, 2] <- 10 * bounds[, 2]
Both functions are to be minimized:
Before calling caRamel in order to optimize the Schaffer’s problem, some algorithmic parameters need to be set:
Then the minimization problem can be launched with a sensitivity analysis:
results <-
caRamel(nobj,
nvar,
minmax,
bounds,
schaffer,
popsize,
archsize,
maxrun,
prec,
carallel=FALSE,
sensitivity=TRUE) # sensitivity required
## Beginning of caRamel optimization <-- Wed Nov 20 04:50:44 2024
## Number of variables : 1
## Number of functions : 2
## Warning in delaunayn(obj): 1 points missing from triangulation.
## It is possible that setting the 'options' argument of delaunayn may help.
## For example:
## options = "Qt Qc Qz Qbb"
## options = "Qt Qc Qz QbB"
## If these options do not work, try shifting the centre of the points
## to the origin by subtracting the mean coordinates from every point.
## Warning in delaunayn(obj): 1 points missing from triangulation.
## It is possible that setting the 'options' argument of delaunayn may help.
## For example:
## options = "Qt Qc Qz Qbb"
## options = "Qt Qc Qz QbB"
## If these options do not work, try shifting the centre of the points
## to the origin by subtracting the mean coordinates from every point.
## Warning in delaunayn(obj): 1 points missing from triangulation.
## It is possible that setting the 'options' argument of delaunayn may help.
## For example:
## options = "Qt Qc Qz Qbb"
## options = "Qt Qc Qz QbB"
## If these options do not work, try shifting the centre of the points
## to the origin by subtracting the mean coordinates from every point.
## Warning in delaunayn(obj): 1 points missing from triangulation.
## It is possible that setting the 'options' argument of delaunayn may help.
## For example:
## options = "Qt Qc Qz Qbb"
## options = "Qt Qc Qz QbB"
## If these options do not work, try shifting the centre of the points
## to the origin by subtracting the mean coordinates from every point.
## Warning in delaunayn(obj): 1 points missing from triangulation.
## It is possible that setting the 'options' argument of delaunayn may help.
## For example:
## options = "Qt Qc Qz Qbb"
## options = "Qt Qc Qz QbB"
## If these options do not work, try shifting the centre of the points
## to the origin by subtracting the mean coordinates from every point.
## Warning in delaunayn(obj): 1 points missing from triangulation.
## It is possible that setting the 'options' argument of delaunayn may help.
## For example:
## options = "Qt Qc Qz Qbb"
## options = "Qt Qc Qz QbB"
## If these options do not work, try shifting the centre of the points
## to the origin by subtracting the mean coordinates from every point.
## Warning in delaunayn(obj): 1 points missing from triangulation.
## It is possible that setting the 'options' argument of delaunayn may help.
## For example:
## options = "Qt Qc Qz Qbb"
## options = "Qt Qc Qz QbB"
## If these options do not work, try shifting the centre of the points
## to the origin by subtracting the mean coordinates from every point.
## Warning in delaunayn(obj): 1 points missing from triangulation.
## It is possible that setting the 'options' argument of delaunayn may help.
## For example:
## options = "Qt Qc Qz Qbb"
## options = "Qt Qc Qz QbB"
## If these options do not work, try shifting the centre of the points
## to the origin by subtracting the mean coordinates from every point.
## Warning in delaunayn(obj): 1 points missing from triangulation.
## It is possible that setting the 'options' argument of delaunayn may help.
## For example:
## options = "Qt Qc Qz Qbb"
## options = "Qt Qc Qz QbB"
## If these options do not work, try shifting the centre of the points
## to the origin by subtracting the mean coordinates from every point.
## Warning in delaunayn(obj): 1 points missing from triangulation.
## It is possible that setting the 'options' argument of delaunayn may help.
## For example:
## options = "Qt Qc Qz Qbb"
## options = "Qt Qc Qz QbB"
## If these options do not work, try shifting the centre of the points
## to the origin by subtracting the mean coordinates from every point.
## Warning in delaunayn(obj): 1 points missing from triangulation.
## It is possible that setting the 'options' argument of delaunayn may help.
## For example:
## options = "Qt Qc Qz Qbb"
## options = "Qt Qc Qz QbB"
## If these options do not work, try shifting the centre of the points
## to the origin by subtracting the mean coordinates from every point.
## Warning in delaunayn(obj): 1 points missing from triangulation.
## It is possible that setting the 'options' argument of delaunayn may help.
## For example:
## options = "Qt Qc Qz Qbb"
## options = "Qt Qc Qz QbB"
## If these options do not work, try shifting the centre of the points
## to the origin by subtracting the mean coordinates from every point.
## Warning in delaunayn(obj): 1 points missing from triangulation.
## It is possible that setting the 'options' argument of delaunayn may help.
## For example:
## options = "Qt Qc Qz Qbb"
## options = "Qt Qc Qz QbB"
## If these options do not work, try shifting the centre of the points
## to the origin by subtracting the mean coordinates from every point.
## Warning in delaunayn(obj): 1 points missing from triangulation.
## It is possible that setting the 'options' argument of delaunayn may help.
## For example:
## options = "Qt Qc Qz Qbb"
## options = "Qt Qc Qz QbB"
## If these options do not work, try shifting the centre of the points
## to the origin by subtracting the mean coordinates from every point.
## Warning in delaunayn(obj): 1 points missing from triangulation.
## It is possible that setting the 'options' argument of delaunayn may help.
## For example:
## options = "Qt Qc Qz Qbb"
## options = "Qt Qc Qz QbB"
## If these options do not work, try shifting the centre of the points
## to the origin by subtracting the mean coordinates from every point.
## Warning in delaunayn(obj): 1 points missing from triangulation.
## It is possible that setting the 'options' argument of delaunayn may help.
## For example:
## options = "Qt Qc Qz Qbb"
## options = "Qt Qc Qz QbB"
## If these options do not work, try shifting the centre of the points
## to the origin by subtracting the mean coordinates from every point.
## Warning in delaunayn(obj): 1 points missing from triangulation.
## It is possible that setting the 'options' argument of delaunayn may help.
## For example:
## options = "Qt Qc Qz Qbb"
## options = "Qt Qc Qz QbB"
## If these options do not work, try shifting the centre of the points
## to the origin by subtracting the mean coordinates from every point.
## Warning in delaunayn(obj): 1 points missing from triangulation.
## It is possible that setting the 'options' argument of delaunayn may help.
## For example:
## options = "Qt Qc Qz Qbb"
## options = "Qt Qc Qz QbB"
## If these options do not work, try shifting the centre of the points
## to the origin by subtracting the mean coordinates from every point.
## Warning in delaunayn(obj): 1 points missing from triangulation.
## It is possible that setting the 'options' argument of delaunayn may help.
## For example:
## options = "Qt Qc Qz Qbb"
## options = "Qt Qc Qz QbB"
## If these options do not work, try shifting the centre of the points
## to the origin by subtracting the mean coordinates from every point.
## Warning in delaunayn(obj): 1 points missing from triangulation.
## It is possible that setting the 'options' argument of delaunayn may help.
## For example:
## options = "Qt Qc Qz Qbb"
## options = "Qt Qc Qz QbB"
## If these options do not work, try shifting the centre of the points
## to the origin by subtracting the mean coordinates from every point.
## Warning in delaunayn(obj): 1 points missing from triangulation.
## It is possible that setting the 'options' argument of delaunayn may help.
## For example:
## options = "Qt Qc Qz Qbb"
## options = "Qt Qc Qz QbB"
## If these options do not work, try shifting the centre of the points
## to the origin by subtracting the mean coordinates from every point.
## Warning in delaunayn(obj): 1 points missing from triangulation.
## It is possible that setting the 'options' argument of delaunayn may help.
## For example:
## options = "Qt Qc Qz Qbb"
## options = "Qt Qc Qz QbB"
## If these options do not work, try shifting the centre of the points
## to the origin by subtracting the mean coordinates from every point.
## Warning in delaunayn(obj): 1 points missing from triangulation.
## It is possible that setting the 'options' argument of delaunayn may help.
## For example:
## options = "Qt Qc Qz Qbb"
## options = "Qt Qc Qz QbB"
## If these options do not work, try shifting the centre of the points
## to the origin by subtracting the mean coordinates from every point.
## Computing the sensitivity of the Pareto front...
## Done in 2.92453408241272 secs --> Wed Nov 20 04:50:47 2024
## Size of the Pareto front : 92
## Number of calls : 1112
Test if the convergence is successful:
## [1] TRUE
Plot the Pareto front:
The sensitivity of the Pareto front is evalutated by computing first order derivatives. For each of the objective, one Jacobian matrix is computed:
## [1] "Jacobian_1" "Jacobian_2"
Plot the sensitivity for the first objective:
plot(results$parameters, results$derivatives$Jacobian_1, main="Sensitivitiy for the first objective", ylab="Sensitivity values", xlab="X values")
Plot the histogram for the second objective:
hist(results$derivatives$Jacobian_2, main="Sensitivitiy for the second objective", xlab="Sensitivity values", ylab="Distribution of the Pareto front")
Plot the sensitivity of the Pareto front for the two objectives: