Example usage for org.apache.commons.math3.exception TooManyEvaluationsException TooManyEvaluationsException

List of usage examples for org.apache.commons.math3.exception TooManyEvaluationsException TooManyEvaluationsException

Introduction

In this page you can find the example usage for org.apache.commons.math3.exception TooManyEvaluationsException TooManyEvaluationsException.

Prototype

public TooManyEvaluationsException(Number max) 

Source Link

Document

Construct the exception.

Usage

From source file:gdsc.smlm.ij.plugins.EMGainAnalysis.java

private MultivariateFunction getFunction(final int[] limits, final double[] y, final int max,
        final int maxEval) {
    MultivariateFunction fun = new MultivariateFunction() {
        int eval = 0;

        public double value(double[] point) {
            IJ.showProgress(++eval, maxEval);
            if (Utils.isInterrupted())
                throw new TooManyEvaluationsException(maxEval);
            // Compute the sum of squares between the two functions
            double photons = point[0];
            double gain = point[1];
            double noise = point[2];
            int bias = (int) Math.round(point[3]);
            //System.out.printf("[%d] = %s\n", eval, Arrays.toString(point));
            final double[] g = pdf(max, photons, gain, noise, bias);
            double ss = 0;
            for (int c = limits[0]; c <= limits[1]; c++) {
                final double d = g[c] - y[c];
                ss += d * d;/*  w ww.  ja va 2 s  .  co m*/
            }
            return ss;
        }
    };
    return fun;
}