[R] Optimization in R similar to MS Excel Solver

Berend Hasselman bhh at xs4all.nl
Sun Oct 21 14:39:54 CEST 2012


On 21-10-2012, at 13:37, Thomas Schu wrote:

> Dear Richard,
> 
> It is funny. I have to perform the approach of sediment fingerprinting for
> my master thesis. Mr. Hasselman gave me the advice to take a closer look
> into the limSolve package a few days ago. 
> http://cran.r-project.org/web/packages/limSolve/index.html
> 
> I guess, the lsei-function of this package is exactly what  you and i are
> looking for. I have tried it out today and compared the lsei-results with
> the results of the MS-Excel solver. They are the same!
> You will find in the manual (Chemtax example), how to define the
> constraints, that every unknown is >= 0 and the sum of unknowns is always 1.
> http://cran.r-project.org/web/packages/limSolve/limSolve.pdf
> 
> Try to get familiar with the lsei-function and if you still need help, i can
> send you my code.
> 
> Bearing the Monte-Carlo simulation in mind, the package could offer some
> nice functions too.


Excellent idea. I hadn't actually tried limSolve.
Using the data for bmat and target from my previous post, limSolve provides an excellent alternative and is fast(est):
You don't need to define any special functions.

library(limSolve)
lsei(A=bmat,B=target,E=matrix(rep(1,4),ncol=4),F=1,G=matrix(rep(1,4),ncol=4),H=0)

Berend




More information about the R-help mailing list