    001package org.cpsolver.ifs.model;
    002
    003import org.cpsolver.ifs.assignment.Assignment;
    004import org.cpsolver.ifs.solver.Solver;
    005
    006/**
    007 * IFS model listener.
    008 *
    009 * @see Model
    010 *
    011 * @version IFS 1.3 (Iterative Forward Search)<br>
    012 *          Copyright (C) 2006 - 2014 Tomáš Müller<br>
    013 *          <a href="mailto:muller@unitime.org">muller@unitime.org</a><br>
    014 *          <a href="http://muller.unitime.org">http://muller.unitime.org</a><br>
    015 * <br>
    016 *          This library is free software; you can redistribute it and/or modify
    017 *          it under the terms of the GNU Lesser General Public License as
    018 *          published by the Free Software Foundation; either version 3 of the
    019 *          License, or (at your option) any later version. <br>
    020 * <br>
    021 *          This library is distributed in the hope that it will be useful, but
    022 *          WITHOUT ANY WARRANTY; without even the implied warranty of
    023 *          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    024 *          Lesser General Public License for more details. <br>
    025 * <br>
    026 *          You should have received a copy of the GNU Lesser General Public
    027 *          License along with this library; if not see
    028 *          <a href='http://www.gnu.org/licenses/'>http://www.gnu.org/licenses/</a>.
    029 *
    030 * @param <V> Variable
    031 * @param <T> Value
    032 */
    033public interface ModelListener<V extends Variable<V, T>, T extends Value<V, T>> {
    034    /**
    035     * Variable is added to the model
    036     *
    037     * @param variable
    038     *            added variable
    039     */
    040    public void variableAdded(V variable);
    041
    042    /**
    043     * Variable is removed from the model
    044     *
    045     * @param variable
    046     *            removed variable
    047     */
    048    public void variableRemoved(V variable);
    049
    050    /**
    051     * Constraint is added to the model
    052     *
    053     * @param constraint
    054     *            added constraint
    055     */
    056    public void constraintAdded(Constraint<V, T> constraint);
    057
    058    /**
    059     * Constraint is removed from the model
    060     *
    061     * @param constraint
    062     *            removed constraint
    063     */
    064    public void constraintRemoved(Constraint<V, T> constraint);
    065
    066    /**
    067     * Called before a value is assigned to its variable (
    068     * {@link Value#variable()}).
    069     *
    070     * @param assignment current assignment
    071     * @param iteration
    072     *            current iteration
    073     * @param value
    074     *            value to be assigned
    075     */
    076    public void beforeAssigned(Assignment<V, T> assignment, long iteration, T value);
    077
    078    /**
    079     * Called before a value is unassigned from its variable (
    080     * {@link Value#variable()}).
    081     *
    082     * @param assignment current assignment
    083     * @param iteration
    084     *            current iteration
    085     * @param value
    086     *            value to be unassigned
    087     */
    088    public void beforeUnassigned(Assignment<V, T> assignment, long iteration, T value);
    089
    090    /**
    091     * Called after a value is assigned to its variable (
    092     * {@link Value#variable()}).
    093     *
    094     * @param assignment current assignment
    095     * @param iteration
    096     *            current iteration
    097     * @param value
    098     *            value to be assigned
    099     */
    100    public void afterAssigned(Assignment<V, T> assignment,  long iteration, T value);
    101
    102    /**
    103     * Called after a value is unassigned from its variable (
    104     * {@link Value#variable()}).
    105     *
    106     * @param assignment current assignment
    107     * @param iteration
    108     *            current iteration
    109     * @param value
    110     *            value to be unassigned
    111     */
    112    public void afterUnassigned(Assignment<V, T> assignment, long iteration, T value);
    113
    114    /**
    115     * Notification that the model was initialized by the solver.
    116     *
    117     * @param solver
    118     *            IFS solver
    119     * @return true if successfully initialized
    120     */
    121    public boolean init(Solver<V, T> solver);
    122}