/**
         * Increment the iterator (used by the boost iterator base class).
         */
        public void increment()
        {
            //BitSet set_mask = new BitSet(_m.getSetBits());
            BitSet set_mask = _m.getSetBits().getBitSetObject();
            int    i        = set_mask.nextClearBit(0);

            while (i < _ap_set.size())
            {
                if (_cur_e.get(i) == false)
                {
                    _cur_e.set(i, true);
                    return;
                }
                else
                {
                    _cur_e.set(i, false);
                    i = set_mask.nextClearBit(i + 1);
                }
            }

            // overflow -> end
            _end_marker = true;
        }
Exemple #2
0
        public List <int> MakeOneMove(int stateIndex, Valuation env, string evt)
        {
            DA_State   state      = this._index[stateIndex];
            List <int> returnList = new List <int>();

            if (state.hasOnlySelfLoop())
            {
                // get first to-state, as all the to-states are the same
                DA_State to = state.edges().get(new APElement(_ap_set.all_elements_begin()));
                returnList.Add(to.Index);
                return(returnList);
            }

            //Transition[] trans = fromTransitions[state];

            //foreach (Transition tran in trans)
            for (int el_it = _ap_set.all_elements_begin(); el_it != _ap_set.all_elements_end(); ++el_it)
            {
                APElement label          = new APElement(el_it);
                DA_State  to_state       = state.edges().get(label);
                int       to_state_index = to_state.Index;

                //bool toAdd = true;
                //for (int i = 0; i < _ap_set.size(); i++)
                bool toAdd = true;
                for (int i = 0; i < _ap_set.size(); i++)
                {
                    ////If the transition is labelled with Sigma, there should not be any other labels.
                    //if (label.IsSigmal)
                    //{
                    //    //if(!returnList.Contains(tran.ToState))
                    //    {
                    //        returnList.Add(tran.ToState);
                    //    }
                    //    break;
                    //}

                    string labelstring = _ap_set.getAP(i);
                    //If the labed is negated, e.g., !eat0.
                    if (!label.get(i))
                    {
                        if (!DeclarationDatabase.ContainsKey(labelstring)) //If the label is an event.
                        {
                            //if the label says that this event can not happen, the event is eat0 and the label is !eat0.
                            if (labelstring == evt)
                            {
                                toAdd = false;
                                break;
                            }
                        }
                        else //If the label is a proposition.
                        {
                            ExpressionValue v = EvaluatorDenotational.Evaluate(DeclarationDatabase[labelstring], env);

                            //liuyang: v must be a boolconstant, 20/04/2009
                            Debug.Assert(v is BoolConstant);
                            //if (v is BoolConstant)
                            //{
                            if ((v as BoolConstant).Value)
                            {
                                toAdd = false;
                                break;
                            }
                            //}
                        }
                    }
                    else //if (!label.Negated)
                    {
                        if (!DeclarationDatabase.ContainsKey(labelstring)) //If the label is an event.
                        {
                            if (labelstring != evt)
                            {
                                toAdd = false;
                                break;
                            }
                        }
                        else //If the label is a proposition.
                        {
                            ExpressionValue v = EvaluatorDenotational.Evaluate(DeclarationDatabase[labelstring], env);

                            //liuyang: v must be a boolconstant, 20/04/2009
                            Debug.Assert(v is BoolConstant);
                            //if (v is BoolConstant)
                            //{
                            if (!(v as BoolConstant).Value)
                            {
                                toAdd = false;
                                break;
                            }
                            //}
                        }
                    }
                }

                if (toAdd && !returnList.Contains(to_state_index))
                {
                    returnList.Add(to_state_index);
                }
            }

            return(returnList);
        }
Exemple #3
0
        public List<int> MakeOneMove(int stateIndex, Valuation env, string evt)
        {
            DA_State state = this._index[stateIndex];
            List<int> returnList = new List<int>();

            if (state.hasOnlySelfLoop())
            {
                // get first to-state, as all the to-states are the same
                DA_State to = state.edges().get(new APElement(_ap_set.all_elements_begin()));
                returnList.Add(to.Index);
                return returnList;
            }

            //Transition[] trans = fromTransitions[state];

            //foreach (Transition tran in trans)
            for (int el_it = _ap_set.all_elements_begin(); el_it != _ap_set.all_elements_end(); ++el_it)
            {
                APElement label = new APElement(el_it);
                DA_State to_state = state.edges().get(label);
                int to_state_index = to_state.Index;

                //bool toAdd = true;
                //for (int i = 0; i < _ap_set.size(); i++)
                bool toAdd = true;
                for (int i = 0; i < _ap_set.size(); i++)
                {
                    ////If the transition is labelled with Sigma, there should not be any other labels.
                    //if (label.IsSigmal)
                    //{
                    //    //if(!returnList.Contains(tran.ToState))
                    //    {
                    //        returnList.Add(tran.ToState);
                    //    }
                    //    break;
                    //}

                    string labelstring = _ap_set.getAP(i);
                    //If the labed is negated, e.g., !eat0.
                    if (!label.get(i))
                    {
                        if (!DeclarationDatabase.ContainsKey(labelstring)) //If the label is an event.
                        {
                            //if the label says that this event can not happen, the event is eat0 and the label is !eat0.
                            if (labelstring == evt)
                            {
                                toAdd = false;
                                break;
                            }
                        }
                        else //If the label is a proposition.
                        {
                            ExpressionValue v = EvaluatorDenotational.Evaluate(DeclarationDatabase[labelstring], env);

                            //liuyang: v must be a boolconstant, 20/04/2009
                            Debug.Assert(v is BoolConstant);
                            //if (v is BoolConstant)
                            //{
                            if ((v as BoolConstant).Value)
                            {
                                toAdd = false;
                                break;
                            }
                            //}
                        }
                    }
                    else //if (!label.Negated)
                    {
                        if (!DeclarationDatabase.ContainsKey(labelstring)) //If the label is an event.
                        {
                            if (labelstring != evt)
                            {
                                toAdd = false;
                                break;
                            }
                        }
                        else //If the label is a proposition.
                        {
                            ExpressionValue v = EvaluatorDenotational.Evaluate(DeclarationDatabase[labelstring], env);

                            //liuyang: v must be a boolconstant, 20/04/2009
                            Debug.Assert(v is BoolConstant);
                            //if (v is BoolConstant)
                            //{
                            if (!(v as BoolConstant).Value)
                            {
                                toAdd = false;
                                break;
                            }
                            //}
                        }
                    }
                }

                if (toAdd && !returnList.Contains(to_state_index))
                {
                    returnList.Add(to_state_index);
                }

            }

            return returnList;
        }