    001    /*
    002     * Licensed to the Apache Software Foundation (ASF) under one or more
    003     * contributor license agreements.  See the NOTICE file distributed with
    004     * this work for additional information regarding copyright ownership.
    005     * The ASF licenses this file to You under the Apache License, Version 2.0
    006     * (the "License"); you may not use this file except in compliance with
    007     * the License.  You may obtain a copy of the License at
    008     *
    009     *      http://www.apache.org/licenses/LICENSE-2.0
    010     *
    011     * Unless required by applicable law or agreed to in writing, software
    012     * distributed under the License is distributed on an "AS IS" BASIS,
    013     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    014     * See the License for the specific language governing permissions and
    015     * limitations under the License.
    016     */
    017
    018    package org.apache.commons.math3.optim;
    019
    020    /**
    021     * This interface specifies how to check if an optimization algorithm has
    022     * converged.
    023     * <br/>
    024     * Deciding if convergence has been reached is a problem-dependent issue. The
    025     * user should provide a class implementing this interface to allow the
    026     * optimization algorithm to stop its search according to the problem at hand.
    027     * <br/>
    028     * For convenience, three implementations that fit simple needs are already
    029     * provided: {@link SimpleValueChecker}, {@link SimpleVectorValueChecker} and
    030     * {@link SimplePointChecker}. The first two consider that convergence is
    031     * reached when the objective function value does not change much anymore, it
    032     * does not use the point set at all.
    033     * The third one considers that convergence is reached when the input point
    034     * set does not change much anymore, it does not use objective function value
    035     * at all.
    036     *
    037     * @param <PAIR> Type of the (point, objective value) pair.
    038     *
    039     * @see org.apache.commons.math3.optim.SimplePointChecker
    040     * @see org.apache.commons.math3.optim.SimpleValueChecker
    041     * @see org.apache.commons.math3.optim.SimpleVectorValueChecker
    042     *
    043     * @version $Id: ConvergenceChecker.java 1364392 2012-07-22 18:27:12Z tn $
    044     * @since 3.0
    045     */
    046    public interface ConvergenceChecker<PAIR> {
    047        /**
    048         * Check if the optimization algorithm has converged.
    049         *
    050         * @param iteration Current iteration.
    051         * @param previous Best point in the previous iteration.
    052         * @param current Best point in the current iteration.
    053         * @return {@code true} if the algorithm is considered to have converged.
    054         */
    055        boolean converged(int iteration, PAIR previous, PAIR current);
    056    }