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