Dear all, I am trying to find the solution for the optimization problem focused on the finding minimum cost. I used the solution proposed by excel solver, but there is a restriction in the number of variables.
My data consists of 300 rows represent cities and 6 columns represent the centres. It constitutes a cost matrix, where the cost are distances between each city and each of six centres. ..+ 1 column contains variables, represents number of firms. I want to calculate the minimum cost between cities and centres. Each city can belong only to one of the centres. A model example: costs: distance between municipalities and centres + plus number of firms in each municipality "Municipality" "Centre1" "Centre2" "Centre3" "Centre4" "Centre5" "Centre6" "Firms" "Muni1" 30 20 60 40 66 90 15 "Muni2" 20 30 60 40 66 90 10 "Muni3" 25 31 60 40 66 90 5 "Muni4" 27 26 60 40 66 90 30 The outcome of excel functon Solver is: cost assigned "Municipality" "Centre1" "Centre2" "Centre3" "Centre4" "Centre5" "Centre6" "Solution" "Muni1" 0 20 0 0 0 0 300 "Muni2" 20 0 0 0 0 0 200 "Muni3" 25 0 0 0 0 0 125 "Muni4" 0 26 0 0 0 0 780 objective : 1405 I used package "lpSolve" but there is a problem with variables "firms": s <- as.matrix(read.table("C:/R/OPTIMALIZATION/DATA.TXT", dec = ",", sep=";",header=TRUE)) [2] [3] [4] [5] [6] [1] 30 20 60 40 66 90 [2] 20 30 60 40 66 90 [3] 25 31 60 40 66 90 [4] 27 26 60 40 66 90 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 Does anyone know where could the problem ? Does there exist any other possibility how to perform that analysis in R ? I am bit confused here about how can I treat with the variables "firms". Thanks Pavel -- View this message in context: http://r.789695.n4.nabble.com/Optimization-in-R-similar-to-MS-Excel-Solver-tp4660997.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.