I am optimizing a function that takes a vector of size ~300 as input. That objective function calls several other functions that each use a subset of the input vector. An example of that setup is below:
function mainprog(θ)
α = θ[1:20]
β = θ[21:35]
...
fun1(α)
fun2(β)
...
return X
end
I do not want to have the α
and β
hardcoded like in the example above because of elegance, maintenance, and sanity reasons. I much rather prefer to have them as NamedArrays
, NamedTuples
, or Dict
. What’s a good way of defining those subvectors α
and β
?
I’m worried about performance, and the only constraint that I have is that I’d like to be able to use Optim
to optimize over θ
without too much trouble. Does anyone have any suggestions on how to go about that?