| 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 ona 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 functionaddUnionGroup aids in generation of such a meta-group whilefunctionaddAllGroup is a wrapper around the former which generates aunion 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 ofpoints, 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 leastspecified byobj.cols and “prob”. The reference set foreach unique problem in column “prob” is then obtained bycombining all approximation sets generated by all considered algorithmsfor 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 columnsobj.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-objectivealgorithm aims to incorporate expert knowledge into multi-objective optimization [1].The algorithm expects an aspiration set, i.e., a set of reference points. Itthen creates an approximation of the pareto front close to the aspiration setutilizing 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 regularecr interface and offers a more R like interface while still being quiteadaptable.
References
[1] Rudolph, G., Schuetze, S., Grimme, C., Trautmann, H: An Aspiration SetEMOA Based on Averaged Hausdorff Distances. LION 2014: 153-156.[2] G. Rudolph, O. Schuetze, C. Grimme, and H. Trautmann: A MultiobjectiveEvolutionary Algorithm Guided by Averaged Hausdorff Distance to AspirationSets, pp. 261-273 in A.-A. Tantar et al. (eds.): Proceedings of EVOLVE - Abridge between Probability, Set Oriented Numerics and Evolutionary ComputationV, 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 functiongenerates 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 setsA andB.
Compute the crowding distance of a set of points.
Description
The crowding distance is a measure of spread of solutions in theapproximation of the Pareto front. It is used, e.g., in the NSGA-II algorithmas 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 elitistmultiobjective genetic algorithm: NSGA-II, IEEE Transactions on EvolutionaryComputation 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 allalgorithms and runs per instance. Next, each approximation setC is assigned arank which is 1 plus the number of approximation sets that are better thanC. A setD is better thanC, if for each pointx \in C thereexists a point iny \in D which weakly dominatesx.Thus, each approximation set is reduced to a number – its rank. This rank distributionmay act for first comparrison of multi-objecitve stochastic optimizers.See [1] for more details.This function makes use ofparallelMap toparallelize the computation of dominance ranks.
Usage
computeDominanceRanking(df, obj.cols)Arguments
df | [ |
obj.cols | [ |
Value
[data.frame] Reduceddf with columns “prob”, “algorithm”, “repl”and “rank”.
Note
Since pairwise non-domination checks are performed over all algorithms andalgorithm runs this function may take some time if the number of problems, algorithmsand/or replications is high.
References
[1] Knowles, J., Thiele, L., & Zitzler, E. (2006). A Tutorial on the Performance Assessmentof 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 functioncomputeHV computes the dominatedhypervolume of a set of points given a reference set wherebycomputeHVContr computes the hypervolume contributionof each point.
If no reference point is given the nadir point of the setx isdetermined and a positive offset with default 1 is added. This is to ensurethat 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 ofcomputeHV and the dominated hypervolume contributionsfor each point in the case ofcomputeHVContr.
Note
: Keep in mind that this function assumes all objectives to be minimized.In case at least one objective is to be maximized the matrixx needsto be transformed accordingly in advance.
Computation of EMOA performance indicators.
Description
Given a data.frame of Pareto-front approximations for differentsets of problems, algorithms and replications, the function computes setsof unary and binary EMOA performance indicators.This function makes use ofparallelMap toparallelize 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 ofunary 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 Assessmentof 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 PerformanceIndices for Multi-Objective Optimisation. In Proceedings of the 2003 Congress on EvolutionaryComputation Conference (CEC03) (pp. 878–885). Canberra, ACT, Australia: IEEE.
Computes Inverted Generational Distance.
Description
Helper to compute the Inverted Generational Distance (IGD) between two setsof 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 sortingexpects a set of points and returns aset of non-dominated fronts. In short words this is done as follows: thenon-dominated points of the entire set are determined and assigned rank 1.Afterwards all points with the current rank are removed, the rank is increasedby 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 higherthe rank, the higher the domination front the corresponding point islocated on.- dom.counter
Integer vector of length
ncol(x). The i-th elementis the domination number of the i-th point.
Note
This procedure is the key survival selection of the famous NSGA-II multi-objectiveevolutionary algorithm (seensga2).
References
[1] Deb, K., Pratap, A., and Agarwal, S. A Fast and Elitist Multiobjective GeneticAlgorithm: NSGA-II. IEEE Transactions on Evolutionary Computation, 6 (8) (2002),182-197.
Check for pareto dominance.
Description
These functions take a numeric matrixx where each column corresponds toa point and return a logical vector. The i-th position of the latter isTRUE if the i-th point is dominated by at least one other point fordominated andFALSE fornonDominated.
Usage
dominated(x)nondominated(x)Arguments
x | [ |
Value
[logical]
Dominance relation check.
Description
Check if a vector dominates another (dominates) or isdominated by another (isDominated). There are corresponding infixoperatorsdominates andisDominatedBy.
Usage
dominates(x, y)isDominated(x, y)x %dominates% yx %isDominatedBy% yArguments
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 byexplicitely writing the evolutionary loop utilizing various ecr utlity functions.However, in everyday life R users frequently need to optimize a single-objective R function.Theecr function thus provides a more R like interface for singleobjective optimization similar to the interface of theoptimfunction.
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 evaluationto make use, e.g., of multiple CP cores or nodes in a HPC cluster.For maximal flexibility this is realized by means of theparallelMap package(see theofficialGitHub page for instructions on how to set up parallelization).The different levels of parallelization can be specified in theparallelStart* function. At them moment only the level“ecr.evaluateFitness” is supported.
Keep in mind that parallelization comes along with some overhead. Thus activatingparallelization, e.g., for evaluation a fitness function which is evaluatedlightning-fast, may result in higher computation time. However, if the functionevaluations are computationally more expensive, parallelization leads tosignificant running time benefits.
Result object.
Description
S3 object returned byecr containing the best foundparameter setting and value in the single-objective case and the Pareto-front/-setin case of a multi-objective optimization problem. Moreover a set of furtherinformation, 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 thefollowing 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 nis the number of non-dominated points and d is the number of objectives.
- pareto.set
Matrix of decision space values resulting with objective valuesgiven 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 whichare useful for the evaluation of the performace of EMOAs. See the referencessection for literature on these indicators.
Given a set of pointspoints,emoaIndEps computes theunary epsilon-indicator provided a set of reference pointsref.points.
TheemoaIndHV function computes the hypervolume indicatorHyp(X, R, r). Given a set of points X (points), another set of referencepoints R (ref.points) (which maybe the true Pareto front) and a referencepoint r (ref.point) it is defined as Hyp(X, R, r) = HV(R, r) - HV(X, r).
FunctionemoaIndR1,emoaIndR2 andemoaIndR3 calculate theR1, R2 and R3 indicator respectively.
FunctionemoaIndMD computes the minimum distance indicator, i.e., the minimumEuclidean distance between two points of the setpoints while functionemoaIndM1 determines the mean Euclidean distance betweenpointsand points from a reference setref.points.
FunctionemoaIndC calculates the coverage of the setspoints (A) andref.points (B). This is the ratio of points in B which are dominated byat 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 pointsinpoints.
FunctionsemoaIndSP andemoaIndDelta calculate spacing indicators.The former was proposed by Schott: first calculate the sum of squared distancesbetween minimal distancesof points to all other points and the mean of these minimaldistance. Next, normalize by the number of points minus 1 and finally calculate thesquare 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 alwaysreturns 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 ofparallelMap toparallelize 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, functionexplode splits the content of a column by a specifieddelimiter (thus exploded) into multiple columns. Functionimplodedoes vice versa, i.e., given a non-empty set of column names ornumbers, the function glues together the columns. Hence, functionsexplode andimplode 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 inputx.
Note
Note that this may be misleading if there can be solutions with identicalobjective function values but different values in decision space.
Helper functions for offspring generation
Description
Functionmutate expects a control object, a list of individuals, and a mutationprobability. The mutation operator registered in the control object is then appliedwith the given probability to each individual.Functionrecombinate expects a control object, a list of individuals as well astheir fitness matrix and createslambda offspring individuals by recombining parentsfrominds. Which parents take place in the parent selection depends ontheparent.selector registered in the control object.Finally, functiongenerateOffspring is a wrapper for bothrecombinateandmutate. Both functions are applied subsequently to generate new individualsby 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 functiongen expects an R expression and a number n in order to create a listof n individuals based on the given expression. FunctionsgenBin,genPerm andgenReal are shortcuts for initializing populationsof 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 numberof 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.framewith 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 withlog.pop = FALSE (seeinitLogger).
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 ofevolutionary 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 theevolutionary process, e.g., fitness statistics. The logger of ecr keepstrack of different user-defined statistics and the population.It may also be used to check stopping conditions (seemakeECRTerminator). Mostimportant this logger is used internally by theecr 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 classecr_logger with the following components:
- log.stats
The
log.statslist.- log.pop
The
log.popparameter.- init.size
Initial size of the log.
- env
The actual log. This is an R environment which ensures, thatin-place modification is possible.
Note
Statistics are logged in adata.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 constructorpopulation = initPopulation(mu = 10L, genBin, n.dim = 10L)fitness = evaluateFitness(control, population)# append fitness to individuals and init agefor (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 thenon-dominated points stored during a run of an multi-objective evolutionaryalgorithm.
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 solutionscan 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 typeecr_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., printingsome status messages to the console. Each monitor includes the functionsbefore,step andafter, each being a function and expectinga loglog of typeecr_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 computeperformance indicators for multi-objective stochastic algorithm.Basically this function appends some meta information to thepassed functionfun.
Usage
makeEMOAIndicator(fun, minimize, name, latex.name)Arguments
fun | [ |
minimize | [ |
name | [ |
latex.name | [ |
Value
[function(points, ...)] Argumentfun with all otherarguments 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 itsderiviatives likemakeMutator ormakeSelector.
Creates an optimization task.
Description
An optimization task consists of the fitness/objective function, thenumber of objectives, the “direction” of optimization, i.e.,which objectives should be minimized/maximized and the names of theobjectives.
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, themultiple.childrenparameter needs to beTRUE, which is the default. In case of multiplechildren 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 whichtakes 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 severalalgorithms for the multi-criteria minimum spanning tree (mcMST) problem.
Usage
mcMSTFormat
A data frame with four variables:
f1First objective (to be minimized).
f2Second objective (to be minimized).
algorithmShort name of algorithm used.
probShort name of problem instance.
replAlgorithm run.
The data is based on themcMST package.
Bitplip mutator.
Description
This operator works only on binary representation and flips each bitwith a given probabilityp \in (0, 1). Usually it is recommended tosetp = \frac{1}{n} wheren is the number of bits in therepresentation.
Usage
mutBitflip(ind, p = 0.1)Arguments
ind | [ |
p | [ |
Value
[binary]
References
[1] Eiben, A. E. & Smith, James E. (2015). Introduction to EvolutionaryComputing (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 forrepresentation="float". Givenan individual\mathbf{x} \in R^l this mutator adds a Gaussiandistributed 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 basedon 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 ata 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 atrandom 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 atrandom, saya andb witha < b. Next, all elements atpositionsb-1, b-2, ..., a are shifted to the right by one positionand finally the element at positionb is assigned at positiona.
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 atrandom 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 positionin the solution vector at random and replaced it with a uniformally chosen valuewithin 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 mayhinder premature convergence. However, in later stages - when fine tuning isnecessary, 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 totables where each table cell contains ap-value ofa statistical significance test. SeetoLatexfor 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 themin.value for each dimensionand dividing by the differencemax.value - min.value for each dimensionCertain EMOA indicators require all elements to be strictly positive. Hence, an optionaloffset 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, normalizationis performed for each unique element of the “prob” column independently (ifexistent).
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 andreduces it by means of the following procedure: It first applies the nondominated sorting algorithm to obtain the nondominated fronts. Starting withthe 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 missingindividuals 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 regularecr interface and offers a more R like interface while still being quiteadaptable.
References
Deb, K., Pratap, A., and Agarwal, S. A Fast and Elitist Multiobjective GeneticAlgorithm: 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 indicatorbased on the results ofcomputeIndicators.
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 first2 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 thenumber of rows (in case of a matrix) the function internally callsplotScatter2d orplotScatter3d.
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 matrizesx this functionvisualizes 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) matrizesx = 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 instancesthe function generatesggplot plots of the obtainedPareto-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 datadata(mcMST)print(head(mcMST))# no customization; use the defaultspl = plotFronts(mcMST)# algo PRIM is obtained by weighted sum scalarization# Since the front is (mainly) convex we highlight these solutionspl = plotFronts(mcMST, highlight.algos = "PRIM")# customize layoutpl = 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 instancesthe 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 froma logger object by callinggetStatistics, and generates a basicline plot. The plot is generated with theggplot2 package and the ggplotobject 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 binaryrepresentations. Given two real-valued/binary vectors of length n, theselector samples a random position i between 1 and n-1. In the next stepit creates two children. The first part of the first child contains of thesubvector from position 1 to position i of the first parent, the second partfrom position i+1 to n is taken from the second parent. The second childis build analogously.If the parents are list of real-valued/binary vectors, the procedure describedabove 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 thek 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 offspringas follows: a) copy the subsequence of one parent and b) remove the copiednode indizes from the entire sequence of the second parent from the sescondcut 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 offspringas follows: a) copy the subsequence of one parent and b) fill the remainingpositions 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 forfloat representation only and creates two offspring. Given parentsp_1, p_2the offspring are generated asc_{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 (seensga2).
References
[1] Deb, K. and Agrawal, R. B. (1995). Simulated binary crossover for continuoussearch 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 probabilityp and from parent2 with probability1-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 fitnessfunction and serves as a storage for evolutionary components used by your evolutionaryalgorithm. 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 lambdaoffspring individuals and selects mu individuals out of the union set accordingto 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 frontwith minimal hypervolume contribution. This selector is the basis of theS-Metric Selection Evolutionary Multi-Objective Algorithm, termed SMS-EMOA(seesmsemoa).
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 expectsn.select = ncol(fitness) - 1and the selection process quits with an error message ifn.select is greaterthan 1.
See Also
Other selectors:selGreedy(),selNondom(),selRanking(),selRoulette(),selSimple(),selTournament()
Simple selector.
Description
Sorts the individuals according to their fitness value in increasing orderand 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 crowdingdistance computation to select a subset of individuals. This is the selector usedby the famous NSGA-II EMOA (seensga2).
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 thepopulation on the basis of fitness, and then allocating selectionprobabilities to individuals according to their rank, rather than accordingto 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 reproductionprocess. 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 objectivemaximization problems. However, negative fitness values can are problematic.The Roulette-Wheel selector thus works with the following heuristic: ifnegative values occur, the negative of the smallest fitness value is addedto each fitness value. In this case to avoid the smallest shifted fitnessvalue to be zero and thus have a zero probability of being selected an additionalpositive constantoffset 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 randomsample ofncol(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 isselected to be included into the mating pool. This process is repeated untilthe 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 offitness 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 forselectForMatingor survival selector forselectForSurvival is than called internallyand 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 taskinside the control object, i.e., whether to minimize or maximize each objective,and transparently prepare/transform thefitness 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 pointsis 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 afunction 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)) andmutBitflip(fun(c(1, 0, 0), p = 0.3).Basically, this type of preinitialization is only neccessary if operatorswith additional parameters shall be initialized in order to use the black-boxecr.
Usage
setup(operator, ...)Arguments
operator | [ |
... | [any] |
Value
[function] Wrapper evolutionary operator with parametersx and....
Examples
# initialize bitflip mutator with p = 0.3bf = setup(mutBitflip, p = 0.3)# sample binary stringx = sample(c(0, 1), 100, replace = TRUE)set.seed(1)# apply preinitialized functionprint(bf(x))set.seed(1)# apply raw functionprint(mutBitflip(x, p = 0.3))# overwrite preinitialized values with mutatectrl = initECRControl(fitness.fun = function(x) sum(x), n.objectives = 1L)# here we define a mutation probability of 0.3ctrl = registerECROperator(ctrl, "mutate", setup(mutBitflip, p = 0.3))# here we overwrite with 1, i.e., each bit is flippedprint(x)print(mutate(ctrl, list(x), p.mut = 1, p = 1)[[1]])Default monitor.
Description
Default monitor object that outputs messages to the consolebased on a default logger (seeinitLogger).
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 groupof indicator based multi-objective evolutionary algorithms. In each generation,the SMS-EMOA selects two parents uniformly at, applies recombination and mutationand finally selects the best subset of individuals among all subsets by maximizingthe 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 moreR like interface of this state of the art EMOA.
References
Beume, N., Naujoks, B., Emmerich, M., SMS-EMOA: Multiobjective selection basedon 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, aftera predefined number of generations/iterations, a given cutoff time orif 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 toggplot2-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 ofstatistical tests performed with functionteston per-instance basis. I.e., a table is returned for each instances combiningthe 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 theselected problem instances inprobs.
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) matrixwhereo is the number of objectives andn 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, orminimization (most others). This function computes a factor from -1, 1 foreach objective to match supported selector optimization directions andthe 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-thcolumn. |
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 makingcopies.
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-dominatedpoints. It expects the archive, a set of individuals, a matrix of fitness values(each column corresponds to the fitness vector of one individual) and updatesthe archive “in-place”. If the archive has unlimited capacity all non-dominated points ofthe union of archive and passed individuals are stored. Otherwise, i.e., in casethe archive is limited in capacity (argumentmax.size ofinitParetoArchive was set to an integer value greater zero), thetrunc.fun function passed toinitParetoArchive is applied toall 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 columnwhich.dominated returns thecolumn numbers of the dominated points andwhich.nondominated the columnnumbers of the nondominated points. FunctionisMaximallyDominated returnsa logical vector withTRUE for each point which is located on the lastnon-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.