Als erstes schaffen wir eine geeignete Fuzzy-Logik.
with Fuzzy_Boolean, Defs;
with My_Fuzzy_Boolean, General_Set, Defs;
package Fuzzy_Set is new General_Set(Defs.real,My_Fuzzy_Boolean.fuzzy_bool);
Abbildung: Eine dreiecksförmige Verteilung einer Membership-Funktion
with Fuzzy_Boolean;
generic
type real is digits
l,m,u: real;
type fuzzy_real is digits
with package This_Fuzzy_Boolean is new Fuzzy_Boolean(fuzzy_real);
function Triangle(I: real)
return This_Fuzzy_Boolean.fuzzy_bool'CLASS;
function Triangle(I: real)
return This_Fuzzy_Boolean.fuzzy_bool'CLASS
is
begin
if I
return This_Fuzzy_Boolean.zero;
elsif I=m then
return This_Fuzzy_Boolean.one;
elsif I
return This_Fuzzy_Boolean.Convert(
fuzzy_real((I-l)
else -I
return This_Fuzzy_Boolean.Convert(
fuzzy_real((I-u)
end if;
end Triangle;
with Triangle, My_Fuzzy_Boolean, Defs;
function Triangle_1 is new Triangle(
Defs.real,0.0,1.0,2.0,Defs.fuzzy_real,My_Fuzzy_Boolean);
with Triangle, Defs, My_Fuzzy_Boolean;
function Triangle_2 is new Triangle(
Defs.real,1.0,2.0,3.0,Defs.fuzzy_real,My_Fuzzy_Boolean);
with Defs, Triangle, My_Fuzzy_Boolean, Fuzzy_Set, Ada.Text_IO, Triangle_1, Triangle_2;
procedure main_fuzzy
is
tr_1_ptr: Fuzzy_Set.Member_Function_Pointer := Triangle_1'Access;
tr_2_ptr: Fuzzy_Set.Member_Function_Pointer := Triangle_2'Access;
my_set_1, my_set_2, my_set_3: Fuzzy_Set.set;
package Real_IO is new Ada.Text_IO.Float_IO(Defs.fuzzy_real);
begin
my_set_1 :=
Fuzzy_Set.Create(
Member_Function =
my_set_2 :=
Fuzzy_Set.Create(
Member_Function =
my_set_3 := Fuzzy_Set.Union(my_set_1, my_set_2);
Real_IO.Put(My_Fuzzy_Boolean.Convert(Fuzzy_Set.Is_Member(1.5, my_set_3)));
end main_fuzzy;