Ejemplo n.º 1
0
        public static string GetFullName(PlanningParser.TermAtomFormContext context, StringDictionary assignment)
        {
            string name            = context.predicate().GetText();
            var    termContextList = context.term();

            return(GetFullName(name, termContextList, assignment));
        }
Ejemplo n.º 2
0
        private static CUDDNode GetCuddNode(this PlanningParser.TermAtomFormContext context,
                                            IReadOnlyDictionary <string, Predicate> predicateDict, StringDictionary assignment)
        {
            CUDDNode result;

            if (context.predicate() != null)
            {
                string    predicateFullName = ConstContainer.GetFullName(context, assignment);
                Predicate predicate         = predicateDict[predicateFullName];
                int       cuddIndex         = predicate.PreviousCuddIndex;
                result = CUDD.Var(cuddIndex);
            }
            else
            {
                string firstTermString  = Globals.TermInterpreter.GetString(context.term(0), assignment);
                string secondTermString = Globals.TermInterpreter.GetString(context.term(1), assignment);
                if (context.EQ() != null)
                {
                    result = firstTermString == secondTermString ? CUDD.ONE : CUDD.ZERO;
                }
                else if (context.NEQ() != null)
                {
                    result = firstTermString != secondTermString ? CUDD.ONE : CUDD.ZERO;
                }
                else
                {
                    int firstValue  = int.Parse(firstTermString);
                    int secondValue = int.Parse(secondTermString);
                    if (context.LT() != null)
                    {
                        result = firstValue < secondValue ? CUDD.ONE : CUDD.ZERO;
                    }
                    else if (context.LEQ() != null)
                    {
                        result = firstValue <= secondValue ? CUDD.ONE : CUDD.ZERO;
                    }
                    else if (context.GT() != null)
                    {
                        result = firstValue > secondValue ? CUDD.ONE : CUDD.ZERO;
                    }
                    else
                    {
                        result = firstValue >= secondValue ? CUDD.ONE : CUDD.ZERO;
                    }
                }
                CUDD.Ref(result);
            }

            return(result);
        }