    001package org.cpsolver.ifs.termination;
    002
    003import org.cpsolver.ifs.model.Value;
    004import org.cpsolver.ifs.model.Variable;
    005import org.cpsolver.ifs.solution.Solution;
    006
    007/**
    008 * Termination condition. <br>
    009 * <br>
    010 * The termination condition determines when the algorithm should finish. For
    011 * example, the solver should terminate when the maximal number of iterations or
    012 * some other given timeout value is reached. Moreover, it can stop the search
    013 * process when the current solution is good enough, e.g., all variables are
    014 * assigned and/or some other solution parameters are in the required ranges.
    015 * For example, the solver can stop when all variables are assigned and less
    016 * than 10% of the soft constraints are violated. Termination of the process by
    017 * the user can also be a part of the termination condition.
    018 *
    019 * @see org.cpsolver.ifs.solver.Solver
    020 *
    021 * @author  Tomáš Müller
    022 * @version IFS 1.3 (Iterative Forward Search)<br>
    023 *          Copyright (C) 2006 - 2014 Tomáš Müller<br>
    024 *          <a href="mailto:muller@unitime.org">muller@unitime.org</a><br>
    025 *          <a href="http://muller.unitime.org">http://muller.unitime.org</a><br>
    026 * <br>
    027 *          This library is free software; you can redistribute it and/or modify
    028 *          it under the terms of the GNU Lesser General Public License as
    029 *          published by the Free Software Foundation; either version 3 of the
    030 *          License, or (at your option) any later version. <br>
    031 * <br>
    032 *          This library is distributed in the hope that it will be useful, but
    033 *          WITHOUT ANY WARRANTY; without even the implied warranty of
    034 *          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    035 *          Lesser General Public License for more details. <br>
    036 * <br>
    037 *          You should have received a copy of the GNU Lesser General Public
    038 *          License along with this library; if not see <a href='http://www.gnu.org/licenses'>http://www.gnu.org/licenses</a>.
    039 *
    040 * @param <V> Variable
    041 * @param <T> Value
    042 **/
    043public interface TerminationCondition<V extends Variable<V, T>, T extends Value<V, T>> {
    044    /**
    045     * Returns true when the solver can continue with the next iteration
    046     *
    047     * @param currentSolution
    048     *            current solution
    049     * @return true if the solver can continue with the next iteration
    050     */
    051    public boolean canContinue(Solution<V, T> currentSolution);
    052}