/// <summary>
        /// Evaluates the label of the operator with the specified preconditions and substitution.
        /// </summary>
        /// <param name="conditions">Operator conditions.</param>
        /// <param name="substitution">Variable substitution.</param>
        /// <param name="stateLabels">Atom labels in the predecessor layer.</param>
        /// <param name="evaluationStrategy">Evaluation strategy.</param>
        /// <returns>Operator label value in the relaxed planning graph.</returns>
        public double Evaluate(ConditionsCNF conditions, ISubstitution substitution, StateLabels stateLabels, ForwardCostEvaluationStrategy evaluationStrategy)
        {
            Substitution       = substitution;
            StateLabels        = stateLabels;
            EvaluationStrategy = evaluationStrategy;

            return(conditions.Accept(this).Item1);
        }
Exemple #2
0
 /// <summary>
 /// Constructs the state layer from the initial state of the problem.
 /// </summary>
 /// <param name="state">State.</param>
 /// <param name="initLabels">Should the labels be initialized?</param>
 public StateLayer(IState state, bool initLabels = true)
 {
     State = state;
     if (initLabels)
     {
         Labels = new StateLabels(State);
     }
 }
        /// <summary>
        /// Visits and performs a property count on predicate expression.
        /// </summary>
        /// <param name="expression">Predicate expression.</param>
        /// <returns>Tuple (property satisfied count, property not satisfied count).</returns>
        public Tuple <double, double> Visit(PredicateLiteralCNF expression)
        {
            var groundedAtom = GroundingManager.GroundAtom(expression.PredicateAtom, Substitution);

            double value;

            if (StateLabels.TryGetValue(groundedAtom, out value))
            {
                return((expression.IsNegated) ? Tuple.Create(0.0, value) : Tuple.Create(value, 0.0));
            }

            return(Tuple.Create(0.0, 0.0));
        }
Exemple #4
0
        /// <summary>
        /// Checks the equality of objects.
        /// </summary>
        /// <param name="obj">Object to be checked.</param>
        /// <returns>True if the objects are equal, false otherwise.</returns>
        public override bool Equals(object obj)
        {
            if (obj == this)
            {
                return(true);
            }

            StateLabels other = obj as StateLabels;

            if (other == null)
            {
                return(false);
            }

            return(CollectionsEquality.Equals(this, other));
        }
Exemple #5
0
 /// <summary>
 /// Constructs the state layer from other state layer.
 /// </summary>
 /// <param name="other">Other state layer.</param>
 public StateLayer(StateLayer other)
 {
     State  = (IState)other.State.Clone();
     Labels = new StateLabels(other.Labels);
 }
Exemple #6
0
 /// <summary>
 /// Computes the operator label in the relaxed planning graph.
 /// </summary>
 /// <param name="substitution">Variable substitution.</param>
 /// <param name="stateLabels">Atom labels from the predecessor layer in the graph.</param>
 /// <param name="evaluationStrategy">Evaluation strategy of the planning graph.</param>
 /// <returns>Computed operator label in the relaxed planning graph.</returns>
 public double ComputePlanningGraphLabel(ISubstitution substitution, StateLabels stateLabels, ForwardCostEvaluationStrategy evaluationStrategy)
 {
     return(Preconditions.EvaluateOperatorPlanningGraphLabel(substitution, stateLabels, evaluationStrategy));
 }
Exemple #7
0
 /// <summary>
 /// Computes the operator label in the relaxed planning graph.
 /// </summary>
 /// <param name="conditions">Operator preconditions.</param>
 /// <param name="substitution">Variable substitution.</param>
 /// <param name="stateLabels">Atom labels from the predecessor layer in the graph.</param>
 /// <param name="evaluationStrategy">Evaluation strategy of the planning graph.</param>
 /// <returns>Computed operator label in the relaxed planning graph.</returns>
 public double EvaluateOperatorPlanningGraphLabel(ConditionsCNF conditions, ISubstitution substitution, StateLabels stateLabels, ForwardCostEvaluationStrategy evaluationStrategy)
 {
     return(PlanningGraphOperatorLabelEvaluatorCNF.Value.Evaluate(conditions, substitution, stateLabels, evaluationStrategy));
 }
Exemple #8
0
 /// <summary>
 /// Constructs state labels from other state labels.
 /// </summary>
 public StateLabels(StateLabels other) : base(other)
 {
 }