View Javadoc
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  
18  package org.apache.commons.math3.optimization.direct;
19  
20  import org.apache.commons.math3.analysis.MultivariateFunction;
21  import org.apache.commons.math3.optimization.BaseMultivariateOptimizer;
22  import org.apache.commons.math3.optimization.BaseMultivariateSimpleBoundsOptimizer;
23  import org.apache.commons.math3.optimization.GoalType;
24  import org.apache.commons.math3.optimization.InitialGuess;
25  import org.apache.commons.math3.optimization.SimpleBounds;
26  import org.apache.commons.math3.optimization.PointValuePair;
27  import org.apache.commons.math3.optimization.ConvergenceChecker;
28  
29  /**
30   * Base class for implementing optimizers for multivariate scalar functions,
31   * subject to simple bounds: The valid range of the parameters is an interval.
32   * The interval can possibly be infinite (in one or both directions).
33   * This base class handles the boiler-plate methods associated to thresholds
34   * settings, iterations and evaluations counting.
35   *
36   * @param <FUNC> Type of the objective function to be optimized.
37   *
38   * @deprecated As of 3.1 (to be removed in 4.0).
39   * @since 3.0
40   * @deprecated As of 3.1 since the {@link BaseAbstractMultivariateOptimizer
41   * base class} contains similar functionality.
42   */
43  @Deprecated
44  public abstract class BaseAbstractMultivariateSimpleBoundsOptimizer<FUNC extends MultivariateFunction>
45      extends BaseAbstractMultivariateOptimizer<FUNC>
46      implements BaseMultivariateOptimizer<FUNC>,
47                 BaseMultivariateSimpleBoundsOptimizer<FUNC> {
48      /**
49       * Simple constructor with default settings.
50       * The convergence checker is set to a
51       * {@link org.apache.commons.math3.optimization.SimpleValueChecker}.
52       *
53       * @see BaseAbstractMultivariateOptimizer#BaseAbstractMultivariateOptimizer()
54       * @deprecated See {@link org.apache.commons.math3.optimization.SimpleValueChecker#SimpleValueChecker()}
55       */
56      @Deprecated
57      protected BaseAbstractMultivariateSimpleBoundsOptimizer() {}
58  
59      /**
60       * @param checker Convergence checker.
61       */
62      protected BaseAbstractMultivariateSimpleBoundsOptimizer(ConvergenceChecker<PointValuePair> checker) {
63          super(checker);
64      }
65  
66      /** {@inheritDoc} */
67      @Override
68      public PointValuePair optimize(int maxEval, FUNC f, GoalType goalType,
69                                     double[] startPoint) {
70          return super.optimizeInternal(maxEval, f, goalType,
71                                        new InitialGuess(startPoint));
72      }
73  
74      /** {@inheritDoc} */
75      public PointValuePair optimize(int maxEval, FUNC f, GoalType goalType,
76                                     double[] startPoint,
77                                     double[] lower, double[] upper) {
78          return super.optimizeInternal(maxEval, f, goalType,
79                                        new InitialGuess(startPoint),
80                                        new SimpleBounds(lower, upper));
81      }
82  }