示例#1
0
 public CsAutomaton(CsAlgebra <S> productAlgebra, Automaton <CsLabel <S> > aut, PowerSetStateBuilder stateBuilder, Dictionary <int, ICounter> countingStates, HashSet <int> origFinalStates) : base(aut)
 {
     this.stateBuilder    = stateBuilder;
     this.countingStates  = countingStates;
     this.origFinalStates = origFinalStates;
     activeCounterMap     = new Dictionary <int, HashSet <int> >();
     finalCounterSet      = new HashSet <int>();
     counters             = new ICounter[countingStates.Count];
     foreach (var q in aut.States)
     {
         var q_set = new HashSet <int>();
         activeCounterMap[q] = q_set;
         foreach (var mem in stateBuilder.GetMembers(q))
         {
             if (countingStates.ContainsKey(mem))
             {
                 var counterId = countingStates[mem].CounterId;
                 q_set.Add(counterId);
                 if (origFinalStates.Contains(mem))
                 {
                     finalCounterSet.Add(counterId);
                 }
                 counters[counterId] = countingStates[mem];
             }
         }
     }
     this.productAlgebra      = productAlgebra;
     stateDescr[InitialState] = SpecialCharacters.S(0);
 }
示例#2
0
        /// <summary>
        /// Describe the state information, including original states if determinized, as well as counters.
        /// </summary>
        public override string DescribeState(int state)
        {
            string s;

            if (!stateDescr.TryGetValue(state, out s))
            {
                s = SpecialCharacters.S(stateDescr.Count);
                stateDescr[state] = s;
            }

            var mems = new List <int>(stateBuilder.GetMembers(state));

            mems.Sort();
            if (!__hidePowersets)
            {
                s += "\n" + "{";
                foreach (var q in mems)
                {
                    if (!s.EndsWith("{"))
                    {
                        s += ",";
                    }
                    s += SpecialCharacters.q(q);
                }
                s += "}";
            }
            var state_counters      = GetCountersOfState(state);
            var state_counters_list = new List <int>(state_counters);

            state_counters_list.Sort();
            foreach (var c in state_counters_list)
            {
                s += "\n";
                s += "(" + SpecialCharacters.c(c) + ")";
                //s += "(" + counters[c].LowerBound +
                //    SpecialCharacters.LEQ + SpecialCharacters.Cntr(c) + SpecialCharacters.LEQ + counters[c].UpperBound + ")";
                if (finalCounterSet.Contains(c))
                {
                    s += SpecialCharacters.XI_LOWERCASE + SpecialCharacters.ToSubscript(c);
                    s += SpecialCharacters.CHECKMARK;
                }
            }
            return(s);
        }