use of com.sri.ai.expresso.optimization.GradientToOptimize 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;
}
Aggregations