Package com.imsl.math
Class BoundedVariableLeastSquares
java.lang.Object
com.imsl.math.BoundedVariableLeastSquares
- All Implemented Interfaces:
Serializable,Cloneable
Solve a linear least-squares problem with bounds on the variables.
BoundedVariableLeastSquares solves the least-squares problem
$$\min_x \| Ax-b\|^2$$
subject to the conditions
$$\alpha_k \le x_k \le \beta_k$$
for all k.
This algorithm is a generalization of NonNegativeLeastSquares,
that solves the least-squares problem, Ax = b, subject to all
\(x_j \ge 0\). NonNegativeLeastSquares is based on the
subroutine NNLS which appeared in Lawson and Hanson (1974). The additional
work on bounded variable least squares was published in a later reprint
(Lawson and Hanson, 1995).
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classMaximum number of iterations exceeded. -
Constructor Summary
ConstructorsConstructorDescriptionBoundedVariableLeastSquares(double[][] a, double[] b, double[] lowerBound, double[] upperBound) Construct a new BoundedVariableLeastSquares instance to solve Ax-b subject to bounds on the variables. -
Method Summary
Modifier and TypeMethodDescriptiondouble[]Returns the dual solution vector, w.intReturns the number of iterations used to find the solution.doubleReturns the euclidean norm of the residual vector, \(\|Ax-b\|^2\).double[]Returns the solution to the problem.voidsetMaxIterations(int maxIterations) Sets the maximum number of iterations.voidsetTolerance(double tolerance) Sets the internal tolerance used to determine the relative linear dependence of a column vector for a variable moved from its initial value.voidsolve()Find the solution x to the problem for the current constraints.
-
Constructor Details
-
BoundedVariableLeastSquares
public BoundedVariableLeastSquares(double[][] a, double[] b, double[] lowerBound, double[] upperBound) Construct a new BoundedVariableLeastSquares instance to solve Ax-b subject to bounds on the variables. Each upper bound must be greater than or equal to the corresponding lower bound.- Parameters:
a- thedoubleinput matrix.b- adoublearray of lengtha.length.lowerBound- adoublearray of length n containing lower bounds. UseDouble.NEGATIVE_INFINITYfor variables which are not bounded below.upperBound- adoublearray of length n containing upper bounds. UseDouble.POSITIVE_INFINITYfor variables which are not bounded above.
-
-
Method Details
-
solve
Find the solution x to the problem for the current constraints. -
setMaxIterations
public void setMaxIterations(int maxIterations) Sets the maximum number of iterations.- Parameters:
maxIterations- anintspecifying the maximum number of iterations. The default is three timesa[0].length.
-
setTolerance
public void setTolerance(double tolerance) Sets the internal tolerance used to determine the relative linear dependence of a column vector for a variable moved from its initial value.- Parameters:
tolerance- adoublevalue specifying the tolerance. The default value is 1.0e-7.
-
getIterations
public int getIterations()Returns the number of iterations used to find the solution.- Returns:
- an
intcontaining the number of iterations.
-
getSolution
public double[] getSolution()Returns the solution to the problem.- Returns:
- a
doublearray containing the solution.
-
getDualSolution
public double[] getDualSolution()Returns the dual solution vector, w. If \(x_j\) is at neither its upper nor lower bound then \(w_j=0\). If \(x_j\) is at its lower bound then \(w_j \le{0}\). If \(x_j\) is at its upper bound then \(w_j\ge{0}\). If the upper and lower bound for the j -th variable are equal, fixing the value of \(x_j\), then the value of \(w_j\) is arbitrary.- Returns:
- a
doublearray containing the dual solution vector, w.
-
getResidualNorm
public double getResidualNorm()Returns the euclidean norm of the residual vector, \(\|Ax-b\|^2\).- Returns:
- a
doublecontaining the euclidean norm of the residual vector.
-