source: cpp/_old/f0-fuzzy/neuroimpl-fuzzy.h @ 477

Last change on this file since 477 was 193, checked in by Maciej Komosinski, 11 years ago

Set svn:eol-style native for all textual files

  • Property svn:eol-style set to native
File size: 2.9 KB
Line 
1#ifndef _NEUROIMPLFUZZY_H_
2#define _NEUROIMPLFUZZY_H_
3
4#include <stdlib.h>
5#include <math.h>
6
7#include "neuroimpl.h"
8#include "sstring.h"
9
10extern ParamEntry NI_FuzzyNeuro_tab[];
11
12/** Does the fuzzyfication process (of inputs) and defuzzyfication proces (of outpurs) - represents fuzzy rules
13*/
14class NI_FuzzyNeuro : public NeuroImpl
15{
16private:
17
18  double *fuzzySets;    /// list of four digits which represents fuzzy sets: [0]-l, [1]-m, [2]-n, [3]-r, ...  fuzzySet[4*i] = left, fuzzySet[4*i + 1] = midleft, fuzzySet[4*i + 2] = midright, fuzzySet[4*i + 3] = right
19
20  /** Determines, which fuzzy set is connected with each input of neuron. For instance third rule:
21  *   'IF input3 = fuzzy set #3 AND input5 = fuzzy set #1 then output2 = fuzzy set #6 AND output7 = fuzzy set #5'
22  *   the variables shoul have values as shown below:
23  *   RulesDef[4]=2; RulesDef[5]=2; //rule 3: 2 inputs, 2 outputs
24  *   Rules[2][0]=3, Rules[2][1]=3, Rules[2][2]=5, Rules[2][3]=1, Rules[2][4]=2, Rules[2][5]=6, Rules[2][6]=7, Rules[2][3]=5
25  */
26  int *rulesDef;    ///list of rules definitions: nr of inputs in rule 1, nr of outputs in rule 1, ... and so on for each rule
27  int **rules;      ///list of rules body: input nr, fuzzy set nr, ... , output nr, fuzzy set nr, ... and so on for each rule
28
29  /**
30  *  Sets defuzzyfication parameters: determines - for each rule - cut level <0;1> (minimum membership function of current rule).
31  *  In fact, defuzzParam remembers the values from 'first layer' - fuzzyfication layer (see neuron at documentation)
32  *  i.e. rule 1: defuzzParam[0] = 0.3522
33  */
34  double *defuzzParam; /// i.e.: defuzParam[5] = 0.455 means that rule #6 has got a minimum membership function (of given inputs set for this rule) at value 0.455 (it's cut level)
35
36protected:
37
38  ///Fuzzy functions
39  double TrapeziumFuzz(int which_fuzzy_set, double input_val);
40  int Fuzzyfication();
41  int Defuzzyfication();
42  int GetFuzzySetParam(int set_nr, double &left, double &midleft, double &midright, double &right);
43
44public:
45
46  int fuzzySetsNr;      /// number of fuzzy sets
47  int rulesNr;      ///number of rules
48  SString fuzzySetString; /// strings containing all fuzzy sets given in f0
49  SString fuzzyRulesString; /// strings containing all fuzzy rules given in f0
50
51  NI_FuzzyNeuro() {paramentries=NI_FuzzyNeuro_tab; fuzzySets=defuzzParam=NULL; rulesDef=NULL; rules=NULL;}
52  ~NI_FuzzyNeuro();
53  NeuroImpl* makeNew() { return new NI_FuzzyNeuro(); };
54  void go();
55  int lateinit();
56  /** Function build model based on given genotype and conts number of neurons connected with fuzzy neuro,
57    also checks number of fuzzy neuron inputs.
58    \param genotype genotype to be scanned
59    \param inputs number of fuzzy neuron inputs
60    \param output number of fuzzy neuron outputs (= number of neurons connected to fuzzy neuron)
61    @return success or failure
62  **/
63  static int countOuts(const Model *m, const Neuro *fuzzy);
64 
65};
66
67#endif
Note: See TracBrowser for help on using the repository browser.