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
20dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond/** This interface specifies how to check if an {@link MultivariateRealOptimizer optimization
21dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * algorithm} has converged.
22dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond *
23dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * <p>Deciding if convergence has been reached is a problem-dependent issue. The
24dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * user should provide a class implementing this interface to allow the optimization
25dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * algorithm to stop its search according to the problem at hand.</p>
26dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * <p>For convenience, two implementations that fit simple needs are already provided:
27dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * {@link SimpleScalarValueChecker} and {@link SimpleRealPointChecker}. The first
28dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * one considers convergence is reached when the objective function value does not
29dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * change much anymore, it does not use the point set at all. The second one
30dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * considers convergence is reached when the input point set does not change
31dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * much anymore, it does not use objective function value at all.</p>
32dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond *
33dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * @version $Revision: 799857 $ $Date: 2009-08-01 15:07:12 +0200 (sam. 01 août 2009) $
34dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * @since 2.0
35dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond */
36dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond
37dee0849a9704d532af0b550146cbafbaa6ee1d19Raymondpublic interface RealConvergenceChecker {
38dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond
39dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond  /** Check if the optimization algorithm has converged considering the last points.
40dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond   * <p>
41dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond   * This method may be called several time from the same algorithm iteration with
42dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond   * different points. This can be detected by checking the iteration number at each
43dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond   * call if needed. Each time this method is called, the previous and current point
44dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond   * correspond to points with the same role at each iteration, so they can be
45dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond   * compared. As an example, simplex-based algorithms call this method for all
46dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond   * points of the simplex, not only for the best or worst ones.
47dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond   * </p>
48dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond   * @param iteration index of current iteration
49dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond   * @param previous point from previous iteration
50dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond   * @param current point from current iteration
51dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond   * @return true if the algorithm is considered to have converged
52dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond   */
53dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond  boolean converged(int iteration, RealPointValuePair previous, RealPointValuePair current);
54dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond
55dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond}
56