예제 #1
0
        /// <summary>
        /// Create a new variable which know whether event is tick or not
        /// Later all event information is removed from the transition
        /// Return the justice based on that new varaible
        /// justice: event = tick, event != tick
        /// </summary>
        /// <param name="modelBDD"></param>
        /// <param name="model"></param>
        /// <returns></returns>
        public List <CUDDNode> GetJustices(AutomataBDD modelBDD, Model model)
        {
            model.AddLocalVar(EVENT_DUMMY, 0, 1);

            //Because later event variables are removed, add new variable to check whether it is tick or not
            Expression guard = Expression.OR(
                Expression.AND(
                    TimeBehaviors.GetTickTransExpression(),
                    new Assignment(EVENT_DUMMY,
                                   new IntConstant(1))),
                Expression.AND(
                    TimeBehaviors.GetNotTickTransExpression(),
                    new Assignment(EVENT_DUMMY,
                                   new IntConstant(0))));

            modelBDD.transitionBDD = CUDD.Function.And(modelBDD.transitionBDD, guard.TranslateBoolExpToBDD(model).GuardDDs);

            //the cycle must contain tick transition (zeno) and other transitions (progress)
            List <CUDDNode> justices = new List <CUDDNode>();

            guard = Expression.EQ(new Variable(EVENT_DUMMY),
                                  new IntConstant(0));

            justices.Add(CUDD.Function.Or(guard.TranslateBoolExpToBDD(model).GuardDDs));

            guard = Expression.EQ(new Variable(EVENT_DUMMY),
                                  new IntConstant(1));

            justices.Add(CUDD.Function.Or(guard.TranslateBoolExpToBDD(model).GuardDDs));

            return(justices);
        }
예제 #2
0
        /// <summary>
        /// Find the deadlock state. This state can be reached by a terminate event.
        /// Later termination transition is removed from the transition to finding path
        /// [ REFS: , DEREFS: ]
        /// </summary>
        /// <param name="transitions"></param>
        /// <param name="model"></param>
        /// <returns></returns>
        public static CUDDNode GetDeadlockDD(List <CUDDNode> transitions, Model model)
        {
            CUDDNode result = CUDD.Constant(1);

            //result contains state not having not tick outgoing transition
            foreach (CUDDNode transition in transitions)
            {
                CUDD.Ref(transition);
                CUDDNode notTickTrans = CUDD.Function.And(transition, CUDD.Function.Not(TimeBehaviors.GetTickTransEncoding(model)));

                //having not tick outgoing transition
                CUDDNode notDeadlockState = CUDD.Abstract.ThereExists(notTickTrans, model.AllColVars);

                CUDDNode deadlockState = CUDD.Function.Not(notDeadlockState);
                result = CUDD.Function.And(result, deadlockState);
            }

            CUDD.Ref(transitions);
            List <CUDDNode> tickTrans = CUDD.Function.And(transitions, TimeBehaviors.GetTickTransEncoding(model));

            CUDD.Ref(tickTrans);
            CUDDNode stateHasTickTrans = CUDD.Function.Or(CUDD.Abstract.ThereExists(tickTrans, model.AllColVars));

            List <int> eventIndex = model.GetEventIndex();

            for (int i = 0; i < model.GetNumberOfVars(); i++)
            {
                if (!eventIndex.Contains(i))
                {
                    CUDD.Ref(model.varIdentities[i]);
                    tickTrans = CUDD.Function.And(tickTrans, model.varIdentities[i]);
                }
            }
            CUDDNode stateHasLoopTick = CUDD.Function.Or(CUDD.Abstract.ThereExists(tickTrans, model.AllColVars));

            //Deadlock state: not having not tick transition and if has tick, then it must loop tick
            CUDD.Ref(result);
            result = CUDD.Function.Or(CUDD.Function.And(result, CUDD.Function.Not(stateHasTickTrans)), CUDD.Function.And(result, stateHasLoopTick));

            return(result);
        }