use of org.apache.commons.math3.optim.nonlinear.scalar.noderiv.NelderMeadSimplex in project GDSC-SMLM by aherbert.
the class PCPALMMolecules method optimiseSimplex.
private double[] optimiseSimplex(float[] x, float[] y, double[] initialSolution) {
// Simplex optimisation
SkewNormalMultivariateFunction sn2 = new SkewNormalMultivariateFunction(initialSolution);
sn2.addData(x, y);
NelderMeadSimplex simplex = new NelderMeadSimplex(4);
SimplexOptimizer opt = new SimplexOptimizer(1e-6, 1e-10);
PointValuePair solution = opt.optimize(new MaxEval(1000), new InitialGuess(initialSolution), simplex, new ObjectiveFunction(sn2), GoalType.MINIMIZE);
double[] skewParameters2 = solution.getPointRef();
return skewParameters2;
}
use of org.apache.commons.math3.optim.nonlinear.scalar.noderiv.NelderMeadSimplex in project aic-expresso by aic-sri-international.
the class OptimizationWithNelderMead method optimize.
/**
* Main method. It computes the optimum of the function and returns a PointValuePair which contains the argopt and the optimum.
* Both can be computed directly with findOptimum and findArgopt.
*/
private PointValuePair optimize(SimplexOptimizer optimizer) {
final FunctionToOptimize f = new FunctionToOptimize(this.expressionToOptimize);
double[] nelderMeadSimplexParameters = new double[numberOfVariablesInExpression()];
for (int i = 0; i < numberOfVariablesInExpression(); i++) {
nelderMeadSimplexParameters[i] = 0.2;
}
final PointValuePair optimum = optimizer.optimize(this.maxEval, new ObjectiveFunction(f), this.goalType, this.initialGuess, new NelderMeadSimplex(nelderMeadSimplexParameters));
return optimum;
}
use of org.apache.commons.math3.optim.nonlinear.scalar.noderiv.NelderMeadSimplex in project tetrad by cmu-phil.
the class GeneralizedSemEstimator method optimize.
private double[] optimize(MultivariateFunction function, double[] values, int optimizer) {
PointValuePair pair;
if (optimizer == 1) {
// 0.01, 0.000001
// 2.0D * FastMath.ulp(1.0D), 1e-8
MultivariateOptimizer search = new PowellOptimizer(1e-7, 1e-7);
pair = search.optimize(new InitialGuess(values), new ObjectiveFunction(function), GoalType.MINIMIZE, new MaxEval(100000));
} else if (optimizer == 2) {
MultivariateOptimizer search = new SimplexOptimizer(1e-7, 1e-7);
pair = search.optimize(new InitialGuess(values), new ObjectiveFunction(function), GoalType.MINIMIZE, new MaxEval(100000), new NelderMeadSimplex(values.length));
} else if (optimizer == 3) {
int dim = values.length;
int additionalInterpolationPoints = 0;
final int numIterpolationPoints = 2 * dim + 1 + additionalInterpolationPoints;
BOBYQAOptimizer search = new BOBYQAOptimizer(numIterpolationPoints);
pair = search.optimize(new MaxEval(100000), new ObjectiveFunction(function), GoalType.MINIMIZE, new InitialGuess(values), SimpleBounds.unbounded(dim));
} else if (optimizer == 4) {
MultivariateOptimizer search = new CMAESOptimizer(3000000, .05, false, 0, 0, new MersenneTwister(), false, new SimplePointChecker<PointValuePair>(0.5, 0.5));
pair = search.optimize(new MaxEval(30000), new ObjectiveFunction(function), GoalType.MINIMIZE, new InitialGuess(values), new CMAESOptimizer.Sigma(new double[values.length]), new CMAESOptimizer.PopulationSize(1000));
} else if (optimizer == 5) {
// 0.01, 0.000001
// 2.0D * FastMath.ulp(1.0D), 1e-8
MultivariateOptimizer search = new PowellOptimizer(.05, .05);
pair = search.optimize(new InitialGuess(values), new ObjectiveFunction(function), GoalType.MINIMIZE, new MaxEval(100000));
} else if (optimizer == 6) {
MultivariateOptimizer search = new PowellOptimizer(1e-7, 1e-7);
pair = search.optimize(new InitialGuess(values), new ObjectiveFunction(function), GoalType.MAXIMIZE, new MaxEval(10000));
} else {
throw new IllegalStateException();
}
return pair.getPoint();
}
use of org.apache.commons.math3.optim.nonlinear.scalar.noderiv.NelderMeadSimplex in project GDSC-SMLM by aherbert.
the class Fire method findMin.
private static UnivariatePointValuePair findMin(UnivariatePointValuePair current, SimplexOptimizer optimiser, MultivariateFunction func, double qvalue) {
try {
final NelderMeadSimplex simplex = new NelderMeadSimplex(1);
final double[] initialSolution = { qvalue };
final PointValuePair solution = optimiser.optimize(new MaxEval(1000), new InitialGuess(initialSolution), simplex, new ObjectiveFunction(func), GoalType.MINIMIZE);
final UnivariatePointValuePair next = (solution == null) ? null : new UnivariatePointValuePair(solution.getPointRef()[0], solution.getValue());
if (next == null) {
return current;
}
if (current != null) {
return (next.getValue() < current.getValue()) ? next : current;
}
return next;
} catch (final Exception ex) {
return current;
}
}
Aggregations