Skip to content
Prev 374470 / 398513 Next

adding overall constraint in optim()

Hi Michael,
A few comments
1. To add the constraint sum(wgt.vect=1) you would use the method of
Lagrange multipliers.
    What this means is that in addition to the w_i (the components of the
weight variables) you would add an additional variable, call it lambda.
    Then you would modify your optim.fun() function to add the term
 lambda * (sum(wgt.vect - 1)
2. Are you sure that you have defined Mo.vect correctly? It is a scalar the
way you have written it.
3. Similarly your definition of wgt.vect creates a scalar.

HTH,
Eric


On Fri, May 4, 2018 at 5:18 AM, Joshua Ulrich <josh.m.ulrich at gmail.com>
wrote: