BaseAbstractMultivariateSimpleBoundsOptimizer.java

  1. /*
  2.  * Licensed to the Apache Software Foundation (ASF) under one or more
  3.  * contributor license agreements.  See the NOTICE file distributed with
  4.  * this work for additional information regarding copyright ownership.
  5.  * The ASF licenses this file to You under the Apache License, Version 2.0
  6.  * (the "License"); you may not use this file except in compliance with
  7.  * the License.  You may obtain a copy of the License at
  8.  *
  9.  *      http://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the License for the specific language governing permissions and
  15.  * limitations under the License.
  16.  */

  17. package org.apache.commons.math3.optimization.direct;

  18. import org.apache.commons.math3.analysis.MultivariateFunction;
  19. import org.apache.commons.math3.optimization.BaseMultivariateOptimizer;
  20. import org.apache.commons.math3.optimization.BaseMultivariateSimpleBoundsOptimizer;
  21. import org.apache.commons.math3.optimization.GoalType;
  22. import org.apache.commons.math3.optimization.InitialGuess;
  23. import org.apache.commons.math3.optimization.SimpleBounds;
  24. import org.apache.commons.math3.optimization.PointValuePair;
  25. import org.apache.commons.math3.optimization.ConvergenceChecker;

  26. /**
  27.  * Base class for implementing optimizers for multivariate scalar functions,
  28.  * subject to simple bounds: The valid range of the parameters is an interval.
  29.  * The interval can possibly be infinite (in one or both directions).
  30.  * This base class handles the boiler-plate methods associated to thresholds
  31.  * settings, iterations and evaluations counting.
  32.  *
  33.  * @param <FUNC> Type of the objective function to be optimized.
  34.  *
  35.  * @deprecated As of 3.1 (to be removed in 4.0).
  36.  * @since 3.0
  37.  * @deprecated As of 3.1 since the {@link BaseAbstractMultivariateOptimizer
  38.  * base class} contains similar functionality.
  39.  */
  40. @Deprecated
  41. public abstract class BaseAbstractMultivariateSimpleBoundsOptimizer<FUNC extends MultivariateFunction>
  42.     extends BaseAbstractMultivariateOptimizer<FUNC>
  43.     implements BaseMultivariateOptimizer<FUNC>,
  44.                BaseMultivariateSimpleBoundsOptimizer<FUNC> {
  45.     /**
  46.      * Simple constructor with default settings.
  47.      * The convergence checker is set to a
  48.      * {@link org.apache.commons.math3.optimization.SimpleValueChecker}.
  49.      *
  50.      * @see BaseAbstractMultivariateOptimizer#BaseAbstractMultivariateOptimizer()
  51.      * @deprecated See {@link org.apache.commons.math3.optimization.SimpleValueChecker#SimpleValueChecker()}
  52.      */
  53.     @Deprecated
  54.     protected BaseAbstractMultivariateSimpleBoundsOptimizer() {}

  55.     /**
  56.      * @param checker Convergence checker.
  57.      */
  58.     protected BaseAbstractMultivariateSimpleBoundsOptimizer(ConvergenceChecker<PointValuePair> checker) {
  59.         super(checker);
  60.     }

  61.     /** {@inheritDoc} */
  62.     @Override
  63.     public PointValuePair optimize(int maxEval, FUNC f, GoalType goalType,
  64.                                    double[] startPoint) {
  65.         return super.optimizeInternal(maxEval, f, goalType,
  66.                                       new InitialGuess(startPoint));
  67.     }

  68.     /** {@inheritDoc} */
  69.     public PointValuePair optimize(int maxEval, FUNC f, GoalType goalType,
  70.                                    double[] startPoint,
  71.                                    double[] lower, double[] upper) {
  72.         return super.optimizeInternal(maxEval, f, goalType,
  73.                                       new InitialGuess(startPoint),
  74.                                       new SimpleBounds(lower, upper));
  75.     }
  76. }