예제 #1
0
        public void convert(NBA nba, DRA dra_result, int limit)  //=0
        {
            if (nba.size() == 0 || nba.getStartState() == null)
            {
                // the NBA is empty -> construct DRA that is empty

                dra_result.constructEmpty();
                return;
            }

            if (_options.dba_check && nba.isDeterministic())
            {
                DBA2DRA.dba2dra(nba, dra_result);
                return;
            }

            if (_options.stutter_closure)
            {
                if (_stutter_information != null && !_stutter_information.isCompletelyInsensitive())
                {
                    //std::cerr <<
                    //"WARNING: NBA might not be 100% stutter insensitive, applying stutter closure can create invalid results!" <<
                    //std::endl;
                }

                NBA nba_closed = NBAStutterClosure.stutter_closure(nba);

                if (can_stutter())
                {
                    convert_safra_stuttered(nba_closed, dra_result, limit);
                    return;
                }

                convert_safra(nba_closed, dra_result, limit);
                return;
            }


            if (can_stutter())
            {
                convert_safra_stuttered(nba, dra_result, limit);
                return;
            }

            convert_safra(nba, dra_result, limit);

            return;
        }
예제 #2
0
        public void setStutterInformation(StutterSensitivenessInformation stutter_information)
        {
            _stutter_information = stutter_information;

            //new StutterSensitivenessInformation(
            //new StutterSensitivenessInformation(
            StutterSensitivenessInformation left_stutter_info  = stutter_information;
            StutterSensitivenessInformation right_stutter_info = stutter_information;

            if (!stutter_information.isCompletelyInsensitive())
            {
                left_stutter_info.checkLTL(_left);
                right_stutter_info.checkLTL(_right);
            }

            if (!left_stutter_info.isCompletelyInsensitive())
            {
                left_stutter_info.checkPartial(_left_tree.getNBA(), buchiAutomata, _left.negate().toPNF(), _sched.getLTL2DRA());/////////////add buchiautomata
            }

            if (!right_stutter_info.isCompletelyInsensitive())
            {
                right_stutter_info.checkPartial(_right_tree.getNBA(), buchiAutomata, _right.negate().toPNF(), _sched.getLTL2DRA());///////add buchiautomata
            }

            _left_tree.setStutterInformation(left_stutter_info);
            _right_tree.setStutterInformation(right_stutter_info);
        }
예제 #3
0
        //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;
        //typedef TreeWithAcceptance<algo_state_t, typename Acceptance::signature_type> stuttered_state_t;
        //typedef typename stuttered_state_t::ptr stuttered_state_ptr_t;

        //typedef std::pair<stuttered_state_ptr_t, da_state_t*> unprocessed_value_t;
        //typedef std::stack<unprocessed_value_t> unprocessed_stack_t;

        /** Convert the NBA to the DA */
        public void convert()
        {
            APSet ap_set = _da_result.getAPSet();

            if (_algo.checkEmpty())
            {
                _da_result.constructEmpty();
                return;
            }

            _algo.prepareAcceptance(_da_result.acceptance());

            TreeWithAcceptance s_start     = new TreeWithAcceptance(_algo.getStartState());
            DA_State           start_state = _da_result.newState();

            s_start.generateAcceptance(start_state.acceptance());
            if (_detailed_states)
            {
                //start_state->setDescription(s_start->toHTML());
                start_state.setDescription("hahahahah");
            }

            _state_mapper.add(s_start, start_state);
            _da_result.setStartState(start_state);

            Stack <KeyValuePair <TreeWithAcceptance, DA_State> > unprocessed;

            _unprocessed.Push(new KeyValuePair <TreeWithAcceptance, DA_State>(s_start, start_state));

            bool   all_insensitive     = _stutter_information.isCompletelyInsensitive();
            BitSet partial_insensitive = _stutter_information.getPartiallyInsensitiveSymbols();

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

                TreeWithAcceptance from    = top.Key;
                DA_State           da_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);

                    if (da_from.edges().get(elem) == null)
                    {
                        // the edge was not yet calculated...

                        if (!all_insensitive && partial_insensitive.get(it_elem) == null)
                        {
                            // can't stutter for this symbol, do normal step
                            UnionState         next_tree  = _algo.delta(from.getTree() as UnionState, elem).getState();
                            TreeWithAcceptance next_state = new TreeWithAcceptance(next_tree);
                            add_transition(da_from, next_state, elem);

                            continue;
                        }

                        // normal stuttering...

                        calc_delta(from, da_from, elem);

                        if (_limit != 0 && _da_result.size() > _limit)
                        {
                            //THROW_EXCEPTION(LimitReachedException, "");
                            throw new Exception("LimitReachedException");
                        }
                    }
                }
            }
        }
예제 #4
0
        /** Generate the tree */
        public override void generateTree()
        {
            LTL2DSTAR_Tree_Rabin   rabin   = null;
            LTL2DSTAR_Tree_Streett streett = null;

            if (_options.automata == automata_type.RABIN || _options.automata == automata_type.RABIN_AND_STREETT)
            {
                rabin = new LTL2DSTAR_Tree_Rabin(_ltl, buchiAutomata, _options, _sched);
            }

            if (_options.automata == automata_type.STREETT || _options.automata == automata_type.RABIN_AND_STREETT)
            {
                streett = new LTL2DSTAR_Tree_Streett(_ltl.negate().toPNF(), buchiAutomata, _options, _sched);
            }

            if (rabin != null && streett != null)
            {
                int rabin_est   = rabin.guestimate();
                int streett_est = streett.guestimate();

                //if (_options.verbose_scheduler) {
                //  std::cerr << "NBA-Estimates: Rabin: "<<rabin_est <<
                //    " Streett: " << streett_est << std::endl;
                //}

                if (rabin_est <= streett_est)
                {
                    addChild(rabin);
                    addChild(streett);
                }
                else
                {
                    addChild(streett);
                    addChild(rabin);
                }
            }
            else
            {
                if (rabin != null)
                {
                    addChild(rabin);
                }
                if (streett != null)
                {
                    addChild(streett);
                }
            }


            if (_options.opt_safra.stutter)
            {
                StutterSensitivenessInformation stutter_information = new StutterSensitivenessInformation();
                stutter_information.checkLTL(_ltl);

                if (!stutter_information.isCompletelyInsensitive() && _options.opt_safra.partial_stutter_check)
                {
                    NBA nba            = null;
                    NBA complement_nba = null;
                    if (rabin != null)
                    {
                        nba = rabin.getNBA();
                    }
                    else if (streett != null)
                    {
                        nba = streett.getNBA();
                    }

                    if (rabin != null && streett != null)
                    {
                        complement_nba = streett.getNBA();
                    }

                    if (nba == null)
                    {
                        stutter_information.checkPartial(_ltl, buchiAutomata, _sched.getLTL2DRA());//////////add buchiAutomata
                    }
                    else if (complement_nba == null)
                    {
                        stutter_information.checkPartial(nba, buchiAutomata, _ltl.negate().toPNF(), _sched.getLTL2DRA());///////////add buchiAutomata
                    }
                    else
                    {
                        stutter_information.checkNBAs(nba, complement_nba);
                    }
                }

                if (rabin != null)
                {
                    rabin.setStutterInformation(stutter_information);
                }
                if (streett != null)
                {
                    streett.setStutterInformation(stutter_information);
                }
            }
        }
예제 #5
0
        public void setStutterInformation(StutterSensitivenessInformation stutter_information)
        {
            _stutter_information = stutter_information;

            //new StutterSensitivenessInformation(
            //new StutterSensitivenessInformation(
            StutterSensitivenessInformation left_stutter_info = stutter_information;
            StutterSensitivenessInformation right_stutter_info = stutter_information;

            if (!stutter_information.isCompletelyInsensitive())
            {
                left_stutter_info.checkLTL(_left);
                right_stutter_info.checkLTL(_right);
            }

            if (!left_stutter_info.isCompletelyInsensitive())
            {
                left_stutter_info.checkPartial(_left_tree.getNBA(), buchiAutomata, _left.negate().toPNF(), _sched.getLTL2DRA());/////////////add buchiautomata
            }

            if (!right_stutter_info.isCompletelyInsensitive())
            {
                right_stutter_info.checkPartial(_right_tree.getNBA(), buchiAutomata, _right.negate().toPNF(), _sched.getLTL2DRA());///////add buchiautomata
            }

            _left_tree.setStutterInformation(left_stutter_info);
            _right_tree.setStutterInformation(right_stutter_info);
        }
예제 #6
0
        /** Generate the tree */
        public override void generateTree()
        {
            LTL2DSTAR_Tree_Rabin rabin = null;
            LTL2DSTAR_Tree_Streett streett = null;

            if (_options.automata == automata_type.RABIN || _options.automata == automata_type.RABIN_AND_STREETT)
            {
                rabin = new LTL2DSTAR_Tree_Rabin(_ltl, buchiAutomata, _options, _sched);
            }

            if (_options.automata == automata_type.STREETT || _options.automata == automata_type.RABIN_AND_STREETT)
            {
                streett = new LTL2DSTAR_Tree_Streett(_ltl.negate().toPNF(), buchiAutomata, _options, _sched);
            }

            if (rabin != null && streett != null)
            {
                int rabin_est = rabin.guestimate();
                int streett_est = streett.guestimate();

                //if (_options.verbose_scheduler) {
                //  std::cerr << "NBA-Estimates: Rabin: "<<rabin_est <<
                //    " Streett: " << streett_est << std::endl;
                //}

                if (rabin_est <= streett_est)
                {
                    addChild(rabin);
                    addChild(streett);
                }
                else
                {
                    addChild(streett);
                    addChild(rabin);
                }
            }
            else
            {
                if (rabin != null)
                    addChild(rabin);
                if (streett != null)
                    addChild(streett);
            }

            if (_options.opt_safra.stutter)
            {
                StutterSensitivenessInformation stutter_information = new StutterSensitivenessInformation();
                stutter_information.checkLTL(_ltl);

                if (!stutter_information.isCompletelyInsensitive() && _options.opt_safra.partial_stutter_check)
                {
                    NBA nba = null;
                    NBA complement_nba = null;
                    if (rabin != null)
                    {
                        nba = rabin.getNBA();
                    }
                    else if (streett != null)
                    {
                        nba = streett.getNBA();
                    }

                    if (rabin != null && streett != null)
                    {
                        complement_nba = streett.getNBA();
                    }

                    if (nba == null)
                    {
                        stutter_information.checkPartial(_ltl, buchiAutomata, _sched.getLTL2DRA());//////////add buchiAutomata
                    }
                    else if (complement_nba == null)
                    {
                        stutter_information.checkPartial(nba, buchiAutomata, _ltl.negate().toPNF(), _sched.getLTL2DRA());///////////add buchiAutomata
                    }
                    else
                    {
                        stutter_information.checkNBAs(nba, complement_nba);
                    }
                }

                if (rabin != null)
                {
                    rabin.setStutterInformation(stutter_information);
                }
                if (streett != null)
                {
                    streett.setStutterInformation(stutter_information);
                }
            }
        }