Example #1
0
        private void drawTrapezoidFuzzyNumberGraph(ref Chart chart, string name, TrapezoidFuzzyNumber fnum, Color color)
        {
            // chart by point
            Series seriesPoint = chartFuzzy.Series.Add(name + "_point");
            seriesPoint.ChartType = SeriesChartType.Point;
            seriesPoint.BorderWidth = 2;
            seriesPoint.Color = color;
            seriesPoint.IsVisibleInLegend = false;
            decimal y = 0;
            Interval acut;
            while (y <= 1)
            {
                acut = fnum.AlphaCut(y);
                seriesPoint.Points.AddXY(acut.LowerBound, y);
                seriesPoint.Points.AddXY(acut.UpperBound, y);
                y = y + smooth;
            }

            y = 1;
            acut = fnum.AlphaCut(y);
            decimal x = acut.LowerBound;
            while (x <= acut.UpperBound)
            {
                seriesPoint.Points.AddXY(x, y);
                x += smooth;
            }

            // chart by line
            Series series = chart.Series.Add(name);
            series.ChartType = SeriesChartType.Line;
            series.BorderWidth = 2;
            series.Color = color;

            if (checkBoxDrawLine.Checked)
            {
                series.Points.AddXY(fnum.BottomLeft, 0);
                series.Points.AddXY(fnum.TopLeft, 1);
                series.Points.AddXY(fnum.TopRight, 1);
                series.Points.AddXY(fnum.BottomRight, 0);
            }
        }
Example #2
0
 private void resetGraphCoordinate(TrapezoidFuzzyNumber fnumA, TrapezoidFuzzyNumber fnumB)
 {
     // reset coordinate
     decimal minAxisX = Math.Min(fnumA.BottomLeft, fnumB.BottomLeft);
     Interval acut;
     if (checkBoxOperationAdd.Checked)
     {
         acut = ArithmeticInterval.Calculate(Operation.Add, fnumA.AlphaCut(0), fnumB.AlphaCut(0));
         minAxisX = Math.Min(minAxisX, acut.LowerBound);
     }
     if (checkBoxOperationSub.Checked)
     {
         acut = ArithmeticInterval.Calculate(Operation.Sub, fnumA.AlphaCut(0), fnumB.AlphaCut(0));
         minAxisX = Math.Min(minAxisX, acut.LowerBound);
     }
     if (checkBoxOperationMul.Checked)
     {
         acut = ArithmeticInterval.Calculate(Operation.Mul, fnumA.AlphaCut(0), fnumB.AlphaCut(0));
         minAxisX = Math.Min(minAxisX, acut.LowerBound);
     }
     if (checkBoxOperationDiv.Checked && !fnumB.IsZero())
     {
         acut = ArithmeticInterval.Calculate(Operation.Div, fnumA.AlphaCut(0), fnumB.AlphaCut(0));
         minAxisX = Math.Min(minAxisX, acut.LowerBound);
     }
     chartFuzzy.ChartAreas[0].AxisX.Minimum = (int)Math.Floor(minAxisX);
 }
Example #3
0
        private void drawResultIntervalBasedGraph(ref Chart chart, TrapezoidFuzzyNumber fnumA, TrapezoidFuzzyNumber fnumB, Operation operation, Color color)
        {
            // calculate result points list
            decimal y = 0;
            Interval acut, a, b;
            List<CPoint> resultPointListLeft = new List<CPoint>();
            List<CPoint> resultPointListRight = new List<CPoint>();
            while (y <= 1)
            {
                a = fnumA.AlphaCut(y);
                b = fnumB.AlphaCut(y);
                acut = ArithmeticInterval.Calculate(operation, a, b);

                resultPointListLeft.Add(new CPoint(acut.LowerBound, y));
                resultPointListRight.Add(new CPoint(acut.UpperBound, y));
                y += smooth;
            }

            y = 1;
            a = fnumA.AlphaCut(y);
            b = fnumB.AlphaCut(y);
            acut = ArithmeticInterval.Calculate(operation, a, b);
            decimal x = acut.LowerBound;
            while (x <= acut.UpperBound)
            {
                resultPointListLeft.Add(new CPoint(x, y));
                x += smooth;
            }

            // chart by line
            Series seriesLine = chart.Series.Add(operation.ToString());
            seriesLine.ChartType = SeriesChartType.Line;
            seriesLine.BorderWidth = 2;
            seriesLine.Color = color;
            // chart by point
            Series seriesPoint = chart.Series.Add(operation.ToString() + "_point");
            seriesPoint.ChartType = SeriesChartType.Point;
            seriesPoint.BorderWidth = 2;
            seriesPoint.Color = color;
            seriesPoint.IsVisibleInLegend = false;

            // draw the graph
            foreach (CPoint p in resultPointListLeft.OrderBy(i => i.x).OrderBy(i => i.y))
            {
                // by line
                if (checkBoxDrawLine.Checked)
                    seriesLine.Points.AddXY(p.x, p.y);
                // by point
                seriesPoint.Points.AddXY(p.x, p.y);
            }
            foreach (CPoint p in resultPointListRight.OrderBy(i => i.x).OrderByDescending(i => i.y))
            {
                // by line
                if (checkBoxDrawLine.Checked)
                    seriesLine.Points.AddXY(p.x, p.y);
                // by point
                seriesPoint.Points.AddXY(p.x, p.y);
            }

            addLog(operation.ToString() + " num of point :" + (resultPointListLeft.Count + resultPointListRight.Count).ToString());
            resultPointListLeft.Clear();
            resultPointListRight.Clear();
        }