Exemplo n.º 1
0
 public DeterministicFAState AddInitialState()
 {
     DeterministicFAState toReturn = new DeterministicFAState(0);
     States.Add(0, toReturn);
     InitialState = toReturn;
     return toReturn;
 }
Exemplo n.º 2
0
 public DeterministicFAState AddState()
 {
     int id = States.Count;
     DeterministicFAState toReturn = new DeterministicFAState(States.Count);
     States.Add(id, toReturn);
     return toReturn;
 }
Exemplo n.º 3
0
        public DeterministicAutomata Determinize()
        {
            Dictionary <string, DeterministicFAState> Visited = new Dictionary <string, DeterministicFAState>(Ultility.Ultility.MC_INITIAL_SIZE);
            Stack <NormalizedFAState> pending = new Stack <NormalizedFAState>(1024);

            NormalizedFAState current = (new NormalizedFAState(InitialState)).TauReachable();

            pending.Push(current);

            DeterministicAutomata toReturn = new DeterministicAutomata();

            Visited.Add(current.GetID(), toReturn.AddInitialState());

            while (pending.Count > 0)
            {
                current = pending.Pop();
                DeterministicFAState currentState = Visited[current.GetID()];

                Dictionary <string, HashSet <FAState> > nexts = new Dictionary <string, HashSet <FAState> >();

                foreach (FAState state in current.States)
                {
                    foreach (KeyValuePair <string, HashSet <FAState> > pair in state.Post)
                    {
                        if (pair.Key != Constants.TAU)
                        {
                            HashSet <FAState> states;
                            if (!nexts.TryGetValue(pair.Key, out states))
                            {
                                states = new HashSet <FAState>();
                                nexts.Add(pair.Key, states);
                            }

                            foreach (FAState faState in pair.Value)
                            {
                                states.Add(faState);
                            }
                        }
                    }
                }

                foreach (KeyValuePair <string, HashSet <FAState> > keyValuePair in nexts)
                {
                    NormalizedFAState next     = new NormalizedFAState(keyValuePair.Value);
                    NormalizedFAState newState = next.TauReachable();

                    DeterministicFAState target;
                    if (!Visited.TryGetValue(newState.GetID(), out target))
                    {
                        target = toReturn.AddState();
                        Visited.Add(newState.GetID(), target);
                        pending.Push(newState);
                    }

                    toReturn.AddTransition(currentState, keyValuePair.Key, target);
                }
            }

            return(toReturn);
        }
Exemplo n.º 4
0
        public DeterministicFAState AddState()
        {
            int id = States.Count;
            DeterministicFAState toReturn = new DeterministicFAState(States.Count);

            States.Add(id, toReturn);
            return(toReturn);
        }
Exemplo n.º 5
0
        public DeterministicFAState AddInitialState()
        {
            DeterministicFAState toReturn = new DeterministicFAState(0);

            States.Add(0, toReturn);
            InitialState = toReturn;
            return(toReturn);
        }
Exemplo n.º 6
0
 public void AddTransition(DeterministicFAState source, string evt, DeterministicFAState target)
 {
     source.AddTransition(evt,target);
 }
Exemplo n.º 7
0
 /// <summary>
 /// return true iff deterministic
 /// </summary>
 /// <param name="evt"></param>
 /// <param name="target"></param>
 /// <returns></returns>
 public void AddTransition(string evt, DeterministicFAState target)
 {
     Post.Add(evt, target);
 }
Exemplo n.º 8
0
 public Tuple(MDPConfiguration imp, DeterministicFAState spec, MDPState mdp)
 {
     ImplState = imp;
     SpecState = spec;
     MDPState = mdp;
 }
Exemplo n.º 9
0
 /// <summary>
 /// return true iff deterministic
 /// </summary>
 /// <param name="evt"></param>
 /// <param name="target"></param>
 /// <returns></returns>
 public void AddTransition(string evt, DeterministicFAState target)
 {
     Post.Add(evt, target);
 }
Exemplo n.º 10
0
 public void AddTransition(DeterministicFAState source, string evt, DeterministicFAState target)
 {
     source.AddTransition(evt, target);
 }