Skip to content

Commit f1f9dcf

Browse files
authored
...
1 parent 1bef660 commit f1f9dcf

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

src/main/doe/Morris.R

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ getInitialDesign <- function(algorithm, input, output) {
2626
set.seed(algorithm$seed)
2727
algorithm$m <- morris(model = NULL, factors = d, r = algorithm$r,
2828
design = list(type = "oat", levels = algorithm$levels))
29-
return(algorithm$m$X)
29+
names(algorithm$m$X) <- names(input)
30+
return(from01(algorithm$m$X,input))
3031
}
3132

3233
getNextDesign <- function(algorithm, X, Y) {
@@ -39,7 +40,7 @@ displayResults <- function(algorithm, X, Y) {
3940

4041
algorithm$files = "plot.png"
4142
png(file = algorithm$files, bg = "transparent", height = 600, width = 600)
42-
plot(algorithm$m)
43+
try(plot(algorithm$m))
4344
dev.off()
4445

4546
mu = colMeans(algorithm$m$ee)
@@ -60,3 +61,21 @@ displayResults <- function(algorithm, X, Y) {
6061
}
6162

6263
displayResultsTmp <- function(algorithm, X, Y) {}
64+
65+
from01 = function(X, inp) {
66+
nX = names(X)
67+
for (i in 1:ncol(X)) {
68+
namei = nX[i]
69+
X[,i] = X[,i] * (inp[[ namei ]]$max-inp[[ namei ]]$min) + inp[[ namei ]]$min
70+
}
71+
return(X)
72+
}
73+
74+
to01 = function(X, inp) {
75+
nX = names(X)
76+
for (i in 1:ncol(X)) {
77+
namei = nX[i]
78+
X[,i] = (X[,i] - inp[[ namei ]]$min) / (inp[[ namei ]]$max-inp[[ namei ]]$min)
79+
}
80+
return(X)
81+
}

0 commit comments

Comments
 (0)