    001package net.sf.cpsolver.ifs.solution;
    002
    003import java.util.Collection;
    004import java.util.Map;
    005
    006import net.sf.cpsolver.ifs.model.Value;
    007import net.sf.cpsolver.ifs.model.Variable;
    008
    009/**
    010 * IFS solution listener.
    011 *
    012 * @see Solution
    013 *
    014 * @version IFS 1.2 (Iterative Forward Search)<br>
    015 *          Copyright (C) 2006 - 2010 Tomáš Müller<br>
    016 *          <a href="mailto:muller@unitime.org">muller@unitime.org</a><br>
    017 *          <a href="http://muller.unitime.org">http://muller.unitime.org</a><br>
    018 * <br>
    019 *          This library is free software; you can redistribute it and/or modify
    020 *          it under the terms of the GNU Lesser General Public License as
    021 *          published by the Free Software Foundation; either version 3 of the
    022 *          License, or (at your option) any later version. <br>
    023 * <br>
    024 *          This library is distributed in the hope that it will be useful, but
    025 *          WITHOUT ANY WARRANTY; without even the implied warranty of
    026 *          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    027 *          Lesser General Public License for more details. <br>
    028 * <br>
    029 *          You should have received a copy of the GNU Lesser General Public
    030 *          License along with this library; if not see
    031 *          <a href='http://www.gnu.org/licenses/'>http://www.gnu.org/licenses/</a>.
    032 */
    033public interface SolutionListener<V extends Variable<V, T>, T extends Value<V, T>> {
    034    /**
    035     * Called by the solution when it is updated, see
    036     * {@link Solution#update(double)}.
    037     *
    038     * @param solution
    039     *            source solution
    040     */
    041    public void solutionUpdated(Solution<V, T> solution);
    042
    043    /**
    044     * Called by the solution when it is asked to produce info table, see
    045     * {@link Solution#getInfo()}. A listener can also add some its info into
    046     * this table.
    047     *
    048     * @param solution
    049     *            source solution
    050     * @param info
    051     *            produced info table
    052     */
    053    public void getInfo(Solution<V, T> solution, Map<String, String> info);
    054
    055    /**
    056     * Called by the solution when it is asked to produce info table, see
    057     * {@link Solution#getInfo()}. A listener can also add some its info into
    058     * this table.
    059     *
    060     * @param solution
    061     *            source solution
    062     * @param info
    063     *            produced info table
    064     * @param variables
    065     *            only variables from this set are included
    066     */
    067    public void getInfo(Solution<V, T> solution, Map<String, String> info, Collection<V> variables);
    068
    069    /**
    070     * Called by the solution when method {@link Solution#clearBest()} is
    071     * called.
    072     *
    073     * @param solution
    074     *            source solution
    075     */
    076    public void bestCleared(Solution<V, T> solution);
    077
    078    /**
    079     * Called by the solution when method {@link Solution#saveBest()} is called.
    080     *
    081     * @param solution
    082     *            source solution
    083     */
    084    public void bestSaved(Solution<V, T> solution);
    085
    086    /**
    087     * Called by the solution when method {@link Solution#restoreBest()} is
    088     * called.
    089     *
    090     * @param solution
    091     *            source solution
    092     */
    093    public void bestRestored(Solution<V, T> solution);
    094}