-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
issue #102: export 'makeMutator', 'makeRecombinator' and 'makeSelector'
- Loading branch information
Showing
9 changed files
with
212 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
} | ||
|