コード例 #1
0
        ///
        /// <summary>
        /// Use when the boolen constant is used as expression: a = true
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public override ExpressionBDDEncoding TranslateIntExpToBDD(Model model)
        {
            string channelName          = Arguments[0].ToString();
            string countChannelVariable = Model.GetCountVarChannel(channelName);
            string topChannelVariable   = Model.GetTopVarChannel(channelName);

            switch (MethodName)
            {
            case Constants.cfull:
                Expression            isFull     = Expression.EQ(new Variable(countChannelVariable), new IntConstant(model.mapChannelToSize[channelName]));
                ExpressionBDDEncoding isFullTemp = isFull.TranslateBoolExpToBDD(model);
                isFullTemp.ExpressionDDs = new List <CUDDNode>(isFullTemp.GuardDDs);
                isFullTemp.GuardDDs      = new List <CUDDNode>()
                {
                    CUDD.Constant(1)
                };
                return(isFullTemp);

            case Constants.cempty:
                Expression            isEmpty     = Expression.EQ(new Variable(countChannelVariable), new IntConstant(0));
                ExpressionBDDEncoding isEmptyTemp = isEmpty.TranslateBoolExpToBDD(model);
                isEmptyTemp.ExpressionDDs = new List <CUDDNode>(isEmptyTemp.GuardDDs);
                isEmptyTemp.GuardDDs      = new List <CUDDNode>()
                {
                    CUDD.Constant(1)
                };
                return(isEmptyTemp);

            case Constants.ccount:
                return(new Variable(countChannelVariable).TranslateIntExpToBDD(model));

            case Constants.csize:
                return(new IntConstant(model.mapChannelToSize[channelName]).TranslateIntExpToBDD(model));

            case Constants.cpeek:
                //(top_a - count_a) % L
                Expression popedElementPosition = new PrimitiveApplication(PrimitiveApplication.MOD,
                                                                           Expression.MINUS(new Variable(topChannelVariable), new Variable(countChannelVariable)),
                                                                           new IntConstant(model.mapChannelToSize[channelName]));

                //a[top_a - count_a % L][i]
                return(new PrimitiveApplication(PrimitiveApplication.ARRAY, new Variable(channelName), Expression.TIMES(
                                                    popedElementPosition,
                                                    new IntConstant(Model.MAX_MESSAGE_LENGTH))
                                                ).TranslateIntExpToBDD(model));
            }

            throw new Exception("Static call can not be encoded in BDD");
        }
コード例 #2
0
        ///
        /// <summary>
        /// Use when the boolen constant is used as expression: a = true
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public override ExpressionBDDEncoding TranslateBoolExpToBDD(Model model)
        {
            string channelName          = Arguments[0].ToString();
            string countChannelVariable = Model.GetCountVarChannel(channelName);

            switch (MethodName)
            {
            case Constants.cfull:
                Expression isFull = Expression.EQ(new Variable(countChannelVariable), new IntConstant(model.mapChannelToSize[channelName]));
                return(isFull.TranslateBoolExpToBDD(model));

            case Constants.cempty:
                Expression isEmpty = Expression.EQ(new Variable(countChannelVariable), new IntConstant(0));
                return(isEmpty.TranslateBoolExpToBDD(model));
            }

            throw new Exception("Static call can not be encoded in BDD");
        }
コード例 #3
0
ファイル: Variable.cs プロジェクト: vu111293/pat-design
 /// <summary>
 /// Encode as booleane expression, check whether the variable is true
 /// </summary>
 public override ExpressionBDDEncoding TranslateBoolExpToBDD(Model model)
 {
     return(Expression.EQ(new Variable(this.expressionID), new BoolConstant(true)).TranslateBoolExpToBDD(model));
 }