tunable_parameters(sys) returns the parameters of sys that are marked
tunable (Parameter("k", tunable = TRUE)); parameters without the
metadata count as tunable when default = TRUE.
subset_tunables(sys, new_tunables) returns the system with only
new_tunables tunable; the other tunable parameters are marked not
tunable. reorder_dimension_by_tunables(sys, arr, syms) takes an array
whose dimension dim is ordered as tunable_parameters(sys) and
reorders it as syms, a permutation of the tunable parameters. R arrays
are not modified in place, so there is no separate mutating variant.
Usage
tunable_parameters(sys, p = .parameters_of(sys, TRUE), default = TRUE)
subset_tunables(sys, new_tunables)
reorder_dimension_by_tunables(sys, arr, syms, dim = 1L)Arguments
- sys
A
System; complete forsubset_tunables()andreorder_dimension_by_tunables().- p
The parameters to filter.
- default
Whether parameters without
tunablemetadata are tunable.- new_tunables
A list of parameters, a subset of the tunable ones.
- arr
A vector, matrix or array.
- syms
A list of parameters, a permutation of the tunable ones.
- dim
The dimension of
arrto reorder.
Examples
x <- Variable("x", t_nounits)
a <- Parameter("a"); b <- Parameter("b"); cc <- Parameter("cc", tunable = FALSE)
sys <- mtkcompile(System(list(D_nounits(x) ~ -a * x + b + cc), t_nounits, name = "tun"))
tunable_parameters(sys)
#> [[1]]
#> a
#>
#> [[2]]
#> b
#>
tunable_parameters(subset_tunables(sys, list(b)))
#> [[1]]
#> b
#>
reorder_dimension_by_tunables(sys, c(10, 20), list(b, a))
#> [1] 20 10