Exemplo n.º 1
0
        // Testing basic funcionality of fuzzy sets
        private void runFuzzySetTestButton_Click( object sender, EventArgs e )
        {
            ClearDataSeries( );

            // create 2 fuzzy sets to represent the Cool and Warm temperatures
            TrapezoidalFunction function1 = new TrapezoidalFunction( 13, 18, 23, 28 );
            FuzzySet fsCool = new FuzzySet( "Cool", function1 );
            TrapezoidalFunction function2 = new TrapezoidalFunction( 23, 28, 33, 38 );
            FuzzySet fsWarm = new FuzzySet( "Warm", function2 );

            // get membership of some points to the cool fuzzy set
            double[,] coolValues = new double[20, 2];
            for ( int i = 10; i < 30; i++ )
            {
                coolValues[i - 10, 0] = i;
                coolValues[i - 10, 1] = fsCool.GetMembership( i );
            }

            // getting memberships of some points to the warm fuzzy set
            double[,] warmValues = new double[20, 2];
            for ( int i = 20; i < 40; i++ )
            {
                warmValues[i - 20, 0] = i;
                warmValues[i - 20, 1] = fsWarm.GetMembership( i );
            }

            // plot membership to a chart
            chart.UpdateDataSeries( "COOL", coolValues );
            chart.UpdateDataSeries( "WARM", warmValues );
        }
Exemplo n.º 2
0
 /// <summary>
 /// Evaluates the fuzzy clause.
 /// </summary>
 ///
 /// <returns>Degree of membership [0..1] of the clause.</returns>
 ///
 public float Evaluate( )
 {
     return(label.GetMembership(variable.NumericInput));
 }
        /// <summary>
        /// Calculate the membership of a given value to a given label. Used to evaluate linguistics clauses like
        /// "X IS A", where X is a value and A is a linguistic label.
        /// </summary>
        ///
        /// <param name="labelName">Label (fuzzy set) to evaluate value's membership.</param>
        /// <param name="value">Value which label's membership will to be calculated.</param>
        ///
        /// <returns>Degree of membership [0..1] of the value to the label (fuzzy set).</returns>
        ///
        /// <exception cref="KeyNotFoundException">The label indicated in labelName was not found in the linguistic variable.</exception>
        ///
        public float GetLabelMembership(string labelName, float value)
        {
            FuzzySet fs = labels[labelName];

            return(fs.GetMembership(value));
        }