コード例 #1
0
        /// <summary>
        /// Visits the given input data node.
        /// </summary>
        /// <param name="data">Input data node.</param>
        public override void PostVisit(InputData.PDDL.NumericAssignEffect data)
        {
            int          functionNameId = IdManager.Functions.GetId(data.Function.Name, data.Function.Terms.Count);
            List <ITerm> terms          = new List <ITerm>();

            data.Function.Terms.ForEach(term => terms.Add(TermsBuilder.Value.Build(term)));

            NumericExpressionsBuilder numericExpressionsBuilder = new NumericExpressionsBuilder(IdManager);
            INumericExpression        valueExpression           = numericExpressionsBuilder.Build(data.Value);

            IAtom functionAtom = new Atom(functionNameId, terms);

            IEffect newEffect = null;

            switch (data.AssignOperator)
            {
            case InputData.PDDL.Traits.AssignOperator.ASSIGN:
            {
                newEffect = new NumericAssignEffect(functionAtom, valueExpression, IdManager);
                break;
            }

            case InputData.PDDL.Traits.AssignOperator.INCREASE:
            {
                newEffect = new NumericIncreaseEffect(functionAtom, valueExpression, IdManager);
                break;
            }

            case InputData.PDDL.Traits.AssignOperator.DECREASE:
            {
                newEffect = new NumericDecreaseEffect(functionAtom, valueExpression, IdManager);
                break;
            }

            case InputData.PDDL.Traits.AssignOperator.SCALE_UP:
            {
                newEffect = new NumericScaleUpEffect(functionAtom, valueExpression, IdManager);
                break;
            }

            case InputData.PDDL.Traits.AssignOperator.SCALE_DOWN:
            {
                newEffect = new NumericScaleDownEffect(functionAtom, valueExpression, IdManager);
                break;
            }

            default:
            {
                Debug.Assert(false);
                break;
            }
            }

            EffectsStack.Push(newEffect);
        }
コード例 #2
0
        /// <summary>
        /// Visits the given input data node.
        /// </summary>
        /// <param name="data">Input data node.</param>
        public override void PostVisit(InputData.PDDL.NumericCompareExpression data)
        {
            NumericExpressionsBuilder numericExpressionsBuilder = new NumericExpressionsBuilder(IdManager);
            INumericExpression        firstArgument             = numericExpressionsBuilder.Build(data.NumericExpression1);
            INumericExpression        secondArgument            = numericExpressionsBuilder.Build(data.NumericExpression2);

            NumericCompareExpression.RelationalOperator relOperator = NumericCompareExpression.RelationalOperator.EQ;
            switch (data.NumericComparer)
            {
            case InputData.PDDL.Traits.NumericComparer.EQ:
            {
                relOperator = NumericCompareExpression.RelationalOperator.EQ;
                break;
            }

            case InputData.PDDL.Traits.NumericComparer.LT:
            {
                relOperator = NumericCompareExpression.RelationalOperator.LT;
                break;
            }

            case InputData.PDDL.Traits.NumericComparer.LTE:
            {
                relOperator = NumericCompareExpression.RelationalOperator.LTE;
                break;
            }

            case InputData.PDDL.Traits.NumericComparer.GT:
            {
                relOperator = NumericCompareExpression.RelationalOperator.GT;
                break;
            }

            case InputData.PDDL.Traits.NumericComparer.GTE:
            {
                relOperator = NumericCompareExpression.RelationalOperator.GTE;
                break;
            }

            default:
            {
                Debug.Assert(false, "Unhandled operator!");
                break;
            }
            }

            ExpressionStack.Push(new NumericCompareExpression(relOperator, firstArgument, secondArgument));
        }