    001package org.cpsolver.ifs.model;
    002
    003import java.util.Set;
    004
    005import org.cpsolver.ifs.assignment.Assignment;
    006
    007
    008/**
    009 * IFS constraint listener.
    010 *
    011 * @see Constraint
    012 *
    013 * @version IFS 1.3 (Iterative Forward Search)<br>
    014 *          Copyright (C) 2006 - 2014 Tomáš Müller<br>
    015 *          <a href="mailto:muller@unitime.org">muller@unitime.org</a><br>
    016 *          <a href="http://muller.unitime.org">http://muller.unitime.org</a><br>
    017 * <br>
    018 *          This library is free software; you can redistribute it and/or modify
    019 *          it under the terms of the GNU Lesser General Public License as
    020 *          published by the Free Software Foundation; either version 3 of the
    021 *          License, or (at your option) any later version. <br>
    022 * <br>
    023 *          This library is distributed in the hope that it will be useful, but
    024 *          WITHOUT ANY WARRANTY; without even the implied warranty of
    025 *          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    026 *          Lesser General Public License for more details. <br>
    027 * <br>
    028 *          You should have received a copy of the GNU Lesser General Public
    029 *          License along with this library; if not see
    030 *          <a href='http://www.gnu.org/licenses/'>http://www.gnu.org/licenses/</a>.
    031 * @param <V> Variable
    032 * @param <T> Value
    033 */
    034public interface ConstraintListener<V extends Variable<V, T>, T extends Value<V, T>> {
    035    /**
    036     * Called by the constraint, before a value is assigned to its variable.
    037     *
    038     * @param assignment current assignment
    039     * @param iteration
    040     *            current iteration
    041     * @param constraint
    042     *            source constraint
    043     * @param assigned
    044     *            value which will be assigned to its variable (
    045     *            {@link Value#variable()})
    046     * @param unassigned
    047     *            set of conflicting values which will be unassigned by the
    048     *            constraint before it assigns the given value
    049     */
    050    public void constraintBeforeAssigned(Assignment<V, T> assignment, long iteration, Constraint<V, T> constraint, T assigned, Set<T> unassigned);
    051
    052    /**
    053     * Called by the constraint, after a value is assigned to its variable.
    054     *
    055     * @param assignment current assignment
    056     * @param iteration
    057     *            current iteration
    058     * @param constraint
    059     *            source constraint
    060     * @param assigned
    061     *            value which was assigned to its variable (
    062     *            {@link Value#variable()})
    063     * @param unassigned
    064     *            set of conflicting values which were unassigned by the
    065     *            constraint before it assigned the given value
    066     */
    067    public void constraintAfterAssigned(Assignment<V, T> assignment, long iteration, Constraint<V, T> constraint, T assigned, Set<T> unassigned);
    068}