use of gdsc.smlm.fitting.nonlinear.stop.ErrorStoppingCriteria in project GDSC-SMLM by aherbert.
the class BoundedFunctionSolverTest method getLVM.
private NonLinearFit getLVM(int bounded, int clamping, boolean mle) {
Gaussian2DFunction f = GaussianFunctionFactory.create2D(1, size, size, flags, null);
StoppingCriteria sc = new ErrorStoppingCriteria(5);
sc.setMaximumIterations(100);
NonLinearFit solver = (bounded != 0 || clamping != 0) ? new BoundedNonLinearFit(f, sc, null) : new NonLinearFit(f, sc);
if (clamping != 0) {
BoundedNonLinearFit bsolver = (BoundedNonLinearFit) solver;
ParameterBounds bounds = new ParameterBounds(f);
bounds.setClampValues(defaultClampValues);
bounds.setDynamicClamp(clamping == 2);
bsolver.setBounds(bounds);
}
solver.setMLE(mle);
solver.setInitialLambda(1);
return solver;
}
use of gdsc.smlm.fitting.nonlinear.stop.ErrorStoppingCriteria in project GDSC-SMLM by aherbert.
the class FitConfiguration method createStoppingCriteria.
/**
* Creates the appropriate stopping criteria for the configuration
*
* @param func
* The Gaussian function
* @param params
* The Gaussian parameters
* @return The stopping criteria
*/
public StoppingCriteria createStoppingCriteria(Gaussian2DFunction func, double[] params) {
StoppingCriteria stoppingCriteria;
if (fitCriteria == FitCriteria.PARAMETERS) {
ParameterStoppingCriteria sc = new ParameterStoppingCriteria(func);
sc.setSignificantDigits(significantDigits);
addPeakRestrictions(func, sc, params);
stoppingCriteria = sc;
} else if (fitCriteria == FitCriteria.COORDINATES) {
GaussianStoppingCriteria sc = new GaussianStoppingCriteria(func);
sc.setDelta(delta);
addPeakRestrictions(func, sc, params);
stoppingCriteria = sc;
} else {
ErrorStoppingCriteria sc = new ErrorStoppingCriteria();
sc.setSignificantDigits(significantDigits);
sc.setAvoidPlateau(fitCriteria == FitCriteria.LEAST_SQUARED_PLUS);
stoppingCriteria = sc;
}
// Removed to reduce verbosity of logging output
//stoppingCriteria.setLog(log);
stoppingCriteria.setMinimumIterations(minIterations);
stoppingCriteria.setMaximumIterations(maxIterations);
return stoppingCriteria;
}
Aggregations