Title: | Evolutionary Computation in R |
Description: | Framework for building evolutionary algorithms for both single- and multi-objective continuous or discrete optimization problems. A set of predefined evolutionary building blocks and operators is included. Moreover, the user can easily set up custom objective functions, operators, building blocks and representations sticking to few conventions. The package allows both a black-box approach for standard tasks (plug-and-play style) and a much more flexible white-box approach where the evolutionary cycle is written by hand. |
Version: | 2.1.1 |
Encoding: | UTF-8 |
Date: | 2023-03-08 |
Maintainer: | Jakob Bossek <j.bossek@gmail.com> |
License: | GPL-3 |
URL: | https://github.com/jakobbossek/ecr2 |
BugReports: | https://github.com/jakobbossek/ecr2/issues |
Depends: | R (≥ 2.10), BBmisc (≥ 1.6), smoof (≥ 1.4), ParamHelpers (≥ 1.1) |
Imports: | checkmate (≥ 1.1), Rcpp (≥ 0.12.16), parallelMap (≥ 1.3), reshape2 (≥ 1.4.1), ggplot2 (≥ 1.0.0), viridis, dplyr, plot3D, plot3Drgl, scatterplot3d, plotly, knitr, kableExtra, lazyeval |
Suggests: | testthat (≥ 0.9.1), rmarkdown, mlr, mlbench, randomForest, covr |
ByteCompile: | yes |
LinkingTo: | Rcpp |
VignetteBuilder: | knitr |
LazyData: | true |
RoxygenNote: | 7.2.3 |
NeedsCompilation: | yes |
Packaged: | 2023-03-08 16:02:04 UTC; bossek |
Author: | Jakob Bossek [aut, cre, cph], Michael H. Buselli [ctb, cph], Wessel Dankers [ctb, cph], Carlos M. Fonseca [ctb, cph], Manuel Lopez-Ibanez [ctb, cph], Luis Paquete [ctb, cph], Joshua Knowles [ctb, cph], Eckart Zitzler [ctb, cph], Olaf Mersmann [ctb] |
Repository: | CRAN |
Date/Publication: | 2023-03-08 22:10:06 UTC |
Grouping helpers
Description
Consider a data frame with results of multi-objective stochastic optimizers on
a set of problems from different categories/groups (say indicated by column “group”).
Occasionally, it is useful to unite the results of several groups into a meta-group.
The function addUnionGroup
aids in generation of such a meta-group while
function addAllGroup
is a wrapper around the former which generates a
union of all groups.
Usage
addUnionGroup(df, col, group, values)
addAllGroup(df, col, group = "all")
Arguments
df |
[ |
col |
[ |
group |
[ |
values |
[ |
Value
[data.frame
] Modified data frame.
Examples
df = data.frame(
group = c("A1", "A1", "A2", "A2", "B"),
perf = runif(5),
stringsAsFactors = FALSE)
df2 = addUnionGroup(df, col = "group", group = "A", values = c("A1", "A2"))
df3 = addAllGroup(df, col = "group", group = "ALL")
Reference point approximations.
Description
Helper functions to compute nadir or ideal point from sets of points, e.g., multiple approximation sets.
Usage
approximateNadirPoint(..., sets = NULL)
approximateIdealPoint(..., sets = NULL)
Arguments
... |
[ |
sets |
[ |
Value
[numeric
] Reference point.
See Also
Other EMOA performance assessment tools:
approximateRefPoints()
,
approximateRefSets()
,
computeDominanceRanking()
,
emoaIndEps()
,
makeEMOAIndicator()
,
niceCellFormater()
,
normalize()
,
plotDistribution()
,
plotFront()
,
plotScatter2d()
,
plotScatter3d()
,
toLatex()
Helper function to estimate reference points.
Description
E.g., for calculation of dominated hypervolume.
Usage
approximateRefPoints(df, obj.cols = c("f1", "f2"), offset = 0, as.df = FALSE)
Arguments
df |
[ |
obj.cols |
[ |
offset |
[ |
as.df |
[ |
Value
[list
| data.frame
]
See Also
Other EMOA performance assessment tools:
approximateNadirPoint()
,
approximateRefSets()
,
computeDominanceRanking()
,
emoaIndEps()
,
makeEMOAIndicator()
,
niceCellFormater()
,
normalize()
,
plotDistribution()
,
plotFront()
,
plotScatter2d()
,
plotScatter3d()
,
toLatex()
Helper function to estimate reference set(s).
Description
The function takes an data frame with columns at least
specified by obj.cols
and “prob”. The reference set for
each unique problem in column “prob” is then obtained by
combining all approximation sets generated by all considered algorithms
for the corresponding problem and filtering the non-dominated solutions.
Usage
approximateRefSets(df, obj.cols, as.df = FALSE)
Arguments
df |
[ |
obj.cols |
[ |
as.df |
[ |
Value
[list
| data.frame
] Named list of matrizes
(names are the problems) or data frame with columns obj.cols
and “prob”.
See Also
Other EMOA performance assessment tools:
approximateNadirPoint()
,
approximateRefPoints()
,
computeDominanceRanking()
,
emoaIndEps()
,
makeEMOAIndicator()
,
niceCellFormater()
,
normalize()
,
plotDistribution()
,
plotFront()
,
plotScatter2d()
,
plotScatter3d()
,
toLatex()
Implementation of the NSGA-II EMOA algorithm by Deb.
Description
The AS-EMOA, short for aspiration set evolutionary multi-objective algorithm aims to incorporate expert knowledge into multi-objective optimization [1]. The algorithm expects an aspiration set, i.e., a set of reference points. It then creates an approximation of the pareto front close to the aspiration set utilizing the average Hausdorff distance.
Usage
asemoa(
fitness.fun,
n.objectives = NULL,
minimize = NULL,
n.dim = NULL,
lower = NULL,
upper = NULL,
mu = 10L,
aspiration.set = NULL,
normalize.fun = NULL,
dist.fun = computeEuclideanDistance,
p = 1,
parent.selector = setup(selSimple),
mutator = setup(mutPolynomial, eta = 25, p = 0.2, lower = lower, upper = upper),
recombinator = setup(recSBX, eta = 15, p = 0.7, lower = lower, upper = upper),
terminators = list(stopOnIters(100L))
)
Arguments
fitness.fun |
[ |
n.objectives |
[ |
minimize |
[ |
n.dim |
[ |
lower |
[ |
upper |
[ |
mu |
[ |
aspiration.set |
[ |
normalize.fun |
[ |
dist.fun |
[ |
p |
[ |
parent.selector |
[ |
mutator |
[ |
recombinator |
[ |
terminators |
[ |
Value
[ecr_multi_objective_result
]
Note
This is a pure R implementation of the AS-EMOA algorithm. It hides the regular ecr interface and offers a more R like interface while still being quite adaptable.
References
[1] Rudolph, G., Schuetze, S., Grimme, C., Trautmann, H: An Aspiration Set EMOA Based on Averaged Hausdorff Distances. LION 2014: 153-156. [2] G. Rudolph, O. Schuetze, C. Grimme, and H. Trautmann: A Multiobjective Evolutionary Algorithm Guided by Averaged Hausdorff Distance to Aspiration Sets, pp. 261-273 in A.-A. Tantar et al. (eds.): Proceedings of EVOLVE - A bridge between Probability, Set Oriented Numerics and Evolutionary Computation V, Springer: Berlin Heidelberg 2014.
Assign group membership based on another group membership.
Description
Given a data frame and a grouping column of type factor or character this function generates a new grouping column which groups the groups.
Usage
categorize(df, col, categories, cat.col, keep = TRUE, overwrite = FALSE)
Arguments
df |
[ |
col |
[ |
categories |
[ |
cat.col |
[ |
keep |
[ |
overwrite |
[ |
Value
[data.frame
]
df = data.frame(
group = c("A1", "A1", "A2", "A2", "B1", "B2"),
perf = runif(6),
stringsAsFactors = FALSE)
df2 = categorize(df, col = "group", categories = list(A = c("A1", "A2"), B = c("B1", "B2")), cat.col = "group2")
Average Hausdorff Distance computation.
Description
Computes the average Hausdroff distance measure between two point sets.
Usage
computeAverageHausdorffDistance(
A,
B,
p = 1,
normalize = FALSE,
dist.fun = computeEuclideanDistance
)
Arguments
A |
[ |
B |
[ |
p |
[ |
normalize |
[ |
dist.fun |
[ |
Value
[numeric(1)
] Average Hausdorff distance of sets A
and B
.
Compute the crowding distance of a set of points.
Description
The crowding distance is a measure of spread of solutions in the approximation of the Pareto front. It is used, e.g., in the NSGA-II algorithm as a second selection criterion.
Usage
computeCrowdingDistance(x)
Arguments
x |
[ |
Value
[numeric
] Vector of crowding distance values.
References
K. Deb, A. Pratap, S. Agarwal, T. Meyarivan, A fast and elitist multiobjective genetic algorithm: NSGA-II, IEEE Transactions on Evolutionary Computation In Evolutionary Computation, IEEE Transactions on, Vol. 6, No. 2. (07 April 2002), pp. 182-197, doi:10.1109/4235.996017
Computes distance between a single point and set of points.
Description
Helper to compute distance between a single point and a point set.
Usage
computeDistanceFromPointToSetOfPoints(
a,
B,
dist.fun = computeEuclideanDistance
)
Arguments
a |
[ |
B |
[ |
dist.fun |
[ |
Value
[numeric(1)
]
Ranking of approximation sets.
Description
Ranking is performed by merging all approximation sets over all
algorithms and runs per instance. Next, each approximation set C
is assigned a
rank which is 1 plus the number of approximation sets that are better than
C
. A set D
is better than C
, if for each point x \in C
there
exists a point in y \in D
which weakly dominates x
.
Thus, each approximation set is reduced to a number – its rank. This rank distribution
may act for first comparrison of multi-objecitve stochastic optimizers.
See [1] for more details.
This function makes use of parallelMap
to
parallelize the computation of dominance ranks.
Usage
computeDominanceRanking(df, obj.cols)
Arguments
df |
[ |
obj.cols |
[ |
Value
[data.frame
] Reduced df
with columns “prob”, “algorithm”, “repl”
and “rank”.
Note
Since pairwise non-domination checks are performed over all algorithms and algorithm runs this function may take some time if the number of problems, algorithms and/or replications is high.
References
[1] Knowles, J., Thiele, L., & Zitzler, E. (2006). A Tutorial on the Performance Assessment of Stochastic Multiobjective Optimizers. Retrieved from https://sop.tik.ee.ethz.ch/KTZ2005a.pdf
See Also
Other EMOA performance assessment tools:
approximateNadirPoint()
,
approximateRefPoints()
,
approximateRefSets()
,
emoaIndEps()
,
makeEMOAIndicator()
,
niceCellFormater()
,
normalize()
,
plotDistribution()
,
plotFront()
,
plotScatter2d()
,
plotScatter3d()
,
toLatex()
Computes Generational Distance.
Description
Helper to compute the Generational Distance (GD) between two sets of points.
Usage
computeGenerationalDistance(
A,
B,
p = 1,
normalize = FALSE,
dist.fun = computeEuclideanDistance
)
Arguments
A |
[ |
B |
[ |
p |
[ |
normalize |
[ |
dist.fun |
[ |
Value
[numeric(1)
]
Functions for the calculation of the dominated hypervolume (contribution).
Description
The function computeHV
computes the dominated
hypervolume of a set of points given a reference set whereby
computeHVContr
computes the hypervolume contribution
of each point.
If no reference point is given the nadir point of the set x
is
determined and a positive offset with default 1 is added. This is to ensure
that the reference point dominates all of the points in the reference set.
Usage
computeHV(x, ref.point = NULL, ...)
computeHVContr(x, ref.point = NULL, offset = 1)
Arguments
x |
[ |
ref.point |
[ |
... |
[any] |
offset |
[ |
Value
[numeric(1)
] Dominated hypervolume in the case of
computeHV
and the dominated hypervolume contributions
for each point in the case of computeHVContr
.
Note
: Keep in mind that this function assumes all objectives to be minimized.
In case at least one objective is to be maximized the matrix x
needs
to be transformed accordingly in advance.
Computation of EMOA performance indicators.
Description
Given a data.frame of Pareto-front approximations for different
sets of problems, algorithms and replications, the function computes sets
of unary and binary EMOA performance indicators.
This function makes use of parallelMap
to
parallelize the computation of indicators.
Usage
computeIndicators(
df,
obj.cols = c("f1", "f2"),
unary.inds = NULL,
binary.inds = NULL,
normalize = FALSE,
offset = 0,
ref.points = NULL,
ref.sets = NULL
)
Arguments
df |
[ |
obj.cols |
[ |
unary.inds |
[ |
binary.inds |
[ |
normalize |
[ |
offset |
[ |
ref.points |
[ |
ref.sets |
[ |
Value
[list
] List with components “unary” (data frame of
unary indicators), “binary” (list of matrizes of binary indicators),
“ref.points” (list of reference points used) and “ref.sets”
(reference sets used).
References
[1] Knowles, J., Thiele, L., & Zitzler, E. (2006). A Tutorial on the Performance Assessment of Stochastic Multiobjective Optimizers. Retrieved from https://sop.tik.ee.ethz.ch/KTZ2005a.pdf [2] Knowles, J., & Corne, D. (2002). On Metrics for Comparing Non-Dominated Sets. In Proceedings of the 2002 Congress on Evolutionary Computation Conference (CEC02) (pp. 711–716). Honolulu, HI, USA: Institute of Electrical and Electronics Engineers. [3] Okabe, T., Yaochu, Y., & Sendhoff, B. (2003). A Critical Survey of Performance Indices for Multi-Objective Optimisation. In Proceedings of the 2003 Congress on Evolutionary Computation Conference (CEC03) (pp. 878–885). Canberra, ACT, Australia: IEEE.
Computes Inverted Generational Distance.
Description
Helper to compute the Inverted Generational Distance (IGD) between two sets of points.
Usage
computeInvertedGenerationalDistance(
A,
B,
p = 1,
normalize = FALSE,
dist.fun = computeEuclideanDistance
)
Arguments
A |
[ |
B |
[ |
p |
[ |
normalize |
[ |
dist.fun |
[ |
Value
[numeric(1)
]
Fast non-dominated sorting algorithm.
Description
Fast non-dominated sorting algorithm proposed by Deb. Non-dominated sorting expects a set of points and returns a set of non-dominated fronts. In short words this is done as follows: the non-dominated points of the entire set are determined and assigned rank 1. Afterwards all points with the current rank are removed, the rank is increased by one and the procedure starts again. This is done until the set is empty, i.~e., each point is assigned a rank.
Usage
doNondominatedSorting(x)
Arguments
x |
[ |
Value
[list
]
List with the following components
- ranks
Integer vector of ranks of length
ncol(x)
. The higher the rank, the higher the domination front the corresponding point is located on.- dom.counter
Integer vector of length
ncol(x)
. The i-th element is the domination number of the i-th point.
Note
This procedure is the key survival selection of the famous NSGA-II multi-objective
evolutionary algorithm (see nsga2
).
References
[1] Deb, K., Pratap, A., and Agarwal, S. A Fast and Elitist Multiobjective Genetic Algorithm: NSGA-II. IEEE Transactions on Evolutionary Computation, 6 (8) (2002), 182-197.
Check for pareto dominance.
Description
These functions take a numeric matrix x
where each column corresponds to
a point and return a logical vector. The i-th position of the latter is
TRUE
if the i-th point is dominated by at least one other point for
dominated
and FALSE
for nonDominated
.
Usage
dominated(x)
nondominated(x)
Arguments
x |
[ |
Value
[logical
]
Dominance relation check.
Description
Check if a vector dominates another (dominates
) or is
dominated by another (isDominated
). There are corresponding infix
operators dominates
and isDominatedBy
.
Usage
dominates(x, y)
isDominated(x, y)
x %dominates% y
x %isDominatedBy% y
Arguments
x |
[ |
y |
[ |
Value
[logical(1)
]
Interface to ecr similar to the optim function.
Description
The most flexible way to setup evolutionary algorithms with ecr is by
explicitely writing the evolutionary loop utilizing various ecr utlity functions.
However, in everyday life R users frequently need to optimize a single-objective R function.
The ecr
function thus provides a more R like interface for single
objective optimization similar to the interface of the optim
function.
Usage
ecr(
fitness.fun,
minimize = NULL,
n.objectives = NULL,
n.dim = NULL,
lower = NULL,
upper = NULL,
n.bits,
representation,
mu,
lambda,
perm = NULL,
p.recomb = 0.7,
p.mut = 0.3,
survival.strategy = "plus",
n.elite = 0L,
log.stats = list(fitness = list("min", "mean", "max")),
log.pop = FALSE,
monitor = NULL,
initial.solutions = NULL,
parent.selector = NULL,
survival.selector = NULL,
mutator = NULL,
recombinator = NULL,
terminators = list(stopOnIters(100L)),
...
)
Arguments
fitness.fun |
[ |
minimize |
[ |
n.objectives |
[ |
n.dim |
[ |
lower |
[ |
upper |
[ |
n.bits |
[ |
representation |
[ |
mu |
[ |
lambda |
[ |
perm |
[ |
p.recomb |
[ |
p.mut |
[ |
survival.strategy |
[ |
n.elite |
[ |
log.stats |
[ |
log.pop |
[ |
monitor |
[ |
initial.solutions |
[ |
parent.selector |
[ |
survival.selector |
[ |
mutator |
[ |
recombinator |
[ |
terminators |
[ |
... |
[any] |
Value
Examples
fn = function(x) {
sum(x^2)
}
lower = c(-5, -5); upper = c(5, 5)
res = ecr(fn, n.dim = 2L, n.objectives = 1L, lower = lower, upper = lower,
representation = "float", mu = 20L, lambda = 10L,
mutator = setup(mutGauss, lower = lower, upper = upper))
Parallelization in ecr
Description
In ecr it is possible to parallelize the fitness function evaluation
to make use, e.g., of multiple CP cores or nodes in a HPC cluster.
For maximal flexibility this is realized by means of the parallelMap package
(see the official
GitHub page for instructions on how to set up parallelization).
The different levels of parallelization can be specified in the
parallelStart*
function. At them moment only the level
“ecr.evaluateFitness” is supported.
Keep in mind that parallelization comes along with some overhead. Thus activating parallelization, e.g., for evaluation a fitness function which is evaluated lightning-fast, may result in higher computation time. However, if the function evaluations are computationally more expensive, parallelization leads to significant running time benefits.
Result object.
Description
S3 object returned by ecr
containing the best found
parameter setting and value in the single-objective case and the Pareto-front/-set
in case of a multi-objective optimization problem. Moreover a set of further
information, e.g., reason of termination, the control object etc. are returned.
The single objective result object contains the following fields:
- task
The
ecr_optimization_task
.- best.x
Overall best parameter setting.
- best.y
Overall best objective value.
- log
Logger object.
- last.population
Last population.
- last.fitness
Numeric vector of fitness values of the last population.
- message
Character string describing the reason of termination.
In case of a solved multi-objective function the result object contains the following fields:
- task
The
ecr_optimization_task
.- log
Logger object.
- pareto.idx
Indizes of the non-dominated solutions in the last population.
- pareto.front
(n x d) matrix of the approximated non-dominated front where n is the number of non-dominated points and d is the number of objectives.
- pareto.set
Matrix of decision space values resulting with objective values given in pareto.front.
- last.population
Last population.
- message
Character string describing the reason of termination.
EMOA performance indicators
Description
Functions for the computation of unary and binary measures which are useful for the evaluation of the performace of EMOAs. See the references section for literature on these indicators.
Given a set of points points
, emoaIndEps
computes the
unary epsilon-indicator provided a set of reference points ref.points
.
The emoaIndHV
function computes the hypervolume indicator
Hyp(X, R, r). Given a set of points X (points
), another set of reference
points R (ref.points
) (which maybe the true Pareto front) and a reference
point r (ref.point
) it is defined as Hyp(X, R, r) = HV(R, r) - HV(X, r).
Function emoaIndR1
, emoaIndR2
and emoaIndR3
calculate the
R1, R2 and R3 indicator respectively.
Function emoaIndMD
computes the minimum distance indicator, i.e., the minimum
Euclidean distance between two points of the set points
while function
emoaIndM1
determines the mean Euclidean distance between points
and points from a reference set ref.points
.
Function emoaIndC
calculates the coverage of the sets points
(A) and
ref.points
(B). This is the ratio of points in B which are dominated by
at least one solution in A.
emoaIndONVG
calculates the “Overall Non-dominated Vector Generation”
indicator. Despite its complicated name it is just the number of non-dominated points
in points
.
Functions emoaIndSP
and emoaIndDelta
calculate spacing indicators.
The former was proposed by Schott: first calculate the sum of squared distances
between minimal distancesof points to all other points and the mean of these minimal
distance. Next, normalize by the number of points minus 1 and finally calculate the
square root. In contrast, Delta-indicator
Usage
emoaIndEps(points, ref.points, ...)
emoaIndHV(points, ref.points, ref.point = NULL, ...)
emoaIndR1(
points,
ref.points,
ideal.point = NULL,
nadir.point = NULL,
lambda = NULL,
utility = "tschebycheff",
...
)
emoaIndR2(
points,
ref.points,
ideal.point = NULL,
nadir.point = NULL,
lambda = NULL,
utility = "tschebycheff",
...
)
emoaIndR3(
points,
ref.points,
ideal.point = NULL,
nadir.point = NULL,
lambda = NULL,
utility = "tschebycheff",
...
)
emoaIndMD(points, ...)
emoaIndC(points, ref.points, ...)
emoaIndM1(points, ref.points, ...)
emoaIndONVG(points, ...)
emoaIndGD(
points,
ref.points,
p = 1,
normalize = FALSE,
dist.fun = computeEuclideanDistance,
...
)
emoaIndIGD(
points,
ref.points,
p = 1,
normalize = FALSE,
dist.fun = computeEuclideanDistance,
...
)
emoaIndDeltap(
points,
ref.points,
p = 1,
normalize = FALSE,
dist.fun = computeEuclideanDistance,
...
)
emoaIndSP(points, ...)
emoaIndDelta(points, ...)
Arguments
points |
[ |
ref.points |
[ |
... |
[any] |
ref.point |
[ |
ideal.point |
[ |
nadir.point |
[ |
lambda |
[ |
utility |
[ |
p |
[ |
normalize |
[ |
dist.fun |
[ |
Value
[numeric(1)
] Epsilon indicator.
See Also
Other EMOA performance assessment tools:
approximateNadirPoint()
,
approximateRefPoints()
,
approximateRefSets()
,
computeDominanceRanking()
,
makeEMOAIndicator()
,
niceCellFormater()
,
normalize()
,
plotDistribution()
,
plotFront()
,
plotScatter2d()
,
plotScatter3d()
,
toLatex()
Computes the fitness value(s) for each individual of a given set.
Description
This function expects a list of individuals, computes the fitness and always
returns a matrix of fitness values; even in single-objective optimization a
(1 x n) matrix is returned for consistency, where n is the number of individuals.
This function makes use of parallelMap
to
parallelize the fitness evaluation.
Usage
evaluateFitness(control, inds, ...)
Arguments
control |
[ |
inds |
[ |
... |
[any] |
Value
[matrix
].
Explode/implode data frame column(s).
Description
Given a data frame and a column name, function
explode
splits the content of a column by a specified
delimiter (thus exploded) into multiple columns. Function implode
does vice versa, i.e., given a non-empty set of column names or
numbers, the function glues together the columns. Hence, functions
explode
and implode
are kind of inverse to each other.
Usage
explode(df, col, by = ".", keep = FALSE, col.names = NULL)
implode(df, cols, by = ".", keep = FALSE, col.name)
Arguments
df |
[ |
col |
[ |
by |
[ |
keep |
[ |
col.names |
[ |
cols |
[ |
col.name |
[ |
Value
[data.frame
] Modified data frame.
Examples
df = data.frame(x = 1:3, y = c("a.c", "a.b", "a.c"))
df.ex = explode(df, col = "y", col.names = c("y1", "y2"))
df.im = implode(df.ex, cols = c("y1", "y2"), by = "---", col.name = "y", keep = TRUE)
Filter approximation sets by duplicate objective vectors.
Description
Filter approximation sets by duplicate objective vectors.
Usage
filterDuplicated(x, ...)
## S3 method for class 'data.frame'
filterDuplicated(x, ...)
## S3 method for class 'matrix'
filterDuplicated(x, ...)
## S3 method for class 'ecr_multi_objective_result'
filterDuplicated(x, ...)
## S3 method for class 'list'
filterDuplicated(x, ...)
Arguments
x |
[ |
... |
[any] |
Value
[object
] Modified input x
.
Note
Note that this may be misleading if there can be solutions with identical objective function values but different values in decision space.
Helper functions for offspring generation
Description
Function mutate
expects a control object, a list of individuals, and a mutation
probability. The mutation operator registered in the control object is then applied
with the given probability to each individual.
Function recombinate
expects a control object, a list of individuals as well as
their fitness matrix and creates lambda
offspring individuals by recombining parents
from inds
. Which parents take place in the parent selection depends on
the parent.selector
registered in the control object.
Finally, function generateOffspring
is a wrapper for both recombinate
and mutate
. Both functions are applied subsequently to generate new individuals
by variation and mutation.
Usage
generateOffspring(control, inds, fitness, lambda, p.recomb = 0.7, p.mut = 0.1)
mutate(control, inds, p.mut = 0.1, slot = "mutate", ...)
recombinate(
control,
inds,
fitness,
lambda = length(inds),
p.recomb = 0.7,
slot = "recombine",
...
)
Arguments
control |
[ |
inds |
[ |
fitness |
[ |
lambda |
[ |
p.recomb |
[ |
p.mut |
[ |
slot |
[ |
... |
[any] |
Value
[list
] List of individuals.
Does the recombinator generate multiple children?
Description
Returns as to whether the recombinator generates multiple Children.
Usage
generatesMultipleChildren(recombinator)
Arguments
recombinator |
[ |
Value
[logical
]
Boolean
Population generators
Description
Utility functions to build a set of individuals. The function
gen
expects an R expression and a number n in order to create a list
of n individuals based on the given expression. Functions genBin
,
genPerm
and genReal
are shortcuts for initializing populations
of binary strings, permutations or real-valued vectors respectively.
Usage
gen(expr, n)
genBin(n, n.dim)
genPerm(n, n.dim)
genReal(n, n.dim, lower, upper)
Arguments
expr |
[R expression] |
n |
[ |
n.dim |
[ |
lower |
[ |
upper |
[ |
Value
[list
]
Extract fitness values from Pareto archive.
Description
Get all non-dominated points in objective space, i.e., an (m x n) matrix of fitness with m being the number of objectives and n being the number of non-dominated points in the Pareto archive.
Usage
getFront(x)
Arguments
x |
[ |
Value
[matrix
]
Extract individuals from Pareto archive.
Description
Get the non-dominated individuals logged in the Pareto archive.
Usage
getIndividuals(x)
Arguments
x |
[ |
Value
[list
]
See Also
Other ParetoArchive:
getSize()
,
initParetoArchive()
,
updateParetoArchive()
Number of children
Description
Returns the number children generated by the recombinator
Usage
getNumberOfChildren(recombinator)
Arguments
recombinator |
[ |
Value
[numeric
]
Number of children generated
Number of parents needed for mating
Description
Returns the number of parents needed for mating.
Usage
getNumberOfParentsNeededForMating(recombinator)
Arguments
recombinator |
[ |
Value
[numeric
]
Number of Parents need for mating
Access to logged population fitness.
Description
Returns the fitness values of all individuals as a data.frame with columns f1, ..., fo, where o is the number of objectives and column “gen” for generation.
Usage
getPopulationFitness(log, trim = TRUE)
Arguments
log |
[ |
trim |
[ |
Value
[list
] List of populations.
See Also
Other logging:
getPopulations()
,
getStatistics()
,
initLogger()
,
updateLogger()
Access to logged populations.
Description
Simple getter for the logged populations.
Usage
getPopulations(log, trim = TRUE)
Arguments
log |
[ |
trim |
[ |
Details
This functions throws an error if the logger was initialized with
log.pop = FALSE
(see initLogger
).
Value
[list
] List of populations.
See Also
Other logging:
getPopulationFitness()
,
getStatistics()
,
initLogger()
,
updateLogger()
Get size of Pareto-archive.
Description
Returns the number of stored individuals in Pareto archive.
Usage
getSize(x)
Arguments
x |
[ |
Value
[integer(1)
]
See Also
Other ParetoArchive:
getIndividuals()
,
initParetoArchive()
,
updateParetoArchive()
Access the logged statistics.
Description
Simple getter for the logged fitness statistics.
Usage
getStatistics(log, trim = TRUE)
Arguments
log |
[ |
trim |
[ |
Value
[data.frame
] Logged statistics.
See Also
Other logging:
getPopulationFitness()
,
getPopulations()
,
initLogger()
,
updateLogger()
Get supported representations.
Description
Returns the character vector of representation which the operator supports.
Usage
getSupportedRepresentations(operator)
Arguments
operator |
[ |
Value
[character
]
Vector of representation types.
Control object generator.
Description
The control object keeps information on the objective function and a set of evolutionary components, i.e., operators.
Usage
initECRControl(fitness.fun, n.objectives = NULL, minimize = NULL)
Arguments
fitness.fun |
[ |
n.objectives |
[ |
minimize |
[ |
Value
[ecr_control
]
Initialize a log object.
Description
Logging is a central aspect of each EA. Besides the final solution(s)
especially in research often we need to keep track of different aspects of the
evolutionary process, e.g., fitness statistics. The logger of ecr keeps
track of different user-defined statistics and the population.
It may also be used to check stopping conditions (see makeECRTerminator
). Most
important this logger is used internally by the ecr
black-box interface.
Usage
initLogger(
control,
log.stats = list(fitness = list("min", "mean", "max")),
log.extras = NULL,
log.pop = FALSE,
init.size = 1000L
)
Arguments
control |
[ |
log.stats |
[ |
log.extras |
[ |
log.pop |
[ |
init.size |
[ |
Value
[ecr_logger
]
An S3 object of class ecr_logger
with the following components:
- log.stats
The
log.stats
list.- log.pop
The
log.pop
parameter.- init.size
Initial size of the log.
- env
The actual log. This is an R environment which ensures, that in-place modification is possible.
Note
Statistics are logged in a data.frame
.
See Also
Other logging:
getPopulationFitness()
,
getPopulations()
,
getStatistics()
,
updateLogger()
Examples
control = initECRControl(function(x) sum(x), minimize = TRUE,
n.objectives = 1L)
control = registerECROperator(control, "mutate", mutBitflip, p = 0.1)
control = registerECROperator(control, "selectForMating", selTournament, k = 2)
control = registerECROperator(control, "selectForSurvival", selGreedy)
log = initLogger(control,
log.stats = list(
fitness = list("mean", "myRange" = function(x) max(x) - min(x)),
age = list("min", "max")
), log.pop = TRUE, init.size = 1000L)
# simply pass stuff down to control object constructor
population = initPopulation(mu = 10L, genBin, n.dim = 10L)
fitness = evaluateFitness(control, population)
# append fitness to individuals and init age
for (i in seq_along(population)) {
attr(population[[i]], "fitness") = fitness[, i]
attr(population[[i]], "age") = 1L
}
for (iter in seq_len(10)) {
# generate offspring
offspring = generateOffspring(control, population, fitness, lambda = 5)
fitness.offspring = evaluateFitness(control, offspring)
# update age of population
for (i in seq_along(population)) {
attr(population[[i]], "age") = attr(population[[i]], "age") + 1L
}
# set offspring attributes
for (i in seq_along(offspring)) {
attr(offspring[[i]], "fitness") = fitness.offspring[, i]
# update age
attr(offspring[[i]], "age") = 1L
}
sel = replaceMuPlusLambda(control, population, offspring)
population = sel$population
fitness = sel$fitness
# do some logging
updateLogger(log, population, n.evals = 5)
}
head(getStatistics(log))
Initialize Pareto Archive.
Description
A Pareto archive is usually used to store all / a part of the non-dominated points stored during a run of an multi-objective evolutionary algorithm.
Usage
initParetoArchive(control, max.size = Inf, trunc.fun = NULL)
Arguments
control |
[ |
max.size |
[ |
trunc.fun |
[ |
Value
[ecr_pareto_archive
]
See Also
Other ParetoArchive:
getIndividuals()
,
getSize()
,
updateParetoArchive()
Helper function to build initial population.
Description
Generates the initial population. Optionally a set of initial solutions can be passed.
Usage
initPopulation(mu, gen.fun, initial.solutions = NULL, ...)
Arguments
mu |
[ |
gen.fun |
[ |
initial.solutions |
[ |
... |
[any] |
Value
[ecr_population
]
Check if ecr operator supports given representation.
Description
Check if the given operator supportds a certain representation, e.g., “float”.
Usage
is.supported(operator, representation)
Arguments
operator |
[ |
representation |
[ |
Value
[logical(1)
]
TRUE
, if operator supports the representation type.
Check if given function is an ecr operator.
Description
Checks if the passed object is of type ecr_operator
.
Usage
isEcrOperator(obj)
Arguments
obj |
[any] |
Value
[logical(1)
]
Factory method for monitor objects.
Description
Monitor objects serve for monitoring the optimization process, e.g., printing
some status messages to the console. Each monitor includes the functions
before
, step
and after
, each being a function and expecting
a log log
of type ecr_logger
and ...
as the only parameters.
This way the logger has access to the entire log.
Usage
makeECRMonitor(before = NULL, step = NULL, after = NULL, ...)
Arguments
before |
[ |
step |
[ |
after |
[ |
... |
[ |
Value
[ecr_monitor
]
Monitor object.
Constructor for EMOA indicators.
Description
Simple wrapper for function which compute
performance indicators for multi-objective stochastic algorithm.
Basically this function appends some meta information to the
passed function fun
.
Usage
makeEMOAIndicator(fun, minimize, name, latex.name)
Arguments
fun |
[ |
minimize |
[ |
name |
[ |
latex.name |
[ |
Value
[function(points, ...)
] Argument fun
with all other
arguments appended.
See Also
Other EMOA performance assessment tools:
approximateNadirPoint()
,
approximateRefPoints()
,
approximateRefSets()
,
computeDominanceRanking()
,
emoaIndEps()
,
niceCellFormater()
,
normalize()
,
plotDistribution()
,
plotFront()
,
plotScatter2d()
,
plotScatter3d()
,
toLatex()
Construct a mutation operator.
Description
Helper function which constructs a mutator, i. e., a mutation operator.
Usage
makeMutator(mutator, supported = getAvailableRepresentations())
Arguments
mutator |
[ |
supported |
[ |
Value
[ecr_mutator
]
Mutator object.
Construct evolutionary operator.
Description
Helper function which constructs an evolutionary operator.
Usage
makeOperator(operator, supported = getAvailableRepresentations())
Arguments
operator |
[ |
supported |
[ |
Value
[ecr_operator
] Operator object.
Note
In general you will not need this function, but rather one of its
deriviatives like makeMutator
or makeSelector
.
Creates an optimization task.
Description
An optimization task consists of the fitness/objective function, the number of objectives, the “direction” of optimization, i.e., which objectives should be minimized/maximized and the names of the objectives.
Usage
makeOptimizationTask(
fun,
n.objectives = NULL,
minimize = NULL,
objective.names = NULL
)
Arguments
fun |
[ |
n.objectives |
[ |
minimize |
[ |
objective.names |
[ |
Value
[ecr_optimization_task
]
Construct a recombination operator.
Description
Helper function which constructs a recombinator, i. e., a recombination operator.
Usage
makeRecombinator(
recombinator,
supported = getAvailableRepresentations(),
n.parents = 2L,
n.children = NULL
)
Arguments
recombinator |
[ |
supported |
[ |
n.parents |
[ |
n.children |
[ |
Value
[ecr_recombinator
]
Recombinator object.
Note
If a recombinator returns more than one child, the multiple.children
parameter needs to be TRUE
, which is the default. In case of multiple
children produced these have to be placed within a list.
Construct a selection operator.
Description
Helper function which defines a selector method, i. e., an operator which takes the population and returns a part of it for mating or survival.
Usage
makeSelector(
selector,
supported = getAvailableRepresentations(),
supported.objectives,
supported.opt.direction = "minimize"
)
Arguments
selector |
[ |
supported |
[ |
supported.objectives |
[ |
supported.opt.direction |
[ |
Value
[ecr_selector
]
Selector object.
Generate stopping condition.
Description
Wrap a function within a stopping condition object.
Usage
makeTerminator(condition.fun, name, message)
Arguments
condition.fun |
[ |
name |
[ |
message |
[ |
Value
[ecr_terminator
]
mcMST
Description
Pareto-front approximations for some graph problems obtained by several algorithms for the multi-criteria minimum spanning tree (mcMST) problem.
Usage
mcMST
Format
A data frame with four variables:
f1
First objective (to be minimized).
f2
Second objective (to be minimized).
algorithm
Short name of algorithm used.
prob
Short name of problem instance.
repl
Algorithm run.
The data is based on the mcMST package.
Bitplip mutator.
Description
This operator works only on binary representation and flips each bit
with a given probability p \in (0, 1)
. Usually it is recommended to
set p = \frac{1}{n}
where n
is the number of bits in the
representation.
Usage
mutBitflip(ind, p = 0.1)
Arguments
ind |
[ |
p |
[ |
Value
[binary
]
References
[1] Eiben, A. E. & Smith, James E. (2015). Introduction to Evolutionary Computing (2nd ed.). Springer Publishing Company, Incorporated. 52.
See Also
Other mutators:
mutGauss()
,
mutInsertion()
,
mutInversion()
,
mutJump()
,
mutPolynomial()
,
mutScramble()
,
mutSwap()
,
mutUniform()
Gaussian mutator.
Description
Default Gaussian mutation operator known from Evolutionary Algorithms.
This mutator is applicable only for representation="float"
. Given
an individual \mathbf{x} \in R^l
this mutator adds a Gaussian
distributed random value to each component of \mathbf{x}
, i.~e.,
\tilde{\mathbf{x}}_i = \mathbf{x}_i + \sigma \mathcal{N}(0, 1)
.
Usage
mutGauss(ind, p = 1L, sdev = 0.05, lower, upper)
Arguments
ind |
[ |
p |
[ |
sdev |
[ |
lower |
[ |
upper |
[ |
Value
[numeric
]
References
[1] Beyer, Hans-Georg & Schwefel, Hans-Paul (2002). Evolution strategies. Kluwer Academic Publishers.
[2] Mateo, P. M. & Alberto, I. (2011). A mutation operator based on a Pareto ranking for multi-objective evolutionary algorithms. Springer Science+Business Meda. 57.
See Also
Other mutators:
mutBitflip()
,
mutInsertion()
,
mutInversion()
,
mutJump()
,
mutPolynomial()
,
mutScramble()
,
mutSwap()
,
mutUniform()
Insertion mutator.
Description
The Insertion mutation operator selects a position random and inserts it at a random position.
Usage
mutInsertion(ind)
Arguments
ind |
[ |
Value
[integer
]
See Also
Other mutators:
mutBitflip()
,
mutGauss()
,
mutInversion()
,
mutJump()
,
mutPolynomial()
,
mutScramble()
,
mutSwap()
,
mutUniform()
Inversion mutator.
Description
The Inversion mutation operator selects two positions within the chromosome at random and inverts the elements inbetween.
Usage
mutInversion(ind)
Arguments
ind |
[ |
Value
[integer
]
See Also
Other mutators:
mutBitflip()
,
mutGauss()
,
mutInsertion()
,
mutJump()
,
mutPolynomial()
,
mutScramble()
,
mutSwap()
,
mutUniform()
Jump mutator.
Description
The jump mutation operator selects two positions within the chromosome at
random, say a
and b
with a < b
. Next, all elements at
positions b-1, b-2, ..., a
are shifted to the right by one position
and finally the element at position b
is assigned at position a
.
Usage
mutJump(ind)
Arguments
ind |
[ |
Value
[integer
]
See Also
Other mutators:
mutBitflip()
,
mutGauss()
,
mutInsertion()
,
mutInversion()
,
mutPolynomial()
,
mutScramble()
,
mutSwap()
,
mutUniform()
Polynomial mutation.
Description
Performs an polynomial mutation as used in the SMS-EMOA algorithm. Polynomial mutation tries to simulate the distribution of the offspring of binary-encoded bit flip mutations based on real-valued decision variables. Polynomial mutation favors offspring nearer to the parent.
Usage
mutPolynomial(ind, p = 0.2, eta = 10, lower, upper)
Arguments
ind |
[ |
p |
[ |
eta |
[ |
lower |
[ |
upper |
[ |
Value
[numeric
]
References
[1] Deb, Kalyanmoy & Goyal, Mayank. (1999). A Combined Genetic Adaptive Search (GeneAS) for Engineering Design. Computer Science and Informatics. 26. Retrieved from http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.27.767&rep=rep1&type=pdf
See Also
Other mutators:
mutBitflip()
,
mutGauss()
,
mutInsertion()
,
mutInversion()
,
mutJump()
,
mutScramble()
,
mutSwap()
,
mutUniform()
Scramble mutator.
Description
The Scramble mutation operator selects two positions within the chromosome at random and randomly intermixes the subsequence between these positions.
Usage
mutScramble(ind)
Arguments
ind |
[ |
Value
[integer
]
See Also
Other mutators:
mutBitflip()
,
mutGauss()
,
mutInsertion()
,
mutInversion()
,
mutJump()
,
mutPolynomial()
,
mutSwap()
,
mutUniform()
Swap mutator.
Description
Chooses two positions at random and swaps the genes.
Usage
mutSwap(ind)
Arguments
ind |
[ |
Value
[integer
]
See Also
Other mutators:
mutBitflip()
,
mutGauss()
,
mutInsertion()
,
mutInversion()
,
mutJump()
,
mutPolynomial()
,
mutScramble()
,
mutUniform()
Uniform mutator.
Description
This mutation operator works on real-valued genotypes only. It selects a position in the solution vector at random and replaced it with a uniformally chosen value within the box constraints of the corresponding parameter. This mutator may proof beneficial in early stages of the optimization process, since it distributes points widely within the box constraints and thus may hinder premature convergence. However, in later stages - when fine tuning is necessary, this feature is disadvantegous.
Usage
mutUniform(ind, lower, upper)
Arguments
ind |
[ |
lower |
[ |
upper |
[ |
Value
[numeric
]
See Also
Other mutators:
mutBitflip()
,
mutGauss()
,
mutInsertion()
,
mutInversion()
,
mutJump()
,
mutPolynomial()
,
mutScramble()
,
mutSwap()
Formatter for table cells of LaTeX tables.
Description
This formatter function should be applied to
tables where each table cell contains a p
-value of
a statistical significance test. See toLatex
for an application.
Usage
niceCellFormater(cell, alpha = 0.05)
Arguments
cell |
[any] |
alpha |
[ |
Value
Formatted output.
See Also
Other EMOA performance assessment tools:
approximateNadirPoint()
,
approximateRefPoints()
,
approximateRefSets()
,
computeDominanceRanking()
,
emoaIndEps()
,
makeEMOAIndicator()
,
normalize()
,
plotDistribution()
,
plotFront()
,
plotScatter2d()
,
plotScatter3d()
,
toLatex()
Normalize approximations set(s).
Description
Normalization is done by subtracting the min.value
for each dimension
and dividing by the difference max.value - min.value
for each dimension
Certain EMOA indicators require all elements to be strictly positive. Hence, an optional
offset
is added to each element which defaults to zero.
Usage
normalize(x, obj.cols, min.value = NULL, max.value = NULL, offset = NULL)
Arguments
x |
[ |
obj.cols |
[ |
min.value |
[ |
max.value |
[ |
offset |
[ |
Value
[matrix
| data.frame
]
Note
In case a data.frame is passed and a “prob” column exists, normalization is performed for each unique element of the “prob” column independently (if existent).
See Also
Other EMOA performance assessment tools:
approximateNadirPoint()
,
approximateRefPoints()
,
approximateRefSets()
,
computeDominanceRanking()
,
emoaIndEps()
,
makeEMOAIndicator()
,
niceCellFormater()
,
plotDistribution()
,
plotFront()
,
plotScatter2d()
,
plotScatter3d()
,
toLatex()
Implementation of the NSGA-II EMOA algorithm by Deb.
Description
The NSGA-II merges the current population and the generated offspring and reduces it by means of the following procedure: It first applies the non dominated sorting algorithm to obtain the nondominated fronts. Starting with the first front, it fills the new population until the i-th front does not fit. It then applies the secondary crowding distance criterion to select the missing individuals from the i-th front.
Usage
nsga2(
fitness.fun,
n.objectives = NULL,
n.dim = NULL,
minimize = NULL,
lower = NULL,
upper = NULL,
mu = 100L,
lambda = mu,
mutator = setup(mutPolynomial, eta = 25, p = 0.2, lower = lower, upper = upper),
recombinator = setup(recSBX, eta = 15, p = 0.7, lower = lower, upper = upper),
terminators = list(stopOnIters(100L)),
...
)
Arguments
fitness.fun |
[ |
n.objectives |
[ |
n.dim |
[ |
minimize |
[ |
lower |
[ |
upper |
[ |
mu |
[ |
lambda |
[ |
mutator |
[ |
recombinator |
[ |
terminators |
[ |
... |
[any] |
Value
[ecr_multi_objective_result
]
Note
This is a pure R implementation of the NSGA-II algorithm. It hides the regular ecr interface and offers a more R like interface while still being quite adaptable.
References
Deb, K., Pratap, A., and Agarwal, S. A Fast and Elitist Multiobjective Genetic Algorithm: NSGA-II. IEEE Transactions on Evolutionary Computation, 6 (8) (2002), 182-197.
Plot distribution of EMOA indicators.
Description
Visualizes of empirical distributions of unary EMOA indicator
based on the results of computeIndicators
.
Usage
plotDistribution(
inds,
plot.type = "boxplot",
fill = "algorithm",
facet.type = "grid",
facet.args = list(),
logscale = character()
)
Arguments
inds |
[ |
plot.type |
[ |
fill |
[ |
facet.type |
[ |
facet.args |
[ |
logscale |
[ |
Value
[ggplot
]
See Also
Other EMOA performance assessment tools:
approximateNadirPoint()
,
approximateRefPoints()
,
approximateRefSets()
,
computeDominanceRanking()
,
emoaIndEps()
,
makeEMOAIndicator()
,
niceCellFormater()
,
normalize()
,
plotFront()
,
plotScatter2d()
,
plotScatter3d()
,
toLatex()
Draw scatterplot of Pareto-front approximation
Description
The function expects a data.frame or a matrix. By default the first
2 or 3 columns/rows are assumed to contain the elements of the approximation sets.
Depending on the number of numeric columns (in case of a data.frame) or the
number of rows (in case of a matrix) the function internally calls
plotScatter2d
or plotScatter3d
.
Usage
plotFront(x, obj.names = NULL, minimize = TRUE, ...)
Arguments
x |
[ |
obj.names |
[ |
minimize |
[ |
... |
[any] |
Value
[ggplot
] ggplot object.
See Also
Other EMOA performance assessment tools:
approximateNadirPoint()
,
approximateRefPoints()
,
approximateRefSets()
,
computeDominanceRanking()
,
emoaIndEps()
,
makeEMOAIndicator()
,
niceCellFormater()
,
normalize()
,
plotDistribution()
,
plotScatter2d()
,
plotScatter3d()
,
toLatex()
Plot heatmap.
Description
Given a matrix or list of matrizes x
this function
visualizes each matrix with a heatmap.
Usage
plotHeatmap(x, value.name = "Value", show.values = FALSE)
Arguments
x |
[ |
value.name |
[ |
show.values |
[ |
Value
[ggplot
] ggplot object.
Examples
# simulate two (correlation) matrizes
x = matrix(runif(100), ncol = 10)
y = matrix(runif(100), ncol = 10)
## Not run:
pl = plotHeatmap(x)
pl = plotHeatmap(list(x, y), value.name = "Correlation")
pl = plotHeatmap(list(MatrixX = x, MatrixY = y), value.name = "Correlation")
## End(Not run)
Visualize bi-objective Pareto-front approximations.
Description
Given a data frame with the results of (multiple) runs of (multiple)
different multi-objective optimization algorithms on (multiple) problem instances
the function generates ggplot
plots of the obtained
Pareto-front approximations.
Usage
plotScatter2d(
df,
obj.cols = c("f1", "f2"),
shape = "algorithm",
colour = NULL,
highlight.algos = NULL,
offset.highlighted = 0,
title = NULL,
subtitle = NULL,
facet.type = "wrap",
facet.args = list()
)
Arguments
df |
[ |
obj.cols |
[ |
shape |
[ |
colour |
[ |
highlight.algos |
[ |
offset.highlighted |
[ |
title |
[ |
subtitle |
[ |
facet.type |
[ |
facet.args |
[ |
Value
[ggplot
] A ggplot object.
Note
At the moment only approximations of bi-objective functions are supported.
See Also
Other EMOA performance assessment tools:
approximateNadirPoint()
,
approximateRefPoints()
,
approximateRefSets()
,
computeDominanceRanking()
,
emoaIndEps()
,
makeEMOAIndicator()
,
niceCellFormater()
,
normalize()
,
plotDistribution()
,
plotFront()
,
plotScatter3d()
,
toLatex()
Examples
## Not run:
# load examplary data
data(mcMST)
print(head(mcMST))
# no customization; use the defaults
pl = plotFronts(mcMST)
# algo PRIM is obtained by weighted sum scalarization
# Since the front is (mainly) convex we highlight these solutions
pl = plotFronts(mcMST, highlight.algos = "PRIM")
# customize layout
pl = plotFronts(mcMST, title = "Pareto-approximations",
subtitle = "based on different mcMST algorithms.", facet.args = list(nrow = 2))
## End(Not run)
Visualize three-objective Pareto-front approximations.
Description
Given a data frame with the results of (multiple) runs of (multiple) different three-objective optimization algorithms on (multiple) problem instances the function generates 3D scatterplots of the obtained Pareto-front approximations.
Usage
plotScatter3d(
df,
obj.cols = c("f1", "f2", "f3"),
max.in.row = 4L,
package = "scatterplot3d",
...
)
Arguments
df |
[ |
obj.cols |
[ |
max.in.row |
[ |
package |
[ |
... |
[any] |
Value
Nothing
See Also
Other EMOA performance assessment tools:
approximateNadirPoint()
,
approximateRefPoints()
,
approximateRefSets()
,
computeDominanceRanking()
,
emoaIndEps()
,
makeEMOAIndicator()
,
niceCellFormater()
,
normalize()
,
plotDistribution()
,
plotFront()
,
plotScatter2d()
,
toLatex()
Generate line plot of logged statistics.
Description
Expects a data.frame of logged statistics, e.g., extracted from
a logger object by calling getStatistics
, and generates a basic
line plot. The plot is generated with the ggplot2 package and the ggplot
object is returned.
Usage
plotStatistics(x, drop.stats = character(0L))
Arguments
x |
[ |
drop.stats |
[ |
One-point crossover recombinator.
Description
The one-point crossover recombinator is defined for float and binary representations. Given two real-valued/binary vectors of length n, the selector samples a random position i between 1 and n-1. In the next step it creates two children. The first part of the first child contains of the subvector from position 1 to position i of the first parent, the second part from position i+1 to n is taken from the second parent. The second child is build analogously. If the parents are list of real-valued/binary vectors, the procedure described above is applied to each element of the list.
Usage
recCrossover(inds)
Arguments
inds |
[ |
Value
[list
]
See Also
Other recombinators:
recIntermediate()
,
recOX()
,
recPMX()
,
recSBX()
,
recUnifCrossover()
Indermediate recombinator.
Description
Intermediate recombination computes the component-wise mean value of the
k
given parents. It is applicable only for float representation.
Usage
recIntermediate(inds)
Arguments
inds |
[ |
Value
[numeric
] Single offspring.
See Also
Other recombinators:
recCrossover()
,
recOX()
,
recPMX()
,
recSBX()
,
recUnifCrossover()
Ordered-Crossover (OX) recombinator.
Description
This recombination operator is specifically designed for permutations. The operators chooses two cut-points at random and generates two offspring as follows: a) copy the subsequence of one parent and b) remove the copied node indizes from the entire sequence of the second parent from the sescond cut point and b) fill the remaining gaps with this trimmed sequence.
Usage
recOX(inds)
Arguments
inds |
[ |
Value
[list
]
See Also
Other recombinators:
recCrossover()
,
recIntermediate()
,
recPMX()
,
recSBX()
,
recUnifCrossover()
Partially-Mapped-Crossover (PMX) recombinator.
Description
This recombination operator is specifically designed for permutations. The operators chooses two cut-points at random and generates two offspring as follows: a) copy the subsequence of one parent and b) fill the remaining positions while preserving the order and position of as many genes as possible.
Usage
recPMX(inds)
Arguments
inds |
[ |
Value
[ecr_recombinator
]
See Also
Other recombinators:
recCrossover()
,
recIntermediate()
,
recOX()
,
recSBX()
,
recUnifCrossover()
Simulated Binary Crossover (SBX) recombinator.
Description
The Simulated Binary Crossover was first proposed by [1]. It i suited for
float representation only and creates two offspring. Given parents p_1, p_2
the offspring are generated as c_{1/2} = \bar{x} \pm \frac{1}{2}\beta(p_2 - p_1)
where \bar{x} = \frac{1}{2}(p_1 + p_2), p_2 > p_1
. This way \bar{c} = \bar{x}
is assured.
Usage
recSBX(inds, eta = 5, p = 1, lower, upper)
Arguments
inds |
[ |
eta |
[ |
p |
[ |
lower |
[ |
upper |
[ |
Value
[ecr_recombinator
]
Note
This is the default recombination operator used in the NSGA-II EMOA (see nsga2
).
References
[1] Deb, K. and Agrawal, R. B. (1995). Simulated binary crossover for continuous search space. Complex Systems 9(2), 115-148.
See Also
Other recombinators:
recCrossover()
,
recIntermediate()
,
recOX()
,
recPMX()
,
recUnifCrossover()
Uniform crossover recombinator.
Description
Produces two child individuals. The i-th gene is from parent1 with probability
p
and from parent2 with probability 1-p
.
Usage
recUnifCrossover(inds, p = 0.5)
Arguments
inds |
[ |
p |
[ |
Value
[list
]
See Also
Other recombinators:
recCrossover()
,
recIntermediate()
,
recOX()
,
recPMX()
,
recSBX()
Combine multiple data frames into a single data.frame.
Description
Combine multiple data frames into a single data.frame.
Usage
reduceToSingleDataFrame(res = list(), what = NULL, group.col.name)
Arguments
res |
[ |
what |
[ |
group.col.name |
[ |
Register operators to control object.
Description
In ecr the control object stores information on the fitness function and serves as a storage for evolutionary components used by your evolutionary algorithm. This function handles the registration process.
Usage
registerECROperator(control, slot, fun, ...)
Arguments
control |
[ |
slot |
[ |
fun |
[ |
... |
[any] |
Value
[ecr_control
]
(mu + lambda) selection
Description
Takes a population of mu individuals and another set of lambda offspring individuals and selects mu individuals out of the union set according to the survival selection strategy stored in the control object.
Usage
replaceMuPlusLambda(
control,
population,
offspring,
fitness = NULL,
fitness.offspring = NULL
)
replaceMuCommaLambda(
control,
population,
offspring,
fitness = NULL,
fitness.offspring = NULL,
n.elite = base::max(ceiling(length(population) * 0.1), 1L)
)
Arguments
control |
[ |
population |
[ |
offspring |
[ |
fitness |
[ |
fitness.offspring |
[ |
n.elite |
[ |
Value
[list
] List with selected population and corresponding fitness matrix.
Dominated Hypervolume selector.
Description
Performs non-dominated sorting and drops the individual from the last front
with minimal hypervolume contribution. This selector is the basis of the
S-Metric Selection Evolutionary Multi-Objective Algorithm, termed SMS-EMOA
(see smsemoa
).
Usage
selDomHV(fitness, n.select, ref.point)
Arguments
fitness |
[ |
n.select |
[ |
ref.point |
[ |
Value
[integer
] Vector of survivor indizes.
Note
Note that the current implementation expects n.select = ncol(fitness) - 1
and the selection process quits with an error message if n.select
is greater
than 1.
See Also
Other selectors:
selGreedy()
,
selNondom()
,
selRanking()
,
selRoulette()
,
selSimple()
,
selTournament()
Simple selector.
Description
Sorts the individuals according to their fitness value in increasing order and selects the best ones.
Usage
selGreedy(fitness, n.select)
Arguments
fitness |
[ |
n.select |
[ |
Value
[integer
] Vector of survivor indizes.
See Also
Other selectors:
selDomHV()
,
selNondom()
,
selRanking()
,
selRoulette()
,
selSimple()
,
selTournament()
Non-dominated sorting selector.
Description
Applies non-dominated sorting of the objective vectors and subsequent crowding
distance computation to select a subset of individuals. This is the selector used
by the famous NSGA-II EMOA (see nsga2
).
Usage
selNondom(fitness, n.select)
Arguments
fitness |
[ |
n.select |
[ |
Value
[setOfIndividuals
]
See Also
Other selectors:
selDomHV()
,
selGreedy()
,
selRanking()
,
selRoulette()
,
selSimple()
,
selTournament()
Rank Selection Operator
Description
Rank-based selection preserves a constant selection pressure by sorting the population on the basis of fitness, and then allocating selection probabilities to individuals according to their rank, rather than according to their actual fitness values.
Usage
selRanking(fitness, n.select, s = 1.5, scheme = "linear")
Arguments
fitness |
[ |
n.select |
[ |
s |
[ |
scheme |
[ |
Value
[setOfIndividuals
]
References
Eiben, A. E., & Smith, J. E. (2007). Introduction to evolutionary computing. Berlin: Springer.
See Also
Other selectors:
selDomHV()
,
selGreedy()
,
selNondom()
,
selRoulette()
,
selSimple()
,
selTournament()
Roulette-wheel / fitness-proportional selector.
Description
The chance of an individual to get selected is proportional to its fitness, i.e., better individuals get a higher chance to take part in the reproduction process. Low-fitness individuals however, have a positive fitness as well.
Usage
selRoulette(fitness, n.select, offset = 0.1)
Arguments
fitness |
[ |
n.select |
[ |
offset |
[ |
Details
Fitness proportional selection can be naturally applied to single objective
maximization problems. However, negative fitness values can are problematic.
The Roulette-Wheel selector thus works with the following heuristic: if
negative values occur, the negative of the smallest fitness value is added
to each fitness value. In this case to avoid the smallest shifted fitness
value to be zero and thus have a zero probability of being selected an additional
positive constant offset
is added (see parameters).
Value
[setOfIndividuals
]
See Also
Other selectors:
selDomHV()
,
selGreedy()
,
selNondom()
,
selRanking()
,
selSimple()
,
selTournament()
Simple (naive) selector.
Description
Just for testing. Actually does not really select, but instead returns a random
sample of ncol(fitness)
indizes.
Usage
selSimple(fitness, n.select)
Arguments
fitness |
[ |
n.select |
[ |
Value
[setOfIndividuals
]
See Also
Other selectors:
selDomHV()
,
selGreedy()
,
selNondom()
,
selRanking()
,
selRoulette()
,
selTournament()
k-Tournament selector.
Description
k individuals from the population are chosen randomly and the best one is selected to be included into the mating pool. This process is repeated until the desired number of individuals for the mating pool is reached.
Usage
selTournament(fitness, n.select, k = 3L)
Arguments
fitness |
[ |
n.select |
[ |
k |
[ |
Value
[integer
] Vector of survivor indizes.
See Also
Other selectors:
selDomHV()
,
selGreedy()
,
selNondom()
,
selRanking()
,
selRoulette()
,
selSimple()
Select individuals.
Description
This utility functions expect a control object, a matrix of
fitness values - each column containing the fitness value(s) of one individual -
and the number of individuals to select.
The corresponding selector, i.e., mating selector for selectForMating
or survival selector for selectForSurvival
is than called internally
and a vector of indizes of selected individuals is returned.
Usage
selectForMating(control, fitness, n.select)
selectForSurvival(control, fitness, n.select)
Arguments
control |
[ |
fitness |
[ |
n.select |
[ |
Details
Both functions check the optimization directions stored in the task
inside the control object, i.e., whether to minimize or maximize each objective,
and transparently prepare/transform the fitness
matrix for the selector.
Value
[integer
] Integer vector with the indizes of selected individuals.
Check if one set is better than another.
Description
The function checks, whether each points of the second set of points is dominated by at least one point from the first set.
Usage
setDominates(x, y)
Arguments
x |
[ |
y |
[ |
Value
[logical(1)
]
Set up parameters for evolutionary operator.
Description
This function builds a simple wrapper around an evolutionary operator, i.e.,
mutator, recombinator or selector and defines its parameters. The result is a
function that does not longer depend on the parameters. E.g., fun = setup(mutBitflip, p = 0.3)
initializes a bitflip mutator with mutation probability 0.3. Thus,
the following calls have the same behaviour: fun(c(1, 0, 0))
and
mutBitflip(fun(c(1, 0, 0), p = 0.3)
.
Basically, this type of preinitialization is only neccessary if operators
with additional parameters shall be initialized in order to use the black-box
ecr
.
Usage
setup(operator, ...)
Arguments
operator |
[ |
... |
[any] |
Value
[function
] Wrapper evolutionary operator with parameters x
and ...
.
Examples
# initialize bitflip mutator with p = 0.3
bf = setup(mutBitflip, p = 0.3)
# sample binary string
x = sample(c(0, 1), 100, replace = TRUE)
set.seed(1)
# apply preinitialized function
print(bf(x))
set.seed(1)
# apply raw function
print(mutBitflip(x, p = 0.3))
# overwrite preinitialized values with mutate
ctrl = initECRControl(fitness.fun = function(x) sum(x), n.objectives = 1L)
# here we define a mutation probability of 0.3
ctrl = registerECROperator(ctrl, "mutate", setup(mutBitflip, p = 0.3))
# here we overwrite with 1, i.e., each bit is flipped
print(x)
print(mutate(ctrl, list(x), p.mut = 1, p = 1)[[1]])
Default monitor.
Description
Default monitor object that outputs messages to the console
based on a default logger (see initLogger
).
Usage
setupECRDefaultMonitor(step = 10L)
Arguments
step |
[ |
Value
[ecr_monitor
]
Implementation of the SMS-EMOA by Emmerich et al.
Description
Pure R implementation of the SMS-EMOA. This algorithm belongs to the group of indicator based multi-objective evolutionary algorithms. In each generation, the SMS-EMOA selects two parents uniformly at, applies recombination and mutation and finally selects the best subset of individuals among all subsets by maximizing the Hypervolume indicator.
Usage
smsemoa(
fitness.fun,
n.objectives = NULL,
n.dim = NULL,
minimize = NULL,
lower = NULL,
upper = NULL,
mu = 100L,
ref.point = NULL,
mutator = setup(mutPolynomial, eta = 25, p = 0.2, lower = lower, upper = upper),
recombinator = setup(recSBX, eta = 15, p = 0.7, lower = lower, upper = upper),
terminators = list(stopOnIters(100L)),
...
)
Arguments
fitness.fun |
[ |
n.objectives |
[ |
n.dim |
[ |
minimize |
[ |
lower |
[ |
upper |
[ |
mu |
[ |
ref.point |
[ |
mutator |
[ |
recombinator |
[ |
terminators |
[ |
... |
[any] |
Value
[ecr_multi_objective_result
]
Note
This helper function hides the regular ecr interface and offers a more R like interface of this state of the art EMOA.
References
Beume, N., Naujoks, B., Emmerich, M., SMS-EMOA: Multiobjective selection based on dominated hypervolume, European Journal of Operational Research, Volume 181, Issue 3, 16 September 2007, Pages 1653-1669.
Sort Pareto-front approximation by objective.
Description
Sort Pareto-front approximation by objective.
Usage
sortByObjective(x, obj = 1L, ...)
## S3 method for class 'data.frame'
sortByObjective(x, obj = 1L, ...)
## S3 method for class 'matrix'
sortByObjective(x, obj = 1L, ...)
## S3 method for class 'ecr_multi_objective_result'
sortByObjective(x, obj = 1L, ...)
## S3 method for class 'list'
sortByObjective(x, obj = 1L, ...)
Arguments
x |
[ |
obj |
[ |
... |
[any] |
Value
Modified object.
Stopping conditions
Description
Stop the EA after a fixed number of fitness function evaluations, after a predefined number of generations/iterations, a given cutoff time or if the known optimal function value is approximated (only for single-objective optimization).
Usage
stopOnEvals(max.evals = NULL)
stopOnIters(max.iter = NULL)
stopOnOptY(opt.y, eps)
stopOnMaxTime(max.time = NULL)
Arguments
max.evals |
[ |
max.iter |
[ |
opt.y |
[ |
eps |
[ |
max.time |
[ |
Value
[ecr_terminator
]
Transform to long format.
Description
Transform the data.frame of logged statistics from wide to ggplot2-friendly long format.
Usage
toGG(x, drop.stats = character(0L))
Arguments
x |
[ |
drop.stats |
[ |
Value
[data.frame
]
Export results of statistical tests to LaTeX table(s).
Description
Returns high-quality LaTeX-tables of the test results of
statistical tests performed with function test
on per-instance basis. I.e., a table is returned for each instances combining
the results of different indicators.
Usage
toLatex(
stats,
stat.cols = NULL,
probs = NULL,
type = "by.instance",
cell.formatter = NULL
)
## S3 method for class 'list'
toLatex(
stats,
stat.cols = NULL,
probs = NULL,
type = "by.instance",
cell.formatter = NULL
)
## S3 method for class 'data.frame'
toLatex(
stats,
stat.cols = NULL,
probs = NULL,
type = "by.instance",
cell.formatter = NULL
)
Arguments
stats |
[ |
stat.cols |
[ |
probs |
[ |
type |
[ |
cell.formatter |
[ |
Value
[list
] Named list of strings (LaTeX tables). Names correspond to the
selected problem instances in probs
.
See Also
Other EMOA performance assessment tools:
approximateNadirPoint()
,
approximateRefPoints()
,
approximateRefSets()
,
computeDominanceRanking()
,
emoaIndEps()
,
makeEMOAIndicator()
,
niceCellFormater()
,
normalize()
,
plotDistribution()
,
plotFront()
,
plotScatter2d()
,
plotScatter3d()
Convert matrix to Pareto front data frame.
Description
Inside ecr EMOA algorithms the fitness is maintained in an (o, n)
matrix
where o
is the number of objectives and n
is the number of individuals.
This function basically transposes such a matrix and converts it into a data frame.
Usage
toParetoDf(x, filter.dups = FALSE)
Arguments
x |
[ |
filter.dups |
[ |
Value
[data.frame
]
Fitness transformation / scaling.
Description
Some selectors support maximization only, e.g., roulette wheel selector, or minimization (most others). This function computes a factor from -1, 1 for each objective to match supported selector optimization directions and the actual objectives of the task.
Usage
transformFitness(fitness, task, selector)
Arguments
fitness |
[matrix] Matrix of fitness values with the fitness vector of individual i in the i-th column. |
task |
[ecr_optimization_task] Optimization task. |
selector |
[ecr_selector] Selector object. |
Value
[matrix] Transformed / scaled fitness matrix.
Update the log.
Description
This function modifies the log in-place, i.e., without making copies.
Usage
updateLogger(log, population, fitness = NULL, n.evals, extras = NULL, ...)
Arguments
log |
[ |
population |
[ |
fitness |
[ |
n.evals |
[ |
extras |
[ |
... |
[any] |
See Also
Other logging:
getPopulationFitness()
,
getPopulations()
,
getStatistics()
,
initLogger()
Update Pareto Archive.
Description
This function updates a Pareto archive, i.e., an archive of non-dominated
points. It expects the archive, a set of individuals, a matrix of fitness values
(each column corresponds to the fitness vector of one individual) and updates
the archive “in-place”. If the archive has unlimited capacity all non-dominated points of
the union of archive and passed individuals are stored. Otherwise, i.e., in case
the archive is limited in capacity (argument max.size
of
initParetoArchive
was set to an integer value greater zero), the
trunc.fun
function passed to initParetoArchive
is applied to
all non-dominated points to determine which points should be dropped.
Usage
updateParetoArchive(archive, inds, fitness, ...)
Arguments
archive |
[ |
inds |
[ |
fitness |
[ |
... |
[any] |
See Also
Other ParetoArchive:
getIndividuals()
,
getSize()
,
initParetoArchive()
Determine which points of a set are (non)dominated.
Description
Given a matrix with one point per column which.dominated
returns the
column numbers of the dominated points and which.nondominated
the column
numbers of the nondominated points. Function isMaximallyDominated
returns
a logical vector with TRUE
for each point which is located on the last
non-domination level.
Usage
which.dominated(x)
which.nondominated(x)
isMaximallyDominated(x)
Arguments
x |
[ |
Value
[integer
]
Examples
data(mtcars)
# assume we want to maximize horsepower and minimize gas consumption
cars = mtcars[, c("mpg", "hp")]
cars$hp = -cars$hp
idxs = which.nondominated(as.matrix(cars))
print(mtcars[idxs, ])
Wrap the individuals constructed by a recombination operator.
Description
Should be used if the recombinator returns multiple children.
Usage
wrapChildren(...)
Arguments
... |
[any] |
Value
[list
] List of individuals.