Hi, I'm dealing with an optimization problem. I'm using 'optim' to maximize the output of a function, given some restrictions on the input. I would like to know if there is a way to impose some restrictions on 'intermediate variables' of the function. An example..
fx = function (x) { s <- 0 for (i in 1:3) { s <- x[i]^3 + s } s } optim(rep(4,3), method="L-BFGS-B", lower=rep(-10,nlin), upper=rep(10,nlin)) It would return '-10' for all variables. I want, however, a solution satisfying mean(x)>7. Please, don't analyse this specific example, but the logic of satisfying a criterium for the mean of the input (with thousands of variables). My real problem involves price elasticity and I want to find the price increase for each individual that would give me maximum total profit margin, but respecting a minimum retention of clients. Thank you very much, John Mayer -- View this message in context: http://r.789695.n4.nabble.com/Optimization-problem-tp4630278.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.