1 | #ifndef _GENO_f0Fuzzy_H_ |
---|
2 | #define _GENO_f0Fuzzy_H_ |
---|
3 | |
---|
4 | /// Table of probabilities - names used in project facilitate reading |
---|
5 | |
---|
6 | #define F0Fuzzy_ADDSET 0 |
---|
7 | #define F0Fuzzy_REMSET 1 |
---|
8 | #define F0Fuzzy_ADDRULE 2 |
---|
9 | #define F0Fuzzy_REMRULE 3 |
---|
10 | #define F0Fuzzy_MODRULE 4 |
---|
11 | #define F0Fuzzy_MOD2RULE 5 |
---|
12 | #define F0Fuzzy_COUNT 6 |
---|
13 | |
---|
14 | #include "sstring.h" |
---|
15 | #include "geno_fx.h" |
---|
16 | |
---|
17 | class Geno_f0Fuzzy : public Geno_fx |
---|
18 | { |
---|
19 | private: |
---|
20 | /** Function finds number of nearest fuzzy (in list of sets) to given fuzzy set |
---|
21 | \param set fuzzy set to be matched |
---|
22 | \param sets fuzzy sets list |
---|
23 | \param setsNr number of fuzzy sets in list |
---|
24 | @return number of the nearest fuzzy set in sets list |
---|
25 | **/ |
---|
26 | int nearestSet(double set[4], double sets[], int setsNr); |
---|
27 | /** Function changes numeration of fuzzy sets numbers in fuzzy rules string, according to transformation table. |
---|
28 | \param rules fuzzy rules string |
---|
29 | \param transTable table of fuzzy sets transformation - [old_number]=new_number |
---|
30 | \param nrItems number of old fuzzy sets |
---|
31 | @return success or failure |
---|
32 | **/ |
---|
33 | int changeSetsNumeration(SString &rules, int transTable[], int nrItems); |
---|
34 | /** Function checks which fuzzy sets are used in rules and removed unused from fuzzy sets string, filling |
---|
35 | appropriate values into transformation table. |
---|
36 | \param sets fuzzy sets string |
---|
37 | \param rules fuzzy rules string |
---|
38 | \param setsNr number of fuzzy sets (input value: before removing, output value: after removing) |
---|
39 | \param transTable table of fuzzy sets transformation - [old_number]=new_number |
---|
40 | @return success or failure |
---|
41 | **/ |
---|
42 | int removeUnusedSets(SString &sets, SString rules, int &setsNr, int transTable[]); |
---|
43 | /** Function checks every rule whether input or output number does not duplicace in one rule. If so, removes |
---|
44 | excessive input or output. |
---|
45 | \param rules fuzzy rules string |
---|
46 | \param inputsNr number of system inputs |
---|
47 | \param outputsNr number of system outputs |
---|
48 | @return success or failure |
---|
49 | **/ |
---|
50 | int removeExcessiveInOut(SString &rules, int inputsNr, int outputsNr); |
---|
51 | /** Function checks rule-based system whether there there is no duplicate rule's premise part. If so, removes |
---|
52 | excessive one. |
---|
53 | \param rules fuzzy rules string |
---|
54 | \param inputsNr number of system inputs |
---|
55 | \param outputsNr number of system outputs |
---|
56 | @return success or failure |
---|
57 | **/ |
---|
58 | int removeExcessiveRules(SString &rules, int setsNr, int &rulesNr); |
---|
59 | /** Function sorts given fuzzy sets in not decreasing rank. |
---|
60 | \param set fuzzy set |
---|
61 | @return success or failure |
---|
62 | **/ |
---|
63 | int sortSet(double set[4]); |
---|
64 | /** Function calculates randomly new fuzzy set, using random gauss routines from rndutil.h. |
---|
65 | \param newSet values (4 numbers) of new fuzzy set |
---|
66 | @return success or failure |
---|
67 | **/ |
---|
68 | int computeSet(double newSet[4]); |
---|
69 | /** Function conducts checkValidity od validate procedures, depending on repair parameter. |
---|
70 | \param geno given input genotype (if repair=true and needs to be repaired and it was possible to repair, |
---|
71 | also output genotype) |
---|
72 | \param repair flag whether repair genotype (if needed) or not |
---|
73 | @return success or failure |
---|
74 | **/ |
---|
75 | int checkOrValidate(char *&geno, bool repair); |
---|
76 | /** |
---|
77 | Function compares fuzzy sets from two creatures and mark duplicated fuzzy sets. |
---|
78 | \param fuzzySets1 fuzzy sets from creature #1 |
---|
79 | \param setsNr1 number of fuzzy sets from creature #1 |
---|
80 | \param fuzzySets2 fuzzy sets from creature #2 |
---|
81 | \param setsNr2 number of fuzzy sets from creature #2 |
---|
82 | \param transTable table which remembers numbers of duplicated sets |
---|
83 | \param setsNr3 number of fuzzy sets from creatures #1 + #2 |
---|
84 | @return success or failure |
---|
85 | **/ |
---|
86 | int markDuplicatedSets(const double fuzzySets1[], const int setsNr1, const double fuzzySets2[], const int setsNr2, int transTable[], const int setsNr3); |
---|
87 | public: |
---|
88 | |
---|
89 | double probtab[F0Fuzzy_COUNT]; //table of probabilities - see #define above |
---|
90 | int maximumSetsNr; //total number of sets can not be greater than maximum |
---|
91 | int maximumRulesNr; //total number of rules can not be greater than maximum |
---|
92 | |
---|
93 | Geno_f0Fuzzy(); |
---|
94 | char *getSimplest(); |
---|
95 | int mutate(char *&g, float &chg,int &method); |
---|
96 | int crossOver(char *&g1, char *&g2, float &chg1, float &chg2); |
---|
97 | int checkValidity(const char *geno); |
---|
98 | int validate(char *&); |
---|
99 | }; |
---|
100 | |
---|
101 | #endif |
---|
102 | |
---|