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