use of org.hipparchus.optim.nonlinear.vector.leastsquares.LeastSquaresBuilder in project Orekit by CS-SI.
the class AbstractPropagatorConverter method fit.
/**
* Find the propagator that minimize the mean square error for a sample of {@link SpacecraftState states}.
* @param initial initial estimation parameters (position, velocity, free parameters)
* @return fitted parameters
* @exception OrekitException if propagator cannot be adapted
* @exception MathRuntimeException if maximal number of iterations is exceeded
*/
private double[] fit(final double[] initial) throws OrekitException, MathRuntimeException {
final LeastSquaresProblem problem = new LeastSquaresBuilder().maxIterations(maxIterations).maxEvaluations(Integer.MAX_VALUE).model(getModel()).target(target).weight(new DiagonalMatrix(weight)).start(initial).checker(checker).build();
optimum = optimizer.optimize(problem);
return optimum.getPoint().toArray();
}
use of org.hipparchus.optim.nonlinear.vector.leastsquares.LeastSquaresBuilder in project Orekit by CS-SI.
the class SecularAndHarmonic method fit.
/**
* Fit parameters.
* @see #getFittedParameters()
*/
public void fit() {
final AbstractCurveFitter fitter = new AbstractCurveFitter() {
/**
* {@inheritDoc}
*/
@Override
protected LeastSquaresProblem getProblem(final Collection<WeightedObservedPoint> observations) {
// Prepare least-squares problem.
final int len = observations.size();
final double[] target = new double[len];
final double[] weights = new double[len];
int i = 0;
for (final WeightedObservedPoint obs : observations) {
target[i] = obs.getY();
weights[i] = obs.getWeight();
++i;
}
final AbstractCurveFitter.TheoreticalValuesFunction model = new AbstractCurveFitter.TheoreticalValuesFunction(new LocalParametricFunction(), observations);
// build a new least squares problem set up to fit a secular and harmonic curve to the observed points
return new LeastSquaresBuilder().maxEvaluations(Integer.MAX_VALUE).maxIterations(Integer.MAX_VALUE).start(fitted).target(target).weight(new DiagonalMatrix(weights)).model(model.getModelFunction(), model.getModelFunctionJacobian()).build();
}
};
fitted = fitter.fit(observedPoints);
}
Aggregations