/// <summary>
        /// Evaluates the expression.
        /// </summary>
        /// <param name="expression">Expression.</param>
        /// <returns>True if the expression is logically true, false otherwise.</returns>
        public virtual bool Visit(PredicateLiteralCNF expression)
        {
            IAtom groundedPredicateAtom = GroundingManager.GroundAtomDeep(expression.PredicateAtom, Substitution, ReferenceState);
            bool  evaluationResult      = (RigidRelations.Contains(groundedPredicateAtom) || ReferenceState.HasPredicate(groundedPredicateAtom));

            return(!expression.IsNegated == evaluationResult);
        }
Пример #2
0
        /// <summary>
        /// Set the rigid properties of the corresponding planning problem.
        /// </summary>
        /// <param name="rigidRelations">Rigid relations of the planning problem.</param>
        public void SetRigidRelations(RigidRelations rigidRelations)
        {
            RigidRelations = rigidRelations;

            if (ExpressionEvaluator.IsValueCreated)
            {
                ExpressionEvaluator.Value.SetRigidRelations(RigidRelations);
            }
            else
            {
                ExpressionEvaluator = new Lazy <ExpressionEvaluator>(() => new ExpressionEvaluator(GroundingManager, RigidRelations));
            }

            if (ConditionsCNFEvaluator.IsValueCreated)
            {
                ConditionsCNFEvaluator.Value.SetRigidRelations(RigidRelations);
            }
            else
            {
                ConditionsCNFEvaluator = new Lazy <ConditionsCNFEvaluator>(() => new ConditionsCNFEvaluator(GroundingManager, RigidRelations));
            }

            if (RigidRelationsComplianceEvaluator.IsValueCreated)
            {
                RigidRelationsComplianceEvaluator.Value.SetRigidRelations(RigidRelations);
            }
            else
            {
                RigidRelationsComplianceEvaluator = new Lazy <RigidRelationsComplianceEvaluator>(() => new RigidRelationsComplianceEvaluator(GroundingManager, RigidRelations));
            }
        }
Пример #3
0
 /// <summary>
 /// Visits and evaluates predicate expression.
 /// </summary>
 /// <param name="expression">Predicate expression.</param>
 /// <returns>True if the specified expression evaluates as true, false otherwise.</returns>
 public bool Visit(PredicateExpression expression)
 {
     // if the predicate is a rigid relation, then check whether it has the correct value
     if (RigidRelations.IsPredicateRigidRelation(expression.PredicateAtom))
     {
         IAtom predicateAtom = GroundingManager.GroundAtom(expression.PredicateAtom, Substitution);
         return(RigidRelations.Contains(predicateAtom));
     }
     return(true);
 }
Пример #4
0
 /// <summary>
 /// Constructs the evaluation manager.
 /// </summary>
 /// <param name="groundingManager">Grounding manager.</param>
 /// <param name="rigidRelations">Rigid relations.</param>
 public EvaluationManager(GroundingManager groundingManager, RigidRelations rigidRelations = null)
 {
     ExpressionEvaluator                    = new Lazy <ExpressionEvaluator>(() => new ExpressionEvaluator(groundingManager, rigidRelations));
     ConditionsCNFEvaluator                 = new Lazy <ConditionsCNFEvaluator>(() => new ConditionsCNFEvaluator(groundingManager, rigidRelations));
     RigidRelationsComplianceEvaluator      = new Lazy <RigidRelationsComplianceEvaluator>(() => new RigidRelationsComplianceEvaluator(groundingManager, rigidRelations));
     NotAccomplishedConstraintsCounter      = new Lazy <NotAccomplishedConstraintsCounter>(() => new NotAccomplishedConstraintsCounter(groundingManager, ExpressionEvaluator));
     NotAccomplishedConstraintsCounterCNF   = new Lazy <NotAccomplishedConstraintsCounterCNF>(() => new NotAccomplishedConstraintsCounterCNF(ConditionsCNFEvaluator));
     PlanningGraphOperatorLabelEvaluator    = new Lazy <PlanningGraphOperatorLabelEvaluator>(() => new PlanningGraphOperatorLabelEvaluator(groundingManager));
     PlanningGraphOperatorLabelEvaluatorCNF = new Lazy <PlanningGraphOperatorLabelEvaluatorCNF>(() => new PlanningGraphOperatorLabelEvaluatorCNF(groundingManager));
     SatisfyingAtomsEvaluator               = new Lazy <SatisfyingAtomsEvaluator>(() => new SatisfyingAtomsEvaluator(groundingManager, rigidRelations));
     ConditionsParametersRenamer            = new Lazy <ConditionsParametersRenamer>(() => new ConditionsParametersRenamer());
     ConditionsUsedPredicatesCollector      = new Lazy <ConditionsUsedPredicatesCollector>(() => new ConditionsUsedPredicatesCollector());
     RigidRelations   = rigidRelations;
     GroundingManager = groundingManager;
 }
Пример #5
0
        /// <summary>
        /// Constructs the PDDL planning problem from the input data.
        /// </summary>
        /// <param name="inputData">Input data.</param>
        public Problem(InputData.PDDLInputData inputData)
        {
            DomainName        = inputData.Domain.Name;
            ProblemName       = inputData.Problem.Name;
            OriginalInputData = inputData;

            IdManager         = new IdManager(inputData);
            EvaluationManager = new EvaluationManager(new GroundingManager(inputData, IdManager));

            Operators            = new LiftedOperators(inputData.Domain.Actions, IdManager, EvaluationManager);
            InitialState         = new State(inputData.Problem.Init, IdManager);
            GoalConditions       = new Conditions(inputData.Problem.Goal, null, IdManager, EvaluationManager);
            RigidRelations       = new RigidRelations(InitialState, Operators);
            TransitionsGenerator = new Lazy <TransitionsGenerator>(() => new TransitionsGenerator(this));

            EvaluationManager.SetRigidRelations(RigidRelations);
        }
        /// <summary>
        /// Evaluates the expression.
        /// </summary>
        /// <param name="expression">Expression.</param>
        /// <returns>True if the expression is logically true, false otherwise.</returns>
        public override bool Visit(PredicateLiteralCNF expression)
        {
            IAtom groundedPredicateAtom = GroundingManager.GroundAtomDeep(expression.PredicateAtom, Substitution, ReferenceState);

            if (RigidRelations.Contains(groundedPredicateAtom))
            {
                // satisfied or failed by rigid relation
                return(!expression.IsNegated);
            }

            bool hasPredicate = ReferenceState.HasPredicate(groundedPredicateAtom);

            if (hasPredicate == expression.IsNegated)
            {
                // failed by state predicate
                return(false);
            }

            // satisfied by state predicate -> store this atom
            Atoms.Add(groundedPredicateAtom);
            return(true);
        }
Пример #7
0
 /// <summary>
 /// Set the rigid properties of the corresponding planning problem.
 /// </summary>
 /// <param name="rigidRelations">Rigid relations of the planning problem.</param>
 public void SetRigidRelations(RigidRelations rigidRelations)
 {
     RigidRelations = rigidRelations;
 }
Пример #8
0
 /// <summary>
 /// Constructs the evaluator.
 /// </summary>
 /// <param name="groundingManager">Grounding manager.</param>
 /// <param name="rigidRelations">Rigid relations.</param>
 public RigidRelationsComplianceEvaluator(GroundingManager groundingManager, RigidRelations rigidRelations = null)
 {
     GroundingManager = groundingManager;
     RigidRelations   = rigidRelations ?? new RigidRelations();
 }
Пример #9
0
 /// <summary>
 /// Checks whether the specified predicate is a rigid relation of the planning problem.
 /// </summary>
 /// <param name="predicateAtom">Predicate atom.</param>
 /// <returns>True if the predicate is of rigid relation, false otherwise.</returns>
 public bool IsPredicateRigidRelation(IAtom predicateAtom)
 {
     return(RigidRelations.IsPredicateRigidRelation(predicateAtom));
 }
 /// <summary>
 /// Constructs the evaluator.
 /// </summary>
 /// <param name="groundingManager">Grounding manager.</param>
 /// <param name="rigidRelations">Rigid relations.</param>
 public SatisfyingAtomsEvaluator(GroundingManager groundingManager, RigidRelations rigidRelations) : base(groundingManager, rigidRelations)
 {
 }
Пример #11
0
        /// <summary>
        /// Visits and evaluates predicate expression.
        /// </summary>
        /// <param name="expression">Predicate expression.</param>
        /// <returns>True if the specified expression evaluates as true, false otherwise.</returns>
        public bool Visit(PredicateExpression expression)
        {
            IAtom groundedPredicateAtom = GroundingManager.GroundAtomDeep(expression.PredicateAtom, Substitution, ReferenceState);

            return(RigidRelations.Contains(groundedPredicateAtom) || ReferenceState.HasPredicate(groundedPredicateAtom));
        }
Пример #12
0
 /// <summary>
 /// Constructs the logical evaluator.
 /// </summary>
 /// <param name="groundingManager">Grounding manager.</param>
 /// <param name="rigidRelations">Rigid relations.</param>
 public ExpressionEvaluator(GroundingManager groundingManager, RigidRelations rigidRelations = null)
 {
     GroundingManager = groundingManager;
     NumericEvaluator = new Lazy <NumericExpressionEvaluator>(() => new NumericExpressionEvaluator(groundingManager));
     RigidRelations   = rigidRelations ?? new RigidRelations();
 }