public Quantifier(string name, QuantifierEnum enumVal) { ID = -1; Rule = String.Empty; QuantEnumRule = enumVal; Name = name; }
public static void DrawTrapezMF(Graphics area, int w, int h, Color color, double a, double b, double c, double d, double Xbottom, double Xtop, BoundaryTypeEnum bound, QuantifierEnum quantEnum = QuantifierEnum.EMPTY) { Pen pen = new Pen(color, 2); //var w = panel.Width; //var h = panel.Height; var gx = 0.1f * w; var gw = 0.8f * w; var gy = 0.1f * h; var gh = 0.7f * h; var k = (Xtop - Xbottom) / gw; var nul = (float)(Xbottom / k); //float yBottom = (float)MFunc.TrapezoidalMF(Xbottom, a, b, c, d, bound); //float yA = (float)MFunc.TrapezoidalMF(a, a, b, c, d, bound); //float yB = (float)MFunc.TrapezoidalMF(b, a, b, c, d, bound); //float yC = (float)MFunc.TrapezoidalMF(c, a, b, c, d, bound); //float yD = (float)MFunc.TrapezoidalMF(d, a, b, c, d, bound); //float yTop = (float)MFunc.TrapezoidalMF(Xtop, a, b, c, d, bound); float yBottom, yA, yB, yC, yD, yTop; switch (quantEnum) { case QuantifierEnum.NOT: yBottom = 1.0f - (float)MFunc.TrapezoidalMF(Xbottom, a, b, c, d, bound); yA = 1.0f - (float)MFunc.TrapezoidalMF(a, a, b, c, d, bound); yB = 1.0f - (float)MFunc.TrapezoidalMF(b, a, b, c, d, bound); yC = 1.0f - (float)MFunc.TrapezoidalMF(c, a, b, c, d, bound); yD = 1.0f - (float)MFunc.TrapezoidalMF(d, a, b, c, d, bound); yTop = 1.0f - (float)MFunc.TrapezoidalMF(Xtop, a, b, c, d, bound); break; case QuantifierEnum.VERY: yBottom = (float)Math.Pow(MFunc.TrapezoidalMF(Xbottom, a, b, c, d, bound), 2); yA = (float)Math.Pow(MFunc.TrapezoidalMF(a, a, b, c, d, bound), 2); yB = (float)Math.Pow(MFunc.TrapezoidalMF(b, a, b, c, d, bound), 2); yC = (float)Math.Pow(MFunc.TrapezoidalMF(c, a, b, c, d, bound), 2); yD = (float)Math.Pow(MFunc.TrapezoidalMF(d, a, b, c, d, bound), 2); yTop = (float)Math.Pow(MFunc.TrapezoidalMF(Xtop, a, b, c, d, bound), 2); break; case QuantifierEnum.MORE_OR_LESS: yBottom = (float)Math.Sqrt(MFunc.TrapezoidalMF(Xbottom, a, b, c, d, bound)); yA = (float)Math.Sqrt(MFunc.TrapezoidalMF(a, a, b, c, d, bound)); yB = (float)Math.Sqrt(MFunc.TrapezoidalMF(b, a, b, c, d, bound)); yC = (float)Math.Sqrt(MFunc.TrapezoidalMF(c, a, b, c, d, bound)); yD = (float)Math.Sqrt(MFunc.TrapezoidalMF(d, a, b, c, d, bound)); yTop = (float)Math.Sqrt(MFunc.TrapezoidalMF(Xtop, a, b, c, d, bound)); break; default: yBottom = (float)MFunc.TrapezoidalMF(Xbottom, a, b, c, d, bound); yA = (float)MFunc.TrapezoidalMF(a, a, b, c, d, bound); yB = (float)MFunc.TrapezoidalMF(b, a, b, c, d, bound); yC = (float)MFunc.TrapezoidalMF(c, a, b, c, d, bound); yD = (float)MFunc.TrapezoidalMF(d, a, b, c, d, bound); yTop = (float)MFunc.TrapezoidalMF(Xtop, a, b, c, d, bound); break; } if (a >= Xbottom) { area.DrawLine(pen, (float)(Xbottom / k - nul + gx), gy + (1 - yBottom) * gh, (float)(a / k - nul + gx), gy + (1 - yA) * gh); } if (d <= Xtop) { area.DrawLine(pen, (float)(d / k - nul + gx), gy + (1 - yD) * gh, (float)(Xtop / k - nul + gx), gy + (1 - yTop) * gh); } area.DrawLine(pen, (float)(a / k - nul + gx), gy + (1 - yA) * gh, (float)(b / k - nul + gx), gy + (1 - yB) * gh); area.DrawLine(pen, (float)(b / k - nul + gx), gy + (1 - yB) * gh, (float)(c / k - nul + gx), gy + (1 - yC) * gh); area.DrawLine(pen, (float)(c / k - nul + gx), gy + (1 - yC) * gh, (float)(d / k - nul + gx), gy + (1 - yD) * gh); }
public static void DrawGaussMF(Graphics area, int w, int h, Color color, double c, double sigma, double Xbottom, double Xtop, BoundaryTypeEnum bound, QuantifierEnum quantEnum = QuantifierEnum.EMPTY) { Pen pen = new Pen(color, 2); //var w = panel.Width; //var h = panel.Height; var gx = 0.1f * w; var gw = 0.8f * w; var gy = 0.1f * h; var gh = 0.7f * h; var k = (Xtop - Xbottom) / gw; double xLast = Xbottom; double yLast;// = MFunc.GaussMF(xLast, c, sigma, bound); switch (quantEnum) { case QuantifierEnum.NOT: yLast = 1 - MFunc.GaussMF(xLast, c, sigma, bound); break; case QuantifierEnum.VERY: yLast = Math.Pow(MFunc.GaussMF(xLast, c, sigma, bound), 2); break; case QuantifierEnum.MORE_OR_LESS: yLast = Math.Sqrt(MFunc.GaussMF(xLast, c, sigma, bound)); break; default: yLast = MFunc.GaussMF(xLast, c, sigma, bound); break; } double y; for (int i = 1; i <= gw; i++) { double x = Xbottom + k * i; switch (quantEnum) { case QuantifierEnum.NOT: y = 1 - MFunc.GaussMF(x, c, sigma, bound); break; case QuantifierEnum.VERY: y = Math.Pow(MFunc.GaussMF(x, c, sigma, bound), 2); break; case QuantifierEnum.MORE_OR_LESS: y = Math.Sqrt(MFunc.GaussMF(x, c, sigma, bound)); break; default: y = MFunc.GaussMF(x, c, sigma, bound); break; } area.DrawLine(pen, (float)gx + i - 1, (float)(gy + (1 - yLast) * gh), (float)gx + i, (float)(gy + (1 - y) * gh)); xLast = x; yLast = y; } }