Example #1
0
        private static void Main()
        {
            List <DeterministicFiniteAutomaton> plants;
            List <DeterministicFiniteAutomaton> specs;

            // Choose one option below
            ITL(out plants, out specs);
            //FSM(out plants, out specs);
            //ClusterTool(3, out plants, out specs);
            //ClusterTool(4, out plants, out specs);
            //ClusterTool(5, out plants, out specs);

            Console.WriteLine("Supervisor:");
            var timer = new Stopwatch(); // to measure time

            timer.Start();
            // computes the monolithic supervisor and stores the resulting automaton in 'sup'
            var sup = DeterministicFiniteAutomaton.MonolithicSupervisor(plants, specs, true);

            timer.Stop();

            // shows informations about supervisor and the elapsed time
            Console.WriteLine("\tStates: {0}", sup.Size);
            Console.WriteLine("\tTransitions: {0}", sup.Transitions.Count());
            Console.WriteLine("\tComputation Time: {0}", timer.ElapsedMilliseconds / 1000.0);

            // this is used to prevent the program from closing immediately
            Console.ReadLine();
        }
        private MyGraph MyGraph_Setup(DeterministicFiniteAutomaton dfa)
        {
            var dataGraph = new MyGraph();

            for (uint i = 0; i < dfa.States; i++)
            {
                var dataVertex = new DataVertex("q" + i.ToString())
                {
                    ID = i
                };
                dataGraph.AddVertex(dataVertex);
            }

            var vlist = dataGraph.Vertices.ToList();

            for (uint i = 0; i < dfa.States; i++)
            {
                for (uint j = 0; j < dfa.Alphabet; j++)
                {
                    var dataEdge = new DataEdge(vlist[(int)i], vlist[(int)dfa.GetNextState(i, j)])
                    {
                        Text = j.ToString()
                    };
                }
            }

            return(dataGraph);
        }
        public GraphWindow(DeterministicFiniteAutomaton dfa)
        {
            InitializeComponent();

            zoomctrl.ZoomToFill();

            MyGraphArea_Setup(dfa);
        }
Example #4
0
        private static void Methods()
        {
            List <DeterministicFiniteAutomaton> plants, specs;

            FSM(out plants, out specs);

            Console.WriteLine("\nFSM\n");

            var Plant         = DeterministicFiniteAutomaton.ParallelComposition(plants);
            var Specification = DeterministicFiniteAutomaton.ParallelComposition(specs);
            var K             = Plant.ParallelCompositionWith(Specification);

            Console.WriteLine("\tPlant: {0} states", Plant.Size);
            Console.WriteLine("\tSpecification: {0} states", Specification.Size);
            Console.WriteLine("\tK: {0} states", K.Size);

            // Controllability
            if (K.IsControllable(Plant))
            {
                Console.WriteLine("\tK is controllable");
            }
            else
            {
                Console.WriteLine("\tK is not controllable");
            }

            // Computes the supervisor using the global plant and specification
            var S = DeterministicFiniteAutomaton.MonolithicSupervisor(
                new[] { Plant },         // global plant
                new[] { Specification }, // global specification
                true
                );

            Console.WriteLine("\tSupervisor: {0} states", S.Size);

            // Computes the supervisor using all plants and specifications.
            S = DeterministicFiniteAutomaton.MonolithicSupervisor(plants, specs, true);
            Console.WriteLine("\tSupervisor (method 2): {0} states", S.Size);

            var proj = S.Projection(S.UncontrollableEvents);

            Console.WriteLine("\tProjection: {0} states", proj.Size);

            S.simplifyName("S");
            Console.WriteLine("\tDisabled Events (first 5):");
            ShowDisablement(S, Plant, 5);

            Console.WriteLine("------------------------------------------------------");

            var P = Plant.ProductWith(Specification);

            Console.WriteLine("\tProduct 1: {0} state{1}", P.Size, P.Size > 1 ? "s" : "");
            P = DeterministicFiniteAutomaton.Product(plants);
            Console.WriteLine("\tProduct 2: {0} state{1}", P.Size, P.Size > 1 ? "s" : "");
            P = Plant.ProductWith(specs);
            Console.WriteLine("\tProduct 3: {0} state{1}", P.Size, P.Size > 1 ? "s" : "");
        }
Example #5
0
        private static void HandlingFiles()
        {
            List <DeterministicFiniteAutomaton> plants, specs;

            FSM(out plants, out specs);

            var robot = plants.Where(s => s.Name == "Robot").First();

            var Plant         = DeterministicFiniteAutomaton.ParallelComposition(plants);
            var Specification = DeterministicFiniteAutomaton.ParallelComposition(specs);

            // Exporting a automaton to a ADS file (TCT)
            robot.ToAdsFile("ROBOT.ADS");

            DeterministicFiniteAutomaton.ToAdsFile(
                new[] { Plant, Specification },
                new[] { "G.ADS", "E.ADS" }
                );

            // Notice: Export all automata calling the method 'ToAdsFile' just once.
            // This is necessary to generate unique number for each event.

            // Plant.ToAdsFile("G.ADS");
            // Specification.ToAdsFile("E.ADS");

            // The code above can generate unexpected results because differents events can receive
            // a same number when exported to ADS files.

            // -------------------------------------------------------------

            // Reading a automaton from a ADS file
            robot = DeterministicFiniteAutomaton.FromAdsFile("ROBOT.ADS");

            // Exporting to a WMod File (Supremica)
            DeterministicFiniteAutomaton.ToWmodFile("FSM.wmod", plants, specs);

            // Importing plants and specifications from WMod file
            // (Will be saved in plants and specs)
            DeterministicFiniteAutomaton.FromWmodFile("FSM.wmod", out plants, out specs);

            // Exporting to a XML File
            robot.ToXMLFile("robot.xml");

            // Building a automaton from a xml file
            robot = DeterministicFiniteAutomaton.FromXMLFile("robot.xml");

            // Serializes the automaton to the file (stores in the file (binary mode)).
            Plant.SerializeAutomaton("Plant.bin");

            Plant = DeterministicFiniteAutomaton.DeserializeAutomaton("Plant.bin");

            // If you wish view some automaton you can use:
            plants.ForEach(g => g.drawSVGFigure(null, false));
        }
        public void TestEvenExample()
        {
            var s1 = new State("S1");
            var s2 = new State("S2");
            var i0 = new Symbol("0");
            var i1 = new Symbol("1");

            var states = new HashSet <State> {
                s1, s2
            };
            var alphabet = new Alphabet(new HashSet <Symbol> {
                i0, i1
            });
            var acceptStates = new HashSet <State> {
                s1
            };
            var transitionFunction = new DeterministicFiniteTransitionFunction(new HashSet <DeterministicFinitePartialTransitionFunction>
            {
                new DeterministicFinitePartialTransitionFunction(s1, i0, s2),
                new DeterministicFinitePartialTransitionFunction(s1, i1, s1),
                new DeterministicFinitePartialTransitionFunction(s2, i0, s1),
                new DeterministicFinitePartialTransitionFunction(s2, i1, s2)
            });

            // Even number of zeros
            var automaton = new DeterministicFiniteAutomaton(
                states,
                alphabet,
                transitionFunction,
                s1,
                acceptStates
                );


            var negative = Word.Parse("0101010001001101", alphabet);
            var positive = Word.Parse("010011101010", alphabet);

            Assert.False(automaton.Accepts(negative), "The automaton was not expected to accept an odd number of zeros");
            Assert.True(automaton.Accepts(positive), "The automaton was expected to accept an even number of zeros");

            for (var i = 0; i < 10; i++)
            {
                var unknown = Word.Parse(string.Join("", Enumerable.Range(1, Random.Next(20)).Select(_ => Random.Next(2))), alphabet);

                if (unknown.InputSymbols.Count(symbol => symbol.Value.Equals("0")) % 2 == 0)
                {
                    Assert.True(automaton.Accepts(unknown));
                }
                else
                {
                    Assert.False(automaton.Accepts(unknown));
                }
            }
        }
    public DeterministicFiniteAutomaton <S, T> Minimize()
    {
        var  dic     = new Dictionary <Vertex <DirectedGraph <S, IEnumerable <T>?>, S, IEnumerable <T>?>, Vertex <DirectedGraph <S, IEnumerable <T>?>, S, IEnumerable <T>?> >();
        var  copy    = new DirectedGraph <S, IEnumerable <T>?>();
        bool changes = true;

        foreach (var v in _graph.Vertices)
        {
            dic[v] = copy.AddVertex(v.Data);
        }

        foreach (var e in _graph.Edges)
        {
            copy.AddEdge(dic[e.From], dic[e.To]).Data = e.Data;
        }

        var accepted = _accepted.Select(a => dic[a]);
        var start    = dic[Start];

        while (changes)
        {
            changes = copy.RemoveVerticesWhere(v => (v.OutDegree == 0 && !accepted.Contains(v)) ||
                                               (v.InDegree == 0 && !start.Equals(v))) > 0;

            foreach (var e in copy.Edges)
            {
                if (e.Data is null)
                {
                    if (!e.IsLoop)
                    {
                        foreach (var end in e.To.OutboundEdges.ToArray())
                        {
                            copy.AddEdge(e.From, end.To).Data = end.Data;
                        }
                    }

                    e.Remove();

                    changes = true;
                }
            }
        }

        var dfa = new DeterministicFiniteAutomaton <S, T>(copy, start);

        foreach (var a in accepted)
        {
            dfa.Accepted[a] = true;
        }

        return(dfa);
    }
Example #8
0
        private static void Methods()
        {
            FSM(out var plants, out var specs);

            Console.WriteLine("\nFSM\n");

            var Plant         = DeterministicFiniteAutomaton.ParallelComposition(plants);
            var Specification = DeterministicFiniteAutomaton.ParallelComposition(specs);
            var K             = Plant.ParallelCompositionWith(Specification);

            Console.WriteLine($"\tPlant: {Plant.Size} states");
            Console.WriteLine($"\tSpecification: {Specification.Size} states");
            Console.WriteLine($"\tK: {K.Size} states");

            // Controllability
            Console.WriteLine(K.IsControllable(Plant) ? "\tK is controllable" : "\tK is not controllable");

            // Computes the supervisor using the global plant and specification
            var S = DeterministicFiniteAutomaton.MonolithicSupervisor(
                new[] { Plant }, // global plant
                new[] { Specification }
                );

            Console.WriteLine($"\tSupervisor: {S.Size} states");

            // Computes the supervisor using all plants and specifications.
            S = DeterministicFiniteAutomaton.MonolithicSupervisor(plants, specs);
            Console.WriteLine($"\tSupervisor (method 2): {S.Size} states");

            var proj = S.Projection(S.UncontrollableEvents);

            Console.WriteLine($"\tProjection: {proj.Size} states");

            S = S.SimplifyStatesName();
            Console.WriteLine("\tDisabled Events (first 5):");
            ShowDisablement(S, Plant, 5);

            Console.WriteLine("------------------------------------------------------");

            var P = Plant.ProductWith(Specification);

            Console.WriteLine($"\tProduct 1: {P.Size} state{(P.Size > 1 ? "s" : "")}");
            P = DeterministicFiniteAutomaton.Product(plants);
            Console.WriteLine($"\tProduct 2: {P.Size} state{(P.Size > 1 ? "s" : "")}");
            P = Plant.ProductWith(specs);
            Console.WriteLine($"\tProduct 3: {P.Size} state{(P.Size > 1 ? "s" : "")}");
        }
Example #9
0
        private static void ComputingMonolithicSupervisor()
        {
            // Choose one option below
            ClusterTool(8, out var plants, out var specs);

            Console.WriteLine("Monolithic Supervisor:");
            var timer = new Stopwatch(); // to measure time

            timer.Start();
            // computes the monolithic supervisor and stores the resulting automaton in 'sup'
            var sup = DeterministicFiniteAutomaton.MonolithicSupervisor(plants, specs, true);

            timer.Stop();

            // shows information about supervisor and the elapsed time
            Console.WriteLine("\tStates: {0}", sup.Size);
            Console.WriteLine("\tTransitions: {0}", sup.Transitions.Count());
            Console.WriteLine("\tComputation Time: {0}", timer.ElapsedMilliseconds / 1000.0);
        }
Example #10
0
        private static void ShowDisablement(DeterministicFiniteAutomaton S, DeterministicFiniteAutomaton G, int limit)
        {
            var statesAndEventsList = S.DisabledEvents(G);
            int i = 0;

            foreach (var pairStateEventList in statesAndEventsList)
            {
                Console.WriteLine("\tState: {0}", pairStateEventList.Key.ToString());

                foreach (var _event in pairStateEventList.Value)
                {
                    Console.WriteLine("\t\tEvent: {0}", _event.ToString());
                }
                Console.Write("\n");

                if (++i >= limit)
                {
                    break;
                }
            }
        }
Example #11
0
        private static void ComputingModularSupervisor()
        {
            // Choose one option below
            ITL(out var plants, out var specs);

            Console.WriteLine("Modular Supervisor:");
            var timer = new Stopwatch(); // to measure time

            timer.Start();
            // computes the monolithic supervisor and stores the resulting automaton in 'sup'
            var sups = DeterministicFiniteAutomaton.LocalModularSupervisor(plants, specs);

            timer.Stop();

            foreach (var s in sups)
            {
                Console.WriteLine("\tSupervisor: {0}", s);
                Console.WriteLine("\t-States: {0}", s.Size);
                Console.WriteLine("\t-Transitions: {0}", s.Transitions.Count());
            }
            Console.WriteLine("\tComputation Time: {0}", timer.ElapsedMilliseconds / 1000.0);
        }
        private void MyGraphArea_Setup(DeterministicFiniteAutomaton dfa)
        {
            var logicCore = new MyGXLogicCore()
            {
                Graph = MyGraph_Setup(dfa)
            };

            logicCore.DefaultLayoutAlgorithm = LayoutAlgorithmTypeEnum.KK;

            logicCore.DefaultLayoutAlgorithmParams = logicCore.AlgorithmFactory.CreateLayoutParameters(LayoutAlgorithmTypeEnum.KK);

            ((KKLayoutParameters)logicCore.DefaultLayoutAlgorithmParams).MaxIterations = (int)(dfa.States * dfa.States);

            logicCore.DefaultOverlapRemovalAlgorithm = OverlapRemovalAlgorithmTypeEnum.FSA;

            logicCore.DefaultOverlapRemovalAlgorithmParams.HorizontalGap = 50;
            logicCore.DefaultOverlapRemovalAlgorithmParams.VerticalGap   = 50;

            logicCore.DefaultEdgeRoutingAlgorithm = EdgeRoutingAlgorithmTypeEnum.SimpleER;

            logicCore.AsyncAlgorithmCompute = false;

            Area.LogicCore = logicCore;
        }
Example #13
0
        static void Main(string[] args)
        {
            string           input          = "aa";
            string           Alphabet       = "ab";
            string           RegEx          = "a?b";
            List <string>    RegularGrammar = new List <string>();
            HashSet <string> words          = new HashSet <string>();

            words.Add("abbca");
            words.Add("abb");
            words.Add("abc");
            words.Add("c");

            RegularGrammar.Add("<S> ::= 'abc'<A> | 'b'<B>");
            RegularGrammar.Add("<A> ::= 'bbaa'<B> | 'ε'");
            RegularGrammar.Add("<B> ::= 'a'<A> | 'bb'");

            AutomataBuilder builder = new AutomataBuilder();
            NondeterministicFiniteAutomaton NFA1 = builder.BuildAutomatonFromRegularExpression(RegEx, Alphabet);
            NondeterministicFiniteAutomaton NFA3 = builder.BuildAutomatonFromRegularGrammar(RegularGrammar);
            NondeterministicFiniteAutomaton NFA4 = builder.BuildAutomatonFronDerivationOfRegularExpression(words);
            //NFA4.DeleteEpsilonTransitions();
            DeterministicFiniteAutomaton DFA4 = NFA4.ConvertToDeterministicFiniteAutomaton();
            string dotcodeDfa4 = DFA4.GetDotSourceCode();
            string dotcodeNfa4 = NFA4.GetDotSourceCode();
            string dotcode     = NFA3.GetDotSourceCode();
            string dotcodeNFA1 = NFA1.GetDotSourceCode();
            DeterministicFiniteAutomaton DFA1 = NFA1.ConvertToDeterministicFiniteAutomaton();
            string       dotcodeDfa1          = DFA1.GetDotSourceCode();
            List <State> states = new List <State>();

            /*states.Add(new State(1, "q0", true, false));
             * states.Add(new State(2, "q1", false, false));
             * states.Add(new State(3, "q2", false, false));
             * states.Add(new State(4, "q3", false, false));
             * states.Add(new State(5, "q4", false, false));
             * states.Add(new State(6, "q5", false, false));
             * states.Add(new State(7, "q6", false, false));
             * states.Add(new State(8, "q7", false, true));
             * states.Add(new State(9, "q8", false, true));
             * states.Add(new State(10, "q9", false, false));
             * states.Add(new State(11, "q10", false, false));
             * states.Add(new State(12, "q11", false, true));
             * states.Add(new State(13, "q12", false, false));*/
            states.Add(new State(1, "q0", false, false));
            states.Add(new State(2, "q1", false, false));
            states.Add(new State(3, "q2", false, false));
            states.Add(new State(4, "q3", false, true));
            states.Add(new State(5, "q4", true, false));
            states.Add(new State(6, "q5", false, false));
            states.Add(new State(7, "q6", false, false));
            states.Add(new State(8, "q7", false, true));



            List <DeltaFunctionTriplet> dft = new List <DeltaFunctionTriplet>();

            /*dft.Add(new DeltaFunctionTriplet(1, 'a', 3));
             * dft.Add(new DeltaFunctionTriplet(3, 'a', 2));
             * dft.Add(new DeltaFunctionTriplet(2, 'a', 4));
             * dft.Add(new DeltaFunctionTriplet(2, 'a', 5));
             * dft.Add(new DeltaFunctionTriplet(2, 'a', 6));
             * dft.Add(new DeltaFunctionTriplet(5, 'a', 7));
             * dft.Add(new DeltaFunctionTriplet(6, 'a', 8));
             * dft.Add(new DeltaFunctionTriplet(6, 'a', 9));
             * dft.Add(new DeltaFunctionTriplet(13, 'a', 11));*/
            dft.Add(new DeltaFunctionTriplet(1, 'b', 5));
            dft.Add(new DeltaFunctionTriplet(1, 'a', 2));
            dft.Add(new DeltaFunctionTriplet(2, 'a', 6));
            dft.Add(new DeltaFunctionTriplet(2, 'b', 3));
            dft.Add(new DeltaFunctionTriplet(3, 'a', 4));
            dft.Add(new DeltaFunctionTriplet(3, 'b', 7));
            dft.Add(new DeltaFunctionTriplet(4, 'a', 8));
            dft.Add(new DeltaFunctionTriplet(4, 'b', 4));
            dft.Add(new DeltaFunctionTriplet(5, 'a', 6));
            dft.Add(new DeltaFunctionTriplet(5, 'b', 1));
            dft.Add(new DeltaFunctionTriplet(6, 'a', 2));
            dft.Add(new DeltaFunctionTriplet(6, 'b', 7));
            dft.Add(new DeltaFunctionTriplet(7, 'a', 8));
            dft.Add(new DeltaFunctionTriplet(7, 'b', 3));
            dft.Add(new DeltaFunctionTriplet(8, 'a', 8));
            dft.Add(new DeltaFunctionTriplet(8, 'b', 4));



            SortedList <int, List <int> > EpsilonTransition = new SortedList <int, List <int> >();

            /*EpsilonTransition.Add(1, new List<int> { 2 });
             * EpsilonTransition.Add(4, new List<int> { 7 });
             * EpsilonTransition.Add(7, new List<int> { 12 });
             * EpsilonTransition.Add(8, new List<int> { 10, 12 });
             * EpsilonTransition.Add(9, new List<int> { 11 });
             * EpsilonTransition.Add(10, new List<int> { 12 });*/
            EpsilonTransition.Add(4, new List <int> {
                3
            });
            EpsilonTransition.Add(3, new List <int> {
                2
            });

            DeterministicFiniteAutomaton DFA = new DeterministicFiniteAutomaton(states, Alphabet, dft);

            DFA.DeleteEquivalentStates();
            string test = DFA.GetDotSourceCode();
            NondeterministicFiniteAutomaton NFA = new NondeterministicFiniteAutomaton(states, Alphabet, dft, EpsilonTransition);

            if (NFA.Accepts(input))
            {
                Console.WriteLine("Prijima");
            }
            else
            {
                Console.WriteLine("Neprijima");
            }

            string dot = NFA.GetDotSourceCode();

            NFA.DeleteEpsilonTransitions();
            DeterministicFiniteAutomaton DFA2 = NFA.ConvertToDeterministicFiniteAutomaton();
            //DFA.DeleteEquivalentStates();
            //DFA.Save2Xml();
            //NFA.Save2Xml("test.xml");
            //NFA.DeleteUnnecessaryStates();
            //NFA.DeleteUnattainableStates();

            NondeterministicFiniteAutomaton NFA2 = XmlAutomataReader.ReadFromXml("test.xml");

            /* states.Add(new State(1, "q0", true, true));
             * states.Add(new State(2, "q1", false, false));
             * states.Add(new State(3, "q2", false, false));
             * states.Add(new State(4, "q3", false, true));
             * states.Add(new State(5, "q4", false, true));
             *
             * List<DeltaFunctionTriplet> dft = new List<DeltaFunctionTriplet>();
             * dft.Add(new DeltaFunctionTriplet(1, 'b', 1));
             * dft.Add(new DeltaFunctionTriplet(1, 'a', 2));
             * dft.Add(new DeltaFunctionTriplet(2, 'a', 4));
             * dft.Add(new DeltaFunctionTriplet(2, 'b', 5));
             * dft.Add(new DeltaFunctionTriplet(3, 'a', 1));
             * dft.Add(new DeltaFunctionTriplet(3, 'b', 4));
             * dft.Add(new DeltaFunctionTriplet(4, 'a', 1));
             * dft.Add(new DeltaFunctionTriplet(4, 'b', 3));
             * dft.Add(new DeltaFunctionTriplet(5, 'a', 4));
             * dft.Add(new DeltaFunctionTriplet(5, 'b', 5));
             *
             * DeterministicFiniteAutomaton DFA = new DeterministicFiniteAutomaton(states, Alphabet, dft);
             * if(DFA.Accepts(input))
             * {
             *   Console.WriteLine("prijima");
             * }
             * else
             * {
             *   Console.WriteLine("neprijima");
             * }*/
        }
Example #14
0
        private static void FSM(out List <DeterministicFiniteAutomaton> plants, out List <DeterministicFiniteAutomaton> specs)
        {
            var s = new List <State>(); // or State[] s = new State[6];

            for (int i = 0; i < 6; i++)
            {
                if (i == 0)
                {
                    s.Add(new State(i.ToString(), Marking.Marked));
                }
                else
                {
                    s.Add(new State(i.ToString(), Marking.Unmarked));
                }
            }

            // Creating Events (0 to 100)
            var e = new List <Event>(); // or Event[] e = new Event[100];

            for (var i = 0; i < 100; ++i)
            {
                if (i % 2 != 0)
                {
                    e.Add(new Event(String.Format("e{0}", i), Controllability.Controllable));
                }
                else
                {
                    e.Add(new Event(String.Format("e{0}", i), Controllability.Uncontrollable));
                }
            }

            //----------------------------
            // Plants
            //----------------------------


            // C1
            var transC1 = new List <Transition>();

            transC1.Add(new Transition(s[0], e[11], s[1]));
            transC1.Add(new Transition(s[1], e[12], s[0]));

            var c1 = new DeterministicFiniteAutomaton(transC1, s[0], "C1");

            // C2
            var c2 = new DeterministicFiniteAutomaton(
                new[]
            {
                new Transition(s[0], e[21], s[1]),
                new Transition(s[1], e[22], s[0])
            },
                s[0], "C2");

            // Milling
            var milling = new DeterministicFiniteAutomaton(
                new[]
            {
                new Transition(s[0], e[41], s[1]),
                new Transition(s[1], e[42], s[0])
            },
                s[0], "Milling");

            // MP
            var mp = new DeterministicFiniteAutomaton(
                new[]
            {
                new Transition(s[0], e[81], s[1]),
                new Transition(s[1], e[82], s[0])
            },
                s[0], "MP");

            // Lathe
            var lathe = new DeterministicFiniteAutomaton(
                new[]
            {
                new Transition(s[0], e[51], s[1]),
                new Transition(s[1], e[52], s[0]),
                new Transition(s[0], e[53], s[2]),
                new Transition(s[2], e[54], s[0])
            },
                s[0], "Lathe");

            // C3
            var c3 = new DeterministicFiniteAutomaton(
                new[]
            {
                new Transition(s[0], e[71], s[1]),
                new Transition(s[1], e[72], s[0]),
                new Transition(s[0], e[73], s[2]),
                new Transition(s[2], e[74], s[0])
            },
                s[0], "C3");

            // Robot
            var robot = new DeterministicFiniteAutomaton(
                new[]
            {
                new Transition(s[0], e[31], s[1]),
                new Transition(s[1], e[32], s[0]),
                new Transition(s[0], e[33], s[2]),
                new Transition(s[2], e[34], s[0]),
                new Transition(s[0], e[35], s[3]),
                new Transition(s[3], e[36], s[0]),
                new Transition(s[0], e[37], s[4]),
                new Transition(s[4], e[38], s[0]),
                new Transition(s[0], e[39], s[5]),
                new Transition(s[5], e[30], s[0])
            },
                s[0], "Robot");

            // MM
            var mm = new DeterministicFiniteAutomaton(
                new[]
            {
                new Transition(s[0], e[61], s[1]),
                new Transition(s[1], e[63], s[2]),
                new Transition(s[1], e[65], s[3]),
                new Transition(s[2], e[64], s[0]),
                new Transition(s[3], e[66], s[0])
            },
                s[0], "MM");

            //----------------------------
            // Specifications
            //----------------------------

            // E1
            var e1 = new DeterministicFiniteAutomaton(
                new[]
            {
                new Transition(s[0], e[12], s[1]),
                new Transition(s[1], e[31], s[0])
            },
                s[0], "E1");

            // E2
            var e2 = new DeterministicFiniteAutomaton(
                new[]
            {
                new Transition(s[0], e[22], s[1]),
                new Transition(s[1], e[33], s[0])
            },
                s[0], "E2");

            // E5
            var e5 = new DeterministicFiniteAutomaton(
                new[]
            {
                new Transition(s[0], e[36], s[1]),
                new Transition(s[1], e[61], s[0])
            },
                s[0], "E5");

            // E6
            var e6 = new DeterministicFiniteAutomaton(
                new[]
            {
                new Transition(s[0], e[38], s[1]),
                new Transition(s[1], e[63], s[0])
            },
                s[0], "E6");

            // E3
            var e3 = new DeterministicFiniteAutomaton(
                new[]
            {
                new Transition(s[0], e[32], s[1]),
                new Transition(s[1], e[41], s[0]),
                new Transition(s[0], e[42], s[2]),
                new Transition(s[2], e[35], s[0])
            },
                s[0], "E3");

            // E7
            var e7 = new DeterministicFiniteAutomaton(
                new[]
            {
                new Transition(s[0], e[30], s[1]),
                new Transition(s[1], e[71], s[0]),
                new Transition(s[0], e[74], s[2]),
                new Transition(s[2], e[65], s[0])
            },
                s[0], "E7");

            // E8
            var e8 = new DeterministicFiniteAutomaton(
                new[]
            {
                new Transition(s[0], e[72], s[1]),
                new Transition(s[1], e[81], s[0]),
                new Transition(s[0], e[82], s[2]),
                new Transition(s[2], e[73], s[0])
            },
                s[0], "E8");

            // E4
            var e4 = new DeterministicFiniteAutomaton(
                new[]
            {
                new Transition(s[0], e[34], s[1]),
                new Transition(s[1], e[51], s[0]),
                new Transition(s[1], e[53], s[0]),
                new Transition(s[0], e[52], s[2]),
                new Transition(s[2], e[37], s[0]),
                new Transition(s[0], e[54], s[3]),
                new Transition(s[3], e[39], s[0])
            },
                s[0], "E4");

            plants = new[] { c1, c2, milling, lathe, robot, mm, c3, mp }.ToList();
            specs  = new[] { e1, e2, e3, e4, e5, e6, e7, e8 }.ToList();
        }
Example #15
0
        static void Main()
        {
            // creating States (0 to 6)
            var s =
                Enumerable.Range(0, 6)
                    .Select(i =>
                            new State(i.ToString(),
                                i == 0
                                    ? Marking.Marked
                                    : Marking.Unmarked)
                    ).ToArray();

            // Creating Events (0 to 100)
            var e =
                Enumerable.Range(0, 100)
                    .Select(i =>
                        new Event(i.ToString(),
                            i % 2 != 0
                                ? Controllability.Controllable
                                : Controllability.Uncontrollable)
                    ).ToArray();

            //----------------------------
            // Plants
            //----------------------------

            // C1
            var c1 = new DeterministicFiniteAutomaton(
                new[]
                {
                    new Transition(s[0], e[11], s[1]),
                    new Transition(s[1], e[12], s[0])
                },
                s[0], "C1");

            // C2
            var c2 = new DeterministicFiniteAutomaton(
                new[]
                {
                    new Transition(s[0], e[21], s[1]),
                    new Transition(s[1], e[22], s[0])
                },
                s[0], "C2");

            // Milling
            var milling = new DeterministicFiniteAutomaton(
                new[]
                {
                    new Transition(s[0], e[41], s[1]),
                    new Transition(s[1], e[42], s[0])
                },
                s[0], "Milling");

            // MP
            var mp = new DeterministicFiniteAutomaton(
                new[]
                {
                    new Transition(s[0], e[81], s[1]),
                    new Transition(s[1], e[82], s[0])
                },
                s[0], "MP");

            // Lathe
            var lathe = new DeterministicFiniteAutomaton(
                new[]
                {
                    new Transition(s[0], e[51], s[1]),
                    new Transition(s[1], e[52], s[0]),
                    new Transition(s[0], e[53], s[2]),
                    new Transition(s[2], e[54], s[0])
                },
                s[0], "Lathe");

            // C3
            var c3 = new DeterministicFiniteAutomaton(
                new[]
                {
                    new Transition(s[0], e[71], s[1]),
                    new Transition(s[1], e[72], s[0]),
                    new Transition(s[0], e[73], s[2]),
                    new Transition(s[2], e[74], s[0])
                },
                s[0], "C3");

            // Robot
            var robot = new DeterministicFiniteAutomaton(
                new[]
                {
                    new Transition(s[0], e[31], s[1]),
                    new Transition(s[1], e[32], s[0]),
                    new Transition(s[0], e[33], s[2]),
                    new Transition(s[2], e[34], s[0]),
                    new Transition(s[0], e[35], s[3]),
                    new Transition(s[3], e[36], s[0]),
                    new Transition(s[0], e[37], s[4]),
                    new Transition(s[4], e[38], s[0]),
                    new Transition(s[0], e[39], s[5]),
                    new Transition(s[5], e[30], s[0])
                },
                s[0], "Robot");

            // MM
            var mm = new DeterministicFiniteAutomaton(
                new[]
                {
                    new Transition(s[0], e[61], s[1]),
                    new Transition(s[1], e[63], s[2]),
                    new Transition(s[1], e[65], s[3]),
                    new Transition(s[2], e[64], s[0]),
                    new Transition(s[3], e[66], s[0])
                },
                s[0], "MM");

            //----------------------------
            // Specifications
            //----------------------------

            // E1
            var e1 = new DeterministicFiniteAutomaton(
                new[]
                {
                    new Transition(s[0], e[12], s[1]),
                    new Transition(s[1], e[31], s[0])
                },
                s[0], "E1");

            // E2
            var e2 = new DeterministicFiniteAutomaton(
                new[]
                {
                    new Transition(s[0], e[22], s[1]),
                    new Transition(s[1], e[33], s[0])
                },
                s[0], "E2");

            // E5
            var e5 = new DeterministicFiniteAutomaton(
                new[]
                {
                    new Transition(s[0], e[36], s[1]),
                    new Transition(s[1], e[61], s[0])
                },
                s[0], "E5");

            // E6
            var e6 = new DeterministicFiniteAutomaton(
                new[]
                {
                    new Transition(s[0], e[38], s[1]),
                    new Transition(s[1], e[63], s[0])
                },
                s[0], "E6");

            // E3
            var e3 = new DeterministicFiniteAutomaton(
                new[]
                {
                    new Transition(s[0], e[32], s[1]),
                    new Transition(s[1], e[41], s[0]),
                    new Transition(s[0], e[42], s[2]),
                    new Transition(s[2], e[35], s[0])
                },
                s[0], "E3");

            // E7
            var e7 = new DeterministicFiniteAutomaton(
                new[]
                {
                    new Transition(s[0], e[30], s[1]),
                    new Transition(s[1], e[71], s[0]),
                    new Transition(s[0], e[74], s[2]),
                    new Transition(s[2], e[65], s[0])
                },
                s[0], "E7");

            // E8
            var e8 = new DeterministicFiniteAutomaton(
                new[]
                {
                    new Transition(s[0], e[72], s[1]),
                    new Transition(s[1], e[81], s[0]),
                    new Transition(s[0], e[82], s[2]),
                    new Transition(s[2], e[73], s[0])
                },
                s[0], "E8");

            // E4
            var e4 = new DeterministicFiniteAutomaton(
                new[]
                {
                    new Transition(s[0], e[34], s[1]),
                    new Transition(s[1], e[51], s[0]),
                    new Transition(s[1], e[53], s[0]),
                    new Transition(s[0], e[52], s[2]),
                    new Transition(s[2], e[37], s[0]),
                    new Transition(s[0], e[54], s[3]),
                    new Transition(s[3], e[39], s[0])
                },
                s[0], "E4");

            // Computing the confict solving supervisor
            var s78 = DeterministicFiniteAutomaton.MonoliticSupervisor(new[] { c3, mp, mm, robot }, new[] { e7, e8 }, true);

            // Computing the local modular supervisors
            var timer = new Stopwatch();
            timer.Start();
            var sups = DeterministicFiniteAutomaton.LocalModularReducedSupervisor(
                new[] {c1, c2, milling, lathe, robot, mm, c3, mp}, // Plants
                new[] {e1, e2, e3, e4, e5, e6, e7, e8}, // Specifications
                new[] // Confict Solver
                {
                    Tuple.Create(
                        new[] {c3, mp, mm, robot} as IEnumerable<DeterministicFiniteAutomaton>,
                        new[] {e7, e8} as IEnumerable<DeterministicFiniteAutomaton>)
                }).ToArray();
            timer.Stop();

            Console.WriteLine("Computation Time: {0}", timer.ElapsedMilliseconds / 1000.0);

            // Exporting to TCT
            sups[0].Item1.ToAdsFile("S1.ADS", e, 1, 0);

            Console.ReadLine();
        }
Example #16
0
        public static int Count(string pattern, string source, SearchAlgorithm sa)
        {
            int        id  = (int)sa;
            List <int> res = new List <int>();

            if (id == 0)
            {
                res            = ApostolicoCrochemore.Search(pattern, source);
                preProcessTime = ApostolicoCrochemore.preProcessTime;
                searchTime     = ApostolicoCrochemore.searchTime;
                return(res.Count);
            }
            else if (id == 1)
            {
                res            = ApostolicoGiancarlo.Search(pattern, source);
                preProcessTime = ApostolicoGiancarlo.preProcessTime;
                searchTime     = ApostolicoGiancarlo.searchTime;
                return(res.Count);
            }
            else if (id == 2)
            {
                res            = BackwardNondeterministicDawgMatching.Search(pattern, source);
                preProcessTime = BackwardNondeterministicDawgMatching.preProcessTime;
                searchTime     = BackwardNondeterministicDawgMatching.searchTime;
                return(res.Count);
            }
            else if (id == 3)
            {
                res            = BackwardOracleMatching.Search(pattern, source);
                preProcessTime = BackwardOracleMatching.preProcessTime;
                searchTime     = BackwardOracleMatching.searchTime;
                return(res.Count);
            }
            else if (id == 4)
            {
                res            = BerryRavindran.Search(pattern, source);
                preProcessTime = BerryRavindran.preProcessTime;
                searchTime     = BerryRavindran.searchTime;
                return(res.Count);
            }
            else if (id == 5)
            {
                res            = BoyerMoore.Search(pattern, source);
                preProcessTime = BoyerMoore.preProcessTime;
                searchTime     = BoyerMoore.searchTime;
                return(res.Count);
            }
            else if (id == 6)
            {
                res            = BruteForce.Search(pattern, source);
                preProcessTime = BruteForce.preProcessTime;
                searchTime     = BruteForce.searchTime;
                return(res.Count);
            }
            else if (id == 7)
            {
                res            = Colussi.Search(pattern, source);
                preProcessTime = Colussi.preProcessTime;
                searchTime     = Colussi.searchTime;
                return(res.Count);
            }
            else if (id == 8)
            {
                res            = DeterministicFiniteAutomaton.Search(pattern, source);
                preProcessTime = DeterministicFiniteAutomaton.preProcessTime;
                searchTime     = DeterministicFiniteAutomaton.searchTime;
                return(res.Count);
            }
            else if (id == 9)
            {
                res            = ForwardDawgMatching.Search(pattern, source);
                preProcessTime = ForwardDawgMatching.preProcessTime;
                searchTime     = ForwardDawgMatching.searchTime;
                return(res.Count);
            }
            else if (id == 10)
            {
                res            = GalilGiancarlo.Search(pattern, source);
                preProcessTime = GalilGiancarlo.preProcessTime;
                searchTime     = GalilGiancarlo.searchTime;
                return(res.Count);
            }
            else if (id == 11)
            {
                res            = Horspool.Search(pattern, source);
                preProcessTime = Horspool.preProcessTime;
                searchTime     = Horspool.searchTime;
                return(res.Count);
            }
            else if (id == 12)
            {
                res            = KarpRabin.Search(pattern, source);
                preProcessTime = KarpRabin.preProcessTime;
                searchTime     = KarpRabin.searchTime;
                return(res.Count);
            }
            else if (id == 13)
            {
                res            = KMPSkipSearch.Search(pattern, source);
                preProcessTime = KMPSkipSearch.preProcessTime;
                searchTime     = KMPSkipSearch.searchTime;
                return(res.Count);
            }
            else if (id == 14)
            {
                res            = KnuthMorrisPratt.Search(pattern, source);
                preProcessTime = KnuthMorrisPratt.preProcessTime;
                searchTime     = KnuthMorrisPratt.searchTime;
                return(res.Count);
            }
            else if (id == 15)
            {
                res            = MaximalShift.Search(pattern, source);
                preProcessTime = MaximalShift.preProcessTime;
                searchTime     = MaximalShift.searchTime;
                return(res.Count);
            }
            else if (id == 16)
            {
                res            = MorrisPratt.Search(pattern, source);
                preProcessTime = MorrisPratt.preProcessTime;
                searchTime     = MorrisPratt.searchTime;
                return(res.Count);
            }
            else if (id == 17)
            {
                res            = NotSoNaive.Search(pattern, source);
                preProcessTime = NotSoNaive.preProcessTime;
                searchTime     = NotSoNaive.searchTime;
                return(res.Count);
            }
            else if (id == 18)
            {
                res            = OptimalMismatch.Search(pattern, source);
                preProcessTime = OptimalMismatch.preProcessTime;
                searchTime     = OptimalMismatch.searchTime;
                return(res.Count);
            }
            else if (id == 19)
            {
                res            = QuickSearch.Search(pattern, source);
                preProcessTime = QuickSearch.preProcessTime;
                searchTime     = QuickSearch.searchTime;
                return(res.Count);
            }
            else if (id == 20)
            {
                res            = Raita.Search(pattern, source);
                preProcessTime = Raita.preProcessTime;
                searchTime     = Raita.searchTime;
                return(res.Count);
            }
            else if (id == 21)
            {
                res            = ReverseColussi.Search(pattern, source);
                preProcessTime = ReverseColussi.preProcessTime;
                searchTime     = ReverseColussi.searchTime;
                return(res.Count);
            }
            else if (id == 22)
            {
                res            = ReverseFactor.Search(pattern, source);
                preProcessTime = ReverseFactor.preProcessTime;
                searchTime     = ReverseFactor.searchTime;
                return(res.Count);
            }
            else if (id == 23)
            {
                res            = ShiftOr.Search(pattern, source);
                preProcessTime = ShiftOr.preProcessTime;
                searchTime     = ShiftOr.searchTime;
                return(res.Count);
            }
            else if (id == 24)
            {
                res            = Simon.Search(pattern, source);
                preProcessTime = Simon.preProcessTime;
                searchTime     = Simon.searchTime;
                return(res.Count);
            }
            else if (id == 25)
            {
                res            = SkipSearch.Search(pattern, source);
                preProcessTime = SkipSearch.preProcessTime;
                searchTime     = SkipSearch.searchTime;
                return(res.Count);
            }
            else if (id == 26)
            {
                res            = Smith.Search(pattern, source);
                preProcessTime = Smith.preProcessTime;
                searchTime     = Smith.searchTime;
                return(res.Count);
            }
            else if (id == 27)
            {
                res            = StringMatchingonOrderedAlphabets.Search(pattern, source);
                preProcessTime = StringMatchingonOrderedAlphabets.preProcessTime;
                searchTime     = StringMatchingonOrderedAlphabets.searchTime;
                return(res.Count);
            }
            else if (id == 28)
            {
                res            = TunedBoyerMoore.Search(pattern, source);
                preProcessTime = TunedBoyerMoore.preProcessTime;
                searchTime     = TunedBoyerMoore.searchTime;
                return(res.Count);
            }
            else if (id == 29)
            {
                res            = TurboBM.Search(pattern, source);
                preProcessTime = TurboBM.preProcessTime;
                searchTime     = TurboBM.searchTime;
                return(res.Count);
            }
            else if (id == 30)
            {
                res            = TurboReverseFactor.Search(pattern, source);
                preProcessTime = TurboReverseFactor.preProcessTime;
                searchTime     = TurboReverseFactor.searchTime;
                return(res.Count);
            }
            else if (id == 31)
            {
                res            = TwoWay.Search(pattern, source);
                preProcessTime = TwoWay.preProcessTime;
                searchTime     = TwoWay.searchTime;
                return(res.Count);
            }
            else if (id == 32)
            {
                res            = ZhuTakaoka.Search(pattern, source);
                preProcessTime = ZhuTakaoka.preProcessTime;
                searchTime     = ZhuTakaoka.searchTime;
                return(res.Count);
            }
            else if (id == 33)
            {
                res            = NET_IndexOf.Search(pattern, source);
                preProcessTime = NET_IndexOf.preProcessTime;
                searchTime     = NET_IndexOf.searchTime;
                return(res.Count);
            }
            else if (id == 34)
            {
                res            = NET_IndexOf_Ordinal.Search(pattern, source);
                preProcessTime = NET_IndexOf_Ordinal.preProcessTime;
                searchTime     = NET_IndexOf_Ordinal.searchTime;
                return(res.Count);
            }
            else
            {
                return(0);
            }
        }
Example #17
0
        // Creates the plants and specifications of FMS problem.
        // The automata are saved in 'plants' and 'specs'
        private static void FMS(out List <DeterministicFiniteAutomaton> plants, out List <DeterministicFiniteAutomaton> specs)
        {
            var s =
                Enumerable.Range(0, 6)
                .Select(i =>
                        new State(i.ToString(),
                                  i == 0
                                ? Marking.Marked
                                : Marking.Unmarked)
                        ).ToArray();

            // Creating Events (0 to 100)
            var e =
                Enumerable.Range(0, 100)
                .Select(i =>
                        new Event(i.ToString(),
                                  i % 2 != 0
                                ? Controllability.Controllable
                                : Controllability.Uncontrollable)
                        ).ToArray();

            //----------------------------
            // Plants
            //----------------------------


            // C1
            var c1 = new DeterministicFiniteAutomaton(
                new[]
            {
                new Transition(s[0], e[11], s[1]),
                new Transition(s[1], e[12], s[0])
            },
                s[0], "C1");

            // C2
            var c2 = new DeterministicFiniteAutomaton(
                new[]
            {
                new Transition(s[0], e[21], s[1]),
                new Transition(s[1], e[22], s[0])
            },
                s[0], "C2");

            // Milling
            var milling = new DeterministicFiniteAutomaton(
                new[]
            {
                new Transition(s[0], e[41], s[1]),
                new Transition(s[1], e[42], s[0])
            },
                s[0], "Milling");

            // MP
            var mp = new DeterministicFiniteAutomaton(
                new[]
            {
                new Transition(s[0], e[81], s[1]),
                new Transition(s[1], e[82], s[0])
            },
                s[0], "MP");

            // Lathe
            var lathe = new DeterministicFiniteAutomaton(
                new[]
            {
                new Transition(s[0], e[51], s[1]),
                new Transition(s[1], e[52], s[0]),
                new Transition(s[0], e[53], s[2]),
                new Transition(s[2], e[54], s[0])
            },
                s[0], "Lathe");

            // C3
            var c3 = new DeterministicFiniteAutomaton(
                new[]
            {
                new Transition(s[0], e[71], s[1]),
                new Transition(s[1], e[72], s[0]),
                new Transition(s[0], e[73], s[2]),
                new Transition(s[2], e[74], s[0])
            },
                s[0], "C3");

            // Robot
            var robot = new DeterministicFiniteAutomaton(
                new[]
            {
                new Transition(s[0], e[31], s[1]),
                new Transition(s[1], e[32], s[0]),
                new Transition(s[0], e[33], s[2]),
                new Transition(s[2], e[34], s[0]),
                new Transition(s[0], e[35], s[3]),
                new Transition(s[3], e[36], s[0]),
                new Transition(s[0], e[37], s[4]),
                new Transition(s[4], e[38], s[0]),
                new Transition(s[0], e[39], s[5]),
                new Transition(s[5], e[30], s[0])
            },
                s[0], "Robot");

            // MM
            var mm = new DeterministicFiniteAutomaton(
                new[]
            {
                new Transition(s[0], e[61], s[1]),
                new Transition(s[1], e[63], s[2]),
                new Transition(s[1], e[65], s[3]),
                new Transition(s[2], e[64], s[0]),
                new Transition(s[3], e[66], s[0])
            },
                s[0], "MM");

            //----------------------------
            // Specifications
            //----------------------------

            // E1
            var e1 = new DeterministicFiniteAutomaton(
                new[]
            {
                new Transition(s[0], e[12], s[1]),
                new Transition(s[1], e[31], s[0])
            },
                s[0], "E1");

            // E2
            var e2 = new DeterministicFiniteAutomaton(
                new[]
            {
                new Transition(s[0], e[22], s[1]),
                new Transition(s[1], e[33], s[0])
            },
                s[0], "E2");

            // E5
            var e5 = new DeterministicFiniteAutomaton(
                new[]
            {
                new Transition(s[0], e[36], s[1]),
                new Transition(s[1], e[61], s[0])
            },
                s[0], "E5");

            // E6
            var e6 = new DeterministicFiniteAutomaton(
                new[]
            {
                new Transition(s[0], e[38], s[1]),
                new Transition(s[1], e[63], s[0])
            },
                s[0], "E6");

            // E3
            var e3 = new DeterministicFiniteAutomaton(
                new[]
            {
                new Transition(s[0], e[32], s[1]),
                new Transition(s[1], e[41], s[0]),
                new Transition(s[0], e[42], s[2]),
                new Transition(s[2], e[35], s[0])
            },
                s[0], "E3");

            // E7
            var e7 = new DeterministicFiniteAutomaton(
                new[]
            {
                new Transition(s[0], e[30], s[1]),
                new Transition(s[1], e[71], s[0]),
                new Transition(s[0], e[74], s[2]),
                new Transition(s[2], e[65], s[0])
            },
                s[0], "E7");

            // E8
            var e8 = new DeterministicFiniteAutomaton(
                new[]
            {
                new Transition(s[0], e[72], s[1]),
                new Transition(s[1], e[81], s[0]),
                new Transition(s[0], e[82], s[2]),
                new Transition(s[2], e[73], s[0])
            },
                s[0], "E8");

            // E4
            var e4 = new DeterministicFiniteAutomaton(
                new[]
            {
                new Transition(s[0], e[34], s[1]),
                new Transition(s[1], e[51], s[0]),
                new Transition(s[1], e[53], s[0]),
                new Transition(s[0], e[52], s[2]),
                new Transition(s[2], e[37], s[0]),
                new Transition(s[0], e[54], s[3]),
                new Transition(s[3], e[39], s[0])
            },
                s[0], "E4");

            plants = new[] { c1, c2, milling, lathe, robot, mm, c3, mp }.ToList();
            specs  = new[] { e1, e2, e3, e4, e5, e6, e7, e8 }.ToList();
        }
Example #18
0
        // Creates the plants and specifications of Cluster Tools problem.
        // You can choose how many clusters to use.
        // The automata are saved in 'plants' and 'specs'
        private static void ClusterTool(int clusters, out List <DeterministicFiniteAutomaton> plants, out List <DeterministicFiniteAutomaton> specs)
        {
            var s = Enumerable.Range(0, 4).Select(
                k => new State(k.ToString(),
                               k == 0
                        ? Marking.Marked
                        : Marking.Unmarked))
                    .ToArray();

            plants = new List <DeterministicFiniteAutomaton>();
            specs  = new List <DeterministicFiniteAutomaton>();

            int max = clusters;

            var evs = Enumerable.Range(1, max).SelectMany(i => Enumerable.Range(0, 9).Select(
                                                              k => new Event($"{i}|{k}",
                                                                             k % 2 == 0
                        ? Controllability.Uncontrollable
                        : Controllability.Controllable))).ToList();

            for (int i = 1; i <= max; i++)
            {
                var e = Enumerable.Range(0, 9).Select(
                    k => new Event($"{i}|{k}",
                                   k % 2 == 0
                            ? Controllability.Uncontrollable
                            : Controllability.Controllable))
                        .ToArray();

                var Ri = new DeterministicFiniteAutomaton(
                    i != max
                        ? new[]
                {
                    new Transition(s[0], e[1], s[1]),
                    new Transition(s[1], e[2], s[0]),
                    new Transition(s[0], e[3], s[2]),
                    new Transition(s[2], e[4], s[0]),
                    new Transition(s[0], e[5], s[3]),
                    new Transition(s[3], e[6], s[0])
                }
                        : new[]
                {
                    new Transition(s[0], e[1], s[1]),
                    new Transition(s[1], e[2], s[0]),
                    new Transition(s[0], e[5], s[2]),
                    new Transition(s[2], e[4], s[0]),
                },
                    s[0], $"R{i}");

                var Ci = new DeterministicFiniteAutomaton(new[]
                {
                    new Transition(s[0], e[7], s[1]),
                    new Transition(s[1], e[8], s[0]),
                },
                                                          s[0], $"C{i}");

                var Ei = new DeterministicFiniteAutomaton(new[]
                {
                    new Transition(s[0], e[2], s[1]),
                    new Transition(s[1], e[7], s[0]),
                    new Transition(s[0], e[8], s[2]),
                    new Transition(s[2], e[5], s[0])
                },
                                                          s[0], $"E{i}");

                plants.Add(Ri);
                plants.Add(Ci);
                specs.Add(Ei);
            }

            for (int i = 1; i < max; i++)
            {
                var e61 = new Event($"{i}|6",
                                    Controllability.Uncontrollable);
                var e31 = new Event($"{i}|3",
                                    Controllability.Controllable);
                var e12 = new Event($"{i + 1}|1",
                                    Controllability.Controllable);
                var e42 = new Event($"{i + 1}|4",
                                    Controllability.Uncontrollable);

                var Eij = new DeterministicFiniteAutomaton(new[]
                {
                    new Transition(s[0], e61, s[1]),
                    new Transition(s[1], e12, s[0]),
                    new Transition(s[0], e42, s[2]),
                    new Transition(s[2], e31, s[0])
                },
                                                           s[0], $"E{i}_{i + 1}");

                specs.Add(Eij);
            }
        }
        public void TestEnsWithStart()
        {
            var s  = new State("s");
            var q1 = new State("q1");
            var q2 = new State("q2");
            var r1 = new State("r1");
            var r2 = new State("r2");

            var a = new Symbol("a");
            var b = new Symbol("b");

            var states = new HashSet <State> {
                s, q1, q2, r1, r2
            };
            var alphabet = new Alphabet(new HashSet <Symbol> {
                a, b
            });
            var acceptStates = new HashSet <State> {
                q1, r1
            };
            var transitionFunction = new DeterministicFiniteTransitionFunction(new HashSet <DeterministicFinitePartialTransitionFunction>
            {
                new DeterministicFinitePartialTransitionFunction(s, a, q1),
                new DeterministicFinitePartialTransitionFunction(s, b, r1),
                new DeterministicFinitePartialTransitionFunction(q1, a, q1),
                new DeterministicFinitePartialTransitionFunction(q1, b, q2),
                new DeterministicFinitePartialTransitionFunction(q2, b, q2),
                new DeterministicFinitePartialTransitionFunction(q2, a, q1),
                new DeterministicFinitePartialTransitionFunction(r1, b, r1),
                new DeterministicFinitePartialTransitionFunction(r1, a, r2),
                new DeterministicFinitePartialTransitionFunction(r2, a, r2),
                new DeterministicFinitePartialTransitionFunction(r2, b, r1)
            });

            // Ends with the same symbol as it started
            var automaton = new DeterministicFiniteAutomaton(
                states,
                alphabet,
                transitionFunction,
                s,
                acceptStates);


            var negative = Word.Parse("ababbabbab", alphabet);
            var positive = Word.Parse("ababbabbaa", alphabet);

            Assert.False(automaton.Accepts(negative));
            Assert.True(automaton.Accepts(positive));

            for (var i = 0; i < 10; i++)
            {
                var unknown = Word.Parse(string.Join("", Enumerable.Range(1, Random.Next(20)).Select(_ => Random.Next(2) == 1 ? "b" : "a")), alphabet);

                if (unknown.Count() > 0 && unknown.InputSymbols.Peek().Equals(unknown.InputSymbols.ToArray() [unknown.Count() - 1]))
                {
                    Assert.True(automaton.Accepts(unknown));
                }
                else
                {
                    Assert.False(automaton.Accepts(unknown));
                }
            }
        }
Example #20
0
        private static void Main()
        {
            // creating States (0 to 6)
            var s =
                Enumerable.Range(0, 6)
                .Select(i =>
                        new State(i.ToString(),
                                  i == 0
                                ? Marking.Marked
                                : Marking.Unmarked)
                        ).ToArray();

            // Creating Events (0 to 100)
            var e =
                Enumerable.Range(0, 100)
                .Select(i =>
                        new Event(i.ToString(),
                                  i % 2 != 0
                                ? Controllability.Controllable
                                : Controllability.Uncontrollable)
                        ).ToArray();

            //----------------------------
            // Plants
            //----------------------------

            // C1
            var c1 = new DeterministicFiniteAutomaton(
                new[]
            {
                new Transition(s[0], e[11], s[1]),
                new Transition(s[1], e[12], s[0])
            },
                s[0], "C1");

            // C2
            var c2 = new DeterministicFiniteAutomaton(
                new[]
            {
                new Transition(s[0], e[21], s[1]),
                new Transition(s[1], e[22], s[0])
            },
                s[0], "C2");

            // Milling
            var milling = new DeterministicFiniteAutomaton(
                new[]
            {
                new Transition(s[0], e[41], s[1]),
                new Transition(s[1], e[42], s[0])
            },
                s[0], "Milling");

            // MP
            var mp = new DeterministicFiniteAutomaton(
                new[]
            {
                new Transition(s[0], e[81], s[1]),
                new Transition(s[1], e[82], s[0])
            },
                s[0], "MP");

            // Lathe
            var lathe = new DeterministicFiniteAutomaton(
                new[]
            {
                new Transition(s[0], e[51], s[1]),
                new Transition(s[1], e[52], s[0]),
                new Transition(s[0], e[53], s[2]),
                new Transition(s[2], e[54], s[0])
            },
                s[0], "Lathe");

            // C3
            var c3 = new DeterministicFiniteAutomaton(
                new[]
            {
                new Transition(s[0], e[71], s[1]),
                new Transition(s[1], e[72], s[0]),
                new Transition(s[0], e[73], s[2]),
                new Transition(s[2], e[74], s[0])
            },
                s[0], "C3");

            // Robot
            var robot = new DeterministicFiniteAutomaton(
                new[]
            {
                new Transition(s[0], e[31], s[1]),
                new Transition(s[1], e[32], s[0]),
                new Transition(s[0], e[33], s[2]),
                new Transition(s[2], e[34], s[0]),
                new Transition(s[0], e[35], s[3]),
                new Transition(s[3], e[36], s[0]),
                new Transition(s[0], e[37], s[4]),
                new Transition(s[4], e[38], s[0]),
                new Transition(s[0], e[39], s[5]),
                new Transition(s[5], e[30], s[0])
            },
                s[0], "Robot");

            // MM
            var mm = new DeterministicFiniteAutomaton(
                new[]
            {
                new Transition(s[0], e[61], s[1]),
                new Transition(s[1], e[63], s[2]),
                new Transition(s[1], e[65], s[3]),
                new Transition(s[2], e[64], s[0]),
                new Transition(s[3], e[66], s[0])
            },
                s[0], "MM");

            //----------------------------
            // Specifications
            //----------------------------

            // E1
            var e1 = new DeterministicFiniteAutomaton(
                new[]
            {
                new Transition(s[0], e[12], s[1]),
                new Transition(s[1], e[31], s[0])
            },
                s[0], "E1");

            // E2
            var e2 = new DeterministicFiniteAutomaton(
                new[]
            {
                new Transition(s[0], e[22], s[1]),
                new Transition(s[1], e[33], s[0])
            },
                s[0], "E2");

            // E5
            var e5 = new DeterministicFiniteAutomaton(
                new[]
            {
                new Transition(s[0], e[36], s[1]),
                new Transition(s[1], e[61], s[0])
            },
                s[0], "E5");

            // E6
            var e6 = new DeterministicFiniteAutomaton(
                new[]
            {
                new Transition(s[0], e[38], s[1]),
                new Transition(s[1], e[63], s[0])
            },
                s[0], "E6");

            // E3
            var e3 = new DeterministicFiniteAutomaton(
                new[]
            {
                new Transition(s[0], e[32], s[1]),
                new Transition(s[1], e[41], s[0]),
                new Transition(s[0], e[42], s[2]),
                new Transition(s[2], e[35], s[0])
            },
                s[0], "E3");

            // E7
            var e7 = new DeterministicFiniteAutomaton(
                new[]
            {
                new Transition(s[0], e[30], s[1]),
                new Transition(s[1], e[71], s[0]),
                new Transition(s[0], e[74], s[2]),
                new Transition(s[2], e[65], s[0])
            },
                s[0], "E7");

            // E8
            var e8 = new DeterministicFiniteAutomaton(
                new[]
            {
                new Transition(s[0], e[72], s[1]),
                new Transition(s[1], e[81], s[0]),
                new Transition(s[0], e[82], s[2]),
                new Transition(s[2], e[73], s[0])
            },
                s[0], "E8");

            // E4
            var e4 = new DeterministicFiniteAutomaton(
                new[]
            {
                new Transition(s[0], e[34], s[1]),
                new Transition(s[1], e[51], s[0]),
                new Transition(s[1], e[53], s[0]),
                new Transition(s[0], e[52], s[2]),
                new Transition(s[2], e[37], s[0]),
                new Transition(s[0], e[54], s[3]),
                new Transition(s[3], e[39], s[0])
            },
                s[0], "E4");

            // Computing the confict solving supervisor
            var e78 = e7.ParallelCompositionWith(e8);

            var timer = new Stopwatch();

            timer.Start();

            List <DeterministicFiniteAutomaton> plants;
            // computes the local modular supervisors
            var sups = DeterministicFiniteAutomaton.LocalModularSupervisor(
                new[] { c1, c2, milling, lathe, robot, mm, c3, mp }, // Plants
                new[] { e1, e2, e3, e4, e5, e6, e78 },               // Specifications
                out plants                                           // Modular Plants (optional)
                ).ToArray();

            timer.Stop();

            // Shows elapsed time
            Console.WriteLine("Computation Time: {0}", timer.ElapsedMilliseconds / 1000.0);


            // this is used to prevent the program from closing immediately
            Console.ReadLine();
        }
Example #21
0
        private static DeterministicFiniteAutomaton IndustrialTransferLineSBAI()
        {
            var s = Enumerable.Range(0, 4)
                .ToDictionary(i => i, i => new ExpandedState(i.ToString(), i == 0 ? 0u : 1u, i == 0 ? Marking.Marked : Marking.Unmarked));

            var e = (new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }).ToDictionary(ev => ev,
                ev => new Event(ev.ToString(), ev % 2 == 0 ? Controllability.Uncontrollable : Controllability.Controllable));

            var m1 = new DeterministicFiniteAutomaton(
                new[]
                {
                    new Transition(s[0], e[1], s[1]),
                    new Transition(s[1], e[2], s[0])
                },
                s[0], "M1");

            var m2 = new DeterministicFiniteAutomaton(
                new[]
                {
                    new Transition(s[0], e[3], s[1]),
                    new Transition(s[1], e[4], s[0])
                },
                s[0], "M2");

            var m3 = new DeterministicFiniteAutomaton(
                new[]
                {
                    new Transition(s[0], e[5], s[1]),
                    new Transition(s[1], e[6], s[0])
                },
                s[0], "M3");

            var m4 = new DeterministicFiniteAutomaton(
                new[]
                {
                    new Transition(s[0], e[7], s[1]),
                    new Transition(s[1], e[8], s[0])
                },
                s[0], "M4");

            var m5 = new DeterministicFiniteAutomaton(
                new[]
                {
                    new Transition(s[0], e[9], s[1]),
                    new Transition(s[1], e[10], s[0])
                },
                s[0], "M5");

            var m6 = new DeterministicFiniteAutomaton(
                new[]
                {
                    new Transition(s[0], e[11], s[1]),
                    new Transition(s[1], e[12], s[0])
                },
                s[0], "M6");

            s = Enumerable.Range(0, 4)
                .ToDictionary(i => i,
                    i => new ExpandedState(i.ToString(), 0u, i == 0 ? Marking.Marked : Marking.Unmarked));

            var e1 = new DeterministicFiniteAutomaton(
                new[]
                {
                    new Transition(s[0], e[2], s[1]),
                    new Transition(s[1], e[3], s[0])
                },
                s[0], "E1");

            var e2 = new DeterministicFiniteAutomaton(
                new[]
                {
                    new Transition(s[0], e[6], s[1]),
                    new Transition(s[1], e[7], s[0])
                },
                s[0], "E2");

            var e3 = new DeterministicFiniteAutomaton(
                new[]
                {
                    new Transition(s[0], e[4], s[1]),
                    new Transition(s[1], e[8], s[2]),
                    new Transition(s[0], e[8], s[3]),
                    new Transition(s[3], e[4], s[2]),
                    new Transition(s[2], e[9], s[0])
                },
                s[0], "E3");

            var e4 = new DeterministicFiniteAutomaton(
                new[]
                {
                    new Transition(s[0], e[10], s[1]),
                    new Transition(s[1], e[11], s[0])
                },
                s[0], "E4");

            return DeterministicFiniteAutomaton.MonoliticSupervisor(new[] { m1, m2, m3, m4, m5, m6 },
                new[] { e1, e2, e3, e4 }, true);
        }
Example #22
0
        private static IEnumerable<AbstractEvent> MaxParallelPath(DeterministicFiniteAutomaton g, int depth,
            AbstractState target)
        {
            var transitions = g.Transitions.AsParallel().GroupBy(t => t.Origin).ToDictionary(gr => gr.Key, gr => gr.ToArray());

            var distance = new ConcurrentDictionary<AbstractState, Tuple<uint, ImmutableList<AbstractEvent>>>();
            distance.TryAdd(g.InitialState, Tuple.Create(0u, ImmutableList<AbstractEvent>.Empty));

            for (var i = 0; i < depth; i++)
            {
                var nextDistance = new ConcurrentDictionary<AbstractState, Tuple<uint, ImmutableList<AbstractEvent>>>();

                if (distance.Count < 100)
                {
                    foreach (var kvp in distance)
                    {
                        var s1 = kvp.Key;
                        var d = kvp.Value;

                        foreach (var t in transitions[s1])
                        {
                            var s2 = t.Destination;
                            var e = t.Trigger;

                            var w = d.Item1;
                            if (s2 is ExpandedState) w += ((ExpandedState)s2).Tasks;
                            else if (s2 is CompoundExpandedState) w += ((CompoundExpandedState)s2).Tasks;

                            var lst = d.Item2.Add(e);

                            nextDistance.AddOrUpdate(s2, Tuple.Create(w, lst),
                                (key, old) => w > old.Item1 ? Tuple.Create(w, lst) : old);
                        }
                    }
                }
                else
                {

                    Parallel.ForEach(distance, kvp =>
                    {
                        var s1 = kvp.Key;
                        var d = kvp.Value;

                        //Parallel.ForEach(transitions[s1], t =>
                        foreach (var t in transitions[s1])
                        {
                            var s2 = t.Destination;
                            var e = t.Trigger;

                            var w = d.Item1;
                            if (s2 is ExpandedState) w += ((ExpandedState)s2).Tasks;
                            else if (s2 is CompoundExpandedState) w += ((CompoundExpandedState)s2).Tasks;

                            var lst = d.Item2.Add(e);

                            nextDistance.AddOrUpdate(s2, Tuple.Create(w, lst),
                                (key, old) => w > old.Item1 ? Tuple.Create(w, lst) : old);
                        } //);
                    });
                }

                distance = nextDistance;
            }

            return !distance.ContainsKey(target) ? ImmutableList<AbstractEvent>.Empty : distance[target].Item2;
        }
Example #23
0
        static void Main()
        {
            // creating States (0 to 6)
            var s =
                Enumerable.Range(0, 6)
                    .Select(i =>
                            new State(i.ToString(),
                                i == 0
                                    ? Marking.Marked
                                    : Marking.Unmarked)
                    ).ToArray();

            // Creating Events (0 to 100)
            var e =
                Enumerable.Range(0, 100)
                    .Select(i =>
                        new Event(i.ToString(),
                            i%2 != 0
                                ? Controllability.Controllable
                                : Controllability.Uncontrollable)
                    ).ToArray();

            //----------------------------
            // Plants
            //----------------------------

            // C1
            var c1 = new DeterministicFiniteAutomaton(
                new[]
                {
                    new Transition(s[0], e[11], s[1]),
                    new Transition(s[1], e[12], s[0])
                },
                s[0], "C1");

            // C2
            var c2 = new DeterministicFiniteAutomaton(
                new[]
                {
                    new Transition(s[0], e[21], s[1]),
                    new Transition(s[1], e[22], s[0])
                },
                s[0], "C2");

            // Milling
            var milling = new DeterministicFiniteAutomaton(
                new[]
                {
                    new Transition(s[0], e[41], s[1]),
                    new Transition(s[1], e[42], s[0])
                },
                s[0], "Milling");

            // MP
            var mp = new DeterministicFiniteAutomaton(
                new[]
                {
                    new Transition(s[0], e[81], s[1]),
                    new Transition(s[1], e[82], s[0])
                },
                s[0], "MP");

            // Lathe
            var lathe = new DeterministicFiniteAutomaton(
                new[]
                {
                    new Transition(s[0], e[51], s[1]),
                    new Transition(s[1], e[52], s[0]),
                    new Transition(s[0], e[53], s[2]),
                    new Transition(s[2], e[54], s[0])
                },
                s[0], "Lathe");

            // C3
            var c3 = new DeterministicFiniteAutomaton(
                new[]
                {
                    new Transition(s[0], e[71], s[1]),
                    new Transition(s[1], e[72], s[0]),
                    new Transition(s[0], e[73], s[2]),
                    new Transition(s[2], e[74], s[0])
                },
                s[0], "C3");

            // Robot
            var robot = new DeterministicFiniteAutomaton(
                new[]
                {
                    new Transition(s[0], e[31], s[1]),
                    new Transition(s[1], e[32], s[0]),
                    new Transition(s[0], e[33], s[2]),
                    new Transition(s[2], e[34], s[0]),
                    new Transition(s[0], e[35], s[3]),
                    new Transition(s[3], e[36], s[0]),
                    new Transition(s[0], e[37], s[4]),
                    new Transition(s[4], e[38], s[0]),
                    new Transition(s[0], e[39], s[5]),
                    new Transition(s[5], e[30], s[0])
                },
                s[0], "Robot");

            // MM
            var mm = new DeterministicFiniteAutomaton(
                new[]
                {
                    new Transition(s[0], e[61], s[1]),
                    new Transition(s[1], e[63], s[2]),
                    new Transition(s[1], e[65], s[3]),
                    new Transition(s[2], e[64], s[0]),
                    new Transition(s[3], e[66], s[0])
                },
                s[0], "MM");

            //----------------------------
            // Specifications
            //----------------------------

            // E1
            var e1 = new DeterministicFiniteAutomaton(
                new[]
                {
                    new Transition(s[0], e[12], s[1]),
                    new Transition(s[1], e[31], s[0])
                },
                s[0], "E1");

            // E2
            var e2 = new DeterministicFiniteAutomaton(
                new[]
                {
                    new Transition(s[0], e[22], s[1]),
                    new Transition(s[1], e[33], s[0])
                },
                s[0], "E2");

            // E5
            var e5 = new DeterministicFiniteAutomaton(
                new[]
                {
                    new Transition(s[0], e[36], s[1]),
                    new Transition(s[1], e[61], s[0])
                },
                s[0], "E5");

            // E6
            var e6 = new DeterministicFiniteAutomaton(
                new[]
                {
                    new Transition(s[0], e[38], s[1]),
                    new Transition(s[1], e[63], s[0])
                },
                s[0], "E6");

            // E3
            var e3 = new DeterministicFiniteAutomaton(
                new[]
                {
                    new Transition(s[0], e[32], s[1]),
                    new Transition(s[1], e[41], s[0]),
                    new Transition(s[0], e[42], s[2]),
                    new Transition(s[2], e[35], s[0])
                },
                s[0], "E3");

            // E7
            var e7 = new DeterministicFiniteAutomaton(
                new[]
                {
                    new Transition(s[0], e[30], s[1]),
                    new Transition(s[1], e[71], s[0]),
                    new Transition(s[0], e[74], s[2]),
                    new Transition(s[2], e[65], s[0])
                },
                s[0], "E7");

            // E8
            var e8 = new DeterministicFiniteAutomaton(
                new[]
                {
                    new Transition(s[0], e[72], s[1]),
                    new Transition(s[1], e[81], s[0]),
                    new Transition(s[0], e[82], s[2]),
                    new Transition(s[2], e[73], s[0])
                },
                s[0], "E8");

            // E4
            var e4 = new DeterministicFiniteAutomaton(
                new[]
                {
                    new Transition(s[0], e[34], s[1]),
                    new Transition(s[1], e[51], s[0]),
                    new Transition(s[1], e[53], s[0]),
                    new Transition(s[0], e[52], s[2]),
                    new Transition(s[2], e[37], s[0]),
                    new Transition(s[0], e[54], s[3]),
                    new Transition(s[3], e[39], s[0])
                },
                s[0], "E4");

            // Computing the confict solving supervisor
            var e78 = e7.ParallelCompositionWith(e8);

            // Computing the local modular supervisors
            var timer = new Stopwatch();
            timer.Start();
            List<DeterministicFiniteAutomaton> plants;
            var sups = DeterministicFiniteAutomaton.LocalModularSupervisor(
                new[] {c1, c2, milling, lathe, robot, mm, c3, mp}, // Plants
                new[] {e1, e2, e3, e4, e5, e6, e78}, // Specifications
                out plants).ToArray(); // Modular Plant
            timer.Stop();

            Console.WriteLine("Computation Time: {0}", timer.ElapsedMilliseconds/1000.0);

            // Exporting to TCT
            sups[0].ToAdsFile("S1.ADS", e, 1, 0);
            plants[0].ToAdsFile("P1.ADS", e, 1, 0);

            // At TCT
            // 1) Convert ADS files to DES using FD command
            // 2) Generate the disabling structure with command 7 (DAT1 = Condat(P1, S1))
            // 3) Generate the reduced supervisor using the command 8 (Sr1 = Supreduce(P1, S1, DAT1))

            Console.ReadLine();
        }
Example #24
0
        // Creates the plants and specifications of ITL problem.
        // The automata are saved in 'plants' and 'specs'
        private static void ITL(out List <DeterministicFiniteAutomaton> plants, out List <DeterministicFiniteAutomaton> specs)
        {
            var s =
                Enumerable.Range(0, 6)
                .Select(i =>
                        new State(i.ToString(),
                                  i == 0
                                ? Marking.Marked
                                : Marking.Unmarked)
                        ).ToArray();


            var e =
                Enumerable.Range(0, 100)
                .Select(i =>
                        new Event(i.ToString(),
                                  i % 2 != 0
                               ? Controllability.Controllable
                               : Controllability.Uncontrollable)
                        ).ToArray();

            //plants

            //M1
            var M1 = new DeterministicFiniteAutomaton(
                new[]
            {
                new Transition(s[0], e[1], s[1]),
                new Transition(s[1], e[2], s[0])
            },
                s[0], "M1");

            var M2 = new DeterministicFiniteAutomaton(
                new[]
            {
                new Transition(s[0], e[3], s[1]),
                new Transition(s[1], e[4], s[0])
            },
                s[0], "M2");

            var M3 = new DeterministicFiniteAutomaton(
                new[]
            {
                new Transition(s[0], e[5], s[1]),
                new Transition(s[1], e[6], s[0])
            },
                s[0], "M3");

            var M4 = new DeterministicFiniteAutomaton(
                new[]
            {
                new Transition(s[0], e[7], s[1]),
                new Transition(s[1], e[8], s[0])
            },
                s[0], "M4");

            var M5 = new DeterministicFiniteAutomaton(
                new[]
            {
                new Transition(s[0], e[9], s[1]),
                new Transition(s[1], e[10], s[0])
            },
                s[0], "M5");

            var M6 = new DeterministicFiniteAutomaton(
                new[]
            {
                new Transition(s[0], e[11], s[1]),
                new Transition(s[1], e[12], s[0])
            },
                s[0], "M6");

            //Specifications

            var e1 = new DeterministicFiniteAutomaton(
                new[]
            {
                new Transition(s[0], e[2], s[1]),
                new Transition(s[1], e[3], s[0])
            },
                s[0], "E1");

            var e2 = new DeterministicFiniteAutomaton(
                new[]
            {
                new Transition(s[0], e[6], s[1]),
                new Transition(s[1], e[7], s[0])
            },
                s[0], "E2");

            var e3 = new DeterministicFiniteAutomaton(
                new[]
            {
                new Transition(s[0], e[4], s[1]),
                new Transition(s[0], e[8], s[1]),
                new Transition(s[1], e[9], s[0])
            },
                s[0], "E3");

            var e4 = new DeterministicFiniteAutomaton(
                new[]
            {
                new Transition(s[0], e[10], s[1]),
                new Transition(s[1], e[11], s[0])
            },
                s[0], "E4");

            plants = new[] { M1, M2, M3, M4, M5, M6 }.ToList();
            specs  = new[] { e1, e2, e3, e4 }.ToList();
        }