001package org.cpsolver.ifs.solution;
002
003import org.cpsolver.ifs.model.Value;
004import org.cpsolver.ifs.model.Variable;
005
006/**
007 * IFS solution comparator. <br>
008 * <br>
009 * The solution comparator compares two solutions: the current solution and the
010 * best solution found. This comparison can be based on several criteria. For
011 * example, it can lexicographically order solutions according to the number of
012 * unassigned variables (smaller number is better) and the number of violated
013 * soft constraints.
014 * 
015 * @see Solution
016 * @see org.cpsolver.ifs.solver.Solver
017 * 
018 * @version IFS 1.3 (Iterative Forward Search)<br>
019 *          Copyright (C) 2006 - 2014 Tomáš Müller<br>
020 *          <a href="mailto:muller@unitime.org">muller@unitime.org</a><br>
021 *          <a href="http://muller.unitime.org">http://muller.unitime.org</a><br>
022 * <br>
023 *          This library is free software; you can redistribute it and/or modify
024 *          it under the terms of the GNU Lesser General Public License as
025 *          published by the Free Software Foundation; either version 3 of the
026 *          License, or (at your option) any later version. <br>
027 * <br>
028 *          This library is distributed in the hope that it will be useful, but
029 *          WITHOUT ANY WARRANTY; without even the implied warranty of
030 *          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
031 *          Lesser General Public License for more details. <br>
032 * <br>
033 *          You should have received a copy of the GNU Lesser General Public
034 *          License along with this library; if not see
035 *          <a href='http://www.gnu.org/licenses/'>http://www.gnu.org/licenses/</a>.
036 * 
037 * @param <V> Variable
038 * @param <T> Value
039 */
040public interface SolutionComparator<V extends Variable<V, T>, T extends Value<V, T>> {
041    /**
042     * Compares two solutions. Returns true if the given solution is better than
043     * its best ever found solution (see {@link Solution#saveBest()} and
044     * {@link Solution#restoreBest()}).
045     * 
046     * @param currentSolution
047     *            given solution
048     * @return true if the given solution is better than the best ever found
049     *         solution
050     */
051    public boolean isBetterThanBestSolution(Solution<V, T> currentSolution);
052}