List of usage examples for org.apache.commons.math.optimization.univariate BrentOptimizer getIterationCount
public int getIterationCount()
From source file:OughtaFocus.java
private double runAutofocusAlgorithm() throws Exception { UnivariateRealFunction scoreFun = new UnivariateRealFunction() { public double value(double d) throws FunctionEvaluationException { try { return measureFocusScore(d); } catch (Exception e) { throw new FunctionEvaluationException(e, d); }/* ww w . j a v a 2 s . c om*/ } }; BrentOptimizer brentOptimizer = new BrentOptimizer(); brentOptimizer.setAbsoluteAccuracy(tolerance); imageCount_ = 0; CMMCore core = app_.getMMCore(); double z = core.getPosition(core.getFocusDevice()); startZUm_ = z; // getCurrentFocusScore(); double zResult = brentOptimizer.optimize(scoreFun, GoalType.MAXIMIZE, z - searchRange / 2, z + searchRange / 2); ReportingUtils.logMessage("OughtaFocus Iterations: " + brentOptimizer.getIterationCount() + ", z=" + TextUtils.FMT2.format(zResult) + ", dz=" + TextUtils.FMT2.format(zResult - startZUm_) + ", t=" + (System.currentTimeMillis() - startTimeMs_)); return zResult; }