/// <summary> /// Visits and performs a property count on forall expression. /// </summary> /// <param name="expression">Forall expression.</param> /// <returns>Tuple (property satisfied count, property not satisfied count).</returns> public Tuple <double, double> Visit(ForallExpression expression) { double positiveValue = 0; double negativeValue = 0; IEnumerable <ISubstitution> localSubstitutions = GroundingManager.GenerateAllLocalSubstitutions(expression.Parameters); foreach (var localSubstitution in localSubstitutions) { Substitution.AddLocalSubstitution(localSubstitution); var childPropertyCounts = expression.Child.Accept(this); Substitution.RemoveLocalSubstitution(localSubstitution); if (EvaluationStrategy == ForwardCostEvaluationStrategy.ADDITIVE_VALUE) { positiveValue += childPropertyCounts.Item1; negativeValue += childPropertyCounts.Item2; } else { positiveValue = Math.Max(positiveValue, childPropertyCounts.Item1); negativeValue = Math.Max(negativeValue, childPropertyCounts.Item2); } } return(Tuple.Create(positiveValue, negativeValue)); }
/// <summary> /// Visits and handles the effect. /// </summary> /// <param name="effect">Effect.</param> public void Visit(ForallEffect effect) { IEnumerable <ISubstitution> localSubstitutions = GroundingManager.GenerateAllLocalSubstitutions(effect.Parameters); foreach (var localSubstitution in localSubstitutions) { Substitution.AddLocalSubstitution(localSubstitution); foreach (var localEffect in effect.Effects) { localEffect.Accept(this); } Substitution.RemoveLocalSubstitution(localSubstitution); } }
/// <summary> /// Visits and evaluates forall expression. /// </summary> /// <param name="expression">Forall expression.</param> /// <returns>True if the specified expression evaluates as true, false otherwise.</returns> public bool Visit(ForallExpression expression) { IEnumerable <ISubstitution> localSubstitutions = GroundingManager.GenerateAllLocalSubstitutions(expression.Parameters); foreach (var localSubstitution in localSubstitutions) { Substitution.AddLocalSubstitution(localSubstitution); bool subExpressionResult = expression.Child.Accept(this); Substitution.RemoveLocalSubstitution(localSubstitution); if (!subExpressionResult) { return(false); } } return(true); }
/// <summary> /// Visits and performs a property count on exists expression. /// </summary> /// <param name="expression">Exists expression.</param> /// <returns>Tuple (property satisfied count, property not satisfied count).</returns> public Tuple <double, double> Visit(ExistsExpression expression) { double positiveValue = 0.0; double negativeValue = 0.0; IEnumerable <ISubstitution> localSubstitutions = GroundingManager.GenerateAllLocalSubstitutions(expression.Parameters); foreach (var localSubstitution in localSubstitutions) { Substitution.AddLocalSubstitution(localSubstitution); var childPropertyCounts = expression.Child.Accept(this); Substitution.RemoveLocalSubstitution(localSubstitution); positiveValue = Math.Max(positiveValue, childPropertyCounts.Item1); negativeValue = Math.Max(negativeValue, childPropertyCounts.Item2); } return(Tuple.Create(positiveValue, negativeValue)); }
/// <summary> /// Visits and performs a property count on forall expression. /// </summary> /// <param name="expression">Forall expression.</param> /// <returns>Tuple (property satisfied count, property not satisfied count).</returns> public Tuple <int, int> Visit(ForallExpression expression) { int fulfilled = 0; int notFulfilled = 0; IEnumerable <ISubstitution> localSubstitutions = GroundingManager.GenerateAllLocalSubstitutions(expression.Parameters); foreach (var localSubstitution in localSubstitutions) { Substitution.AddLocalSubstitution(localSubstitution); var childPropertyCounts = expression.Child.Accept(this); Substitution.RemoveLocalSubstitution(localSubstitution); fulfilled += childPropertyCounts.Item1; notFulfilled += childPropertyCounts.Item2; } return(Tuple.Create(fulfilled, notFulfilled)); }
/// <summary> /// Visits and performs a property count on exists expression. /// </summary> /// <param name="expression">Exists expression.</param> /// <returns>Tuple (property satisfied count, property not satisfied count).</returns> public Tuple <int, int> Visit(ExistsExpression expression) { int minFulfilled = int.MaxValue; int minNotFulfilled = int.MaxValue; IEnumerable <ISubstitution> localSubstitutions = GroundingManager.GenerateAllLocalSubstitutions(expression.Parameters); foreach (var localSubstitution in localSubstitutions) { Substitution.AddLocalSubstitution(localSubstitution); var childPropertyCounts = expression.Child.Accept(this); Substitution.RemoveLocalSubstitution(localSubstitution); minFulfilled = Math.Min(minFulfilled, childPropertyCounts.Item1); minNotFulfilled = Math.Min(minNotFulfilled, childPropertyCounts.Item2); } return(Tuple.Create(minFulfilled, minNotFulfilled)); }