lp                  package:lpSolve                  R Documentation

_L_i_n_e_a_r _a_n_d _I_n_t_e_g_e_r _P_r_o_g_r_a_m_m_i_n_g

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

     Interface to lp_solve linear/integer programming system

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

     lp (direction = "min", objective.in, const.mat, const.dir, const.rhs,
             transpose.constraints = TRUE, int.vec)

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

direction: Character string giving direction of optimization: "min"
          (default) or "max."

objective.in: Numeric vector of coefficients of objective function

const.mat: Matrix of numeric constraint coefficients, one row  per
          constraint, one column per variable (unless
          transpose.constraints =  FALSE; see below).

const.dir: Vector of character strings giving the direction of  the
          constraint: each value should be one of "<," "<=," "=," "==,"
          ">," or ">=."

const.rhs: Vector of numeric values for the right-hand sides of  the
          constraints.

transpose.constraints: By default each constraint occupies a row  of
          const.mat, and that matrix needs to be transposed before
          being passed  to the optimizing code.  For very large
          constraint matrices it may be wiser  to construct the
          constraints in a matrix column-by-column. In that case set 
          transpose.constraints to FALSE.

 int.vec: Numeric vector giving the indices of variables that are 
          required to be integer. The length of this vector will
          therefore be the  number of integer variables.

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

     This function calls the lp_solve 4.0 solver. That system has many
     options not supported here. The current version is maintained at
     <URL: ftp://ftp.es.ele.tue.nl/pub/lp_solve>

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

     An lp object. See 'link{lp.object}' for details.

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

     Sam Buttrey, buttrey@nps.navy.mil

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

     'lp.assign', 'lp.transport'

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

     #
     # Set up problem: maximize
     #   x1 + 9 x2 +   x3 subject to
     #   x1 + 2 x2 + 3 x3  <= 9
     # 3 x1 + 2 x2 + 2 x3 <= 15
     #
     f.obj <- c(1, 9, 3)
     f.con <- matrix (c(1, 2, 3, 3, 2, 2), nrow=2, byrow=TRUE)
     f.dir <- c("<=", "<=")
     f.rhs <- c(9, 15)
     #
     # Now run.
     #
     lp ("max", f.obj, f.con, f.dir, f.rhs)
     ## Not run: Success: the objective function is 40.5
     lp ("max", f.obj, f.con, f.dir, f.rhs)$solution
     ## Not run: [1] 0.0 4.5 0.0
     #
     # Run again, this time requiring that all three variables be integer
     #
     lp ("max", f.obj, f.con, f.dir, f.rhs, int.vec=1:3)
     ## Not run: Success: the objective function is 37
     lp ("max", f.obj, f.con, f.dir, f.rhs, int.vec=1:3)$solution
     ## Not run: [1] 1 4 0

