Пример #1
0
        public static DA calculateUnion(DRA dra1, DRA dra2, bool trueloop_check, bool detailed_states)
        {
            if (dra1.isStreett() || dra2.isStreett())
            {
                throw new Exception("Can not calculate union for Streett automata");
            }

            return(DAUnionAlgorithm.calculateUnion(dra1, dra2, trueloop_check, detailed_states));
        }
Пример #2
0
        //bool trueloop_check=true, bool detailed_states=false
        public static DA calculateUnionStuttered(DRA dra1, DRA dra2, StutterSensitivenessInformation stutter_information, bool trueloop_check, bool detailed_states)
        {
            if (dra1.isStreett() ||
                dra2.isStreett())
            {
                throw new Exception("Can not calculate union for Streett automata");
            }

            return(DAUnionAlgorithm.calculateUnionStuttered(dra1, dra2, stutter_information, trueloop_check, detailed_states));
        }
Пример #3
0
        /** Constructor.
         * @param algo The Algorithm_t to use
         * @param da_result The result automaton
         * @param limit Limit the number of states in the result automaton?
         * @param detailed_states Generate detailed descriptions?
         * @param stutter_information Information about which symbols may be stuttered
         */
        public StutteredConvertorUnion(DAUnionAlgorithm algo, DRA da_result, int limit, bool detailed_states, StutterSensitivenessInformation stutter_information)
        {
            _da_result           = da_result;
            _limit               = limit;
            _algo                = algo;
            _detailed_states     = detailed_states;
            _stutter_information = stutter_information;

            //added by ly
            _state_mapper = new StateMapper <TreeWithAcceptance, DA_State>();
            _unprocessed  = new Stack <KeyValuePair <TreeWithAcceptance, DA_State> >();
        }
Пример #4
0
        /** Calculate the union of two DA. If the DAs are not compact, they are made compact.
         * @param da_1 The first DA
         * @param da_2 the second DA
         * @param trueloop_check Check for trueloops?
         * @param detailed_states Generate detailed descriptions of the states?
         * @return shared_ptr to result DA
         */
        //bool trueloop_check=true,bool detailed_states=false
        public static DA calculateUnion(DA da_1, DA da_2, bool trueloop_check, bool detailed_states)
        {
            //if (!da_1.isCompact()) {
            //  da_1.makeCompact();
            //}

            //if (!da_2.isCompact()) {
            //  da_2.makeCompact();
            //}

            DAUnionAlgorithm dua = new DAUnionAlgorithm(da_1, da_2, trueloop_check, detailed_states);

            NBA2DA generator = new NBA2DA(detailed_states);

            generator.convert(dua, dua.getResultDA() as DRA, 0);

            return(dua.getResultDA());
        }
Пример #5
0
        /** Calculate the union of two DA, using stuttering if possible. If the DAs are not compact, they are made compact.
         * @param da_1 The first DA
         * @param da_2 the second DA
         * @param stutter_information information about the symbols where stuttering is allowed
         * @param trueloop_check Check for trueloops?
         * @param detailed_states Generate detailed descriptions of the states? */
        //bool trueloop_check=true, bool detailed_states=false
        public static DA calculateUnionStuttered(DA da_1, DA da_2, StutterSensitivenessInformation stutter_information, bool trueloop_check, bool detailed_states)
        {
            //if (!da_1.isCompact()) {
            //  da_1.makeCompact();
            //}

            //if (!da_2.isCompact()) {
            //  da_2.makeCompact();
            //}

            //typedef DAUnionAlgorithm<DA_t> algo_t;
            DAUnionAlgorithm dua = new DAUnionAlgorithm(da_1, da_2, trueloop_check, detailed_states);

            //<algo_t, DA_t>
            StutteredNBA2DAUnion generator = new StutteredNBA2DAUnion(detailed_states, stutter_information);

            generator.convert(dua, dua.getResultDA(), 0);

            return(dua.getResultDA());
        }
Пример #6
0
        /**
         * Perform the stuttered conversion.
         * Throws LimitReachedException if a limit is set (>0) and
         * there are more states in the generated DRA than the limit.
         * @param algo the underlying algorithm to be used
         * @param da_result the DRA where the result is stored
         *        (has to have same APSet as the nba)
         * @param limit a limit for the number of states (0 disables the limit).
         */
        public void convert(DAUnionAlgorithm algo, DA da_result, int limit)
        {
            StutteredConvertorUnion conv = new StutteredConvertorUnion(algo, da_result as DRA, limit, _detailed_states, _stutter_information);

            conv.convert();
        }
Пример #7
0
        /**
         * Generate a DA using the Algorithm
         * Throws LimitReachedException if a limit is set (>0) and
         * there are more states in the generated DA than the limit.
         * @param algo the algorithm
         * @param da_result the DA where the result is stored
         *        (has to have same APSet as the nba)
         * @param limit a limit for the number of states (0 disables the limit).
         */
        public void convert(DAUnionAlgorithm algo, DRA da_result, int limit)
        {
            StateMapper <StateInterface, DA_State> state_mapper = new StateMapper <StateInterface, DA_State>();
            APSet ap_set = da_result.getAPSet();

            if (algo.checkEmpty())
            {
                da_result.constructEmpty();
                return;
            }

            //typedef typename DA_t::state_type da_state_t;
            //typedef typename Algorithm_t::state_t algo_state_t;
            //typedef typename Algorithm_t::result_t algo_result_t;

            algo.prepareAcceptance(da_result.acceptance());

            StateInterface start       = algo.getStartState();
            DA_State       start_state = da_result.newState();

            start.generateAcceptance(start_state.acceptance());
            if (_detailed_states)
            {
                start_state.setDescription(start.toHTML());
            }

            state_mapper.add(start, start_state);
            da_result.setStartState(start_state);

            //typedef std::pair<algo_state_t, da_state_t*> unprocessed_value;

            Stack <KeyValuePair <StateInterface, DA_State> > unprocessed = new Stack <KeyValuePair <StateInterface, DA_State> >();

            unprocessed.Push(new KeyValuePair <StateInterface, DA_State>(start, start_state));

            while (unprocessed.Count > 0)
            {
                KeyValuePair <StateInterface, DA_State> top = unprocessed.Pop();
                //unprocessed.pop();

                StateInterface cur  = top.Key;
                DA_State       from = top.Value;

                //for (APSet::element_iterator it_elem = ap_set.all_elements_begin(); it_elem != ap_set.all_elements_end(); ++it_elem)
                for (int it_elem = ap_set.all_elements_begin(); it_elem != ap_set.all_elements_end(); ++it_elem)
                {
                    APElement elem = new APElement(it_elem);

                    ResultStateInterface <UnionState> result = algo.delta(cur as UnionState, elem);


                    DA_State to = state_mapper.find(result.getState());

                    if (to == null)
                    {
                        to = da_result.newState();
                        result.getState().generateAcceptance(to.acceptance());

                        if (_detailed_states)
                        {
                            to.setDescription(result.getState().toHTML());
                        }

                        state_mapper.add(result.getState(), to);
                        unprocessed.Push(new KeyValuePair <StateInterface, DA_State>(result.getState(), to));
                    }

                    from.edges().set(elem, to);

                    if (limit != 0 && da_result.size() > limit)
                    {
                        throw new LimitReachedException("");
                    }
                }
            }
        }