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    *      https://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  /*
19   * This is not the original file distributed by the Apache Software Foundation
20   * It has been modified by the Hipparchus project
21   */
22  
23  package org.hipparchus.optim;
24  
25  /**
26   * This interface specifies how to check if an optimization algorithm has
27   * converged.
28   * <br>
29   * Deciding if convergence has been reached is a problem-dependent issue. The
30   * user should provide a class implementing this interface to allow the
31   * optimization algorithm to stop its search according to the problem at hand.
32   * <br>
33   * For convenience, three implementations that fit simple needs are already
34   * provided: {@link SimpleValueChecker}, {@link SimpleVectorValueChecker} and
35   * {@link SimplePointChecker}. The first two consider that convergence is
36   * reached when the objective function value does not change much anymore, it
37   * does not use the point set at all.
38   * The third one considers that convergence is reached when the input point
39   * set does not change much anymore, it does not use objective function value
40   * at all.
41   *
42   * @param <P> Type of the (point, objective value) pair.
43   *
44   * @see org.hipparchus.optim.SimplePointChecker
45   * @see org.hipparchus.optim.SimpleValueChecker
46   * @see org.hipparchus.optim.SimpleVectorValueChecker
47   *
48   */
49  public interface ConvergenceChecker<P> {
50      /**
51       * Check if the optimization algorithm has converged.
52       *
53       * @param iteration Current iteration.
54       * @param previous Best point in the previous iteration.
55       * @param current Best point in the current iteration.
56       * @return {@code true} if the algorithm is considered to have converged.
57       */
58      boolean converged(int iteration, P previous, P current);
59  }