CALL LPSOLVE (rc, objvalue, x, dual, reducost, c, a, b <*>, cntl <*>, rowsense <*>, range <*>, l <*>, u );
The LPSOLVE subroutine solves a linear programming problem. It uses a different input format and solver options from the LP call and is the preferred method for solving linear programming problems.
The input arguments to the LPSOLVE subroutine are as follows:
is a vector of dimension n of objective function coefficients. A missing value is treated as 0.
is an matrix of the technological coefficients. A missing value is treated as 0.
is a vector of dimension m of constraints’ right-hand sides (RHS). For a range constraint, b is its constraint upper bound. A missing value is treated as 0.
is an optional vector that contains one to eight elements that represent the LPSOLVE subroutine’s control options. The default value is used if an option is not specified or its value is a missing value. If cntl=(objsense, printlevel, maxtime, maxiter, presolve, algorithm,scaling, tol), then
specifies whether it is a minimization or a maximization problem, where 1 specifies minimization and specifies maximization. The default value is 1.
specifies the type of messages printed to the log. A value of 0 prints warning and error messages only, whereas 1 prints solution information in addition to warning and error messages. The default value is 0.
specifies an upper bound of running time in seconds. The default value is effectively unbounded.
specifies the maximum number of iterations to be processed. The default value is effectively unbounded.
specifies the presolve option, where 0 indicates no presolve and 1 indicates an automatic presolve option.The default value is 1.
specifies the type of solver, where 1 specifies primal simplex, 2 specifies dual simplex, and 3 specifies interior point algorithm. The default value is 2.
specifies whether to scale the problem matrix, where 0 turns off scaling and 1 turns on scaling. The default value is 1.
specifies a feasibility and optimality tolerance. The default value is .
is an optional row vector of dimension m that specifies the sense of each constraint. The values can be E, L, G, or R for equal, less than or equal to, greater than or equal to, or range constraint. If this vector is missing, the solver treats the constraints as E type constraints.
is an optional row vector of dimension m that specifies the range of the constraints. The row sense for a range constraint is R. For the non-range constraints, the corresponding values are ignored. For a range constraint, the range value is the difference between its constraint lower bound and its constraint upper bound b, so it must be nonnegative.
is an optional column vector of dimension n that specifies lower bounds on the decision variables. If you do not specify l or l[j] has a missing value, then the lower bound of variable j is assumed to be 0.
is an optional column vector of dimension n that specifies upper bounds on the decision variables. If you do not specify u or u[j] has a missing value, the upper bound of variable j is assumed to be infinity.
The LPSOLVE subroutine returns the following values:
returns one of the following scalar return codes:
rc |
Termination Reason |
---|---|
0 |
The solution is optimal. |
1 |
The time limit was exceeded. |
2 |
The maximum number of iterations was exceeded. |
3 |
The solution is infeasible. |
4 |
The solution is unbounded or infeasible. |
5 |
The subroutine could not obtain enough memory. |
6 |
The subroutine failed to solve the problem. |
returns the optimal or final objective value at termination.
returns the current primal solution in a column vector of length n.
returns the current dual solution in a row vector of length m.
returns reduced cost in a column vector of length n.
The LPSOLVE subroutine solves linear programs. A standard linear program has the following formulation:
If only c, , and are present, then LPSOLVE solves the following linear programming problem by default:
The primal and dual simplex solvers implement the two-phase simplex method. In phase I, the solver tries to find a feasible solution. If it does not find a feasible solution the LP is infeasible; otherwise, the solver enters phase II to solve the original LP. The interior point solver implements a primal-dual predictor-corrector interior point algorithm.
Consider the following example:
The problem is solved by using the following statements:
object = { 1 1 0 0 }; coef = { 2 .5 -1 0, .2 5 0 -1}; b = { 1, 1 }; l = { 0 0 0 0 }; u = { 9 9 9 9 }; rowsense = {'L','L'}; cntl= -1; call lpsolve (rc,objv,x,dual,rd,object,coef,b,cntl,rowsense,,l,u); print objv, x, dual, rd;
Figure 25.201: Example LPSOLVE Call