Description Usage Arguments Details Value Author(s) References See Also Examples

Interface to lp\_solve linear/integer programming system specifically for solving transportation problems

1 2 | ```
lp.transport (cost.mat, direction="min", row.signs, row.rhs, col.signs,
col.rhs, presolve=0, compute.sens=0, integers = 1:(nc*nr) )
``` |

`cost.mat` |
Matrix of costs; ij-th element is the cost of transporting one item from source i to destination j. |

`direction` |
Character, length 1: "min" or "max" |

`row.signs` |
Vector of character strings giving the direction of the row constraints: each value should be one of "<," "<=," "=," "==," ">," or ">=." (In each pair the two values are identical.) |

`row.rhs` |
Vector of numeric values for the right-hand sides of the row constraints. |

`col.signs` |
Vector of character strings giving the direction of the column constraints: each value should be one of "<," "<=," "=," "==," ">," or ">=." |

`col.rhs` |
Vector of numeric values for the right-hand sides of the column constraints. |

`presolve` |
Numeric: presolve? Default 0 (no); any non-zero value means "yes." Currently ignored. |

`compute.sens` |
Numeric: compute sensitivity? Default 0 (no); any non-zero value means "yes." |

`integers` |
Vector of integers whose ith element gives the index of the ith integer variable. Its length will be the number of integer variables. Default: all variables are integer. Set to NULL to have no variables be integer. |

This is a particular integer programming problem. All the decision variables are assumed to be integers, and there is one constraint per row and one per column (and no others). This is assumed to be a minimization problem.

An `lp`

object. Constraints are implicit and not returned.
See documentation for details.

Sam Buttrey, [email protected]

Example problem from Bronson (1981), *Operations Research*,
Scahum's Outline Series, McGraw-Hill.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | ```
#
# Transportation problem, Bronson, problem 9.1, p. 86
#
# Set up cost matrix
#
costs <- matrix (10000, 8, 5); costs[4,1] <- costs[-4,5] <- 0
costs[1,2] <- costs[2,3] <- costs[3,4] <- 7; costs[1,3] <- costs[2,4] <- 7.7
costs[5,1] <- costs[7,3] <- 8; costs[1,4] <- 8.4; costs[6,2] <- 9
costs[8,4] <- 10; costs[4,2:4] <- c(.7, 1.4, 2.1)
#
# Set up constraint signs and right-hand sides.
#
row.signs <- rep ("<", 8)
row.rhs <- c(200, 300, 350, 200, 100, 50, 100, 150)
col.signs <- rep (">", 5)
col.rhs <- c(250, 100, 400, 500, 200)
#
# Run
#
lp.transport (costs, "min", row.signs, row.rhs, col.signs, col.rhs)
## Not run: Success: the objective function is 7790
lp.transport (costs, "min", row.signs, row.rhs, col.signs, col.rhs)$solution
## Not run:
[,1] [,2] [,3] [,4] [,5]
[1,] 0 100 0 100 0
[2,] 0 0 300 0 0
[3,] 0 0 0 350 0
[4,] 200 0 0 0 0
[5,] 50 0 0 0 50
[6,] 0 0 0 0 50
[7,] 0 0 100 0 0
[8,] 0 0 0 50 100
## End(Not run)
``` |

jmarshallnz/lpSolve documentation built on May 18, 2017, 2:29 a.m.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.