/// <summary>
        /// Collects used numeric functions in the given numeric expression.
        /// </summary>
        /// <param name="expression">Numeric expression.</param>
        /// <returns>Collected numeric functions.</returns>
        public HashSet <NumericFunction> Collect(INumericExpression expression)
        {
            Debug.Assert(NumericFunctions.Count == 0);
            NumericFunctions.Clear();

            expression.Accept(this);

            HashSet <NumericFunction> result = NumericFunctions;

            NumericFunctions = new HashSet <NumericFunction>();

            return(result);
        }
Beispiel #2
0
 /// <summary>
 /// Replaces numeric function instances in the given numeric expression and the whole expression is partially or fully reduced.
 /// </summary>
 /// <param name="numericExpression">Numeric expression to be evaluated.</param>
 /// <returns>Transformed numeric expression.</returns>
 public INumericExpression Replace(INumericExpression numericExpression)
 {
     return(numericExpression.Accept(this));
 }
 /// <summary>
 /// Grounds the expression.
 /// </summary>
 /// <param name="numericExpression">Numeric expression.</param>
 /// <param name="substitution">Variables substitution.</param>
 /// <returns>Grounded expression.</returns>
 public INumericExpression Ground(INumericExpression numericExpression, ISubstitution substitution)
 {
     Substitution = substitution;
     return(numericExpression.Accept(this));
 }
Beispiel #4
0
 /// <summary>
 /// Evaluates numeric expression.
 /// </summary>
 /// <param name="expression">Numeric expression.</param>
 /// <param name="substitution">Variable substitution.</param>
 /// <param name="referenceState">Reference state.</param>
 /// <returns>Evaluated numeric value.</returns>
 public double Evaluate(INumericExpression expression, ISubstitution substitution, IState referenceState)
 {
     Substitution   = substitution;
     ReferenceState = referenceState;
     return(expression.Accept(this));
 }