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