Beispiel #1
0
        /// <summary>
        /// Choose a random member from the BV set.
        /// The member is chosen from the union of the underlying minterm BDDs corresponding to s.
        /// </summary>
        public uint Choose(BV s)
        {
            if (s.Equals(this.zero))
            {
                throw new AutomataException(AutomataExceptionKind.SetIsEmpty);
            }
            BDD bdd;

            TryConvertToCharSet(s, out bdd);
            var res = solver.Choose(bdd);

            return(res);
        }
Beispiel #2
0
        /// <summary>
        /// Generates a random member accepted by fa.
        /// Assumes that fa has no dead states, or else termination is not guaranteed.
        /// </summary>
        public string GenerateMember(Automaton <BDD> fa)
        {
            if (fa.IsEmpty)
            {
                throw new AutomataException(AutomataExceptionKind.AutomatonMustBeNonempty);
            }
            var sb    = new System.Text.StringBuilder();
            int state = fa.InitialState;

            while (!fa.IsFinalState(state) || (fa.OutDegree(state) > 0 && chooser.ChooseTrueOrFalse()))
            {
                var move = fa.GetNthMoveFrom(state, chooser.Choose(fa.GetMovesCountFrom(state)));
                if (!move.IsEpsilon)
                {
                    sb.Append((char)(bddBuilder.Choose(move.Label)));
                }
                state = move.TargetState;
            }
            return(sb.ToString());
        }