| readMps | R Documentation |
This function reads MPS files - the standard format for Linear Programming problems.
readMps( file, solve=FALSE, maximum=FALSE )
file |
a character string naming the file to read. |
solve |
logical. Should the problem be solved after reading it
from the file (using |
maximum |
logical. Should we maximize or minimize (the default)? |
Equality constraints and 'greater than'-bounds are not implemented yet.
readMps returns a list containing following objects:
name |
the name of the Linear Programming problem. |
cvec |
vector c. |
bvec |
vector b. |
Amat |
matrix A. |
res |
if |
Arne Henningsen
solveLP, writeMps
## example of Steinhauser, Langbehn and Peters (1992)
## Production activities
cvec <- c(1800, 600, 600) # gross margins
names(cvec) <- c("Cows","Bulls","Pigs")
## Constraints (quasi-fix factors)
bvec <- c(40, 90, 2500) # endowment
names(bvec) <- c("Land","Stable","Labor")
## Needs of Production activities
Amat <- rbind( c( 0.7, 0.35, 0 ),
c( 1.5, 1, 3 ),
c( 50, 12.5, 20 ) )
## Write to MPS file
writeMps( "steinh.mps", cvec, bvec, Amat, "Steinhauser" )
## delete all LP objects
rm( cvec, bvec, Amat )
## Read LP data from MPS file and solve it.
lp <- readMps( "steinh.mps", TRUE, TRUE )
## Print the results
lp$res
## remove the MPS file
file.remove( "steinh.mps" )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.