Class LeastSquaresFactory
java.lang.Object
org.hipparchus.optim.nonlinear.vector.leastsquares.LeastSquaresFactory
A Factory for creating
LeastSquaresProblem
s.-
Method Summary
Modifier and TypeMethodDescriptionstatic LeastSquaresProblem
countEvaluations
(LeastSquaresProblem problem, Incrementor counter) Count the evaluations of a particular problem.static LeastSquaresProblem
create
(MultivariateVectorFunction model, MultivariateMatrixFunction jacobian, double[] observed, double[] start, RealMatrix weight, ConvergenceChecker<LeastSquaresProblem.Evaluation> checker, int maxEvaluations, int maxIterations) Create aLeastSquaresProblem
from the given elements.static LeastSquaresProblem
create
(MultivariateJacobianFunction model, RealVector observed, RealVector start, RealMatrix weight, ConvergenceChecker<LeastSquaresProblem.Evaluation> checker, int maxEvaluations, int maxIterations) Create aLeastSquaresProblem
from the given elements.static LeastSquaresProblem
create
(MultivariateJacobianFunction model, RealVector observed, RealVector start, RealMatrix weight, ConvergenceChecker<LeastSquaresProblem.Evaluation> checker, int maxEvaluations, int maxIterations, boolean lazyEvaluation, ParameterValidator paramValidator) Create aLeastSquaresProblem
from the given elements.static LeastSquaresProblem
create
(MultivariateJacobianFunction model, RealVector observed, RealVector start, ConvergenceChecker<LeastSquaresProblem.Evaluation> checker, int maxEvaluations, int maxIterations) Create aLeastSquaresProblem
from the given elements.View a convergence checker specified for aPointVectorValuePair
as one specified for anLeastSquaresProblem.Evaluation
.static MultivariateJacobianFunction
model
(MultivariateVectorFunction value, MultivariateMatrixFunction jacobian) Combine aMultivariateVectorFunction
with aMultivariateMatrixFunction
to produce aMultivariateJacobianFunction
.static LeastSquaresProblem
weightDiagonal
(LeastSquaresProblem problem, RealVector weights) Apply a diagonal weight matrix to theLeastSquaresProblem
.static LeastSquaresProblem
weightMatrix
(LeastSquaresProblem problem, RealMatrix weights) Apply a dense weight matrix to theLeastSquaresProblem
.
-
Method Details
-
create
public static LeastSquaresProblem create(MultivariateJacobianFunction model, RealVector observed, RealVector start, RealMatrix weight, ConvergenceChecker<LeastSquaresProblem.Evaluation> checker, int maxEvaluations, int maxIterations, boolean lazyEvaluation, ParameterValidator paramValidator) Create aLeastSquaresProblem
from the given elements. There will be no weights applied (unit weights).- Parameters:
model
- the model function. Produces the computed values.observed
- the observed (target) valuesstart
- the initial guess.weight
- the weight matrixchecker
- convergence checkermaxEvaluations
- the maximum number of times to evaluate the modelmaxIterations
- the maximum number to times to iterate in the algorithmlazyEvaluation
- Whether the call toLeastSquaresProblem.evaluate(RealVector)
will defer the evaluation until access to the value is requested.paramValidator
- Model parameters validator.- Returns:
- the specified General Least Squares problem.
-
create
public static LeastSquaresProblem create(MultivariateJacobianFunction model, RealVector observed, RealVector start, ConvergenceChecker<LeastSquaresProblem.Evaluation> checker, int maxEvaluations, int maxIterations) Create aLeastSquaresProblem
from the given elements. There will be no weights applied (unit weights).- Parameters:
model
- the model function. Produces the computed values.observed
- the observed (target) valuesstart
- the initial guess.checker
- convergence checkermaxEvaluations
- the maximum number of times to evaluate the modelmaxIterations
- the maximum number to times to iterate in the algorithm- Returns:
- the specified General Least Squares problem.
-
create
public static LeastSquaresProblem create(MultivariateJacobianFunction model, RealVector observed, RealVector start, RealMatrix weight, ConvergenceChecker<LeastSquaresProblem.Evaluation> checker, int maxEvaluations, int maxIterations) Create aLeastSquaresProblem
from the given elements.- Parameters:
model
- the model function. Produces the computed values.observed
- the observed (target) valuesstart
- the initial guess.weight
- the weight matrixchecker
- convergence checkermaxEvaluations
- the maximum number of times to evaluate the modelmaxIterations
- the maximum number to times to iterate in the algorithm- Returns:
- the specified General Least Squares problem.
-
create
public static LeastSquaresProblem create(MultivariateVectorFunction model, MultivariateMatrixFunction jacobian, double[] observed, double[] start, RealMatrix weight, ConvergenceChecker<LeastSquaresProblem.Evaluation> checker, int maxEvaluations, int maxIterations) Create aLeastSquaresProblem
from the given elements.This factory method is provided for continuity with previous interfaces. Newer applications should use
create(MultivariateJacobianFunction, RealVector, RealVector, ConvergenceChecker, int, int)
, orcreate(MultivariateJacobianFunction, RealVector, RealVector, RealMatrix, ConvergenceChecker, int, int)
.- Parameters:
model
- the model function. Produces the computed values.jacobian
- the jacobian of the model with respect to the parametersobserved
- the observed (target) valuesstart
- the initial guess.weight
- the weight matrixchecker
- convergence checkermaxEvaluations
- the maximum number of times to evaluate the modelmaxIterations
- the maximum number to times to iterate in the algorithm- Returns:
- the specified General Least Squares problem.
-
weightMatrix
Apply a dense weight matrix to theLeastSquaresProblem
.- Parameters:
problem
- the unweighted problemweights
- the matrix of weights- Returns:
- a new
LeastSquaresProblem
with the weights applied. The originalproblem
is not modified.
-
weightDiagonal
Apply a diagonal weight matrix to theLeastSquaresProblem
.- Parameters:
problem
- the unweighted problemweights
- the diagonal of the weight matrix- Returns:
- a new
LeastSquaresProblem
with the weights applied. The originalproblem
is not modified.
-
countEvaluations
public static LeastSquaresProblem countEvaluations(LeastSquaresProblem problem, Incrementor counter) Count the evaluations of a particular problem. Thecounter
will be incremented every timeLeastSquaresProblem.evaluate(RealVector)
is called on the returned problem.- Parameters:
problem
- the problem to track.counter
- the counter to increment.- Returns:
- a least squares problem that tracks evaluations
-
evaluationChecker
public static ConvergenceChecker<LeastSquaresProblem.Evaluation> evaluationChecker(ConvergenceChecker<PointVectorValuePair> checker) View a convergence checker specified for aPointVectorValuePair
as one specified for anLeastSquaresProblem.Evaluation
.- Parameters:
checker
- the convergence checker to adapt.- Returns:
- a convergence checker that delegates to
checker
.
-
model
public static MultivariateJacobianFunction model(MultivariateVectorFunction value, MultivariateMatrixFunction jacobian) Combine aMultivariateVectorFunction
with aMultivariateMatrixFunction
to produce aMultivariateJacobianFunction
.- Parameters:
value
- the vector value functionjacobian
- the Jacobian function- Returns:
- a function that computes both at the same time
-