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.analysis.DifferentiableMultivariateVectorialFunction;
21dee0849a9704d532af0b550146cbafbaa6ee1d19Raymondimport org.apache.commons.math.FunctionEvaluationException;
22dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond
23dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond/**
24dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * This interface represents an optimization algorithm for {@link DifferentiableMultivariateVectorialFunction
25dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * vectorial differentiable 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 MultivariateRealOptimizer
29dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * @see DifferentiableMultivariateRealOptimizer
30dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * @version $Revision: 1073158 $ $Date: 2011-02-21 22:46:52 +0100 (lun. 21 févr. 2011) $
31dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * @since 2.0
32dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond */
33dee0849a9704d532af0b550146cbafbaa6ee1d19Raymondpublic interface DifferentiableMultivariateVectorialOptimizer {
34dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond
35dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond    /** Set the maximal number of iterations of the algorithm.
36dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * @param maxIterations maximal number of function calls
37dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * .
38dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     */
39dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond    void setMaxIterations(int maxIterations);
40dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond
41dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond    /** Get the maximal number of iterations of the algorithm.
42dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond      * @return maximal number of iterations
43dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     */
44dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond    int getMaxIterations();
45dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond
46dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond    /** Get the number of iterations realized by the algorithm.
47dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * @return number of iterations
48dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond    */
49dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond   int getIterations();
50dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond
51dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond   /** Set the maximal number of functions evaluations.
52dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond    * @param maxEvaluations maximal number of function evaluations
53dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond    */
54dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond   void setMaxEvaluations(int maxEvaluations);
55dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond
56dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond   /** Get the maximal number of functions evaluations.
57dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond    * @return maximal number of functions evaluations
58dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond    */
59dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond   int getMaxEvaluations();
60dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond
61dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond    /** Get the number of evaluations of the objective function.
62dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * <p>
63dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * The number of evaluation correspond to the last call to the
64dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * {@link #optimize(DifferentiableMultivariateVectorialFunction,
65dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * double[], double[], double[]) optimize} method. It is 0 if
66dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * the method has not been called yet.
67dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * </p>
68dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * @return number of evaluations of the objective function
69dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     */
70dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond    int getEvaluations();
71dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond
72dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond    /** Get the number of evaluations of the objective function jacobian .
73dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * <p>
74dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * The number of evaluation correspond to the last call to the
75dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * {@link #optimize(DifferentiableMultivariateVectorialFunction,
76dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * double[], double[], double[]) optimize} method. It is 0 if
77dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * the method has not been called yet.
78dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * </p>
79dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * @return number of evaluations of the objective function jacobian
80dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     */
81dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond    int getJacobianEvaluations();
82dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond
83dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond    /** Set the convergence checker.
84dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * @param checker object to use to check for convergence
85dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     */
86dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond    void setConvergenceChecker(VectorialConvergenceChecker checker);
87dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond
88dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond    /** Get the convergence checker.
89dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * @return object used to check for convergence
90dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     */
91dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond    VectorialConvergenceChecker getConvergenceChecker();
92dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond
93dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond    /** Optimizes an objective function.
94dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * <p>
95dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * Optimization is considered to be a weighted least-squares minimization.
96dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * The cost function to be minimized is
97dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * &sum;weight<sub>i</sub>(objective<sub>i</sub>-target<sub>i</sub>)<sup>2</sup>
98dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * </p>
99dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * @param f objective function
100dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * @param target target value for the objective functions at optimum
101dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * @param weights weight for the least squares cost computation
102dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * @param startPoint the start point for optimization
103dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * @return the point/value pair giving the optimal value for objective function
104dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * @exception FunctionEvaluationException if the objective function throws one during
105dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * the search
106dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * @exception OptimizationException if the algorithm failed to converge
107dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * @exception IllegalArgumentException if the start point dimension is wrong
108dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     */
109dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond    VectorialPointValuePair optimize(DifferentiableMultivariateVectorialFunction f,
110dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond                                     double[] target, double[] weights,
111dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond                                     double[] startPoint)
112dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond        throws FunctionEvaluationException, OptimizationException, IllegalArgumentException;
113dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond
114dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond}
115