use of org.apache.commons.math3.optim.nonlinear.scalar.gradient.NonLinearConjugateGradientOptimizer in project aic-praise by aic-sri-international.
the class RegularParameterEstimation method optimizeModel.
/**
* Call the optimizer of Java Commons Math.
*/
public PointValuePair optimizeModel() {
NonLinearConjugateGradientOptimizer optimizer = new NonLinearConjugateGradientOptimizer(NonLinearConjugateGradientOptimizer.Formula.POLAK_RIBIERE, new SimpleValueChecker(1e-13, 1e-13));
final LoglikelihoodToOptimize f = new LoglikelihoodToOptimize(expressionBasedModel, queries);
final GradientLoglikelihoodToOptimize gradientToOptimize = new GradientLoglikelihoodToOptimize(expressionBasedModel, queries);
ObjectiveFunction objectiveFunction = new ObjectiveFunction(f);
MultivariateVectorFunction gradientMultivariateFunction = gradientToOptimize;
ObjectiveFunctionGradient objectiveFunctionGradient = new ObjectiveFunctionGradient(gradientMultivariateFunction);
double[] startPoint = new double[] { 0.5, 0.5 };
final PointValuePair optimum = optimizer.optimize(new MaxEval(10000), objectiveFunction, objectiveFunctionGradient, GoalType.MAXIMIZE, new InitialGuess(startPoint));
return optimum;
}
use of org.apache.commons.math3.optim.nonlinear.scalar.gradient.NonLinearConjugateGradientOptimizer in project aic-praise by aic-sri-international.
the class RegularSymbolicParameterEstimation method optimize.
/**
* Call the optimizer of Java Commons Math with the objectiveFunction and the gradient given in the arguments.
*/
public PointValuePair optimize(Expression expressionToOptimize, Vector<Expression> gradient) {
NonLinearConjugateGradientOptimizer optimizer = new NonLinearConjugateGradientOptimizer(NonLinearConjugateGradientOptimizer.Formula.POLAK_RIBIERE, new SimpleValueChecker(1e-13, 1e-13));
final FunctionToOptimize f = new FunctionToOptimize(expressionToOptimize);
final GradientToOptimize gradientToOptimize = new GradientToOptimize(expressionToOptimize, gradient);
ObjectiveFunction objectiveFunction = new ObjectiveFunction(f);
MultivariateVectorFunction gradientMultivariateFunction = gradientToOptimize;
ObjectiveFunctionGradient objectiveFunctionGradient = new ObjectiveFunctionGradient(gradientMultivariateFunction);
double[] startPoint = new double[] { 0.5, 0.5 };
final PointValuePair optimum = optimizer.optimize(new MaxEval(10000), objectiveFunction, objectiveFunctionGradient, GoalType.MAXIMIZE, new InitialGuess(startPoint));
return optimum;
}
use of org.apache.commons.math3.optim.nonlinear.scalar.gradient.NonLinearConjugateGradientOptimizer in project aic-expresso by aic-sri-international.
the class OptimizationWithNonlinearConjugateGradientDescent 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.
*/
public PointValuePair optimize(NonLinearConjugateGradientOptimizer optimizer) {
final FunctionToOptimize f = new FunctionToOptimize(this.expressionToOptimize);
final FunctionToOptimizeGradient gradient = new FunctionToOptimizeGradient(expressionToOptimize);
ObjectiveFunction objectiveFunction = new ObjectiveFunction(f);
MultivariateVectorFunction gradientMultivariateFunction = gradient;
ObjectiveFunctionGradient objectiveFunctionGradient = new ObjectiveFunctionGradient(gradientMultivariateFunction);
final PointValuePair optimum = optimizer.optimize(this.maxEval, objectiveFunction, objectiveFunctionGradient, this.goalType, this.initialGuess);
return optimum;
}
Aggregations