diff options
author | René den Hertog | 2017-10-26 17:34:51 +0200 |
---|---|---|
committer | René den Hertog | 2017-10-26 17:34:51 +0200 |
commit | ac914c719d401c44cb2633127952b022bf563ff3 (patch) | |
tree | f7d2399b2ab6cddb86aa996096581a397ff407b9 /assignments/assignment2/Bounded Retransmission Protocol Tester/Source/brpcompare/BRPCompare.java | |
parent | Finish assignment 2, part 1 (diff) |
'Bounded Retransmission Protocol' Blob
Diffstat (limited to 'assignments/assignment2/Bounded Retransmission Protocol Tester/Source/brpcompare/BRPCompare.java')
-rwxr-xr-x | assignments/assignment2/Bounded Retransmission Protocol Tester/Source/brpcompare/BRPCompare.java | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/assignments/assignment2/Bounded Retransmission Protocol Tester/Source/brpcompare/BRPCompare.java b/assignments/assignment2/Bounded Retransmission Protocol Tester/Source/brpcompare/BRPCompare.java new file mode 100755 index 0000000..78d822b --- /dev/null +++ b/assignments/assignment2/Bounded Retransmission Protocol Tester/Source/brpcompare/BRPCompare.java @@ -0,0 +1,38 @@ +package brpcompare; + +import com.google.common.collect.ImmutableSet; +import net.automatalib.util.automata.Automata; +import net.automatalib.words.Word; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Paths; +import java.util.Collection; + +/** + * Created by petra on 14-12-16. + */ +public class BRPCompare { + + public static void main(String[] args) throws IOException { +// String model1 = "/hypothesis0.dot", +// model2 = "/hypothesis1.dot"; + String model1 = "/Final Model Of " + args[0] + ".dot", + model2 = "/Final Model Of Reference.dot"; + Collection<String> inputAlphabet = ImmutableSet.of("IACK", "IREQ_0_0_0", "IREQ_0_0_1", "IREQ_0_1_0", "IREQ_0_1_1", "IREQ_1_0_0", "IREQ_1_0_1", "IREQ_1_1_0", "IREQ_1_1_1", "ISENDFRAME", "ITIMEOUT"); + + GraphvizParser p = new GraphvizParser(Paths.get(new File("").getAbsolutePath().concat(model1))); + GraphvizParser p2 = new GraphvizParser(Paths.get(new File("").getAbsolutePath().concat(model2))); + try { + Word<String> compareResult = Automata.findSeparatingWord(p.createMachine(), p2.createMachine(), inputAlphabet); + if(compareResult == null) { + System.out.println("The automata are equal!"); + } else { + System.out.println("The automata are not equal! A counterexample is: " + compareResult); + } + } catch (NullPointerException e) { + e.printStackTrace(); + System.err.println("Did you compare with the right input alphabet?"); + } + } +} |