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