From ac914c719d401c44cb2633127952b022bf563ff3 Mon Sep 17 00:00:00 2001 From: René den Hertog Date: Thu, 26 Oct 2017 17:34:51 +0200 Subject: 'Bounded Retransmission Protocol' Blob --- .../Source/brpcompare/BRPCompare.java | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 assignments/assignment2/Bounded Retransmission Protocol Tester/Source/brpcompare/BRPCompare.java (limited to 'assignments/assignment2/Bounded Retransmission Protocol Tester/Source/brpcompare/BRPCompare.java') 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 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 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?"); + } + } +} -- cgit v1.2.3