Output Options Examples References
LP solves linear models with or without linear equality or inequality constraints.
LP (MAX/MIN, SILENT, NLW=<number of less than or equal constraints>,
NGE = <number of greater than or equal constraints>, NEQ=<number of equality constraints>, TOL=eps)
b_obj b_constraints rhs ;
Usage
LP solves for the M by 1 vector X that minimizes the objective phi = b_obj'X, with constraints b_constraints*X (<= or >= or =) rhs and X>=0. The order of the constraints must be the following: 1) NLW less than or equal; 2) NGE greater than or equal; 3) NEQ equality. b_obj is an M by 1 vector and b_constraints is a NLW+NGE+NEQ by 1 vector.
LP stores some of the results in data storage for later use.
|
variable |
type |
length |
description |
|
@PHI |
scalar |
1 |
The objective function at the minimum |
|
@IFCONV |
scalar |
1 |
=1 if convergence achieved, 0 otherwise |
|
@COEF |
vector |
M |
the solution for X |
Method
The Simplex method subroutine from Numerical Recipes (Press et al 1992) is used, which has a nice explanation of the method and some examples which were used for testing. The LP command was also tested on LAD estimation with the Stackloss dataset (Brownlee 1965; Dodge 1991).
MAX/MIN specifies whether the objective function phi is to be maximized or minimized (the default).
SILENT suppresses all output; results are still stored.
NLW = number of less than or equal constraints in b_constraint and rhs.
NGE = number of greater than or equal constraints in b_constraint and rhs.
NEQ = number of equality constraints in b_constraint and rhs.
TOL = convergence criterion.
Here is an example of using the LP command to solve the first example in the Numerical Recipes description:
? Maximize: 2*x2 - 4*x3
? Subject to: x1 + 6*x2 - x3 = 2
? -3*x2 + 4*x3 + x4 = 8
?
? The solution is: x2 = 1/3, x4 = 9 (x1=0, x3=0),
? with objective function = 2/3
read(nrow=1,ncol=4) objf1;
0 2 -4 0 ;
read(nrow=2,ncol=1) dep1;
2 8 ;
read(nrow=2,ncol=4) constr1;
1 6 -1 0
0 -3 4 1 ;
LP(NEQ=2,MAX) objf1 constr1 dep1;
Brownlee, K. A., Statistical Theory and Methodology in Science and Engineering, Wiley, New York, 1965.
Dodge, Y. et al, Computational Statistics and Data Analysis, August 1991, p. 97.
Press, W. H., B. P. Flannery, S. A. Teukolsky, and W. T. Vetterling, Numerical Recipes in Fortran 77, 2nd edition, Cambridge University Press, 1992.
http://www.nr.com