Skip to content

Commit b40c8e5

Browse files
committed
..
1 parent e2ecc50 commit b40c8e5

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

R/AcqFunctionMES.R

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ AcqFunctionMES = R6Class("AcqFunctionMES",
6161
self$domain$trafo = NULL # FIXME is it okay to do this?
6262

6363
if (is.null(self$grid)) {
64-
self$grid = generate_design_lhs(self$domain, n = 10000L)$data # FIXME: gridsize
64+
self$grid = generate_design_lhs(self$domain, n = 10000L)$data # FIXME: gridsize as hyperparameter
6565
}
6666
},
6767

@@ -79,7 +79,7 @@ AcqFunctionMES = R6Class("AcqFunctionMES",
7979

8080

8181
# FIXME: AcqFunction ParamSet with at least gridsize and nk
82-
get_maxes = function(nK = 10000L, grid, x, surrogate, surrogate_max_to_min) {
82+
sample_maxes_gumbel = function(n_samples = 1000L, grid, x, surrogate, surrogate_max_to_min) {
8383
xgrid = rbind(grid, x)
8484
p = surrogate$predict(xgrid)
8585
mu = p$mean
@@ -109,23 +109,24 @@ get_maxes = function(nK = 10000L, grid, x, surrogate, surrogate_max_to_min) {
109109
MARGIN = 1L, FUN = prod)
110110

111111
if (sum(prob > 0.05 & prob < 0.95) == 0L) {
112-
return(mu_max + runif(nK, min = 0, max = 1))
112+
return(mu_max + runif(n_samples, min = 0, max = 1))
113113
}
114114

115-
# Gumbel sampling
115+
# inverse Gumbel sampling
116116
q1 = optimize(function(x) abs(probf(x, mu = mu, se = se, surrogate_max_to_min = surrogate_max_to_min) - 0.25), interval = range(mgrid))$minimum
117-
q2 = optimize(function(x) abs(probf(x, mu = mu, se = se, surrogate_max_to_min = surrogate_max_to_min) - 0.5), interval = range(mgrid))$minimum
117+
q2 = optimize(function(x) abs(probf(x, mu = mu, se = se, surrogate_max_to_min = surrogate_max_to_min) - 0.50), interval = range(mgrid))$minimum
118118
q3 = optimize(function(x) abs(probf(x, mu = mu, se = se, surrogate_max_to_min = surrogate_max_to_min) - 0.75), interval = range(mgrid))$minimum
119-
beta = (q1 - q3) / (log(log(4 / 3)) - log(log(4))) # FIXME: assert beta > 0
119+
beta = (q1 - q3) / (log(log(4 / 3)) - log(log(4)))
120+
if (beta < .Machine$double.eps) beta = sqrt(.Machine$double.eps)
120121
alpha = q2 + beta * log(log(2))
121122

122-
-log(-log(runif(nK, min = 0, max = 1))) * beta + alpha
123+
-log(-log(runif(n_samples, min = 0, max = 1))) * beta + alpha
123124
# FIXME: maxes that are <= mu_max + eps should be replaced by mu_max + eps
124125
}
125126

126127

127128

128-
probf = function(mu_, mu, se, surrogate_max_to_min) {
129-
prod(pnorm((mu_ - (- surrogate_max_to_min * mu)) / se))
129+
probf = function(x, mu, se, surrogate_max_to_min) {
130+
prod(pnorm((x - (- surrogate_max_to_min * mu)) / se))
130131
}
131132

0 commit comments

Comments
 (0)