system-rekomendacyjny-zawod.../transfer-rate.fcl

63 lines
2.4 KiB
Plaintext

FUNCTION_BLOCK transfer_rate
VAR_INPUT
season_rate : REAL;
prev_season_rate: REAL; // Póki co nieużywane, możliwe że wywalimy.
age: REAL;
market_value REAL;
END_VAR
VAR_OUTPUT
tranfser_rate : REAL;
END_VAR
FUZZIFY season_rate // Zmienna 'season_rate': {'niska', 'srednia' , 'wysoka'}
TERM niska := (0, 1) (40, 1) (50, 0);
TERM srednia := (40, 0) (50, 1) (60, 1) (80, 0);
TERM wysoka := (70, 0) (80, 1) (100, 1);
END_FUZZIFY
FUZZIFY age // Zmienna 'age': {'mlody', 'sredni' , 'stary'}
TERM mlody := (15, 1) (20, 1) (25, 0);
TERM sredni := (20, 0) (25, 1) (28, 1) (30, 0);
TERM stary := (28, 0) (30, 1) (40, 1);
END_FUZZIFY
FUZZIFY market_value // Zmienna 'market_value': {'malo', 'srednio' , 'duzo'}
TERM malo := (0, 1) (15, 1) (40, 0);
TERM sredno := (30, 0) (50, 1) (80, 0);
TERM duzo := (70, 0) (80, 1) (180, 1);
END_FUZZIFY
DEFUZZIFY tranfser_rate // Zmienna 'tranfser_rate' : {'niski', 'sredni', 'wysoki'}
TERM niski := (0, 1) (40, 1) (50, 0);
TERM sredni := (40, 0) (50, 1) (60, 1) (80, 0);
TERM wysoki := (70, 0) (80, 1) (100, 1);
METHOD : COG; // Metoda defuzyfikacji - 'Center Of Gravity' - 'Sreodka ciezkosci'
DEFAULT := 0;
END_DEFUZZIFY
RULEBLOCK No1
AND : MIN; // Uzycie 'min' jako 'and' (implikuje uzycie 'max' jako 'or' dla zapewnienia praw DeMorgan'a)
ACT : MIN; // Uzycie 'min' jako metody aktywacji
ACCU : MAX; // Metoda agregacji - 'max'
RULE 1 : IF season_rate IS wysoka AND age IS mlody THEN tranfser_rate IS wysoki;
RULE 2 : IF season_rate IS wysoka AND market_value IS sredno THEN tranfser_rate IS wysoki;
RULE 3 : IF season_rate IS wysoka AND age IS sredni THEN tranfser_rate IS wysoki;
RULE 4 : IF age IS mlody AND season_rate IS srednia THEN tranfser_rate IS sredni;
RULE 5 : IF market_value IS malo AND season_rate IS srednia THEN tranfser_rate IS sredni;
RULE 6 : IF market_value IS malo AND age IS mlody THEN tranfser_rate IS sredni;
RULE 7 : IF age IS stary AND market_value IS malo THEN tranfser_rate IS sredni;
RULE 8 : IF age IS stary AND market_value IS malo THEN tranfser_rate IS niski;
RULE 9 : IF age IS srednio AND market_value IS srednio THEN tranfser_rate IS niski;
RULE 10 : IF season_rate IS niska THEN tranfser_rate IS niski;
END_RULEBLOCK
END_FUNCTION_BLOCK