Current way to specify parameters in SensitivityJob class is using $param() which only makes it possible to specify a single field value range.
sen <- Sensitivity$new(path_idf, path_epw)
sen$param(
# Syntax: Object Name = list(Field = c(Min, Max, Levels))
GP01 = list(Thickness = c(min = 0.01, max = 1, levels = 5)),
`Supply Fan 1` = list(Fan_Total_Efficiency = c(0.1, 1.0, 5)),
# See `r` and `grid_jump` in `sensitivity::morris`
.rep = 12, .grid_jump = 4
)
There are cases when the user may want to modify the same field in all related objects, e.g. change the fan efficiency for all fans. Below are several possible interfaces that came into my mind:
(A) Use a special notation := (borrowed from data.table package) in $param() to indicate that input field range should be applied to all objects in that class. For example:
Cons: Have to implement additional functions to manipulate R's language objects to make this work.
(B) Since SensitivityJob class inherits from ParametricJob class in current implementation, the user always can use $apply_measure() to apply complex modifications on the seed mode. Changing the example in README to modify the efficiency in all fans is equivalent to:
my_actions <- function (idf, thickness, fan_efficiency) {
# change the thickness of a single material
idf$set(GP01 = list(Thickness = thickness))
# change the efficiency of all fans
fan <- idf$to_table(class = "Fan:VariableVolume", all = TRUE)
fan[field == "Fan Total Efficiency", value := as.character(fan_efficiency)]
idf$update(fan)
idf
}
sen$apply_measure(my_action,
thickness = c(min = 0.01, max = 1, levels = 5),
fan_efficiency = c(0.1, 1.0, 5)
)
Pros: Using existing API. Less code work. Much more flexible. The arugments in the function can also be used as a factor name in sensitivity::morris().
Cons: Some new users may treat this way as too complicated for them.
It may be better to do both ways to provide more options for different level users.
Current way to specify parameters in
SensitivityJob
class is using$param()
which only makes it possible to specify a single field value range.There are cases when the user may want to modify the same field in all related objects, e.g. change the fan efficiency for all fans. Below are several possible interfaces that came into my mind:
(A) Use a special notation
:=
(borrowed from data.table package) in$param()
to indicate that input field range should be applied to all objects in that class. For example:(B) Since
SensitivityJob
class inherits fromParametricJob
class in current implementation, the user always can use$apply_measure()
to apply complex modifications on the seed mode. Changing the example in README to modify the efficiency in all fans is equivalent to:sensitivity::morris()
.It may be better to do both ways to provide more options for different level users.