help with constrained optimization setup in R -
i have function parameters wish optimize. simplified example, function looks this:
f <- function (d) { num_iterations <- 10 function_data <- c(1,3,5,7,9,11) rslt <- 0 di_1 <- 1 di_2 <- length(function_data) (i in 1:num_iterations) { di <- d [di_1:di_2] rslti <- function_data - di rslt <- rslt + sum(rslti) function_data <- rslti di_1 <- di_1 + length(function_data) di_2 <- di_2 + length(function_data) } homecoming (rslt) }
where d vector length equals to: num_iteration * length(function_data)
.
so wish maximize function f , have optimized values of d
, consisted values of d
every iteration. problem have constrain optimization process in way, in particular iteration within function, di
must smaller or equal function_data
(di <= function_data
). scalar result of function should positive number.
i have difficulties how specify status di <= function_data
since function_data
changes every iteration. have played around optim , constroptim in r, think not possible set constrain in constroptim.
so inquire how (or if) constrained optimization problem can set in r. grateful help, comments, code snippets or optimization bundle recommendations. please have patience me, newbie in this.
thank you.
r optimization
No comments:
Post a Comment