001    package net.sf.cpsolver.ifs.solution;
002    
003    import net.sf.cpsolver.ifs.model.Value;
004    import net.sf.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 net.sf.cpsolver.ifs.solver.Solver
017     * 
018     * @version IFS 1.2 (Iterative Forward Search)<br>
019     *          Copyright (C) 2006 - 2010 Tomas Muller<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    public interface SolutionComparator<V extends Variable<V, T>, T extends Value<V, T>> {
038        /**
039         * Compares two solutions. Returns true if the given solution is better than
040         * its best ever found solution (see {@link Solution#saveBest()} and
041         * {@link Solution#restoreBest()}).
042         * 
043         * @param currentSolution
044         *            given solution
045         * @return true if the given solution is better than the best ever found
046         *         solution
047         */
048        public boolean isBetterThanBestSolution(Solution<V, T> currentSolution);
049    }