1dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond/*
2dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * Licensed to the Apache Software Foundation (ASF) under one or more
3dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * contributor license agreements.  See the NOTICE file distributed with
4dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * this work for additional information regarding copyright ownership.
5dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * The ASF licenses this file to You under the Apache License, Version 2.0
6dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * (the "License"); you may not use this file except in compliance with
7dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * the License.  You may obtain a copy of the License at
8dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond *
9dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond *      http://www.apache.org/licenses/LICENSE-2.0
10dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond *
11dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * Unless required by applicable law or agreed to in writing, software
12dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * distributed under the License is distributed on an "AS IS" BASIS,
13dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * See the License for the specific language governing permissions and
15dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * limitations under the License.
16dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond */
17dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond
18dee0849a9704d532af0b550146cbafbaa6ee1d19Raymondpackage org.apache.commons.math.optimization;
19dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond
20dee0849a9704d532af0b550146cbafbaa6ee1d19Raymondimport org.apache.commons.math.FunctionEvaluationException;
21dee0849a9704d532af0b550146cbafbaa6ee1d19Raymondimport org.apache.commons.math.analysis.MultivariateRealFunction;
22dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond
23dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond/**
24dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * This interface represents an optimization algorithm for {@link MultivariateRealFunction
25dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * scalar objective functions}.
26dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * <p>Optimization algorithms find the input point set that either {@link GoalType
27dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * maximize or minimize} an objective function.</p>
28dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * @see DifferentiableMultivariateRealOptimizer
29dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * @see DifferentiableMultivariateVectorialOptimizer
30dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * @version $Revision: 1065481 $ $Date: 2011-01-31 06:31:41 +0100 (lun. 31 janv. 2011) $
31dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * @since 2.0
32dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond */
33dee0849a9704d532af0b550146cbafbaa6ee1d19Raymondpublic interface MultivariateRealOptimizer {
34dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond
35dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond    /** Set the maximal number of iterations of the algorithm.
36dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * @param maxIterations maximal number of algorithm iterations
37dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     */
38dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond    void setMaxIterations(int maxIterations);
39dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond
40dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond    /** Get the maximal number of iterations of the algorithm.
41dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * @return maximal number of iterations
42dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     */
43dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond    int getMaxIterations();
44dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond
45dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond    /** Set the maximal number of functions evaluations.
46dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * @param maxEvaluations maximal number of function evaluations
47dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     */
48dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond    void setMaxEvaluations(int maxEvaluations);
49dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond
50dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond    /** Get the maximal number of functions evaluations.
51dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * @return maximal number of functions evaluations
52dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     */
53dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond    int getMaxEvaluations();
54dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond
55dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond    /** Get the number of iterations realized by the algorithm.
56dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * <p>
57dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * The number of evaluations corresponds to the last call to the
58dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * {@link #optimize(MultivariateRealFunction, GoalType, double[]) optimize}
59dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * method. It is 0 if the method has not been called yet.
60dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * </p>
61dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * @return number of iterations
62dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     */
63dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond    int getIterations();
64dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond
65dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond    /** Get the number of evaluations of the objective function.
66dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * <p>
67dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * The number of evaluations corresponds to the last call to the
68dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * {@link #optimize(MultivariateRealFunction, GoalType, double[]) optimize}
69dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * method. It is 0 if the method has not been called yet.
70dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * </p>
71dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * @return number of evaluations of the objective function
72dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     */
73dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond    int getEvaluations();
74dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond
75dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond    /** Set the convergence checker.
76dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * @param checker object to use to check for convergence
77dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     */
78dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond    void setConvergenceChecker(RealConvergenceChecker checker);
79dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond
80dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond    /** Get the convergence checker.
81dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * @return object used to check for convergence
82dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     */
83dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond    RealConvergenceChecker getConvergenceChecker();
84dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond
85dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond    /** Optimizes an objective function.
86dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * @param f objective function
87dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * @param goalType type of optimization goal: either {@link GoalType#MAXIMIZE}
88dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * or {@link GoalType#MINIMIZE}
89dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * @param startPoint the start point for optimization
90dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * @return the point/value pair giving the optimal value for objective function
91dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * @exception FunctionEvaluationException if the objective function throws one during
92dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * the search
93dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * @exception OptimizationException if the algorithm failed to converge
94dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * @exception IllegalArgumentException if the start point dimension is wrong
95dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     */
96dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond    RealPointValuePair optimize(MultivariateRealFunction f,
97dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond                                  GoalType goalType,
98dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond                                  double[] startPoint)
99dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond        throws FunctionEvaluationException, OptimizationException, IllegalArgumentException;
100dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond
101dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond}
102