001/* Copyright (C) 2013 TU Dortmund 002 * This file is part of AutomataLib, http://www.automatalib.net/. 003 * 004 * AutomataLib is free software; you can redistribute it and/or 005 * modify it under the terms of the GNU Lesser General Public 006 * License version 3.0 as published by the Free Software Foundation. 007 * 008 * AutomataLib is distributed in the hope that it will be useful, 009 * but WITHOUT ANY WARRANTY; without even the implied warranty of 010 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 011 * Lesser General Public License for more details. 012 * 013 * You should have received a copy of the GNU Lesser General Public 014 * License along with AutomataLib; if not, see 015 * http://www.gnu.de/documents/lgpl.en.html. 016 */ 017package net.automatalib.automata.transout.impl.compact; 018 019import java.util.List; 020 021import net.automatalib.automata.base.compact.AbstractCompactDeterministic; 022import net.automatalib.automata.dot.DOTHelperMealy; 023import net.automatalib.automata.dot.DOTPlottableAutomaton; 024import net.automatalib.automata.graphs.TransitionEdge; 025import net.automatalib.automata.transout.MutableMealyMachine; 026import net.automatalib.automata.transout.abstractimpl.AbstractMealyMachine; 027import net.automatalib.automata.transout.abstractimpl.AbstractTransOutAutomaton; 028import net.automatalib.graphs.dot.GraphDOTHelper; 029import net.automatalib.words.Alphabet; 030import net.automatalib.words.Word; 031 032public class CompactMealy<I, O> extends 033 AbstractCompactDeterministic<I, CompactMealyTransition<O>, Void, O> implements 034 MutableMealyMachine<Integer, I, CompactMealyTransition<O>, O>, DOTPlottableAutomaton<Integer,I,CompactMealyTransition<O>> { 035 036 037 038 public CompactMealy(Alphabet<I> alphabet, float resizeFactor) { 039 super(alphabet, resizeFactor); 040 } 041 042 public CompactMealy(Alphabet<I> alphabet, int stateCapacity, 043 float resizeFactor) { 044 super(alphabet, stateCapacity, resizeFactor); 045 } 046 047 public CompactMealy(Alphabet<I> alphabet, int stateCapacity) { 048 super(alphabet, stateCapacity); 049 } 050 051 public CompactMealy(Alphabet<I> alphabet) { 052 super(alphabet); 053 } 054 055 /* 056 * (non-Javadoc) 057 * @see net.automatalib.automata.concepts.TransitionOutput#getTransitionOutput(java.lang.Object) 058 */ 059 @Override 060 public O getTransitionOutput(CompactMealyTransition<O> transition) { 061 return transition.getOutput(); 062 } 063 064 /* 065 * (non-Javadoc) 066 * @see net.automatalib.automata.MutableAutomaton#setTransitionProperty(java.lang.Object, java.lang.Object) 067 */ 068 @Override 069 public void setTransitionProperty(CompactMealyTransition<O> transition, 070 O property) { 071 transition.setOutput(property); 072 } 073 074 /* 075 * (non-Javadoc) 076 * @see net.automatalib.automata.transout.TransitionOutputAutomaton#getOutput(java.lang.Object, java.lang.Object) 077 */ 078 @Override 079 public O getOutput(Integer state, I input) { 080 return AbstractTransOutAutomaton.getOutput(this, state, input); 081 } 082 083 /* 084 * (non-Javadoc) 085 * @see net.automatalib.automata.transout.TransitionOutputAutomaton#trace(java.lang.Iterable, java.util.List) 086 */ 087 @Override 088 public void trace(Iterable<I> input, List<O> output) { 089 AbstractTransOutAutomaton.trace(this, input, output); 090 } 091 092 /* 093 * (non-Javadoc) 094 * @see net.automatalib.automata.transout.TransitionOutputAutomaton#trace(java.lang.Object, java.lang.Iterable, java.util.List) 095 */ 096 @Override 097 public void trace(Integer state, Iterable<I> input, List<O> output) { 098 AbstractTransOutAutomaton.trace(this, state, input, output); 099 } 100 101 /* 102 * (non-Javadoc) 103 * @see net.automatalib.automata.concepts.SuffixOutput#computeSuffixOutput(java.lang.Iterable, java.lang.Iterable) 104 */ 105 @Override 106 public Word<O> computeSuffixOutput(Iterable<I> prefix, Iterable<I> suffix) { 107 return AbstractTransOutAutomaton.computeSuffixOutput(this, prefix, suffix); 108 } 109 110 /* 111 * (non-Javadoc) 112 * @see net.automatalib.automata.concepts.Output#computeOutput(java.lang.Iterable) 113 */ 114 @Override 115 public Word<O> computeOutput(Iterable<I> input) { 116 return AbstractTransOutAutomaton.computeOutput(this, input); 117 } 118 119 /* 120 * (non-Javadoc) 121 * @see net.automatalib.ts.UniversalTransitionSystem#getTransitionProperty(java.lang.Object) 122 */ 123 @Override 124 public O getTransitionProperty(CompactMealyTransition<O> transition) { 125 return AbstractMealyMachine.getTransitionProperty(this, transition); 126 } 127 128 /* 129 * (non-Javadoc) 130 * @see net.automatalib.automata.concepts.MutableTransitionOutput#setTransitionOutput(java.lang.Object, java.lang.Object) 131 */ 132 @Override 133 public void setTransitionOutput(CompactMealyTransition<O> transition, 134 O output) { 135 transition.setOutput(output); 136 } 137 138 /* 139 * (non-Javadoc) 140 * @see net.automatalib.automata.base.compact.AbstractCompactDeterministic#getIntSuccessor(java.lang.Object) 141 */ 142 @Override 143 public int getIntSuccessor(CompactMealyTransition<O> transition) { 144 return transition.getSuccId(); 145 } 146 147 /* 148 * (non-Javadoc) 149 * @see net.automatalib.automata.base.compact.AbstractCompactDeterministic#getStateProperty(int) 150 */ 151 @Override 152 public Void getStateProperty(int stateId) { 153 return null; 154 } 155 156 /* 157 * (non-Javadoc) 158 * @see net.automatalib.automata.base.compact.AbstractCompactDeterministic#getStateProperty(java.lang.Integer) 159 */ 160 @Override 161 public Void getStateProperty(Integer state) { 162 return null; 163 } 164 165 /* 166 * (non-Javadoc) 167 * @see net.automatalib.automata.base.compact.AbstractCompactDeterministic#createTransition(int, java.lang.Object) 168 */ 169 @Override 170 public CompactMealyTransition<O> createTransition(int succId, O property) { 171 return new CompactMealyTransition<O>(succId, property); 172 } 173 174 /* 175 * (non-Javadoc) 176 * @see net.automatalib.automata.base.compact.AbstractCompactDeterministic#copyTransition(java.lang.Object, int) 177 */ 178 @Override 179 public CompactMealyTransition<O> copyTransition( 180 CompactMealyTransition<O> trans, int succId) { 181 return new CompactMealyTransition<O>(succId, trans.getOutput()); 182 } 183 184 /* 185 * (non-Javadoc) 186 * @see net.automatalib.automata.base.compact.AbstractCompactDeterministic#setStateProperty(int, java.lang.Object) 187 */ 188 @Override 189 public void setStateProperty(int state, Void property) { 190 } 191 192 /* 193 * (non-Javadoc) 194 * @see net.automatalib.automata.dot.DOTPlottableAutomaton#getDOTHelper() 195 */ 196 @Override 197 public GraphDOTHelper<Integer, TransitionEdge<I, CompactMealyTransition<O>>> getDOTHelper() { 198 return new DOTHelperMealy<>(this); 199 } 200 201}