GetLabelMembership() public méthode

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.
The label indicated in labelName was not found in the linguistic variable.
public GetLabelMembership ( string labelName, float value ) : float
labelName string Label (fuzzy set) to evaluate value's membership.
value float Value which label's membership will to be calculated.
Résultat float
Exemple #1
0
        public void SetInput2()
        {
            this.Power = new LinguisticVariable("Moc_samochodu", 20, 180);

            TrapezoidalFunction function1 = new TrapezoidalFunction(40, 100, TrapezoidalFunction.EdgeType.Right);
            FuzzySet            set1      = new FuzzySet("mała", function1);
            TrapezoidalFunction function2 = new TrapezoidalFunction(70, 100, 130);
            FuzzySet            set2      = new FuzzySet("średnia", function2);
            TrapezoidalFunction function3 = new TrapezoidalFunction(100, 160, TrapezoidalFunction.EdgeType.Left);
            FuzzySet            set3      = new FuzzySet("duża", function3);


            Power.AddLabel(set1);
            Power.AddLabel(set2);
            Power.AddLabel(set3);

            database.AddVariable(Power);

            double y1;
            double y2;
            double y3;

            for (float x = 20; x < 180; x += 0.5f)
            {
                if (Power.GetLabelMembership("mała", x + 0.5f) + Power.GetLabelMembership("mała", x) > 0)
                {
                    y1 = Power.GetLabelMembership("mała", x);
                    chart5.Series["Mała"].Points.AddXY(x, y1);
                }

                if (Power.GetLabelMembership("średnia", x + 0.5f) + Power.GetLabelMembership("średnia", x) > 0)
                {
                    y2 = Power.GetLabelMembership("średnia", x);
                    chart5.Series["Średnia"].Points.AddXY(x, y2);
                }
                if (Power.GetLabelMembership("duża", x + 0.5f) + Power.GetLabelMembership("duża", x) > 0)
                {
                    y3 = Power.GetLabelMembership("duża", x);
                    chart5.Series["Duża"].Points.AddXY(x, y3);
                }
            }
        }
Exemple #2
0
        public void SetInput1()
        {
            this.Temp_opon = new LinguisticVariable("Temperatura", 0, 180);

            TrapezoidalFunction function1 = new TrapezoidalFunction(30, 90, TrapezoidalFunction.EdgeType.Right);
            FuzzySet            set1      = new FuzzySet("zimne", function1);
            TrapezoidalFunction function2 = new TrapezoidalFunction(70, 90, 110);
            FuzzySet            set2      = new FuzzySet("średnie", function2);
            TrapezoidalFunction function3 = new TrapezoidalFunction(90, 150, TrapezoidalFunction.EdgeType.Left);
            FuzzySet            set3      = new FuzzySet("gorące", function3);

            Temp_opon.AddLabel(set1);
            Temp_opon.AddLabel(set2);
            Temp_opon.AddLabel(set3);

            database.AddVariable(Temp_opon);

            double y1;
            double y2;
            double y3;

            for (float x = 0; x < 180; x += 0.5f)
            {
                if (Temp_opon.GetLabelMembership("zimne", x + 0.5f) + Temp_opon.GetLabelMembership("zimne", x) > 0)
                {
                    y1 = Temp_opon.GetLabelMembership("zimne", x);
                    chart4.Series["Zimne"].Points.AddXY(x, y1);
                }
                if (Temp_opon.GetLabelMembership("średnie", x + 0.5f) + Temp_opon.GetLabelMembership("średnie", x) > 0)
                {
                    y2 = Temp_opon.GetLabelMembership("średnie", x);
                    chart4.Series["Średnie"].Points.AddXY(x, y2);
                }
                if (Temp_opon.GetLabelMembership("gorące", x + 0.5f) + Temp_opon.GetLabelMembership("gorące", x) > 0)
                {
                    y3 = Temp_opon.GetLabelMembership("gorące", x);
                    chart4.Series["Gorące"].Points.AddXY(x, y3);
                }
            }
        }
Exemple #3
0
        // Testing basic funcionality of linguistic variables
        private void runLingVarTestButton_Click( object sender, EventArgs e )
        {
            ClearDataSeries( );

            // create a linguistic variable to represent temperature
            LinguisticVariable lvTemperature = new LinguisticVariable( "Temperature", 0, 80 );

            // create the linguistic labels (fuzzy sets) that compose the temperature 
            TrapezoidalFunction function1 = new TrapezoidalFunction( 10, 15, TrapezoidalFunction.EdgeType.Right );
            FuzzySet fsCold = new FuzzySet( "Cold", function1 );
            TrapezoidalFunction function2 = new TrapezoidalFunction( 10, 15, 20, 25 );
            FuzzySet fsCool = new FuzzySet( "Cool", function2 );
            TrapezoidalFunction function3 = new TrapezoidalFunction( 20, 25, 30, 35 );
            FuzzySet fsWarm = new FuzzySet( "Warm", function3 );
            TrapezoidalFunction function4 = new TrapezoidalFunction( 30, 35, TrapezoidalFunction.EdgeType.Left );
            FuzzySet fsHot = new FuzzySet( "Hot", function4 );

            // adding labels to the variable
            lvTemperature.AddLabel( fsCold );
            lvTemperature.AddLabel( fsCool );
            lvTemperature.AddLabel( fsWarm );
            lvTemperature.AddLabel( fsHot );

            // get membership of some points to the cool fuzzy set
            double[][,] chartValues = new double[4][,];
            for ( int i = 0; i < 4; i++ )
                chartValues[i] = new double[160, 2];

            // showing the shape of the linguistic variable - the shape of its labels memberships from start to end
            int j = 0;
            for ( float x = 0; x < 80; x += 0.5f, j++ )
            {
                double y1 = lvTemperature.GetLabelMembership( "Cold", x );
                double y2 = lvTemperature.GetLabelMembership( "Cool", x );
                double y3 = lvTemperature.GetLabelMembership( "Warm", x );
                double y4 = lvTemperature.GetLabelMembership( "Hot", x );

                chartValues[0][j, 0] = x;
                chartValues[0][j, 1] = y1;
                chartValues[1][j, 0] = x;
                chartValues[1][j, 1] = y2;
                chartValues[2][j, 0] = x;
                chartValues[2][j, 1] = y3;
                chartValues[3][j, 0] = x;
                chartValues[3][j, 1] = y4;
            }

            // plot membership to a chart
            chart.UpdateDataSeries( "COLD", chartValues[0] );
            chart.UpdateDataSeries( "COOL", chartValues[1] );
            chart.UpdateDataSeries( "WARM", chartValues[2] );
            chart.UpdateDataSeries( "HOT", chartValues[3] );
        }
Exemple #4
0
        public void SetOutput()
        {
            this.Risk = new LinguisticVariable("Ryzyko", 0, 30);

            TrapezoidalFunction function1 = new TrapezoidalFunction(5, 10, TrapezoidalFunction.EdgeType.Right);
            FuzzySet            set1      = new FuzzySet("niskie", function1);
            TrapezoidalFunction function2 = new TrapezoidalFunction(5, 10, 15);
            FuzzySet            set2      = new FuzzySet("średnio_niskie", function2);
            TrapezoidalFunction function3 = new TrapezoidalFunction(10, 15, 20);
            FuzzySet            set3      = new FuzzySet("średnie", function3);
            TrapezoidalFunction function4 = new TrapezoidalFunction(15, 20, 25);
            FuzzySet            set4      = new FuzzySet("średnio_wysokie", function4);
            TrapezoidalFunction function5 = new TrapezoidalFunction(20, 25, TrapezoidalFunction.EdgeType.Left);
            FuzzySet            set5      = new FuzzySet("wysokie", function5);


            Risk.AddLabel(set1);
            Risk.AddLabel(set2);
            Risk.AddLabel(set3);
            Risk.AddLabel(set4);
            Risk.AddLabel(set5);

            database.AddVariable(Risk);

            double y1;
            double y2;
            double y3;
            double y4;
            double y5;

            for (float x = 0; x < 30; x += 0.05f)
            {
                if (Risk.GetLabelMembership("niskie", x + 0.05f) + Risk.GetLabelMembership("niskie", x) > 0)
                {
                    y1 = Risk.GetLabelMembership("niskie", x);
                    chart6.Series["Niskie"].Points.AddXY(x, y1);
                }
                if (Risk.GetLabelMembership("średnio_niskie", x + 0.05f) + Risk.GetLabelMembership("średnio_niskie", x) > 0)
                {
                    y2 = Risk.GetLabelMembership("średnio_niskie", x);
                    chart6.Series["Śr_nisk"].Points.AddXY(x, y2);
                }

                if (Risk.GetLabelMembership("średnie", x + 0.05f) + Risk.GetLabelMembership("średnie", x) > 0)
                {
                    y3 = Risk.GetLabelMembership("średnie", x);
                    chart6.Series["Średnie"].Points.AddXY(x, y3);
                }

                if (Risk.GetLabelMembership("średnio_wysokie", x + 0.05f) + Risk.GetLabelMembership("średnio_wysokie", x) > 0)
                {
                    y4 = Risk.GetLabelMembership("średnio_wysokie", x);
                    chart6.Series["Śr_wys"].Points.AddXY(x, y4);
                }

                if (Risk.GetLabelMembership("wysokie", x + 0.05f) + Risk.GetLabelMembership("wysokie", x) > 0)
                {
                    y5 = Risk.GetLabelMembership("wysokie", x);
                    chart6.Series["Wysokie"].Points.AddXY(x, y5);
                }
            }
        }