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:
mainprog <- function(theta){
alpha <- theta[1:20]
beta <- theta[21:35]
...
fun1(alpha)
fun2(beta)
...
return(X)
}
I do not want to have the alpha
and beta
hardcoded like in the example above because of elegance, maintenance, and sanity reasons. What’s a good way of defining those subvectors alpha
and beta
?
The only constraint that I have is that I’d like to be able to use an optimizer to optimize over theta
without too much trouble. Does anyone have any suggestions on how to go about that?