Class DenseLP
- All Implemented Interfaces:
Serializable,Cloneable
Class DenseLP uses an active set strategy to
solve linear programming problems, i.e., problems of the form
$$\mathop {\min }\limits_{x\; \in \;R^n } c^T x$$
subject to
$$b_l \le Ax \le b_u$$
$$\,\,x_l \le x \le x_u$$
where c is the objective coefficient vector, A is the coefficient matrix, and the vectors \(b_l\), \(b_u\), \(x_l\), and \(x_u\) are the lower and upper bounds on the constraints and the variables, respectively.
If the linear constraints are infeasible an \(L_1\) solution
to the constraints are used as a replacement for the stated constraints.
An exception is thrown but a generalized solution is computed and available
using methods getPrimalSolution or getDualSolution.
Similar comments hold for any of the three additional conditions:
(1) There are multiple solutions; (2) some constraints are discarded, or
(3) cycling in the algorithm is identified.
Refer to the following paper for further information:
Krogh, Fred, T. (2005), see An Algorithm for Linear Programming http://mathalacarte.com/fkrogh/pub/lp.pdf
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classAll constraints are not satisfied.static classThe bounds given are inconsistent.static classThe algorithm appears to be cycling.static classThe problem has multiple solutions giving essentially the same minimum.static classNo acceptable pivot could be found.static classThe LP problem has no constraints.static classThe problem is unbounded.static classThe problem is vacuous.static classSome constraints were discarded because they were too linearly dependent on other active constraints.static classDeprecated. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclone()Creates and returns a copy of this object.double[]Returns the dual solution.intReturns the iteration count.doubleReturns the optimal value of the objective function.double[]Returns the solution x of the linear programming problem.voidsetConstraintType(int[] constraintType) Sets the types of general constraints in the matrixa.voidsetLowerBound(double[] lowerBound) Sets the lower bound, \(x_l\), on the variables.voidsetRefinementType(int iRefinement) Set the type of refinement used.voidsetUpperBound(double[] upperBound) Sets the upper bound, \(x_u\), on the variables.voidsetUpperLimit(double[] upperLimit) Sets the upper limit of the constraints.final voidsolve()Solves the problem using an active set method.
-
Constructor Details
-
DenseLP
Constructor using an MPSReader object.- Parameters:
mps- AnMPSReaderobject specifying the Linear Programming problem.- Throws:
IllegalArgumentException- is thrown if the problem dimensions are not consistent.
-
DenseLP
public DenseLP(double[][] a, double[] b, double[] c) Constructor variables of typedouble.- Parameters:
a- Adoublematrix with coefficients of the constraints.b- Adoublearray containing the right-hand side of the constraints.c- Adoublearray containing the coefficients of the objective function.- Throws:
IllegalArgumentException- is thrown if the dimensions ofa,b.length, andc.lengthare not consistent.
-
-
Method Details
-
clone
Creates and returns a copy of this object. -
solve
public final void solve() throws DenseLP.BoundsInconsistentException, DenseLP.NoAcceptablePivotException, DenseLP.ProblemUnboundedException, DenseLP.ProblemVacuousException, DenseLP.AllConstraintsNotSatisfiedException, DenseLP.MultipleSolutionsException, DenseLP.SomeConstraintsDiscardedException, DenseLP.CyclingOccurringException, DenseLP.NoConstraintsAvailableExceptionSolves the problem using an active set method.solvemust be invoked prior to calling any of the "get" methods.- Throws:
DenseLP.BoundsInconsistentException- is thrown if the bounds are inconsistent.DenseLP.NoAcceptablePivotException- is thrown if an acceptable pivot could not be found.DenseLP.ProblemUnboundedException- is thrown if there is no finite solution to the problem.DenseLP.ProblemVacuousException- is thrown if the problem is vacuous.DenseLP.AllConstraintsNotSatisfiedException- is thrown if all constraints are not satisfied.DenseLP.MultipleSolutionsException- is thrown if the problem has multiple solutions.DenseLP.SomeConstraintsDiscardedException- is thrown if some constraints were discarded because they were too linearly dependent on other active constraints.DenseLP.CyclingOccurringException- is thrown if the algorithm appears to be cycling.DenseLP.NoConstraintsAvailableException- is thrown if all constraints are of constraint type 4.
-
setRefinementType
public void setRefinementType(int iRefinement) Set the type of refinement used.- Parameters:
iRefinement- Anintscalar value which defines the type of refinement to be used. The possible settings are:iRefinement Action 0 No refinement. Always compute dual. Default. 1 Iterative refinement. 2 Use extended refinement. Iterate until no more progress.
If refinement is used, the coefficient matrices and other data are saved at the beginning of the computation. When finished this data together with the solution obtained is checked for consistency. If the discrepancy is too large, the solution process is restarted using the problem data just after processing the equalities, but with the final x values and final active set.
-
setUpperLimit
public void setUpperLimit(double[] upperLimit) Sets the upper limit of the constraints.- Parameters:
upperLimit- adoublearray containing the upper limit, \(b_u\), of the constraints.
-
setLowerBound
public void setLowerBound(double[] lowerBound) Sets the lower bound, \(x_l\), on the variables. If there is no lower bound on a variable, then 1.0e30 should be set as the lower bound.- Parameters:
lowerBound- adoublearray containing the lower bound on the variables. Default = 0.
-
setUpperBound
public void setUpperBound(double[] upperBound) Sets the upper bound, \(x_u\), on the variables. If there is no upper bound on a variable, then -1.0e30 should be set as the upper bound.- Parameters:
upperBound- adoublearray containing the upper bound on the variables. The default is no upper bound.
-
setConstraintType
public void setConstraintType(int[] constraintType) Sets the types of general constraints in the matrixa.- Parameters:
constraintType- anintarray containing the types of general constraints. Let \( r_i=a_{i1}x_1+...+a_{in}x_n\). Then the value ofconstraintType[i]signifies the following:constraintType
Constraint
0 \({\rm {r}}_i = {\rm {b}}_i\) 1 \({\rm {r}}_i \le {\rm {b}}_i \,\,\, or \,\,\, {\rm {r}}_i \le {\rm {b}}_{{\rm {u}}_i} \,\,\, if \,\,supplied\) 2 \({\rm {r}}_i \ge {\rm {b}}_i\) 3 \({\rm {b}}_i \le {\rm {r}}_i \le {\rm {b}}_{{\rm {u}}_i}\) 4 Ignore this constraint
Default=0.
-
getOptimalValue
public double getOptimalValue()Returns the optimal value of the objective function.- Returns:
- a
doublescalar containing the optimal value of the objective function. If a solution has not been computed,Double.NaNis returned.
-
getIterationCount
public int getIterationCount()Returns the iteration count.- Returns:
- an
intscalar containing the iteration count.
-
getPrimalSolution
public double[] getPrimalSolution()Returns the solution x of the linear programming problem.- Returns:
- a
doublearray containing the solution x of the linear programming problem.
-
getDualSolution
public double[] getDualSolution()Returns the dual solution.- Returns:
- a
doublearray containing the dual solution of the linear programming problem.
-
IllegalArgumentException.