0

In cell costs[1,3] I need to use NULL or NA. Because in the problem there is a constraint that says that row 1 should not give supplies to column 3. I tried to use 0 but i'm not getting the corrrect answer. (Is not possible to use NA, NULL ON lp.transport)

# Set up cost matrix
#
costs <- matrix (0, 3, 3); costs[1,1] <- costs[3,3] <- 120
costs[1,2]<-180
costs[2,1]<-300; costs[2,2]<-100; costs[2,3] <- 80
costs[3,1]<-200; costs[3,2]<-250
#
# Set up constraint signs and right-hand sides.
#

row.signs <- rep ("<=", 3)
row.rhs <- c(6,5,8)
col.signs <- rep ("=", 3)
col.rhs <- c(4,8,7)
#
# Run
#
lp.transport (costs, "min", row.signs, row.rhs, col.signs, col.rhs)

lp.transport (costs, "min", row.signs, row.rhs, col.signs, col.rhs)$solution
Phil
  • 7,287
  • 3
  • 36
  • 66

1 Answers1

0

Presumably the problem is that the solution is assigning a positive number to the cell having cost zero. Realize that by giving it a cost of zero it means that transport via that cell is free. We want the cost to be sufficiently high that that cell is not used, not so low that it puts everything it can in the cell.

Assuming the cost matrix in the question use

cost[1, 3] <- 1000
G. Grothendieck
  • 254,981
  • 17
  • 203
  • 341