[R] Optimization in R similar to MS Excel Solver

Pavel_K kuk064 at vsb.cz
Tue Mar 12 08:45:02 CET 2013


Dear Mr Hasselman,
for a better understanding I have attached an example solved in excel by
using the tool Solver.

I want to assign for each municipality one of the centres and apply it for
calculating the minimum cost as you can see in an example.
I used package lpsolve, but it does not work. I am not sure how to treat
with this part of statement, I think I made mistake in it:
row.rhs <- c(15,10,5,30) and
col.rhs <- c(1,1,1,1,1,1)

The example in R:

library(lpSolve)
costs <- as.matrix(read.table("C:/R/OPTIMIZATION/DATA.TXT", dec = ",",
sep=";",header=TRUE)) 
row.signs <- rep ("=", 4) 
row.rhs <- c(15,10,5,30) 
col.signs <- rep ("=", 6) 
col.rhs <- c(1,1,1,1,1,1) 
lp.transport (costs, "min", row.signs, row.rhs, col.signs, col.rhs,
presolve=0, compute.sens=0) 
lp.transport (costs, "min", row.signs, row.rhs, col.signs, col.rhs,
presolve=0, compute.sens=0)$solution 

Outcome: 
Error in lp.transport(costs, "min", row.signs, row.rhs, col.signs, col.rhs, 
: 
Error: We have 6 signs, but 7 columns 
Hope the example solved in excel will help you to understand my problem.

Thank you
Pavel
example.xls <http://r.789695.n4.nabble.com/file/n4661019/example.xls>  



--
View this message in context: http://r.789695.n4.nabble.com/Optimization-in-R-similar-to-MS-Excel-Solver-tp4660997p4661019.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list