예제 #1
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 StutteredConvertor(SafraAlgorithm 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> >();
        }
예제 #2
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(SafraAlgorithm algo, DA da_result, int limit)
    {
        StutteredConvertor conv = new StutteredConvertor(algo, da_result as DRA, limit, _detailed_states, _stutter_information);

        conv.convert();
    }
예제 #3
0
파일: NBA2DRA.cs 프로젝트: nhannhan159/PAT
        //=0
        /**
           * Convert the NBA to a DRA using Safra's algorithm
           * @param nba the NBA
           * @param dra_result the result DRA
           * @param limit limit for the size of the DRA
           */
        public void convert_safra(NBA nba, DRA dra_result, int limit)
        {
            SafraAlgorithm safras_algo = new SafraAlgorithm(nba, _options);

            if (!_options.opt_rename)
            {
                NBA2DA nba2da = new NBA2DA(_detailed_states);

                nba2da.convert(safras_algo, dra_result, limit);
            }
            else
            {
                //typedef typename SafrasAlgorithm<NBA_t>::result_t result_t;
                //typedef typename SafrasAlgorithm<NBA_t>::state_t key_t;

                //<safra_t,DRA_t, StateMapperFuzzy<result_t, key_t, typename DRA_t::state_type, SafraTreeCandidateMatcher> >
                NBA2DA nba2da_fuzzy = new NBA2DA(_detailed_states);

                nba2da_fuzzy.convert(safras_algo, dra_result, limit);
            }
        }
예제 #4
0
파일: NBA2DRA.cs 프로젝트: nhannhan159/PAT
        //=0
        /**
         * Convert the NBA to a DRA using Safra's algorithm, using stuttering
         * @param nba the NBA
         * @param dra_result the result DRA
         * @param limit limit for the size of the DRA
         */
        //template < typename NBA_t, typename DRA_t >
        void convert_safra_stuttered(NBA nba, DRA dra_result, int limit)
        {
            SafraAlgorithm safras_algo = new SafraAlgorithm(nba, _options);

            StutteredNBA2DA nba2dra_stuttered = new StutteredNBA2DA(_detailed_states, _stutter_information);

            nba2dra_stuttered.convert(safras_algo, dra_result, limit);
        }
예제 #5
0
파일: NBA2DA.cs 프로젝트: nhannhan159/PAT
        /**
         * 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(SafraAlgorithm algo, DRA da_result, int limit)
        {
            /** The hash map from DA_State to StateInterface */
            StateMapper<StateInterface, DA_State> state_mapper = new StateMapper<StateInterface, DA_State>();
            APSet ap_set = da_result.getAPSet();////////////************where dose this dra have ap_set?

            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;

            //* Creates new acceptance pairs according to da_result's acceptance.
            algo.prepareAcceptance(da_result.acceptance());////*********don't understand well

            StateInterface start = algo.getStartState();
            DA_State start_state = da_result.newState();/////************?? what is in this 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;//safratreeNode
                DA_State from = top.Value;//DA_state

                //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)///from 0 to 2^ap_set.size
                {
                    APElement elem = new APElement(it_elem);/////////set simpleBitset = it_elem

                    ResultStateInterface<SafraTree> result = algo.delta(cur as SafraTree, elem);/////get a new safraTree through elem

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

                    if (to == null)////////////////result is not in state mapper.
                    {
                        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);//////////////add this edge.
                    if (limit != 0 && da_result.size() > limit)
                    {
                        throw new LimitReachedException("");
                    }
                }
            }
        }