Skip to content

Commit 484af5a

Browse files
committed
v1.15-0
1 parent f443100 commit 484af5a

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

src/test/cases/sobol.R

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
## This file should provide following objects, when loaded:
2+
# f : function
3+
# input.f : list of input dimensions, contains list of properties like lower & upper bounds of each dimensions
4+
# output.f : list of output dimensions
5+
# *.f : list of math properties. To be compared with algorithm results
6+
# [print.f] : method to print/plot the function for information
7+
8+
f <- function(X) {
9+
a <- c(0, 1, 4.5, 9, 99, 99, 99, 99)
10+
y <- 1
11+
for (j in 1:8) {
12+
y <- y * (abs(4 * X[, j] - 2) + a[j]) / (1 + a[j])
13+
}
14+
matrix(y,nrow=nrow(X))
15+
}
16+
17+
input.f = list(
18+
x1=list(min=0,max=1),
19+
x2=list(min=0,max=1),
20+
x3=list(min=0,max=1),
21+
x4=list(min=0,max=1),
22+
x5=list(min=0,max=1),
23+
x6=list(min=0,max=1),
24+
x7=list(min=0,max=1),
25+
x8=list(min=0,max=1)
26+
)
27+
output.f = "sobol"
28+
mu.f = c(2.6129, 2.1610 ,0.4980, 0.4273 ,0.0333 ,0.0375 ,0.0189 ,0.0473)
29+
30+
test = function(algorithm_file) {
31+
results = run.algorithm(algorithm_file, options=NULL,fun=list(input=input.f,output=output.f,fun=f))
32+
library(testthat)
33+
# Replace following test by something suitable
34+
test_that("sobol mu",{expect_equal(as.numeric(results$mu),mu.f,tolerance = .0001)})
35+
}
36+

0 commit comments

Comments
 (0)