use of org.hipparchus.optim.nonlinear.vector.leastsquares.GaussNewtonOptimizer in project Orekit by CS-SI.
the class OrbitDetermination method createEstimator.
/**
* Set up estimator.
* @param parser input file parser
* @param propagatorBuilder propagator builder
* @return estimator
* @throws NoSuchElementException if input parameters are missing
* @throws OrekitException if some propagator parameters cannot be retrieved
*/
private BatchLSEstimator createEstimator(final KeyValueFileParser<ParameterKey> parser, final NumericalPropagatorBuilder propagatorBuilder) throws NoSuchElementException, OrekitException {
final boolean optimizerIsLevenbergMarquardt;
if (!parser.containsKey(ParameterKey.ESTIMATOR_OPTIMIZATION_ENGINE)) {
optimizerIsLevenbergMarquardt = true;
} else {
final String engine = parser.getString(ParameterKey.ESTIMATOR_OPTIMIZATION_ENGINE);
optimizerIsLevenbergMarquardt = engine.toLowerCase().contains("levenberg");
}
final LeastSquaresOptimizer optimizer;
if (optimizerIsLevenbergMarquardt) {
// we want to use a Levenberg-Marquardt optimization engine
final double initialStepBoundFactor;
if (!parser.containsKey(ParameterKey.ESTIMATOR_LEVENBERG_MARQUARDT_INITIAL_STEP_BOUND_FACTOR)) {
initialStepBoundFactor = 100.0;
} else {
initialStepBoundFactor = parser.getDouble(ParameterKey.ESTIMATOR_LEVENBERG_MARQUARDT_INITIAL_STEP_BOUND_FACTOR);
}
optimizer = new LevenbergMarquardtOptimizer().withInitialStepBoundFactor(initialStepBoundFactor);
} else {
// we want to use a Gauss-Newton optimization engine
optimizer = new GaussNewtonOptimizer(Decomposition.QR);
}
final double convergenceThreshold;
if (!parser.containsKey(ParameterKey.ESTIMATOR_NORMALIZED_PARAMETERS_CONVERGENCE_THRESHOLD)) {
convergenceThreshold = 1.0e-3;
} else {
convergenceThreshold = parser.getDouble(ParameterKey.ESTIMATOR_NORMALIZED_PARAMETERS_CONVERGENCE_THRESHOLD);
}
final int maxIterations;
if (!parser.containsKey(ParameterKey.ESTIMATOR_MAX_ITERATIONS)) {
maxIterations = 10;
} else {
maxIterations = parser.getInt(ParameterKey.ESTIMATOR_MAX_ITERATIONS);
}
final int maxEvaluations;
if (!parser.containsKey(ParameterKey.ESTIMATOR_MAX_EVALUATIONS)) {
maxEvaluations = 20;
} else {
maxEvaluations = parser.getInt(ParameterKey.ESTIMATOR_MAX_EVALUATIONS);
}
final BatchLSEstimator estimator = new BatchLSEstimator(optimizer, propagatorBuilder);
estimator.setParametersConvergenceThreshold(convergenceThreshold);
estimator.setMaxIterations(maxIterations);
estimator.setMaxEvaluations(maxEvaluations);
return estimator;
}
use of org.hipparchus.optim.nonlinear.vector.leastsquares.GaussNewtonOptimizer in project Orekit by CS-SI.
the class OrbitDeterminationTest method createEstimator.
/**
* Set up estimator.
* @param parser input file parser
* @param propagatorBuilder propagator builder
* @return estimator
* @throws NoSuchElementException if input parameters are missing
* @throws OrekitException if some propagator parameters cannot be retrieved
*/
private BatchLSEstimator createEstimator(final KeyValueFileParser<ParameterKey> parser, final NumericalPropagatorBuilder propagatorBuilder) throws NoSuchElementException, OrekitException {
final boolean optimizerIsLevenbergMarquardt;
if (!parser.containsKey(ParameterKey.ESTIMATOR_OPTIMIZATION_ENGINE)) {
optimizerIsLevenbergMarquardt = true;
} else {
final String engine = parser.getString(ParameterKey.ESTIMATOR_OPTIMIZATION_ENGINE);
optimizerIsLevenbergMarquardt = engine.toLowerCase().contains("levenberg");
}
final LeastSquaresOptimizer optimizer;
if (optimizerIsLevenbergMarquardt) {
// we want to use a Levenberg-Marquardt optimization engine
final double initialStepBoundFactor;
if (!parser.containsKey(ParameterKey.ESTIMATOR_LEVENBERG_MARQUARDT_INITIAL_STEP_BOUND_FACTOR)) {
initialStepBoundFactor = 100.0;
} else {
initialStepBoundFactor = parser.getDouble(ParameterKey.ESTIMATOR_LEVENBERG_MARQUARDT_INITIAL_STEP_BOUND_FACTOR);
}
optimizer = new LevenbergMarquardtOptimizer().withInitialStepBoundFactor(initialStepBoundFactor);
} else {
// we want to use a Gauss-Newton optimization engine
optimizer = new GaussNewtonOptimizer(Decomposition.QR);
}
final double convergenceThreshold;
if (!parser.containsKey(ParameterKey.ESTIMATOR_NORMALIZED_PARAMETERS_CONVERGENCE_THRESHOLD)) {
convergenceThreshold = 1.0e-3;
} else {
convergenceThreshold = parser.getDouble(ParameterKey.ESTIMATOR_NORMALIZED_PARAMETERS_CONVERGENCE_THRESHOLD);
}
final int maxIterations;
if (!parser.containsKey(ParameterKey.ESTIMATOR_MAX_ITERATIONS)) {
maxIterations = 10;
} else {
maxIterations = parser.getInt(ParameterKey.ESTIMATOR_MAX_ITERATIONS);
}
final int maxEvaluations;
if (!parser.containsKey(ParameterKey.ESTIMATOR_MAX_EVALUATIONS)) {
maxEvaluations = 20;
} else {
maxEvaluations = parser.getInt(ParameterKey.ESTIMATOR_MAX_EVALUATIONS);
}
final BatchLSEstimator estimator = new BatchLSEstimator(optimizer, propagatorBuilder);
estimator.setParametersConvergenceThreshold(convergenceThreshold);
estimator.setMaxIterations(maxIterations);
estimator.setMaxEvaluations(maxEvaluations);
return estimator;
}
Aggregations