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