Ejemplo n.º 1
0
        public override AutomataBDD EncodeComposition(BDDEncoder encoder)
        {
            AutomataBDD processAutomataBDD = this.Process.Encode(encoder);

            if (encoder.model.mapChannelToSize.ContainsKey(this.ChannelName))
            {
                int channelEventIndex = encoder.GetChannelIndex(this.ChannelName, BDDEncoder.EventChannelInfo.EventType.ASYNC_CHANNEL_OUTPUT);

                return(AutomataBDD.ChannelOutputPrefixing(this.ChannelName, channelEventIndex, new List <Expression>(this.ExpressionList), AssignmentExpr, processAutomataBDD, encoder.model));
            }
            else
            {
                List <Expression> expressionList = (this.ExpressionList != null) ? new List <Expression>(this.ExpressionList) : new List <Expression>();
                int channelEventIndex            = encoder.GetEventIndex(this.ChannelName, expressionList.Count);

                return(AutomataBDD.SyncChannelOutputPrefixing(channelEventIndex, expressionList, processAutomataBDD, encoder.model));
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Encode transition, if it is synchronized, then we don't add constraint of unchanged global variables
        /// Parallel process only synchorinize event which does not change global variable or each transition changes same to global variables
        /// 3 kinds of transition: normal event, async channel input and async channel output
        /// </summary>
        /// <param name="encoder"></param>
        /// <param name="processVariableName"></param>
        /// <param name="localVars">Local of the current SymbolicLTS is unchanged</param>
        /// <param name="isSynchronized"></param>
        /// <returns></returns>
        public List <CUDDNode> Encode(BDDEncoder encoder, string processVariableName, List <int> localVars, bool isSynchronized)
        {
            Expression guardExpressions = Expression.EQ(new Variable(processVariableName),
                                                        new IntConstant(encoder.stateIndexOfCurrentProcess[this.FromPNPlace.ID]));

            guardExpressions = Expression.CombineGuard(guardExpressions, GuardCondition);
            Expression eventUpdateExpression;

            if (this.Event is BDDEncoder.EventChannelInfo)
            {
                int channelIndex = encoder.GetChannelIndex(this.Event.BaseName, (this.Event as BDDEncoder.EventChannelInfo).type);
                eventUpdateExpression = new Assignment(Model.EVENT_NAME, new IntConstant(channelIndex));
            }
            else
            {
                eventUpdateExpression = encoder.GetEventExpression(this.Event);
            }

            Assignment PNPlaceUpdateExpression = new Assignment(processVariableName,
                                                                new IntConstant(encoder.stateIndexOfCurrentProcess[this.ToPNPlace.ID]));
            Sequence updateExpressions = new Sequence(eventUpdateExpression, PNPlaceUpdateExpression);

            if (this.ProgramBlock != null)
            {
                updateExpressions = new Sequence(updateExpressions, this.ProgramBlock);
            }

            List <int> unchangedVars = new List <int>(localVars);

            if (!isSynchronized)
            {
                unchangedVars.AddRange(encoder.model.GlobalVarIndex);
            }

            return(encoder.model.EncodeTransition(guardExpressions, updateExpressions, unchangedVars));
        }