コード例 #1
0
ファイル: NBA_State.cs プロジェクト: nhannhan159/PAT
        /**
 * Constructor.
 * @param graph The automaton (NBA) that contains this state.
 */
        public NBA_State(NBA graph, int index)
        {
            _graph = graph;
            _isFinal = false;
            _edge_manager = new NBA_State_EdgeManager(this, graph.getAPSet());
            Index = index;
        }
コード例 #2
0
ファイル: NBA_State.cs プロジェクト: vu111293/pat-design
 /**
  * Constructor.
  * @param graph The automaton (NBA) that contains this state.
  */
 public NBA_State(NBA graph, int index)
 {
     _graph        = graph;
     _isFinal      = false;
     _edge_manager = new NBA_State_EdgeManager(this, graph.getAPSet());
     Index         = index;
 }
コード例 #3
0
ファイル: DBA2DRA.cs プロジェクト: nhannhan159/PAT
        public static DRA dba2dra(NBA nba, bool complement)
        {
            APSet ap_set = nba.getAPSet(); ;

            DRA dra_p = new DRA(ap_set);

            dba2dra(nba, dra_p, complement);
            return dra_p;
        }
コード例 #4
0
        public static DRA dba2dra(NBA nba, bool complement)
        {
            APSet ap_set = nba.getAPSet();;

            DRA dra_p = new DRA(ap_set);

            dba2dra(nba, dra_p, complement);
            return(dra_p);
        }
コード例 #5
0
        public static NBA product_automaton(NBA nba_1, NBA nba_2)
        {
            Debug.Assert(nba_1.getAPSet() == nba_2.getAPSet());
            NBA product_nba = new NBA(nba_1.getAPSet_cp());

            APSet apset = nba_1.getAPSet();

            Debug.Assert(apset == nba_2.getAPSet());

            for (int s_1 = 0; s_1 < nba_1.size(); s_1++)
            {
                for (int s_2 = 0; s_2 < nba_2.size(); s_2++)
                {
                    for (int copy = 0; copy < 2; copy++)
                    {
                        int s_r = product_nba.nba_i_newState();
                        Debug.Assert(s_r == (s_1 * nba_2.size() + s_2) * 2 + copy);

                        int to_copy = copy;

                        if (copy == 0 && nba_1[s_1].isFinal())
                        {
                            to_copy = 1;
                        }
                        if (copy == 1 && nba_2[s_2].isFinal())
                        {
                            product_nba[s_r].setFinal(true);
                            to_copy = 0;
                        }

                        //for (typename APSet::element_iterator it=apset.all_elements_begin();it!=apset.all_elements_end();++it)
                        for (int it = apset.all_elements_begin(); it != apset.all_elements_end(); it++)
                        {
                            APElement label  = new APElement(it);
                            BitSet    to_s1  = nba_1[s_1].getEdge(label);
                            BitSet    to_s2  = nba_2[s_2].getEdge(label);
                            BitSet    to_set = new BitSet();
                            //for (BitSetIterator it_e_1 = BitSetIterator(*to_s1); it_e_1 != BitSetIterator::end(*to_s1); ++it_e_1)
                            //for (int it_e_1 = 0; it_e_1 != to_s1.bitset.Count; ++it_e_1)
                            for (int it_e_1 = BitSetIterator.start(to_s1); it_e_1 != BitSetIterator.end(to_s1); it_e_1 = BitSetIterator.increment(to_s1, it_e_1))
                            {
                                //for (BitSetIterator it_e_2 = BitSetIterator(*to_s2); it_e_2 != BitSetIterator::end(*to_s2); ++it_e_2)
                                //for (int it_e_2 = 0; it_e_2 != to_s2.bitset.Count; ++it_e_2)
                                for (int it_e_2 = BitSetIterator.start(to_s2); it_e_2 != BitSetIterator.end(to_s2); it_e_2 = BitSetIterator.increment(to_s2, it_e_2))
                                {
                                    int to = it_e_1 * nba_2.size() + it_e_2 * 2 + to_copy;
                                    to_set.set(to);
                                }
                            }

                            product_nba[s_r].getEdge(label).Assign(to_set);
                        }
                    }
                }
            }

            int start_1 = nba_1.getStartState().getName();
            int start_2 = nba_2.getStartState().getName();

            product_nba.setStartState(product_nba[start_1 * nba_2.size() + start_2]);

            return(product_nba);
        }
コード例 #6
0
ファイル: NBA.cs プロジェクト: nhannhan159/PAT
        public static NBA product_automaton(NBA nba_1, NBA nba_2)
        {
            Debug.Assert(nba_1.getAPSet() == nba_2.getAPSet());
            NBA product_nba = new NBA(nba_1.getAPSet_cp());

            APSet apset = nba_1.getAPSet();
            Debug.Assert(apset == nba_2.getAPSet());

            for (int s_1 = 0; s_1 < nba_1.size(); s_1++)
            {
                for (int s_2 = 0; s_2 < nba_2.size(); s_2++)
                {
                    for (int copy = 0; copy < 2; copy++)
                    {
                        int s_r = product_nba.nba_i_newState();
                        Debug.Assert(s_r == (s_1 * nba_2.size() + s_2) * 2 + copy);

                        int to_copy = copy;

                        if (copy == 0 && nba_1[s_1].isFinal())
                        {
                            to_copy = 1;
                        }
                        if (copy == 1 && nba_2[s_2].isFinal())
                        {
                            product_nba[s_r].setFinal(true);
                            to_copy = 0;
                        }

                        //for (typename APSet::element_iterator it=apset.all_elements_begin();it!=apset.all_elements_end();++it)
                        for (int it = apset.all_elements_begin(); it != apset.all_elements_end(); it++)
                        {
                            APElement label = new APElement(it);
                            BitSet to_s1 = nba_1[s_1].getEdge(label);
                            BitSet to_s2 = nba_2[s_2].getEdge(label);
                            BitSet to_set = new BitSet();
                            //for (BitSetIterator it_e_1 = BitSetIterator(*to_s1); it_e_1 != BitSetIterator::end(*to_s1); ++it_e_1)
                            //for (int it_e_1 = 0; it_e_1 != to_s1.bitset.Count; ++it_e_1)
                            for (int it_e_1 = BitSetIterator.start(to_s1); it_e_1 != BitSetIterator.end(to_s1); it_e_1 = BitSetIterator.increment(to_s1, it_e_1))
                            {
                                //for (BitSetIterator it_e_2 = BitSetIterator(*to_s2); it_e_2 != BitSetIterator::end(*to_s2); ++it_e_2)
                                //for (int it_e_2 = 0; it_e_2 != to_s2.bitset.Count; ++it_e_2)
                                for (int it_e_2 = BitSetIterator.start(to_s2); it_e_2 != BitSetIterator.end(to_s2); it_e_2 = BitSetIterator.increment(to_s2, it_e_2))
                                {
                                    int to = it_e_1 * nba_2.size() + it_e_2 * 2 + to_copy;
                                    to_set.set(to);
                                }
                            }

                            product_nba[s_r].getEdge(label).Assign(to_set);
                        }
                    }
                }
            }

            int start_1 = nba_1.getStartState().getName();
            int start_2 = nba_2.getStartState().getName();
            product_nba.setStartState(product_nba[start_1 * nba_2.size() + start_2]);

            return product_nba;
        }