Example usage for org.apache.commons.math3.fitting.leastsquares LeastSquaresFactory evaluationChecker

List of usage examples for org.apache.commons.math3.fitting.leastsquares LeastSquaresFactory evaluationChecker

Introduction

In this page you can find the example usage for org.apache.commons.math3.fitting.leastsquares LeastSquaresFactory evaluationChecker.

Prototype

public static ConvergenceChecker<Evaluation> evaluationChecker(
        final ConvergenceChecker<PointVectorValuePair> checker) 

Source Link

Document

View a convergence checker specified for a PointVectorValuePair as one specified for an Evaluation .

Usage

From source file:eu.crisis_economics.abm.markets.clearing.heterogeneous.LevenbergMarquardtClearingAlgorithm.java

@Override
public double applyToNetwork(final MixedClearingNetwork network) {
    Preconditions.checkNotNull(network);

    final VectorCostFunction function = super.getVectorCostFunction(network);
    final MultivariateJacobianFunction model = LeastSquaresFactory.model(function,
            super.getJacobianMatrixFunction(network));
    final RealVector observed = new ArrayRealVector(super.calculateTarget(network)),
            start = new ArrayRealVector(network.getNumberOfEdges());
    for (int i = 0; i < network.getNumberOfEdges(); ++i)
        start.setEntry(i, network.getEdges().get(i).getMaximumRateAdmissibleByBothParties());
    start.set(1.0);//from   w w w  .  j av a 2s .com

    final ConvergenceChecker<LeastSquaresProblem.Evaluation> evaluationChecker = LeastSquaresFactory
            .evaluationChecker(new SimpleVectorValueChecker(relErrorTarget, absErrorTarget));
    final LeastSquaresProblem problem = LeastSquaresFactory.create(model, observed, start, evaluationChecker,
            maximumEvaluations, maximumIterations);

    final LevenbergMarquardtOptimizer optimizer = new LevenbergMarquardtOptimizer();
    final Optimum result = optimizer.optimize(problem);

    final double residualCost = result.getRMS();
    System.out.println("Network cleared: residual cost: " + residualCost + ".");

    return residualCost;
}

From source file:org.orekit.propagation.conversion.AbstractPropagatorConverter.java

/** Build a new instance.
 * @param builder propagator builder/*from   w  w  w . jav  a2 s .  c om*/
 * @param threshold absolute convergence threshold for optimization algorithm
 * @param maxIterations maximum number of iterations for fitting
 */
protected AbstractPropagatorConverter(final PropagatorBuilder builder, final double threshold,
        final int maxIterations) {
    this.builder = builder;
    this.frame = builder.getFrame();
    this.availableParameters = builder.getSupportedParameters();
    this.optimizer = new LevenbergMarquardtOptimizer();
    this.maxIterations = maxIterations;
    this.sample = new ArrayList<SpacecraftState>();

    final SimpleVectorValueChecker svvc = new SimpleVectorValueChecker(-1.0, threshold);
    this.checker = LeastSquaresFactory.evaluationChecker(svvc);

}