Skip to content

Commit

Permalink
add and export makeGenerator
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobbossek committed Apr 14, 2015
1 parent 0b77e6f commit 1a6995d
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export(makeBitFlipMutator)
export(makeConsoleMonitor)
export(makeCrossoverRecombinator)
export(makeGaussMutator)
export(makeGenerator)
export(makeIntermediateRecombinator)
export(makeMaximumIterationsStoppingCondition)
export(makeMaximumTimeStoppingCondition)
Expand Down
23 changes: 23 additions & 0 deletions R/makeGenerator.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#' Helper function which constructs a generator, i. e., a function which generates
#' an initial population.
#
#' @param generator [\code{function}]\cr
#' Actual generator function. Should expect the size of the population \code{size}
#' as a first and a ecr control object \code{control} as the second argument.
#' @param name [\code{character(1)}]\cr
#' Name of the generator.
#' @param description [\code{character(1)}]\cr
#' Short description of how the generator works.
#' @param supported [\code{character}]\cr
#' Vector of strings/names of supported parameter representations, i.e.,
#' 'permutation', 'float', 'binary' or 'custom'.
#' @return [\code{ecr_generator}]
#' Generator object.
#' @export
makeGenerator = function(generator, name, description,
supported = getAvailableRepresentations()) {
assertFunction(generator, args = c("size", "control"), ordered = TRUE)
generator = makeOperator(generator, name, description, supported)
generator = addClasses(generator, c("ecr_generator"))
return(generator)
}
34 changes: 34 additions & 0 deletions man/makeGenerator.Rd
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
% Generated by roxygen2 (4.1.0): do not edit by hand
% Please edit documentation in R/makeGenerator.R
\name{makeGenerator}
\alias{makeGenerator}
\title{Helper function which constructs a generator, i. e., a function which generates
an initial population.}
\usage{
makeGenerator(generator, name, description,
supported = getAvailableRepresentations())
}
\arguments{
\item{generator}{[\code{function}]\cr
Actual generator function. Should expect the size of the population \code{size}
as a first and a ecr control object \code{control} as the second argument.}

\item{name}{[\code{character(1)}]\cr
Name of the generator.}

\item{description}{[\code{character(1)}]\cr
Short description of how the generator works.}

\item{supported}{[\code{character}]\cr
Vector of strings/names of supported parameter representations, i.e.,
'permutation', 'float', 'binary' or 'custom'.}
}
\value{
[\code{ecr_generator}]
Generator object.
}
\description{
Helper function which constructs a generator, i. e., a function which generates
an initial population.
}

0 comments on commit 1a6995d

Please sign in to comment.