public class BoundedVariableLeastSquares extends Object implements Serializable, Cloneable
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).
NonNegativeLeastSquares
,
Example,
Serialized FormModifier and Type | Class and Description |
---|---|
static class |
BoundedVariableLeastSquares.TooManyIterException
Maximum number of iterations exceeded.
|
Constructor and Description |
---|
BoundedVariableLeastSquares(double[][] a,
double[] b,
double[] lowerBound,
double[] upperBound)
Construct a new BoundedVariableLeastSquares instance to solve Ax-b
subject to bounds on the variables.
|
Modifier and Type | Method and Description |
---|---|
double[] |
getDualSolution()
Returns the dual solution vector, w.
|
int |
getIterations()
Returns the number of iterations used to find the solution.
|
double |
getResidualNorm()
Returns the euclidean norm of the residual vector,
\(\|Ax-b\|^2\).
|
double[] |
getSolution()
Returns the solution to the problem.
|
void |
setMaxIterations(int maxIterations)
Sets the maximum number of iterations.
|
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.
|
void |
solve()
Find the solution x to the problem for the current constraints.
|
public BoundedVariableLeastSquares(double[][] a, double[] b, double[] lowerBound, double[] upperBound)
a
- the double
input matrix.b
- a double
array of length a.length
.lowerBound
- a double
array of length n
containing lower bounds. Use
Double.NEGATIVE_INFINITY
for variables
which are not bounded below.upperBound
- a double
array of length n
containing upper bounds. Use
Double.POSITIVE_INFINITY
for variables
which are not bounded above.public void solve() throws BoundedVariableLeastSquares.TooManyIterException
public void setMaxIterations(int maxIterations)
maxIterations
- an int
specifying the maximum number of
iterations. The default is three times
a[0].length
.public void setTolerance(double tolerance)
tolerance
- a double
value specifying the tolerance.
The default value is 1.0e-7.public int getIterations()
int
containing the number of iterations.public double[] getSolution()
double
array containing the solution.public double[] getDualSolution()
double
array containing the dual solution vector,
w.public double getResidualNorm()
double
containing the euclidean norm of the
residual vector.Copyright © 2020 Rogue Wave Software. All rights reserved.