You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Gilles Sadowski (Jira)" <ji...@apache.org> on 2023/03/31 13:48:00 UTC
[jira] [Updated] (MATH-1657) Enhance management the objective function of optimizer
[ https://issues.apache.org/jira/browse/MATH-1657?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Gilles Sadowski updated MATH-1657:
----------------------------------
Description:
In MultivariateOptimizer class, objective function is not accessible once set: only computeObjectiveValue(double[] params) allows to access the value. This is probably to ensure that the evaluation counter is always properly incremented.
But it is not very convenient for my purpose where I need to apply operators to the function. For instance
{code:java}
double[] gradient = gradientOperator.operate(getObjectiveFunction())
{code}
I suggest to wrap the function into an anonymous MultivariateFunction at setting time:
{code:java}
protected void setObjectiveFunction(MultivariateFunction func) {
function = new MultivariateFunction() {
@Override
public double value(double[] point) throws IllegalArgumentException {
incrementEvaluationCount();
return func.value(point);
}
};
}
{code}
So that we can still have at least a protected accessor
{code:java}
protected MultivariateFunction getObjectiveFunction() {
return function;
}
{code}
This is only an extension that has no impact on current API.
was:
In MultivariateOptimizer class, objective function is not accessible once set: only computeObjectiveValue(double[] params) allows to access the value. This is probably to ensure that the evaluation counter is always properly incremented.
But it is not very convenient for my purpose where I need to apply operators to the function. For instance
{code:java}
double[] gradient = gradientOperator.operate(getObjectiveFunction())
{code}
I suggest to wrap the function into an anonymous MultivariateFunction at setting time:
{code:java}
protected void setObjectiveFunction(MultivariateFunction func) {
function = new MultivariateFunction() {
@Override
public double value(double[] point) throws IllegalArgumentException {
incrementEvaluationCount();
return func.value(point);
}
};
}
{code}
So that we can still have at least a protected accessor
{code:java}
protected MultivariateFunction getObjectiveFunction() {
return function;
}
{code}
This is only an extension that has no impact on current API.
2.12.0.0
> Enhance management the objective function of optimizer
> ------------------------------------------------------
>
> Key: MATH-1657
> URL: https://issues.apache.org/jira/browse/MATH-1657
> Project: Commons Math
> Issue Type: Improvement
> Components: legacy
> Affects Versions: 4.0-beta1
> Reporter: François Laferrière
> Priority: Minor
>
> In MultivariateOptimizer class, objective function is not accessible once set: only computeObjectiveValue(double[] params) allows to access the value. This is probably to ensure that the evaluation counter is always properly incremented.
> But it is not very convenient for my purpose where I need to apply operators to the function. For instance
> {code:java}
> double[] gradient = gradientOperator.operate(getObjectiveFunction())
> {code}
> I suggest to wrap the function into an anonymous MultivariateFunction at setting time:
> {code:java}
> protected void setObjectiveFunction(MultivariateFunction func) {
> function = new MultivariateFunction() {
> @Override
> public double value(double[] point) throws IllegalArgumentException {
> incrementEvaluationCount();
> return func.value(point);
> }
> };
> }
> {code}
> So that we can still have at least a protected accessor
> {code:java}
> protected MultivariateFunction getObjectiveFunction() {
> return function;
> }
> {code}
> This is only an extension that has no impact on current API.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)