Skip to content

Commit

Permalink
update stopping conditions (small bugs in santity checking)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobbossek committed Feb 28, 2015
1 parent 8e41b03 commit 6c0cbbf
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 9 deletions.
4 changes: 2 additions & 2 deletions R/setupStoppingConditions.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
# The stopping condition generators should have attributes 'checkFunction' and
# default value (see ecr operators). This way setupStoppingCondition could
# iterate over all available stopping conditions.
setupStoppingConditions = function(max.iter = Inf, max.time = Inf) {
if (is.infinite(max.iter) && is.infinite(max.time)) {
setupStoppingConditions = function(max.iter = NULL, max.time = NULL) {
if (is.null(max.iter) && is.null(max.time)) {
stopf("At least max.iter or max.time must be finite.")
}
list(
Expand Down
8 changes: 6 additions & 2 deletions R/stoppingCondition.max.iter.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@
#' Maximal number of iterations. Default ist \code{Inf}.
#' @return [\code{function}]
#' @export
makeMaximumIterationsStoppingCondition = function(max.iter = Inf) {
assertCount(max.iter, positive = TRUE, na.ok = FALSE)
makeMaximumIterationsStoppingCondition = function(max.iter = NULL) {
if (!is.null(max.iter)) {
assertInt(max.iter, lower = 1L, na.ok = FALSE)
} else {
max.iter = Inf
}
force(max.iter)

condition.fun = function(envir = parent.frame()) {
Expand Down
8 changes: 6 additions & 2 deletions R/stoppingCondition.max.time.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@
#' Time budget in seconds. Default ist \code{Inf}.
#' @return [\code{function}]
#' @export
makeMaximumTimeStoppingCondition = function(max.time = Inf) {
assertCount(max.time, positive = TRUE, na.ok = FALSE)
makeMaximumTimeStoppingCondition = function(max.time = NULL) {
if (!is.null(max.time)) {
assertInt(max.time, lower = 1L, na.ok = FALSE)
} else {
max.time = Inf
}
force(max.time)

condition.fun = function(envir = parent.frame()) {
Expand Down
2 changes: 1 addition & 1 deletion man/makeMaximumIterationsStoppingCondition.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
\alias{makeMaximumIterationsStoppingCondition}
\title{Stopping condition: maximum number of iterations.}
\usage{
makeMaximumIterationsStoppingCondition(max.iter = Inf)
makeMaximumIterationsStoppingCondition(max.iter = NULL)
}
\arguments{
\item{max.iter}{[\code{integer(1)}]\cr
Expand Down
2 changes: 1 addition & 1 deletion man/makeMaximumTimeStoppingCondition.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
\alias{makeMaximumTimeStoppingCondition}
\title{Stopping condition: time limit.}
\usage{
makeMaximumTimeStoppingCondition(max.time = Inf)
makeMaximumTimeStoppingCondition(max.time = NULL)
}
\arguments{
\item{max.time}{[\code{integer(1)}]\cr
Expand Down
2 changes: 1 addition & 1 deletion man/setupStoppingConditions.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
\alias{setupStoppingConditions}
\title{Generator for some frequently used stopping conditions.}
\usage{
setupStoppingConditions(max.iter = Inf, max.time = Inf)
setupStoppingConditions(max.iter = NULL, max.time = NULL)
}
\arguments{
\item{max.iter}{[\code{integer(1)}]\cr
Expand Down

0 comments on commit 6c0cbbf

Please sign in to comment.