AForge.Fuzzy.Clause.Evaluate C# (CSharp) Method

Evaluate() public method

Evaluates the fuzzy clause.
public Evaluate ( ) : float
return float
        public float Evaluate( )
        {
            return label.GetMembership( variable.NumericInput );
        }

Usage Example

示例#1
0
        /// <summary>
        /// Evaluates the firing strength of the Rule, the degree of confidence that the consequent of this Rule
        /// must be executed.
        /// </summary>
        ///
        /// <returns>The firing strength [0..1] of the Rule.</returns>
        ///
        public float EvaluateFiringStrength( )
        {
            // Stack to store the operand values
            Stack <float> s = new Stack <float>( );

            // Logic to calculate the firing strength
            foreach (object o in rpnTokenList)
            {
                // if its a clause, then its value must be calculated and pushed
                if (o.GetType( ) == typeof(Clause))
                {
                    Clause c = o as Clause;
                    s.Push(c.Evaluate( ));
                }
                // if its an operator (AND / OR) the operation is performed and the result
                // returns to the stack
                else
                {
                    float y = s.Pop( );
                    float x = 0;

                    // unary pops only one value
                    if (unaryOperators.IndexOf(o.ToString( )) < 0)
                    {
                        x = s.Pop( );
                    }

                    // operation
                    switch (o.ToString( ))
                    {
                    case "AND":
                        s.Push(normOperator.Evaluate(x, y));
                        break;

                    case "OR":
                        s.Push(conormOperator.Evaluate(x, y));
                        break;

                    case "NOT":
                        s.Push(notOperator.Evaluate(y));
                        break;
                    }
                }
            }

            // result on the top of stack
            return(s.Pop( ));
        }