[R] finding the values to minimize sum of functions
Tranlm at berkeley.edu
Thu Jul 19 19:24:17 CEST 2012
Hi fellow R users,
I am desperately hoping there is an easy way to do this in R.
Say I have three functions:
f(x) = x^2
f(y) = 2y^2
f(z) = 3z^2
constrained such that x+y+z=c (let c=1 for simplicity).
I want to find the values of x,y,z that will minimize f(x) + f(y) + f(z).
I know I can use the optim function when there is only one function, but
don't know how to set it up when there are three.
I would also like to apply this to higher dimensions (i.e. for more than
three functions) if possible.
Thank you for all your help!
Linh Tran, MPH
More information about the R-help