R Mals Chains
R Mals Chains
R Mals Chains
1
2 Rmalschains-package
R topics documented:
Rmalschains-package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
malschains . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
malschains.control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
print.malschains . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Index 9
Description
This package implements an algorithm family for continuous optimization called memetic algo-
rithms with local search chains (MA-LS-Chains).
Details
One of the main issues to optimize a real-coded function is the capability of the algorithm to realize
a good exploration of the search space and, at the same time, to exploit the most promising region
to obtain accurate solutions.
Memetic algorithms are hybridizations of genetic algorithms with local search methods. They are
especially suited for continuous optimization, as they combine the power of evolutionary algorithms
to explore the search space with a local search method to find the local optimum of a promising
region. In these algorithms, it is recommended to increase the effort invested in the local search
(measured in number of evaluations, called intensity) in the improvement of the most promising
solution. However, it is not easy to decide the right intensity for each solution.
MA-LS-Chains is a steady-state memetic algorithm, which combines a steady-state genetic algo-
rithm with various different local search methods. In contrast to the generational approach, where
all individuals are substituted in an iteration, in the steady-state genetic algorithm in each iteration
only one solution, the worst one, is subtituted in the population. This makes it possible to not lose
the improvement obtained by the local search over the individuals.
For MA-LS-Chains, the current state of the local search algorithm is stored along with the individu-
als. So, it becomes possible to run the local search a fixed number of iterations, stop it, and possibly
later continue the previous local search over the same individual. In this way, MA-LS-Chains con-
trols the application of the local search to the most promising solutions.
The package implements various different local search strategies:
CMA-ES is a very effective local search strategy, but quite complicated, and it does not scale well if
the amount of parameters to optimize is huge. The Solis Wets solver is pretty simple and therewith
fast. The SSW strategy is an adapted version of the Solis Wets solver for high dimensional data, so
that the algorithm with this type of local search scales well with the dimensionality of the data. It
applies the Solis Wets solver to randomly chosen subgroups of variables (Subgrouping Solis Wets).
All the local search methods can also be used directly, without making use of the evolutionary
algorithm.
The package contains some demos illustrating its use. To get a list of them, type:
library(Rmalschains)
demo()
The demos currently available are claw, rastrigin, sphere, rastrigin_highDim, and rastrigin_inline.
So in order to, e.g., execute the claw demo, type
demo(claw)
All algorithms are implemented in C++, and they run pretty fast. A usual processing to speed up
optimization is to implement the objective function also in C/C++. However, a bottleneck in this
approach is that the function needs to be passed as an R function, so that the optimizer needs to go
back from C++ to R to C/C++ in each call of the target function. The package provides an interface
which allows to pass the C/C++ target function directly as a pointer. See the rastrigin_inline
demo for how to do that. The demo also shows how an environment can in this approach be used to
pass additional parameters to the target function.
For theoretical background of the algorithm, the reader may refer to the cited literature, where the
algorithms where originally proposed.
Author(s)
Christoph Bergmeir <c.bergmeir@decsai.ugr.es>
Daniel Molina <dmolina@decsai.ugr.es>
José M. Benítez <j.m.benitez@decsai.ugr.es>
DiCITS Lab, Sci2s group, DECSAI, University of Granada.
References
Bergmeir, C., Molina, D., Benítez, J.M. Memetic Algorithms with Local Search Chains in R: The
Rmalschains Package (2016) Journal of Statistical Software, 75(4), 1-33., doi:10.18637/jss.v075.i04
Molina, D., Lozano, M., Sánchez, A.M., Herrera, F. Memetic algorithms based on local search
chains for large scale continuous optimisation problems: MA-SSW-Chains (2011) Soft Computing,
15 (11), pp. 2201-2220.
Molina, D., Lozano, M., Herrera, F. MA-SW-Chains: Memetic algorithm based on local search
chains for large scale continuous global optimization (2010) 2010 IEEE World Congress on Com-
putational Intelligence, WCCI 2010 - 2010 IEEE Congress on Evolutionary Computation, CEC
2010.
Molina, D., Lozano, M., García-Martínez, C., Herrera, F. Memetic algorithms for continuous opti-
misation based on local search chains (2010) Evolutionary Computation, 18 (1), pp. 27-63.
4 Rmalschains-package
See Also
malschains, malschains.control
Examples
##############################################
#Example for maximization of the claw function
##############################################
#use MA-CMA-Chains
res.claw <- malschains(function(x) {-claw(x)}, lower=c(-3), upper=c(3),
maxEvals=50000, control=malschains.control(popsize=50,
istep=300, ls="cmaes", optimum=-5))
## Not run:
#use only the CMA-ES local search
res.claw2 <- malschains(function(x) {-claw(x)}, lower=c(-3), upper=c(3), verbosity=0,
maxEvals=50000, control=malschains.control(ls="cmaes",
lsOnly=TRUE, optimum=-5))
plot(x,claw_x, type="l")
points(res.claw$sol, -res.claw$fitness, col="red")
points(res.claw2$sol, pch=3, -res.claw2$fitness, col="blue")
points(res.claw3$sol, pch=3, -res.claw3$fitness, col="green")
##############################################
#Example for the rastrigin function
##############################################
res
}
res.rastrigin1
res.rastrigin2
## End(Not run)
Description
This is the main function of the package. It minimizes the output of the function fn (for maximiza-
tion, change the sign of the output of fn).
Usage
malschains(fn, lower, upper, dim, maxEvals = 10 * control$istep,
verbosity = 2, initialpop = NULL, control = malschains.control(),
seed = NULL, env)
Arguments
fn The function to minimize.
lower The lower bound (or bounds) of the search domain.
upper The upper bound (or bounds) of the search domain.
dim The dimension of the problem (if lower and upper are vectors it is not needed).
maxEvals The maximal number of evaluations of the fitness function.
6 malschains.control
Details
The output of the function when run with verbosity=2 is the following:
• EA::PopFitness The fitness of the best, the one at the 1st quartile, the one at the 3rd quartile,
and the worst individual.
• EA::Improvement Improvement of the individuals at the according ranked positions in the
population (best, 1st quartile, 3rd quartile, worst).
• LS The number of the individual which is improved on (in braces), its fitness before and after
application of the LS procedure, and their difference.
• EABest If the best fitness present in the population changed: same as LS.
Value
the function returns a list containing the best individual, sol, and its fitness. Furthermore, it con-
tains some information on the optimization process, which can be seen using print.malschains.
References
Molina, D., Lozano, M., Sánchez, A.M., Herrera, F. Memetic algorithms based on local search
chains for large scale continuous optimisation problems: MA-SSW-Chains (2011) Soft Computing,
15 (11), pp. 2201-2220.
Molina, D., Lozano, M., García-Martínez, C., Herrera, F. Memetic algorithms for continuous opti-
misation based on local search chains (2010) Evolutionary Computation, 18 (1), pp. 27-63.
Description
This is a function that initializes and sets the parameters of the algorithm. It generates a list of
parameters, to be used with the malschains function.
Usage
malschains.control(popsize = 50, ls = "cmaes", istep = 500,
effort = 0.5, alpha = 0.5, optimum = -Inf, threshold = 1e-08,
lsOnly = FALSE, lsParam1 = 0, lsParam2 = 0)
malschains.control 7
Arguments
References
Molina, D., Lozano, M., Sánchez, A.M., Herrera, F. Memetic algorithms based on local search
chains for large scale continuous optimisation problems: MA-SSW-Chains (2011) Soft Computing,
15 (11), pp. 2201-2220.
Molina, D., Lozano, M., García-Martínez, C., Herrera, F. Memetic algorithms for continuous opti-
misation based on local search chains (2010) Evolutionary Computation, 18 (1), pp. 27-63.
8 print.malschains
Description
Print out some characteristics of a malschains result. The result shows besides the best solution
and its fitness the total number of evaluations spent for both EA and LS, the ratio of the spent
evaluations (also called effort), the ratio of total improvement of the fitness, the percentage of times
that application of the EA/LS yielded improvement, and some timing results in milliseconds.
Usage
## S3 method for class 'malschains'
print(x, ...)
Arguments
x the malschains result
... additional function parameters (currently not used)
Index
∗Topic MA-LS-Chains
Rmalschains-package, 2
∗Topic optimization
Rmalschains-package, 2
malschains, 4, 5, 6, 8
malschains.control, 4, 6, 6
print.malschains, 6, 8
Rmalschains (Rmalschains-package), 2
Rmalschains-package, 2