Random number chooser.
Esempio n. 1
0
        /// <summary>
        /// Produces a random path of labels from the initial state to some final state.
        /// Assumes that the automaton is nonempty and does not contain deadends.
        /// </summary>
        /// <param name="chooser">uses the chooser for randomizing the choices</param>
        public IEnumerable <S> ChoosePathToSomeFinalState(Chooser chooser)
        {
            if (IsEmpty)
            {
                throw new AutomataException(AutomataExceptionKind.AutomatonMustBeNonempty);
            }

            int state = InitialState;

            while (!IsFinalState(state) || (OutDegree(state) > 0 && chooser.ChooseTrueOrFalse()))
            {
                if (!IsFinalState(state) && OutDegree(state) == 0)
                {
                    throw new AutomataException(AutomataExceptionKind.AutomatonMustNotContainDeadStates);
                }

                var move = GetNthMoveFrom(state, chooser.Choose(GetMovesCountFrom(state)));
                if (!move.IsEpsilon)
                {
                    yield return(move.Label);
                }

                state = move.TargetState;
            }
            yield break;
        }
Esempio n. 2
0
        ///// <summary>
        ///// Equivalent (identical)
        ///// </summary>
        //public static bool operator ==(BV128 x, BV128 y)
        //{
        //    return x.Item1 == y.Item1 && x.Item2 == y.Item2;
        //}

        ///// <summary>
        ///// Inequivalent (different)
        ///// </summary>
        //public static bool operator !=(BV128 x, BV128 y)
        //{
        //    return x.Item1 != y.Item1 || x.Item2 != y.Item2;
        //}

        /// <summary>
        /// Generates a random bitvector.
        /// </summary>
        public static BV128 Random()
        {
            var c  = new Chooser();
            var u1 = c.ChooseBV64();
            var u2 = c.ChooseBV64();

            return(new BV128(u1, u2));
        }
Esempio n. 3
0
 public RegexToAutomatonConverterHashSet(HashSetSolver solver)
     : base(solver, new UnicodeCategoryToHashSetProvider(solver))
 {
     this.solver  = solver;
     this.chooser = new Chooser();
 }
Esempio n. 4
0
 public RegexToAutomatonConverterRanges(CharRangeSolver solver)
     : base(solver, new UnicodeCategoryToRangesProvider(solver))
 {
     this.solver  = solver;
     this.chooser = new Chooser();
 }
Esempio n. 5
0
 public RegexToAutomatonConverterCharSet(CharSetSolver solver) : base(solver, new UnicodeCategoryToCharSetProvider(solver))
 {
     this.bddBuilder = solver;
     this.chooser    = new Chooser();
 }