[R] Maximization

Paul Smith phhs80 at gmail.com
Sun Oct 30 17:44:27 CET 2011


On Tue, Oct 25, 2011 at 12:04 PM, Eliano <eliano.m.marques at gmail.com> wrote:
> hi people,
>
> I'm trying to maximize this function:
>
> fn= function (x) {x[1]^2+5*x[2]^2}
>
> with this restriction
> fn1 = function (x) {x[1]+x[2] <=5}
>
> Can someone help me how to procedure this?
>
> I tried in the alabama and genoud package but i have problems with the
> setting of constrains.

Your problem corresponds to a quadratic programming problem. Thus, you
can solve it with the following package:

http://cran.r-project.org/web/packages/quadprog/index.html

Hope this helps you,

Paul



More information about the R-help mailing list