[R] constrained optimization -which package?

Paul Smith phhs80 at gmail.com
Tue Sep 28 23:38:42 CEST 2010


On Tue, Sep 28, 2010 at 9:47 PM, Leonardo Monasterio
<leonardo.monasterio at gmail.com> wrote:
> In the function bellow I  want to find the maximum value of v,
> subject to the constrain that the sum of x is equal to 1.
>  I want to maximize:
> v<-t(x)%*%distance%*%x
>
> Subject to:
> sum(x)=1
>
> Where:
> "x" is a vector n X 1
> "distance" is a matrix n*n and it is given.
> (In practice, the number of n can go up to hundreds.)
>
> I have a bit of experience using R but not much on optimization
> techniques or on R optimization packages.  I have taken a look at
> optim and nlminb, but I am quite confused.
>  Do you have any suggestion on how to do it?

Your optimization problem corresponds to a quadratic programming
problem. So, you can use, e.g., the package quadprog.

Hope this helps you, Paul



More information about the R-help mailing list