readMps               package:linprog               R Documentation

_r_e_a_d _M_P_S _f_i_l_e_s

_D_e_s_c_r_i_p_t_i_o_n:

     This function reads MPS files - the standard format for Linear
     Programming problems.

_U_s_a_g_e:

        readMps( file, solve=FALSE, maximum=FALSE )

_A_r_g_u_m_e_n_t_s:

    file: a character string naming the file to read.

   solve: logical. Should the problem be solved after reading it from
          the file (using 'solveLP')?

 maximum: logical. Should we maximize or minimize (the default)?

_D_e_t_a_i_l_s:

     Equality constraints and 'greater than'-bounds are not implemented
     yet.

_V_a_l_u_e:

     '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 'solve' is TRUE, it contains the results of the solving
          process (an object of class 'solveLP').

_A_u_t_h_o_r(_s):

     Arne Henningsen ahenningsen@agric-econ.uni-kiel.de

_S_e_e _A_l_s_o:

     'solveLP', 'writeMps'

_E_x_a_m_p_l_e_s:

     ## example of Steinhauser, Langbehn and Peters (1992)
     ## Not run: library( linprog )

     ## Production activities
     cvec <- c(1800, 600, 600)  # gross margins
     names(cvec) <- c("Milk","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

