Exemplo n.º 1
0
        /// <summary>
        /// Visits and evaluates exists expression.
        /// </summary>
        /// <param name="expression">Exists expression.</param>
        /// <returns>True if the specified expression evaluates as true, false otherwise.</returns>
        public bool Visit(ExistsExpression 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(true);
                }
            }
            return(false);
        }
        /// <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));
        }
Exemplo n.º 3
0
        /// <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));
        }
 /// <summary>
 /// Visits and transforms the expression.
 /// </summary>
 /// <param name="expression">Source expression.</param>
 /// <returns>Transformed expression.</returns>
 public override IExpression Visit(ExistsExpression expression)
 {
     return(new ExistsExpression(expression.Parameters, expression.Child.Accept(this)));
 }