Skip to content
Prev 294804 / 398503 Next

Optimization problem

There are a couple of options.

First if you want the mean to equal 7, then that means the sum must
equal 21 and therefore you can let optim only play with 2 of the
variables, then set the 3rd to be 21-s1-s2.

If you want the mean to be greater than 7 then just put in a test, if
the mean is less than 7 then return -Inf or another really small
number, if the mean is large enough then go on to compute the function
that you want to maximize.

Also note that you don't need the loop, it can be replaced with "sum(s^3)".
On Wed, May 16, 2012 at 10:44 AM, Pacin Al <jokloq at gmail.com> wrote: