/** Add a new child */
        public void addChild(LTL2DSTAR_Tree child)
        {
            if (child == null)
            {
                return;
            }

            children.Add(child);
        }
        /** Calculate the automaton for this building block, by default
         * calculate the automata for the children and then choose the smallest. */
        public virtual void calculate(int level, int limit)
        {
            //if (_options.verbose_scheduler) {
            //      std::cerr << "Calculate ("<< level <<"): " << typeid(*this).name() << std::endl;
            //}

            calculateChildren(level, limit);

            bool first = true;

            //for (child_vector::iterator it=children.begin();it!=children.end();++it)
            for (int i = 0; i < children.Count; i++)
            {
                LTL2DSTAR_Tree it = children[i];

                if (it._automaton == null)
                {
                    continue;
                }

                if (first)
                {
                    _automaton = it._automaton;
                    _comment   = it._comment;
                }
                else
                {
                    if (_automaton.size() > it._automaton.size())
                    {
                        _automaton = it._automaton;
                        _comment   = it._comment;
                    }
                }

                first = false;
            }

            hook_after_calculate();
        }
        /** Calculate the automata for the children */
        public void calculateChildren(int level, int limit)
        {
            if (_sched.flagOptLimits())
            {
                DRA _min_automaton;
                int _min_size = 0;

                //for (child_vector::iterator it=children.begin(); it!=children.end(); ++it)
                for (int i = 0; i < children.Count; i++)
                {
                    LTL2DSTAR_Tree it = children[i];
                    int            child_limit;
                    if (_min_size != 0)
                    {
                        if (limit > 0)
                        {
                            child_limit = Math.Min(_sched.calcLimit(_min_size), limit);
                        }
                        else
                        {
                            child_limit = _sched.calcLimit(_min_size);
                        }
                    }
                    else
                    {
                        child_limit = limit;
                    }

                    //  if (_options.verbose_scheduler) {
                    //  std::cerr << " Limit (with alpha) = " << child_limit << std::endl;
                    //}

                    try
                    {
                        it.calculate(level + 1, child_limit);

                        if (it._automaton != null)
                        {
                            if (_min_size == 0 || it._automaton.size() < _min_size)
                            {
                                _min_automaton = it._automaton;
                                _min_size      = _min_automaton.size();
                            }
                            else
                            {
                                // delete automaton as it is bigger
                                // than necessary
                                //it._automaton.reset();
                                it._automaton = null;
                            }
                        }
                    }
                    catch (LimitReachedException e)
                    {
                        //it._automaton.reset();
                        it._automaton = null;
                    }
                }
            }
            else
            {
                //for (child_vector::iterator it=children.begin();it!=children.end();++it) {
                for (int i = 0; i < children.Count; i++)
                {
                    LTL2DSTAR_Tree it = children[i];
                    it.calculate(level + 1, limit);
                }
            }
        }
示例#4
0
        /** Add a new child */
        public void addChild(LTL2DSTAR_Tree child)
        {
            if (child == null) { return; }

            children.Add(child);
        }