JMSLTM Numerical Library 7.2.0
com.imsl.math

## Class NonNegativeLeastSquares

• All Implemented Interfaces:
Serializable, Cloneable

public class NonNegativeLeastSquares
extends Object
implements Serializable, Cloneable
Solves a linear least squares problem with nonnegativity constraints. NonNegativeLeastSquares solves the problem

subject to the condition .

If a starting point is provided, those entries of that are are first combined with a descent gradient component. The start point is the origin. When is not provided the algorithm uses only the gradient to verify that an optimum has been found. The algorithm completes using only the gradient components to reach an optimum. For more information, see Lawson and Hanson (1974).

BoundedVariableLeastSquares, Example, Serialized Form
• ### Constructor Detail

• #### NonNegativeLeastSquares

public NonNegativeLeastSquares(double[][] a,
double[] b)
Construct a new NonNegativeLeastSquares instance to solve Ax-b where x is a vector of n unknowns.
Parameters:
a - the double input matrix.
b - a double array of length a.length.
• ### Method Detail

• #### getDualSolution

public double[] getDualSolution()
Returns the dual solution vector, w. If then , otherwise .
Returns:
a double array containing the dual solution vector, w.
• #### getIterations

public int getIterations()
Returns the number of iterations used to find the solution.
Returns:
an int containing the number of iterations.
• #### getResidualNorm

public double getResidualNorm()
Returns the euclidean norm of the residual vector, .
Returns:
a double containing the euclidean norm of the residual vector.
• #### getSolution

public double[] getSolution()
Returns the solution to the problem, x.
Returns:
a double array containing the solution.
• #### setDualTolerance

public void setDualTolerance(double dualTolerance)
Sets the dual tolerance. The computation stops if largest gradient is smaller than this. The default value is 0.
Parameters:
dualTolerance - a double containing the dual tolerance.
• #### setGuess

public void setGuess(double[] guess)
Sets the initial guess.
Parameters:
guess - a double array containing the initial guess. If set, the guess is used in a two-phase algorithm where the positive components are matched with positive gradients to choose an incoming column. If not set, the algorithm uses only the gradient to verify that an optimum has been found.
• #### setMaximumTime

public void setMaximumTime(long maximumTime)
Sets the maximum time allowed for the solve step.
Parameters:
maximumTime - a long value specifying the maximum time, in milliseconds, to be allowed for the solve step. If maximumTime is less than or equal to zero, then no time limit is imposed. By default, there is no time limit.
• #### setMaxIterations

public void setMaxIterations(int maxIterations)
Sets the maximum number of iterations.
Parameters:
maxIterations - an int specifying the maximum number of iterations. The default is three times a[0].length.
• #### setNormTolerance

public void setNormTolerance(double normTolerance)
Sets the residual norm tolerance.
Parameters:
normTolerance - a double containing the residual norm tolerance. The computation stops if , where rnorm is the residual norm. By default, the value is 0.
• #### setRankTolerance

public void setRankTolerance(double rankTolerance)
Sets the tolerance used for the incoming column rank deficient check.
Parameters:
rankTolerance - a double value used to check for rank deficiency. The default value is 2.220e-016.
JMSLTM Numerical Library 7.2.0