Skip to content

Commit 6befed2

Browse files
committed
Merge branch 'master' into fix201_focussearch
2 parents ecdeca8 + 98dacf7 commit 6befed2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+230
-241
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ bench/mlr/modelsel-files
1010
src/*.o
1111
src/*.so
1212
plots
13-
tests/testthat/Rplots.pdf
13+
tests/testthat/Rplots.pdf
14+
*.sublime-*

.travis.yml

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,46 @@
11
language: R
22
sudo: false
3-
cache: packages
4-
warnings_are_errors: false
3+
r:
4+
- release
5+
addons:
6+
apt:
7+
sources:
8+
- ubuntu-toolchain-r-test
9+
packages:
10+
- gcc-4.9
11+
- g++-4.9
12+
- gfortran-4.9
13+
- libgmp-dev
514
env:
615
global:
716
- _R_CHECK_TIMINGS_=0
17+
- _R_CHECK_FORCE_SUGGESTS_=0
818
- secure: "e2QLomaUqNvpHnGNdBXS4VO2/UWokrKl9UgYrqWo+fhpXaJiJuONNPNL44BuWZR2Cy7noTHrevVbTKBkGpqJR42mkjzcjd6qyR1Ctiveir+84/HTtmexouIUn5OFRH5dgyt/gquld31RlHlSYoKho3nZ7D7SnVExov9tp2FGRhU="
919

20+
warnings_are_errors: false
21+
r_check_args: "--as-cran --run-donttest"
22+
1023
r_github_packages:
11-
- berndbischl/ParamHelpers
24+
- berndbischl/parallelMap
1225
- jakobbossek/smoof
1326
- mlr-org/mlr
1427

28+
r_packages:
29+
- roxygen2
30+
31+
32+
before_install:
33+
- mkdir $HOME/bin
34+
- ln -s $(which gcc-4.9) $HOME/bin/gcc
35+
- ln -s $(which g++-4.9) $HOME/bin/g++
36+
- ln -s $(which gfortran-4.9) $HOME/bin/gfortran
37+
- export PATH=$HOME/bin:$PATH
38+
- echo $LD_LIBRARY_PATH
39+
- echo $LIBRARY_PATH
40+
41+
after_failure:
42+
- ./travis-tool.sh dump_logs
43+
1544
notifications:
1645
email:
1746
recipients:

NAMESPACE

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,12 @@ import(BBmisc)
4141
import(ParamHelpers)
4242
import(checkmate)
4343
import(ggplot2)
44+
import(grDevices)
4445
import(lhs)
4546
import(mlr)
4647
import(parallelMap)
4748
import(smoof)
49+
import(stats)
50+
import(utils)
4851
useDynLib(mlrMBO,c_eps_indicator)
4952
useDynLib(mlrMBO,c_sms_indicator)

R/OptProblem.R

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,10 @@ NULL
3232
# All variables in this Object should be documented here.
3333
# Think of it, when you implement new ones!
3434
# Unfortunately in R we cannot hinder you from putting other values in this object, but please: Don't!
35-
makeOptProblem = function(fun, par.set, design = NULL, learner, control, show.info = TRUE, more.args = list()) {
35+
makeOptProblem = function(fun, design = NULL, learner, control, show.info = TRUE, more.args = list()) {
3636
opt.problem = new.env()
3737

3838
opt.problem$fun = fun
39-
opt.problem$par.set = par.set
4039
opt.problem$design = design
4140
opt.problem$learner = learner
4241
opt.problem$control = control
@@ -62,7 +61,7 @@ getOptProblemControl = function(opt.problem) {
6261
}
6362

6463
getOptProblemParSet = function(opt.problem) {
65-
opt.problem$par.set
64+
getParamSet(getOptProblemFun(opt.problem))
6665
}
6766

6867
getOptProblemMoreArgs = function(opt.problem) {

R/checkLearner.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ NULL
1616
# check and create default learner
1717
checkLearner = function(learner, par.set, control) {
1818
if (missing(learner) || is.null(learner)) {
19-
if (!hasDiscrete(par.set)) {
19+
if (!hasDiscrete(par.set, include.logical = TRUE)) {
2020
if (control$noisy) {
2121
learner = makeLearner("regr.km", covtype = "matern5_2", predict.type = "se", nugget.estim = control$noisy)
2222
} else {

R/convertOptPathToDf.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# MBO control object.
88
# @return [\code{data.frame}]
99
convertOptPathToDf = function(opt.path, control) {
10-
df = as.data.frame(opt.path, discretes.as.factor = TRUE, include.rest = FALSE)
10+
df = as.data.frame(opt.path, include.rest = FALSE)
1111
df = convertDataFrameCols(df, ints.as.num = TRUE, logicals.as.factor = TRUE)
1212
return(df)
1313
}

R/doc_mbo_OptPath.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#' }
1919
#' }
2020
#' \item{multipoint.cb.lambda}{Random lambda-value used in q-CB point proposal. One lambda for each point in that case.}
21-
#' \item{.weight}{Weight vector sampled for multipoint ParEGO}
21+
#' \item{parego.weight}{Weight vector sampled for multipoint ParEGO}
2222
#' }
2323
#'
2424
#' Moreover, the user may pass additional \dQuote{user extras} by appending a named list

R/exampleRun.R

Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ exampleRun = function(fun, design = NULL, learner = NULL, control,
3838
par.types = getParamTypes(par.set)
3939
n.params = sum(getParamLengths(par.set))
4040
noisy = isNoisy(fun)
41+
control$noisy = noisy
42+
control$minimize = shouldBeMinimized(fun)
4143
learner = checkLearner(learner, par.set, control)
4244
assertClass(control, "MBOControl")
4345
points.per.dim = asCount(points.per.dim, positive = TRUE)
@@ -51,8 +53,6 @@ exampleRun = function(fun, design = NULL, learner = NULL, control,
5153
global.opt = smoof::getGlobalOptimum(fun)$value
5254
else
5355
global.opt = NA_real_
54-
control$noisy = noisy
55-
control$minimize = shouldBeMinimized(fun)
5656

5757
if (control$n.objectives != 1L)
5858
stopf("exampleRun can only be applied for single objective functions, but you have %i objectives! Use 'exampleRunMultiCrit'!",
@@ -80,9 +80,9 @@ exampleRun = function(fun, design = NULL, learner = NULL, control,
8080
if (is.null(fun.mean)) {
8181
evals = evaluate(fun, par.set, n.params, par.types, noisy, noisy.evals, points.per.dim, names.x, name.y, seq_along(control$multifid.lvls))
8282
} else {
83-
evals = evaluate(fun.mean, par.set, n.params, par.types, noisy = FALSE, noisy.evals = 1, points.per.dim, names.x, name.y, seq_along(control$multifid.lvls))
83+
evals = evaluate(fun.mean, par.set, n.params, par.types, noisy = FALSE, noisy.evals = 1, points.per.dim, names.x, name.y, multifid.lvls = seq_along(control$multifid.lvls))
8484
}
85-
85+
8686
if (is.na(global.opt))
8787
global.opt.estim = ifelse(shouldBeMinimized(fun), min(evals[, name.y]), max(evals[, name.y]))
8888
else
@@ -93,7 +93,7 @@ exampleRun = function(fun, design = NULL, learner = NULL, control,
9393
messagef("Performing MBO on function.")
9494
if (is.null(design))
9595
messagef("Initial design: %i. Sequential iterations: %i.", control$init.design.points, control$iters)
96-
messagef("Learner: %s. Settings:\n%s", learner$id, mlr:::getHyperParsString(learner))
96+
messagef("Learner: %s. Settings:\n%s", learner$id, mlr:::getHyperParsString(learner, show.missing.values = FALSE))
9797
}
9898

9999
# run optimizer now
@@ -104,7 +104,14 @@ exampleRun = function(fun, design = NULL, learner = NULL, control,
104104
if (!is.null(fun.mean)) {
105105
y.true = vnapply(convertRowsToList(getOptPathX(res$opt.path), name.list = TRUE, name.vector = TRUE), fun.mean)
106106
}
107-
107+
108+
if (control$multifid) {
109+
n.params = n.params - 1
110+
par.set = dropParams(par.set, ".multifid.lvl")
111+
par.types = getParamTypes(par.set)
112+
names.x = getParamIds(par.set, repeated = TRUE, with.nr = TRUE)
113+
}
114+
108115
makeS3Obj("MBOExampleRun",
109116
fun.mean = fun.mean,
110117
par.set = par.set,
@@ -135,7 +142,7 @@ print.MBOExampleRun = function(x, ...) {
135142
catf("True points per dim. : %s", collapse(x$points.per.dim))
136143
print(x$control)
137144
catf("Learner : %s", x$learner$id)
138-
catf("Learner settings:\n%s", mlr:::getHyperParsString(x$learner))
145+
catf("Learner settings:\n%s", mlr:::getHyperParsString(x$learner, show.missing.values = FALSE))
139146
mr = x$mbo.res
140147
op = mr$opt.path
141148
catf("Recommended parameters:")
@@ -158,29 +165,13 @@ getEvals = function(fun, par.set, noisy, noisy.evals, points.per.dim, names.x, n
158165
return(evals)
159166
}
160167

161-
getEvalsForMultifid = function(fun, par.set, noisy, noisy.evals, points.per.dim, names.x, name.y, multifid.lvls) {
162-
eval.list = lapply(multifid.lvls, function(l){
163-
force(l)
164-
force(fun)
165-
this.fun = function(x) {
166-
x$.multifid.lvl = l
167-
fun(x)
168-
}
169-
evals = getEvals(this.fun, par.set, noisy, noisy.evals, points.per.dim, names.x, name.y)
170-
cbind.data.frame(.multifid.lvl = l, evals)
171-
})
172-
do.call("rbind", eval.list)
173-
}
174-
175168
evaluate = function(fun, par.set, n.params, par.types, noisy, noisy.evals, points.per.dim, names.x, name.y, multifid.lvls = numeric(0)) {
176169
if (!noisy && n.params == 1L && par.types == "discrete")
177170
stopf("ExampleRun does not make sense with a single deterministic discrete parameter.")
171+
if (length(multifid.lvls) && n.params %in% c(2L,3L) && all(par.types %in% c("numeric", "numericvector", "discrete", "integer")))
172+
return(getEvals(fun, par.set, noisy, noisy.evals, points.per.dim * length(multifid.lvls), names.x, name.y))
178173
if (n.params %in% c(1L, 2L) && all(par.types %in% c("numeric", "numericvector", "discrete"))) {
179-
if (length(multifid.lvls)) {
180-
return(getEvalsForMultifid(fun, par.set, noisy, noisy.evals, points.per.dim, names.x, name.y, multifid.lvls))
181-
} else {
182-
return(getEvals(fun, par.set, noisy, noisy.evals, points.per.dim, names.x, name.y))
183-
}
174+
return(getEvals(fun, par.set, noisy, noisy.evals, points.per.dim, names.x, name.y))
184175
}
185176
}
186177

R/exampleRunMultiCrit.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ exampleRunMultiCrit= function(fun, design = NULL, learner, control, points.per.d
8585

8686
showInfo(show.info, "Performing MBO on function.")
8787
showInfo(show.info, "Initial design: %i. Sequential iterations: %i.", control$init.design.points, control$iters)
88-
showInfo(show.info, "Learner: %s. Settings:\n%s", learner$id, mlr:::getHyperParsString(learner))
88+
showInfo(show.info, "Learner: %s. Settings:\n%s", learner$id, mlr:::getHyperParsString(learner, show.missing.values = FALSE))
8989

9090
# run optimizer now
9191
res = mbo(fun, design, learner = learner, control = control, show.info = show.info)
@@ -145,7 +145,7 @@ print.MBOExampleRunMultiCrit = function(x, ...) {
145145
catf("Parameter types : %s", collapse(x$par.types))
146146
print(x$control)
147147
catf("Learner : %s", x$learner$id)
148-
catf("Learner settings:\n%s", mlr:::getHyperParsString(x$learner))
148+
catf("Learner settings:\n%s", mlr:::getHyperParsString(x$learner, show.missing.values = FALSE))
149149
catf("Hypervolume : %.4e", x$mbo.hypervolume)
150150
catf("NSGA2 Hypervolume (6000 FEs) : %.4e", x$nsga2.hypervolume)
151151
}

R/getExtras.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# errors.model character(1)
1414
# filter.replace logical(1)
1515
# multipoint.cb.lambda numeric(1)
16-
# .weight<j> numeric(1)
16+
# parego.weight.<j> numeric(1)
1717
#
1818
# Please document the content in doc_mbo_OptPath.R
1919

@@ -54,7 +54,7 @@ getExtras = function(n, prop, train.time, control) {
5454
weight.mat = prop$weight.mat
5555
if (is.null(weight.mat))
5656
weight.mat = matrix(NA_real_, nrow = n, ncol = control$n.objectives)
57-
w = setNames(as.list(weight.mat[i, ]), paste0(".weight", 1:ncol(weight.mat)))
57+
w = setNames(as.list(weight.mat[i, ]), paste0("parego.weight.", 1:ncol(weight.mat)))
5858
ex = c(ex, w)
5959
}
6060
# if we filtered proposed points, store flag

0 commit comments

Comments
 (0)