From faeea3d95f063321f798b51c2e5cdf37660386cb Mon Sep 17 00:00:00 2001 From: Dirk Surmann Date: Mon, 29 Jun 2015 18:05:23 +0200 Subject: [PATCH 1/6] fix typo in bitflip mutator --- R/mutator.bitflip.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/mutator.bitflip.R b/R/mutator.bitflip.R index 5d0c63f..dfa7cc2 100644 --- a/R/mutator.bitflip.R +++ b/R/mutator.bitflip.R @@ -6,7 +6,7 @@ #' @export makeBitFlipMutator = function(mutator.flip.prob = 0.1) { mutatorCheck = function(operator.control) { - assertNumber(operator.control$mutator.flip.pro, lower = 0.000001, upper = 0.999999, na.ok = FALSE) + assertNumber(operator.control$mutator.flip.prob, lower = 0.000001, upper = 0.999999, na.ok = FALSE) } force(mutator.flip.prob) From 57888e132884b6ba70d478f119cd0e0a594d5b32 Mon Sep 17 00:00:00 2001 From: Dirk Surmann Date: Mon, 29 Jun 2015 18:06:25 +0200 Subject: [PATCH 2/6] add cross over probability and recombinator.control for all recombinators --- R/generateOffspring.R | 3 ++- R/recombinator.crossover.R | 29 +++++++++++++++++++++++------ R/recombinator.intermediate.R | 2 +- R/recombinator.null.R | 2 +- R/recombinator.pmx.R | 2 +- man/makeCrossoverRecombinator.Rd | 6 +++++- 6 files changed, 33 insertions(+), 11 deletions(-) diff --git a/R/generateOffspring.R b/R/generateOffspring.R index 5e84dd4..c21f6d2 100644 --- a/R/generateOffspring.R +++ b/R/generateOffspring.R @@ -14,6 +14,7 @@ generateOffspring = function(matingPool, objective.fun, control, opt.path) { mutationStrategyAdaptor = control$mutationStrategyAdaptor mutator.control = control$mutator.control recombinator = control$recombinator + recombinator.control = control$recombinator.control n.offspring = control$n.offspring offspring = vector("list", n.offspring) @@ -23,7 +24,7 @@ generateOffspring = function(matingPool, objective.fun, control, opt.path) { parents = getParents(matingPool) #print(parents) # pass just the individuals and get a single individual - child = recombinator(parents, control) + child = recombinator(parents, recombinator.control, control) #catf("Child %i", i) #print(child) mutator.control = mutationStrategyAdaptor(mutator.control, opt.path) diff --git a/R/recombinator.crossover.R b/R/recombinator.crossover.R index 46b5789..5699f1f 100644 --- a/R/recombinator.crossover.R +++ b/R/recombinator.crossover.R @@ -1,9 +1,21 @@ #' Generator of the One-point crossover recombination operator. #' +#' @param recombinator.crossover.prob [\code{numeric(1)}]\cr +#' Cross over probability to form an offspring. Default is \code{1}. #' @return [\code{ecr_recombinator}] #' @export -makeCrossoverRecombinator = function() { - recombinator = function(inds, control = list()) { +makeCrossoverRecombinator = function(recombinator.crossover.prob = 1) { + recombinatorCheck = function(operator.control) { + assertNumber(operator.control$recombinator.crossover.prob + , lower = 0, upper = 1, na.ok = FALSE + ) + } + + force(recombinator.crossover.prob) + defaults = list(recombinator.crossover.prob = recombinator.crossover.prob) + recombinatorCheck(defaults) + + recombinator = function(inds, args = defaults, control = list()) { parent1 = inds[[1]] parent2 = inds[[2]] n = length(parent1) @@ -12,12 +24,15 @@ makeCrossoverRecombinator = function() { if (n == 1L) { stopf("Crossover recombinator requires genes to have length > 1.") } - idx = sample(1:(n - 1), size = 1L) # at least one allele of each parent should be contained child1 = parent1 child2 = parent2 - child1[(idx + 1L):n] = parent2[(idx + 1L):n] - child2[1:idx] = parent1[1:idx] + do.recombinate = runif(1L) < args$recombinator.crossover.prob + if (do.recombinate) { + idx = sample(1:(n - 1), size = 1L) + child1[(idx + 1L):n] = parent2[(idx + 1L):n] + child2[1:idx] = parent1[1:idx] + } #FIXME: here we just return one offspring for now return(child1) } @@ -27,6 +42,8 @@ makeCrossoverRecombinator = function() { name = "Crossover recombinator", description = "Performs classical one-point crossover.", n.parents = 2L, - supported = c("float", "binary") + supported = c("float", "binary"), + defaults = defaults, + checker = recombinatorCheck ) } diff --git a/R/recombinator.intermediate.R b/R/recombinator.intermediate.R index 26c2199..eebb665 100644 --- a/R/recombinator.intermediate.R +++ b/R/recombinator.intermediate.R @@ -3,7 +3,7 @@ #' @return [\code{ecr_recombinator}] #' @export makeIntermediateRecombinator = function() { - recombinator = function(inds, control = list()) { + recombinator = function(inds, args = list(), control = list()) { n = length(inds[[1]]) child = rep(0, n) for (i in 1:length(inds)) { diff --git a/R/recombinator.null.R b/R/recombinator.null.R index b7d9a12..dedc5f0 100644 --- a/R/recombinator.null.R +++ b/R/recombinator.null.R @@ -3,7 +3,7 @@ #' @return [\code{ecr_recombinator}] #' @export makeNullRecombinator = function() { - recombinator = function(inds, control=list()) { + recombinator = function(inds, args = list(), control=list()) { return(inds[[1L]]) } diff --git a/R/recombinator.pmx.R b/R/recombinator.pmx.R index cebe66c..5f6e80e 100644 --- a/R/recombinator.pmx.R +++ b/R/recombinator.pmx.R @@ -8,7 +8,7 @@ #' @return [\code{ecr_recombinator}] #' @export makePMXRecombinator = function() { - recombinator = function(inds, control = list()) { + recombinator = function(inds, args = list(), control = list()) { p1 = inds[[1]] p2 = inds[[2]] n = length(p1) diff --git a/man/makeCrossoverRecombinator.Rd b/man/makeCrossoverRecombinator.Rd index 6ddd97b..630ae4f 100644 --- a/man/makeCrossoverRecombinator.Rd +++ b/man/makeCrossoverRecombinator.Rd @@ -4,7 +4,11 @@ \alias{makeCrossoverRecombinator} \title{Generator of the One-point crossover recombination operator.} \usage{ -makeCrossoverRecombinator() +makeCrossoverRecombinator(recombinator.crossover.prob = 1) +} +\arguments{ +\item{recombinator.crossover.prob}{[\code{numeric(1)}]\cr +Cross over probability to form an offspring. Default is \code{1}.} } \value{ [\code{ecr_recombinator}] From 31e931c49563c3be73f7bf17dfd3703e33fc5c43 Mon Sep 17 00:00:00 2001 From: Dirk Surmann Date: Mon, 29 Jun 2015 18:36:53 +0200 Subject: [PATCH 3/6] return multiple offsprings --- R/generateOffspring.R | 21 +++++++++++++++++---- R/recombinator.crossover.R | 6 ++++-- R/recombinator.pmx.R | 6 ++++-- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/R/generateOffspring.R b/R/generateOffspring.R index c21f6d2..d4aedce 100644 --- a/R/generateOffspring.R +++ b/R/generateOffspring.R @@ -19,7 +19,8 @@ generateOffspring = function(matingPool, objective.fun, control, opt.path) { offspring = vector("list", n.offspring) - for (i in seq(n.offspring)) { + i = 1 + while (i < n.offspring) { #catf("Parent %i", i) parents = getParents(matingPool) #print(parents) @@ -28,9 +29,21 @@ generateOffspring = function(matingPool, objective.fun, control, opt.path) { #catf("Child %i", i) #print(child) mutator.control = mutationStrategyAdaptor(mutator.control, opt.path) - # pass just the individual and get a single individual - child = mutator(child, mutator.control, control) - offspring[[i]] = child + # mutate the child or children + if (isTRUE(attr(child, "children"))) { + max.children = min(length(child), n.offspring - i + 1) + for (ii in seq(max.children)) { + # pass just the individual and get a single individual + child[[ii]] = mutator(child[[ii]], mutator.control, control) + offspring[[i]] = child[[ii]] + i = i + 1 + } + } else { + # pass just the individual and get a single individual + child = mutator(child, mutator.control, control) + offspring[[i]] = child + i = i + 1 + } } #print(offspring) offspring.fitness = computeFitness(makePopulation(offspring), objective.fun) diff --git a/R/recombinator.crossover.R b/R/recombinator.crossover.R index 5699f1f..3dd36b6 100644 --- a/R/recombinator.crossover.R +++ b/R/recombinator.crossover.R @@ -33,8 +33,10 @@ makeCrossoverRecombinator = function(recombinator.crossover.prob = 1) { child1[(idx + 1L):n] = parent2[(idx + 1L):n] child2[1:idx] = parent1[1:idx] } - #FIXME: here we just return one offspring for now - return(child1) + # return two offsprings + children = list(child1, child2) + attr(children, "children") = TRUE + return(children) } makeRecombinator( diff --git a/R/recombinator.pmx.R b/R/recombinator.pmx.R index 5f6e80e..6126a04 100644 --- a/R/recombinator.pmx.R +++ b/R/recombinator.pmx.R @@ -51,8 +51,10 @@ makePMXRecombinator = function() { c2[i] = ins } } - #FIXME: until now we only allow to return one individual, but we created two - return(c1) + # return two offsprings + children = list(c1, c2) + attr(children, "children") = TRUE + return(children) } makeRecombinator( From 194f5e047b0e20b3f1e5fb1f6c56c84153e5ef3d Mon Sep 17 00:00:00 2001 From: Dirk Surmann Date: Tue, 30 Jun 2015 14:35:39 +0200 Subject: [PATCH 4/6] self explanatory indices --- R/generateOffspring.R | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/R/generateOffspring.R b/R/generateOffspring.R index d4aedce..05f7437 100644 --- a/R/generateOffspring.R +++ b/R/generateOffspring.R @@ -19,30 +19,30 @@ generateOffspring = function(matingPool, objective.fun, control, opt.path) { offspring = vector("list", n.offspring) - i = 1 - while (i < n.offspring) { - #catf("Parent %i", i) + i.offspring = 1 + while (i.offspring < n.offspring) { + #catf("Parent %i", i.offspring) parents = getParents(matingPool) #print(parents) # pass just the individuals and get a single individual child = recombinator(parents, recombinator.control, control) - #catf("Child %i", i) + #catf("Child %i", i.offspring) #print(child) mutator.control = mutationStrategyAdaptor(mutator.control, opt.path) # mutate the child or children if (isTRUE(attr(child, "children"))) { - max.children = min(length(child), n.offspring - i + 1) - for (ii in seq(max.children)) { + max.children = min(length(child), n.offspring - i.offspring + 1) + for (i.child in seq(max.children)) { # pass just the individual and get a single individual - child[[ii]] = mutator(child[[ii]], mutator.control, control) - offspring[[i]] = child[[ii]] - i = i + 1 + child[[i.child]] = mutator(child[[i.child]], mutator.control, control) + offspring[[i.offspring]] = child[[i.child]] + i.offspring = i.offspring + 1 } } else { # pass just the individual and get a single individual child = mutator(child, mutator.control, control) - offspring[[i]] = child - i = i + 1 + offspring[[i.offspring]] = child + i.offspring = i.offspring + 1 } } #print(offspring) From b83339f35f35353a0ed1ec646dea516a1d5c3803 Mon Sep 17 00:00:00 2001 From: Dirk Surmann Date: Thu, 2 Jul 2015 15:32:04 +0200 Subject: [PATCH 5/6] fix typo --- R/mutator.bitflip.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/mutator.bitflip.R b/R/mutator.bitflip.R index dfa7cc2..8b797b0 100644 --- a/R/mutator.bitflip.R +++ b/R/mutator.bitflip.R @@ -22,7 +22,7 @@ makeBitFlipMutator = function(mutator.flip.prob = 0.1) { makeMutator( mutator = mutator, - name = "Bitplip mutator", + name = "Bitflip mutator", description = "Flips each bit of the allele with a specific probability.", supported = "binary", defaults = defaults, From afc6441af70327aeb97963d676548a9f561b9a31 Mon Sep 17 00:00:00 2001 From: Dirk Surmann Date: Thu, 2 Jul 2015 18:28:35 +0200 Subject: [PATCH 6/6] issue #102: export 'makeMutator', 'makeRecombinator' and 'makeSelector' --- NAMESPACE | 3 +++ R/makeMutator.R | 48 +++++++++++++++++++-------------- R/makeOperator.R | 13 ++++----- R/makeRecombinator.R | 49 +++++++++++++++++++++------------- R/makeSelector.R | 48 ++++++++++++++++++--------------- inst/examples/custom_example.R | 2 +- man/makeMutator.Rd | 39 +++++++++++++++++++++++++++ man/makeRecombinator.Rd | 42 +++++++++++++++++++++++++++++ man/makeSelector.Rd | 35 ++++++++++++++++++++++++ 9 files changed, 212 insertions(+), 67 deletions(-) create mode 100644 man/makeMutator.Rd create mode 100644 man/makeRecombinator.Rd create mode 100644 man/makeSelector.Rd diff --git a/NAMESPACE b/NAMESPACE index 00e4f6c..0afc4f8 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -43,12 +43,15 @@ export(makeInversionMutator) export(makeMaximumIterationsStoppingCondition) export(makeMaximumTimeStoppingCondition) export(makeMonitor) +export(makeMutator) export(makeNullMonitor) export(makeNullRecombinator) export(makePMXRecombinator) export(makePermutationGenerator) +export(makeRecombinator) export(makeRouletteWheelSelector) export(makeScrambleMutator) +export(makeSelector) export(makeSimpleSelector) export(makeStoppingCondition) export(makeSwapMutator) diff --git a/R/makeMutator.R b/R/makeMutator.R index b2bbd1e..85678f9 100644 --- a/R/makeMutator.R +++ b/R/makeMutator.R @@ -1,23 +1,31 @@ -# Helper function which constructs a mutator, i. e., a mutation operator. -# -# @param mutator [\code{function}]\cr -# Actual mutation operator. -# @param name [\code{character(1)}]\cr -# Name of the mutator. -# @param description [\code{character(1)}]\cr -# Short description of how the mutator works. -# @param supported [\code{character}]\cr -# Vector of strings/names of supported parameter representations. For example -# 'permutation', 'float', 'binary'. -# @param checker [\code{function}]\cr -# Check object, which performs a sanity check in mutator strategy parameters -# passed to the control object. -# @return [\code{ecr_mutator}] -# Mutator object. -makeMutator = function(mutator, name, description, - supported = getAvailableRepresentations(), - defaults = list(), - checker = function(operator.control) TRUE) { +#' @title +#' Construct a mutation operator +#' @description +#' Helper function which constructs a mutator, i.e., a mutation operator. +#' +#' @param mutator [\code{function}]\cr +#' Actual mutation operator. +#' @param name [\code{character(1)}]\cr +#' Name of the mutator. +#' @param description [\code{character(1)}]\cr +#' Short description of how the mutator works. +#' @param supported [\code{character}]\cr +#' Vector of strings/names of supported parameter representations. Possible are +#' 'permutation', 'binary', 'float', 'custom'. +#' @param defaults [\code{list}]\cr +#' List of default values for the operators strategy parameters. +#' @param checker [\code{function}]\cr +#' Check object, which performs a sanity check in mutator strategy parameters +#' passed to the control object. +#' @return [\code{ecr_mutator}] +#' Mutator object. +#' @export +makeMutator = function(mutator, name, description + , supported = getAvailableRepresentations() + , defaults = list() + , checker = function(operator.control) TRUE + ) { + # create operator mutator = makeOperator(mutator, name, description, supported, defaults, checker) mutator = addClasses(mutator, c("ecr_mutator")) return(mutator) diff --git a/R/makeOperator.R b/R/makeOperator.R index 5c537a7..7dab3f1 100644 --- a/R/makeOperator.R +++ b/R/makeOperator.R @@ -13,13 +13,14 @@ # List of default values for the operators strategy parameters. # @return [\code{ecr_operator}] # Operator object. -makeOperator = function(operator, name, description, - supported = getAvailableRepresentations(), - defaults = list(), - checker = function(operator.control) TRUE) { +makeOperator = function(operator, name, description + , supported = getAvailableRepresentations() + , defaults = list() + , checker = function(operator.control) TRUE + ) { assertFunction(operator) - assertCharacter(name, len = 1L, any.missing = FALSE) - assertCharacter(description, len = 1L, any.missing = FALSE) + assertString(name) + assertString(description) assertSubset(supported, choices = getAvailableRepresentations(), empty.ok = FALSE) assertList(defaults, unique = TRUE, any.missing = FALSE) assertFunction(checker, args = "operator.control") diff --git a/R/makeRecombinator.R b/R/makeRecombinator.R index ef0048f..33d4122 100644 --- a/R/makeRecombinator.R +++ b/R/makeRecombinator.R @@ -1,22 +1,33 @@ -# Helper function which constructs a recombinator, i. e., a recombination operator. -# -# @param recombinator [\code{function}]\cr -# Actual mutation operator. -# @param name [\code{character(1)}]\cr -# Name of the recombinator. -# @param supported [\code{character}]\cr -# Vector of strings/names of supported parameter representations. For example -# 'permutation', 'float', 'binary'. -# @param n.parents [\code{integer(1)}]\cr -# Number of parents supported. -# @return [\code{ecr_recombinator}] -# Recombinator object. -makeRecombinator = function( - recombinator, name, description, - supported = getAvailableRepresentations(), - n.parents = 2L, - defaults = list(), - checker = function(operator.control) TRUE) { +#' @title +#' Construct a recombination operator +#' @description +#' Helper function which constructs a recombinator, i.e., a recombination operator. +#' +#' @param recombinator [\code{function}]\cr +#' Actual mutation operator. +#' @param name [\code{character(1)}]\cr +#' Name of the recombinator. +#' @param description [\code{character(1)}]\cr +#' Short description of how the recombinator works. +#' @param supported [\code{character}]\cr +#' Vector of strings/names of supported parameter representations. For example +#' 'permutation', 'float', 'binary'. +#' @param n.parents [\code{integer(1)}]\cr +#' Number of parents supported. +#' @param defaults [\code{list}]\cr +#' List of default values for the operators strategy parameters. +#' @param checker [\code{function}]\cr +#' Check object, which performs a sanity check in mutator strategy parameters +#' passed to the control object. +#' @return [\code{ecr_recombinator}] +#' Recombinator object. +#' @export +makeRecombinator = function(recombinator, name, description + , supported = getAvailableRepresentations() + , n.parents = 2L + , defaults = list() + , checker = function(operator.control) TRUE + ) { recombinator = makeOperator(recombinator, name, description, supported, defaults) assertInteger(n.parents, len = 1L, lower = 2L, any.missing = FALSE) diff --git a/R/makeSelector.R b/R/makeSelector.R index 46891eb..d546e27 100644 --- a/R/makeSelector.R +++ b/R/makeSelector.R @@ -1,28 +1,34 @@ -# Helper function which defines a selector method, i. e., an operator which -# takes the population return a part of it for mating. -# -# @param selector [\code{function}]\cr -# Actual selection operator. -# @param name [\code{character(1)}]\cr -# Name of the selector. -# @param description [\code{character(1)}]\cr -# Short description of how the selector works. -# @param supported [\code{character}]\cr -# Vector of strings/names of supported parameter representations. For example -# 'permutation', 'float', 'binary'. -# @param supported.objectives [\code{character}]\cr -# At least one of \dQuote{single-objective} or \dQuote{multi-objective}. -# @return [\code{ecr_selector}] -# selector object. -makeSelector = function( - selector, - name, description, - supported = getAvailableRepresentations(), - supported.objectives) { +#' @title +#' Construct a selection operator +#' @description +#' Helper function which defines a selector method, i.e., an operator which +#' takes the population return a part of it for mating. +#' +#' @param selector [\code{function}]\cr +#' Actual selection operator. +#' @param name [\code{character(1)}]\cr +#' Name of the selector. +#' @param description [\code{character(1)}]\cr +#' Short description of how the selector works. +#' @param supported [\code{character}]\cr +#' Vector of strings/names of supported parameter representations. For example +#' 'permutation', 'float', 'binary'. +#' @param supported.objectives [\code{character}]\cr +#' At least one of \dQuote{single-objective} or \dQuote{multi-objective}. +#' @return [\code{ecr_selector}] +#' selector object. +#' @export +makeSelector = function(selector, name, description + , supported = getAvailableRepresentations() + , supported.objectives + ) { + # argument check assertFunction(selector, args = c("population", "n.select", "control"), ordered = TRUE) assertSubset(supported.objectives, c("single-objective", "multi-objective")) + selector = makeOperator(selector, name, description, supported) selector = setAttribute(selector, "supported.objectives", supported.objectives) selector = addClasses(selector, c("ecr_selector")) + return(selector) } diff --git a/inst/examples/custom_example.R b/inst/examples/custom_example.R index 58e9097..9255f9a 100644 --- a/inst/examples/custom_example.R +++ b/inst/examples/custom_example.R @@ -65,7 +65,7 @@ myMutator = makeMutator( ) myRecombinator = makeRecombinator( - recombinator = function(x, control) { + recombinator = function(x, args, control) { x[[1]] }, name = "Convex-Combination recombinator", diff --git a/man/makeMutator.Rd b/man/makeMutator.Rd new file mode 100644 index 0000000..61e687b --- /dev/null +++ b/man/makeMutator.Rd @@ -0,0 +1,39 @@ +% Generated by roxygen2 (4.1.1): do not edit by hand +% Please edit documentation in R/makeMutator.R +\name{makeMutator} +\alias{makeMutator} +\title{Construct a mutation operator} +\usage{ +makeMutator(mutator, name, description, + supported = getAvailableRepresentations(), defaults = list(), + checker = function(operator.control) TRUE) +} +\arguments{ +\item{mutator}{[\code{function}]\cr +Actual mutation operator.} + +\item{name}{[\code{character(1)}]\cr +Name of the mutator.} + +\item{description}{[\code{character(1)}]\cr +Short description of how the mutator works.} + +\item{supported}{[\code{character}]\cr +Vector of strings/names of supported parameter representations. Possible are +'permutation', 'binary', 'float', 'custom'.} + +\item{defaults}{[\code{list}]\cr +List of default values for the operators strategy parameters.} + +\item{checker}{[\code{function}]\cr +Check object, which performs a sanity check in mutator strategy parameters +passed to the control object.} +} +\value{ +[\code{ecr_mutator}] + Mutator object. +} +\description{ +Helper function which constructs a mutator, i.e., a mutation operator. +} + diff --git a/man/makeRecombinator.Rd b/man/makeRecombinator.Rd new file mode 100644 index 0000000..3805b01 --- /dev/null +++ b/man/makeRecombinator.Rd @@ -0,0 +1,42 @@ +% Generated by roxygen2 (4.1.1): do not edit by hand +% Please edit documentation in R/makeRecombinator.R +\name{makeRecombinator} +\alias{makeRecombinator} +\title{Construct a recombination operator} +\usage{ +makeRecombinator(recombinator, name, description, + supported = getAvailableRepresentations(), n.parents = 2L, + defaults = list(), checker = function(operator.control) TRUE) +} +\arguments{ +\item{recombinator}{[\code{function}]\cr +Actual mutation operator.} + +\item{name}{[\code{character(1)}]\cr +Name of the recombinator.} + +\item{description}{[\code{character(1)}]\cr +Short description of how the recombinator works.} + +\item{supported}{[\code{character}]\cr +Vector of strings/names of supported parameter representations. For example +'permutation', 'float', 'binary'.} + +\item{n.parents}{[\code{integer(1)}]\cr +Number of parents supported.} + +\item{defaults}{[\code{list}]\cr +List of default values for the operators strategy parameters.} + +\item{checker}{[\code{function}]\cr +Check object, which performs a sanity check in mutator strategy parameters +passed to the control object.} +} +\value{ +[\code{ecr_recombinator}] + Recombinator object. +} +\description{ +Helper function which constructs a recombinator, i.e., a recombination operator. +} + diff --git a/man/makeSelector.Rd b/man/makeSelector.Rd new file mode 100644 index 0000000..252dd6c --- /dev/null +++ b/man/makeSelector.Rd @@ -0,0 +1,35 @@ +% Generated by roxygen2 (4.1.1): do not edit by hand +% Please edit documentation in R/makeSelector.R +\name{makeSelector} +\alias{makeSelector} +\title{Construct a selection operator} +\usage{ +makeSelector(selector, name, description, + supported = getAvailableRepresentations(), supported.objectives) +} +\arguments{ +\item{selector}{[\code{function}]\cr +Actual selection operator.} + +\item{name}{[\code{character(1)}]\cr +Name of the selector.} + +\item{description}{[\code{character(1)}]\cr +Short description of how the selector works.} + +\item{supported}{[\code{character}]\cr +Vector of strings/names of supported parameter representations. For example +'permutation', 'float', 'binary'.} + +\item{supported.objectives}{[\code{character}]\cr +At least one of \dQuote{single-objective} or \dQuote{multi-objective}.} +} +\value{ +[\code{ecr_selector}] + selector object. +} +\description{ +Helper function which defines a selector method, i.e., an operator which + takes the population return a part of it for mating. +} +