Ejemplo n.º 1
0
        private void UcFuzzySetCanvas_Load(object sender, EventArgs e)
        {
            if (DesignMode)
            {
                return;
            }
            int    count = mFuzzySet.GetMembershipCount();
            double minX  = mFuzzySet.GetMinX();
            double maxX  = mFuzzySet.GetMaxX();

            chtFuzzySet.Series.Clear();

            double deltaX = mFuzzySet.GetDeltaX();

            for (int i = 0; i < count; ++i)
            {
                Membership ms     = mFuzzySet.GetMembership(i);
                Series     series = new Series(mFuzzySet.GetMembershipName(i));
                series.ChartType = SeriesChartType.FastLine;
                for (double x = minX; x <= maxX; x += deltaX)
                {
                    double y = ms.degree(x);
                    series.Points.AddXY(x, y);
                }
                chtFuzzySet.Series.Add(series);
            }
            chtFuzzySet.ChartAreas[0].AxisX.Title = "Crisp Value";
            chtFuzzySet.ChartAreas[0].AxisY.Title = "Membership Degree";
            chtFuzzySet.ChartAreas[0].RecalculateAxesScale();
            chtFuzzySet.Titles.Add(string.Format("FuzzySet: {0}", mFuzzySetName));
        }
Ejemplo n.º 2
0
        public void Fire(List <Rule> rules)
        {
            Dictionary <string, List <double> > degrees = new Dictionary <string, List <double> >();

            for (int i = 0; i < mValues.Count; ++i)
            {
                degrees[mValues[i]] = new List <double>();
            }

            for (int i = 0; i < rules.Count; ++i)
            {
                Rule   rule       = rules[i];
                Clause consequent = rule.Consequent;
                if (consequent.Variable == this)
                {
                    double y = 1;

                    for (int j = 0; j < rule.AntecedentCount; ++j)
                    {
                        Clause     antecedent = rule.getAntecedent(j);
                        FuzzySet   variable   = antecedent.Variable;
                        string     value      = antecedent.Value;
                        Membership ms         = variable.GetMembership(value);
                        double     degree     = ms.degree(variable.X);
                        if (y > degree)
                        {
                            y = degree;
                        }
                    }
                    degrees[consequent.Value].Add(y);
                }
            }

            Dictionary <string, double> consequent_degrees = getRootSumSquare(degrees);

            mValX = getAreaCentroid(consequent_degrees);
        }