Uploaded image for project: 'Commons Math'
  1. Commons Math
  2. MATH-1657

Enhance management the objective function of optimizer

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 4.0-beta1
    • None
    • legacy
    • None
    • Easy

    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

           double[] gradient = gradientOperator.operate(getObjectiveFunction())
      

      I suggest to wrap the function into an anonymous MultivariateFunction at setting time:

          protected void setObjectiveFunction(MultivariateFunction func) {
              function = new MultivariateFunction() {
                  @Override
                  public double value(double[] point) throws IllegalArgumentException {
                      incrementEvaluationCount();
                      return func.value(point);
                  }
              };
          }
      

      So that we can still have at least a protected accessor

          protected MultivariateFunction getObjectiveFunction() {
              return function;
          }
      

      This is only an extension that has no impact on current API.

      Attachments

        Activity

          People

            Unassigned Unassigned
            flaferriere François Laferrière
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: