Skip to content

Commit

Permalink
Merge master and fix issues raised in pull request
Browse files Browse the repository at this point in the history
  • Loading branch information
mboecker committed Dec 9, 2018
2 parents d4b526c + 28988f3 commit 27a7057
Show file tree
Hide file tree
Showing 69 changed files with 1,575 additions and 1,594 deletions.
5 changes: 4 additions & 1 deletion .Rbuildignore
@@ -1,12 +1,14 @@
.github
.gitignore
.ignore
.Rproj.user
.travis.yml
^.*\.Rproj$
^.*\.sublime-project$
^.*\.sublime-workspace$
^.*tar.gz$
^.+_cache$
^test_.*\.*R$
^.+_files$
^.editorconfig$
^\.Rproj\.user$
Expand All @@ -20,4 +22,5 @@ appveyor.yml
man-roxygen
README.md
README.Rmd
todo-files
todo-files
attic
1 change: 1 addition & 0 deletions DESCRIPTION
Expand Up @@ -30,5 +30,6 @@ Suggests:
roxygen2
RoxygenNote: 6.1.1
VignetteBuilder: knitr
Encoding: UTF-8
Remotes:
mlr-org/mlr3misc
13 changes: 6 additions & 7 deletions NAMESPACE
@@ -1,19 +1,18 @@
# Generated by roxygen2: do not edit by hand

S3method("[",OptPath)
S3method(as.data.frame,OptPath)
export(OptPath)
export(ParamCategorical)
export(ParamFlag)
export(ParamDbl)
export(ParamFct)
export(ParamInt)
export(ParamReal)
export(ParamLgl)
export(ParamSet)
export(ParamUntyped)
export(design_to_list)
export(repeatParam)
export(generate_design_grid)
export(generate_design_lhs)
export(trafo_on_repeated_param)
import(checkmate)
import(data.table)
import(mlr3misc)
importFrom(R6,R6Class)
importFrom(utils,head)
importFrom(utils,tail)
36 changes: 36 additions & 0 deletions R/Dependency.R
@@ -0,0 +1,36 @@


Dependency = R6Class("Dependency",
public = list(

# member variables
child = NULL, # the subordinate param
parent = NULL, # the (categ) parent param, that the child depends on

# constructor
initialize = function(child, parent, expr) {
assert_r6(child, "Parameter")
assert_r6(parent, "ParamFct")
self$child = child
self$parent = parent
}
)
)

DependencyNode = R6Class("DependencyNode",
public = list(
# member variables
param = NULL,
children = NULL,
parents = NULL,

# constructor
initialize = function(param) {
self$param = param
}
)
)




113 changes: 0 additions & 113 deletions R/ParamBase.R

This file was deleted.

77 changes: 0 additions & 77 deletions R/ParamCategorical.R

This file was deleted.

57 changes: 57 additions & 0 deletions R/ParamDbl.R
@@ -0,0 +1,57 @@
#' @title Float Parameter Object
#' @format \code{\link{R6Class}} object
#'
#' @description
#' A \code{\link[R6]{R6Class}} to represent numeric, real valued parameters.
#'
#' @section Member Variables:
#' \describe{
#' \item{lower}{[\code{numeric(1)}, \code{default = -Inf}] \cr
#' Upper bound for feasible values.}
#' \item{upper}{[\code{integer(1)}, \code{default = Inf}] \cr
#' Lower bound for feasible values.}
#' \item{allow_inf}{[\code{logical(1)}, \code{default = TRUE}] \cr
#' Are values \code{-Inf} and \code{Inf} feasible?}
#' }
#' @export
ParamDbl = R6Class("ParamDbl", inherit = Parameter,
public = list(
initialize = function(id, lower = -Inf, upper = Inf, special_vals = NULL, default = NULL, tags = NULL) {
super$initialize(
id = id,
storage_type = "double",
lower = lower,
upper = upper,
values = NULL,
special_vals = special_vals,
checker = function(x) checkNumber(x, lower = self$lower, upper = self$upper),
default = default,
tags = tags
)
assert_true(lower <= upper)
},

denorm_vector = function(x) {
assert_true(self$has_finite_bounds)
self$lower + x * self$span
},

value_to_string = function(x, num.format = "%.3g", ...) {
sprintf(num.format, x)
}
),
active = list(
range = function() c(self$lower, self$upper),
has_finite_bounds = function() all(is.finite(self$range)),
center = function() {
assert_true(self$has_finite_bounds)
(self$lower + self$upper) / 2
},
span = function() self$upper - self$lower
),

private = list(
get_range_string = function() sprintf("[%g, %g]", self$lower, self$upper),
get_type_string = function() "d"
)
)
50 changes: 50 additions & 0 deletions R/ParamFct.R
@@ -0,0 +1,50 @@
#' @title Categorical Parameter Object
#' @format \code{\link{R6Class}} object
#'
#' @description
#' A \code{\link[R6]{R6Class}} to represent categorical parameters.
#'
#' @section Member Variables:
#' \describe{
#' \item{values}{[\code{character}] \cr
#' All categorical values.}
#' }
#'
#' @export
ParamFct = R6Class(
"ParamFct",
inherit = Parameter,
public = list(
initialize = function(id, values, default = NULL, special_vals = NULL, tags = NULL) {
super$initialize(
id = id,
storage_type = "character",
lower = NA_real_,
upper = NA_real_,
values = values,
special_vals = special_vals,
checker = function(x) check_choice(x, choices = self$values),
default = default,
tags = tags
)
},

# public methods
denorm_vector = function(x) {
res = cut(x, breaks = seq(0, 1, length.out = self$nlevels+1), include.lowest = TRUE)
levels(res) = self$values
as.character(res)
},

value_to_string = function(x, ...) {
x
}
),
active = list(
nlevels = function() length(self$values)
),
private = list(
get_range_string = function() sprintf("{%s}", paste0(self$values, collapse = ",")),
get_type_string = function() "f"
)
)

0 comments on commit 27a7057

Please sign in to comment.