4 sys
.path
.insert(0, os
.getcwd())
5 prefix
= os
.path
.join(sys
.path
[0], "build")
6 if not os
.path
.exists(prefix
):
11 import matplotlib
.pyplot
as plt
12 except Exception as e
:
16 title
= "Gaussian membership function"
17 x
= np
.arange(-3, 3, 0.001)
18 y
= a
.mf
.gauss(x
, 1, 0)
23 plt
.savefig(os
.path
.join(prefix
, "mf_gauss.png"))
25 title
= "Gaussian combination membership function"
26 x
= np
.arange(-3, 3, 0.001)
27 y
= a
.mf
.gauss2(x
, 1, -1, 1, +1)
32 plt
.savefig(os
.path
.join(prefix
, "mf_gauss2.png"))
34 title
= "Generalized bell-shaped membership function"
35 x
= np
.arange(-3, 3, 0.001)
36 y
= a
.mf
.gbell(x
, 2, 4, 0)
41 plt
.savefig(os
.path
.join(prefix
, "mf_gbell.png"))
43 title
= "Sigmoidal membership function"
44 x
= np
.arange(-3, 3, 0.001)
50 plt
.savefig(os
.path
.join(prefix
, "mf_sig.png"))
52 title
= "Difference between two sigmoidal membership functions"
53 x
= np
.arange(-3, 3, 0.001)
54 y
= a
.mf
.dsig(x
, 5, -2, +5, 2)
59 plt
.savefig(os
.path
.join(prefix
, "mf_dsig.png"))
61 title
= "Product of two sigmoidal membership functions"
62 x
= np
.arange(-3, 3, 0.001)
63 y
= a
.mf
.psig(x
, 5, -2, -5, 2)
68 plt
.savefig(os
.path
.join(prefix
, "mf_psig.png"))
70 title
= "Triangular membership function"
71 x
= np
.arange(0, 2, 0.001)
72 y
= a
.mf
.tri(x
, 0, 1, 2)
77 plt
.savefig(os
.path
.join(prefix
, "mf_tri.png"))
80 title
= "Trapezoidal membership function"
81 x
= np
.arange(0, 3, 0.001)
82 y
= a
.mf
.trap(x
, 0, 1, 2, 3)
87 plt
.savefig(os
.path
.join(prefix
, "mf_trap.png"))
89 title
= "Linear s-shaped saturation membership function"
90 x
= np
.arange(0, 3, 0.001)
91 y
= a
.mf
.lins(x
, 1, 2)
96 plt
.savefig(os
.path
.join(prefix
, "mf_lins.png"))
98 title
= "Linear z-shaped saturation membership function"
99 x
= np
.arange(0, 3, 0.001)
100 y
= a
.mf
.linz(x
, 1, 2)
105 plt
.savefig(os
.path
.join(prefix
, "mf_linz.png"))
107 title
= "S-shaped membership function"
108 x
= np
.arange(0, 3, 0.001)
114 plt
.savefig(os
.path
.join(prefix
, "mf_s.png"))
116 title
= "Z-shaped membership function"
117 x
= np
.arange(0, 3, 0.001)
123 plt
.savefig(os
.path
.join(prefix
, "mf_z.png"))
126 title
= "Pi-shaped membership function"
127 x
= np
.arange(0, 3, 0.001)
128 y
= a
.mf
.pi(x
, 0, 1, 2, 3)
133 plt
.savefig(os
.path
.join(prefix
, "mf_pi.png"))
137 (a
.mf
.TRI
, -3 * S
, -3 * S
, -2 * S
),
138 (a
.mf
.TRI
, -3 * S
, -2 * S
, -1 * S
),
139 (a
.mf
.TRI
, -2 * S
, -1 * S
, +0 * S
),
140 (a
.mf
.TRI
, -1 * S
, +0 * S
, +1 * S
),
141 (a
.mf
.TRI
, +0 * S
, +1 * S
, +2 * S
),
142 (a
.mf
.TRI
, +1 * S
, +2 * S
, +3 * S
),
143 (a
.mf
.TRI
, +2 * S
, +3 * S
, +3 * S
),
146 title
= "membership function"
147 x
= np
.arange(-3 * S
, +3 * S
, 0.001)
151 plt
.plot(x
, a
.mf()(param
[0], x
, param
[1:]))
152 plt
.savefig(os
.path
.join(prefix
, "mf.png"))