コード例 #1
0
        private void ReadInitState(Problem p, Domain d, CompoundExpression eInitState)
        {
            foreach (Expression e in eInitState.SubExpressions)
            {
                CompoundExpression eSub = (CompoundExpression)e;
                if (d.IsFunctionExpression(eSub.Type))
                {
                    p.AddKnown(ReadFunctionExpression(eSub, null, d));
                }
                else if (d.ContainsPredicate(eSub.Type))
                {
                    p.AddKnown(ReadGroundedPredicate(eSub, d));
                }
                else
                {
                    if (eSub.Type != "unknown")
                    {
                        Formula f = ReadGroundedFormula(eSub, d);
                        if (f is CompoundFormula)
                        {
                            p.AddHidden((CompoundFormula)f);
                        }
                        if (f is PredicateFormula)//this happens in (not (p)) statments
                        {
                            p.AddKnown(((PredicateFormula)f).Predicate);
                        }
                    }
                    else
                    {
                        //causing a problem - add operand does some basic reasoning - adding p and ~p results in true for or statements.
                        //skipping unknown for now...

                        Predicate       pUnknown = ReadGroundedPredicate((CompoundExpression)eSub.SubExpressions[0], d);
                        CompoundFormula cfOr     = new CompoundFormula("or");
                        cfOr.SimpleAddOperand(pUnknown);
                        cfOr.SimpleAddOperand(pUnknown.Negate());
                        p.AddHidden(cfOr);
                    }
                }
            }
        }
コード例 #2
0
ファイル: Runner.cs プロジェクト: ronistern/ma-strips
        public static void GetJointDomain(List <Domain> lDomains, List <Problem> lProblems, out Domain dJoint, out Problem pJoint)
        {
            dJoint        = lDomains[0].Clone();
            pJoint        = lProblems[0].Clone();
            pJoint.Domain = dJoint;
            CompoundFormula cfAnd = new CompoundFormula("and");

            cfAnd.AddOperand(pJoint.Goal);
            for (int i = 1; i < lDomains.Count; i++)
            {
                dJoint.Actions.AddRange(lDomains[i].Actions);
                dJoint.Predicates.UnionWith(lDomains[i].Predicates);
                dJoint.Constants.UnionWith(lDomains[i].Constants);
                foreach (Predicate pKnown in lProblems[i].Known)
                {
                    pJoint.AddKnown(pKnown);
                }
                cfAnd.AddOperand(lProblems[i].Goal);
            }
            pJoint.Goal = cfAnd.Simplify();
        }