fuzzy

fuzzy

 written by Igor Dekovich

 fuzzy is set of structures and functions written to enable easier manipulation with fuzzy sets in programming language C.

Table of Contents


Table of Contents

  • Title and first page
  • Introduction
  • Structures
  • Functions (all)
  • Functions(fuzzy)
  • Functions(fuzzy-normalised)
  • Functions(crisp)
  • Functions(fuzzy -> crisp)
  • Functions(crisp -> fuzzy)
  • The BackPropagation (BP) algorithm
  • Projects and compiling

  •  

     

    Appendices
  • EXAMPLE of using functions
  • Read it

  •  

     

    Return to home page


    Introduction

  • Library "fuzzy" is developed to enable easier writing C programs for fuzzy data manipulating. Structure "fuzzy_set" presents fuzzy set and consists of pointers on fuzzy objects in the set. Structure "fuzzy_object " represents one object inside fuzzy set, while structure characteristic represents one of its characteristics. As well as one object is expected to posses more than one characteristic (characteristics) fuzzy set is expected to consist of more than one object. Although structures "fuzzy_set" and "fuzzy_object" work properly also in the case of only one object in fuzzy set and only one characteristic of fuzzy object.
  • Library "fuzzy" also plays an important rule as the basis for library "neuro.h" consists functions for enabling easier manipulation with neural networks.

  •  

     

  • Any comment and suggestion is welcome and users are encouraged to send it to author!
  • Table of Contents


    Structures

  • union mux
  • struct characteristic
  • struct fuzzy_object
  • struct fuzzy_set
  • enum Bool
  • enum check_type
  • struct crisp_set
  • struct time_slice
  • Table of Contents


    Functions (all)

  • 1. char *read_name(char *read_in, char *read_from)
  • 2. characteristic *characteristic_fill(characteristic *link, fuzzy_object*head1, char *names, float *memberships)
  •  3. fuzzy_object*set_fill(int nmbr_characteristics, char *names, float *memberships)
  •  4. fuzzy_set*fuzzy_set_fill(int nmbr_objects, char* f_set_name, char **names, float **memberships, int *nmbr_characteristics)
  •  5. void delete_fuzzy_object(fuzzy_object*head)
  •  6. void delete_fuzzy_set(fuzzy_set*head)
  •  7. void set_read(fuzzy_object*head, char *names, float *memberships)
  •  8. void fuzzy_set_read(fuzzy_set*head, char **names, float **memberships, char *f_set_name)
  •  9. void fill_set(fuzzy_object*head, char *names, float *memberships)
  •  10. void fill_fuzzy_set(fuzzy_set*head, char **names, float **memberships)
  •  11. void fill_fuzzy_object_memberships(fuzzy_object*head, float *memberships)
  •  12. void fill_fuzzy_set_memberships(fuzzy_set*head, float *memberships)
  •  13. enum Bool fuzzy_check_sum(fuzzy_object*head, float border)
  •  14. enum Bool fuzzy_check_membership(fuzzy_object*head)
  •  15. enum check_type fuzzy_object_check(fuzzy_object*head, float border)
  •  16. void fuzzy_object_normalisation(fuzzy_object*head)
  •  17. crisp_set *fill_crisp_set(int number_of_subsets, char *name, int *memberships)
  •  18. void delete_crisp_set(crisp_set *head)
  •  19. fuzzy_object*crisp2fuzzy((char *fuzzy_object_name, int number_of_subsets, char *name, int *crisp_subsets)
  •  20. fuzzy_object*crisp_set2fuzzy(crisp_set crisp, char *name)
  •  21. crisp_set *fuzzy2crisp(fuzzy_object*head, float border)
  •  22. char *fuzzy2crisp_defuzzyfication(fuzzy_object*head)
  •  23. char *fuzzy_object_defuzzyfication(fuzzy_object*head)
  •  24. enum Bool check_name(char *name1, char *name2)
  •  25. fuzzy_object*fuzzy_AND(fuzzy_object*head1, fuzzy_object*head2)
  •  26. fuzzy_object*fAND(fuzzy_object*head1, fuzzy_object*head2)
  •  27. fuzzy_object*fuzzy_OR(fuzzy_object*head1, fuzzy_object*head2)
  •  28. fuzzy_object*fOR(fuzzy_object*head1, fuzzy_object*head2)
  •  29. enum Bool fset_equall_set(fuzzy_object*head1, fuzzy_object*head2)
  •  30. enum Bool f_equall(fuzzy_object*head1, fuzzy_object*head2)
  •  31. enum Bool f_equall_epsilon(fuzzy_object*head1, fuzzy_object*head2, float epsilon)
  •  32. float f_sum_membership(fuzzy_object*head)
  •  33. float fsubsethood(fuzzy_object*head1, fuzzy_object*head2)
  •  34. double divergence(fuzzy_object*head1, fuzzy_object*head2)
  •  35. double entropy_DeLuceTermini(fuzzy_object*head)
  •  36. crisp_set *make_inverse(crisp_set *head)
  •  37. fuzzy_object*inversing(fuzzy_object*head)
  •  38. double entropy_using_divergence(fuzzy_object*head)
  •  39. fuzzy_object *fuzzy_algebraic_product(fuzzy_object*head1, fuzzy_object*head2)
  •  40. fuzzy_object *fuzzy_bounded_product(fuzzy_object*head1, fuzzy_object*head2)
  •  41. fuzzy_object *fuzzy_algebraic_sum(fuzzy_object*head1, fuzzy_object*head2)
  •  42. fuzzy_object *fuzzy_bounded_sum(fuzzy_object*head1, fuzzy_object*head2)
  •  43. fuzzy_object *fuzzy_absolute_difference(fuzzy_object*head1, fuzzy_object*head2)
  •  44. fuzzy_object *fuzzy_convex_combination(fuzzy_object*head1, fuzzy_object*head2, float lambda)
  •  45. fuzzy_object *fuzzy_convex_set_combination(fuzzy_object*head1, fuzzy_object*head2, fuzzy_object*head3)
  •  46. time_slice *setup_fuzzy_batchBP(fuzzy_object *f_s[], int o, int nout, float *W)
  •  47. void delete_fuzzy_batchBP(time_slice *T)
  •  48. void fuzzy_batchBP(time_slice *T, float *expected_output, float *S)
  •  49. void fuzzy_batchBP_adapting_influences(time_slice *T, float correction_weight)
  •  50. void fuzzy_BP(fuzzy_object *f_s[],int o, int nout, float *expected_output, float *W, float *S, float correction_weight)
  •  51. time_slice *start_fuzzy_BP_through_time(fuzzy_object *f_s[], int o, int nout, float **W, int Wpast)
  •  52. void delete_fuzzy_batchBP_through_time(time_slice *T)
  •  53. void fuzzy_BP_through_time(time_slice *T, float *expected_output, float *S)
  •  54. void fuzzy_BP_through_time_adapting_influences(time_slice *T, float correction_weight)
  •  55. float fuzzy_integral_Sugeno(int number_of_evaluation_items, float lambda, float **items)
  •  56. float calculating_lambda(float *confidences, int number_of_confidences)
  •  57. float calculating_positive_lambda(float *confidences, int number_of_confidences)
  •  58. void *testmalloc(size_t nrbytes)
  •  59. void testfree(char *p)
  •  60. 'T'* MA'T'(int number_of_elements)
  •  61. void exit_handling(int number, int location)
  • Table of Contents


    Functions(fuzzy)

  • characteristic *characteristic_fill(characteristic *link, fuzzy_object*head1, char *names, float *memberships)
  • fuzzy_object*set_fill(int nmbr_characteristics, char *names, float *memberships)
  • fuzzy_set*fuzzy_set_fill(int nmbr_objects, char* f_set_name, char **names, float **memberships, int *nmbr_characteristics)
  • void delete_fuzzy_object(fuzzy_object*head)
  • void delete_fuzzy_set(fuzzy_set*head)
  • void set_read(fuzzy_object*head, char *names, float *memberships)
  • void fuzzy_set_read(fuzzy_set*head, char **names, float **memberships, char *f_set_name)
  • void fill_set(fuzzy_object*head, char *names, float *memberships)
  • void fill_fuzzy_set(fuzzy_set*head, char **names, float **memberships)
  • void fill_fuzzy_object_memberships(fuzzy_object*head, float *memberships)
  •  void fill_fuzzy_set_memberships(fuzzy_set*head, float *memberships)
  •  enum Bool fuzzy_check_sum(fuzzy_object*head, float border)
  • enum Bool fuzzy_check_membership(fuzzy_object*head)
  • enum check_type fuzzy_object_check(fuzzy_object*head, float border)
  • void fuzzy_object_normalisation(fuzzy_object*head)
  • char *fuzzy_object_defuzzyfication(fuzzy_object*head)
  • fuzzy_object*fuzzy_AND(fuzzy_object*head1, fuzzy_object*head2)
  • fuzzy_object*fAND(fuzzy_object*head1, fuzzy_object*head2)
  • fuzzy_object*fuzzy_OR(fuzzy_object*head1, fuzzy_object*head2)
  • fuzzy_object*fOR(fuzzy_object*head1, fuzzy_object*head2)
  • enum Bool fset_equall_set(fuzzy_object*head1, fuzzy_object*head2)
  • enum Bool f_equall(fuzzy_object*head1, fuzzy_object*head2)
  • enum Bool f_equall_epsilon(fuzzy_object*head1, fuzzy_object*head2, float epsilon)
  • float f_sum_membership(fuzzy_object*head)
  • float fsubsethood(fuzzy_object*head1, fuzzy_object*head2)
  • double divergence(fuzzy_object*head1, fuzzy_object*head2)
  • double entropy_DeLuceTermini(fuzzy_object*head)
  • fuzzy_object*inversing(fuzzy_object*head)
  • double entropy_using_divergence(fuzzy_object*head)
  • fuzzy_object *fuzzy_algebraic_product(fuzzy_object*head1, fuzzy_object*head2)
  • fuzzy_object *fuzzy_bounded_product(fuzzy_object*head1, fuzzy_object*head2)
  • fuzzy_object *fuzzy_algebraic_sum(fuzzy_object*head1, fuzzy_object*head2)
  • fuzzy_object *fuzzy_bounded_sum(fuzzy_object*head1, fuzzy_object*head2)
  • fuzzy_object *fuzzy_absolute_difference(fuzzy_object*head1, fuzzy_object*head2)
  • fuzzy_object *fuzzy_convex_combination(fuzzy_object*head1, fuzzy_object*head2, float lambda)
  • fuzzy_object *fuzzy_convex_set_combination(fuzzy_object*head1, fuzzy_object*head2, fuzzy_object*head3)
  • time_slice *setup_fuzzy_batchBP(fuzzy_object *f_s[], int o, int nout, float *W)
  • void delete_fuzzy_batchBP(time_slice *T)
  • void fuzzy_batchBP(time_slice *T, float *expected_output, float *S)
  • void fuzzy_batchBP_adapting_influences(time_slice *T, float correction_weight)
  • void fuzzy_BP(fuzzy_object *f_s[],int o, int nout, float *expected_output, float *W, float *S, float correction_weight)
  • time_slice *start_fuzzy_BP_through_time(fuzzy_object *f_s[], int o, int nout, float **W, int Wpast)
  • void delete_fuzzy_batchBP_through_time(time_slice *T)
  • void fuzzy_BP_through_time(time_slice *T, float *expected_output, float *S)
  • void fuzzy_BP_through_time_adapting_influences(time_slice *T, float correction_weight)
  • float fuzzy_integral_Sugeno(int number_of_evaluation_items, float lambda, float **items)
  • float calculating_lambda(float *confidences, int number_of_confidences)
  • float calculating_positive_lambda(float *confidences, int number_of_confidences)
  • Table of Contents


    Functions(fuzzy-normalised)

  • void fuzzy_object_normalisation(fuzzy_object*head)
  • fuzzy_object*fAND(fuzzy_object*head1, fuzzy_object*head2)
  • fuzzy_object*fOR(fuzzy_object*head1, fuzzy_object*head2)
  • Table of Contents


    Functions(crisp) 

  • crisp_set *fill_crisp_set(int number_of_subsets, char *name, int *memberships)
  • void delete_crisp_set(crisp_set *head)
  • crisp_set *make_inverse(crisp_set *head)
  • Table of Contents


    Functions(fuzzy -> crisp)

  • crisp_set *fuzzy2crisp(fuzzy_object*head, float border)
  • char *fuzzy2crisp_defuzzyfication(fuzzy_object*head)
  • char *fuzzy_object_defuzzyfication(fuzzy_object*head)
  • Table of Contents


    Fuctions(crisp -> fuzzy)

  • fuzzy_object*crisp2fuzzy((char *fuzzy_object_name, int number_of_subsets, char *name, int *crisp_subsets)
  • fuzzy_object*crisp_set2fuzzy(crisp_set crisp, char *name)
  • Table of Contents


    Structures used for fuzzy set, fuzzy object and fuzzy characteristic definitions are fuzzy_set, fuzzy_object and characteristic.

    union mux {
    char *name;
    float notes;
    } mux;
     
     

    Table of Contents


  • struct characteristic {

  • char *name;
    float membership;
    struct characteristic *ahead, *follow;
    struct fuzzy_object*set;
    } characteristic, *link_characteristic;
     
     

    Table of Contents


  • struct fuzzy_object {

  • union mux m;
    int number_of_characteristics;
    struct characteristic *first, *actuall, *last;
    } fuzzy_object, *link_set;
     
     

    Table of Contents


  • struct fuzzy_set {

  • char *name;
    int number_of_objects;
    struct fuzzy_object **objects;
    } fuzzy_set;
     
     

    Table of Contents


  • enum Bool {F=0,T=1};
  • Table of Contents


  • enum check_type {Y=0,S=1,M=2,ALL=3};
  • Table of Contents


  • struct crisp_set{

  • int number_of_subsets;
    char *name;
    enum Bool *memberships;
    } crisp_set;

    Table of Contents


  • struct time_slice{

  • fuzzy_object **f_s;
    int dimension;
    int o;
    int nout;
    int counter;
    int Wpast;
    float **W;
    float **BPm;
    float **x;
    float *D_w;
    }

    Table of Contents


    Functions:

  • 1) char *read_name(char *read_in, char *read_from) - Return *read_in to begin of the next word (after first signed end of set). Read set of letters, numbers and punctuation signs with ASCII code between 40 and 58 or 64 and 127, while end of set is signed with any ASCII code out of the interval. Set is read from "char *read_from" and placed in "char *read_in".
  • Table of Contents


  • 2) characteristic *characteristic_fill(characteristic *link, fuzzy_object*head1, char *names, float *memberships) - Form and fill characteristic of the fuzzy set. "characteristic *link" is a pointer to previous characteristic, "fuzzy_object*head1" is pointer to belonging fuzzy set, "char *names" is pointer to vector consists characteristic name (see function *read_name), "float *memberships" is pointer to location consists value of characteristic membership.
  • Table of Contents


  • 3) fuzzy_object *set_fill(int nmbr_characteristics, char *names, float *memberships) - Form and fill fuzzy object. "int nmbr_characteristics" is number of characteristics fuzzy object posses, "char *names" is vector consists first name of fuzzy object and then characteristic names in order separated with an ASCII character coded from 1 to 39 or from 59 to 63 or 127, "float *memberships" is vector consists all memberships in the order.
  • Table of Contents


  • 4) fuzzy_set *fuzzy_set_fill(int nmbr_objects, char* f_set_name, char **names, float **memberships, int *nmbr_characteristics) - Form and fill fuzzy set. "int nmbr_objects" is number of fuzzy objects fuzzy set posses, "char *f_set_name" is vector consists name of fuzzy set , "char **names" is vector of pointers on vectors consist names of each fuzzy object followed by characteristic names in order separated with an ASCII character coded from 1 to 39 or from 59 to 63 or 127, "float **memberships" is vector of pointers on vectors consist all memberships of each fuzzy object in the order, "int *nmbr_characteristics" is vector consists of number of characteristics each fuzzy object posses.
  • Table of Contents


  • 5) void delete_fuzzy_object(fuzzy_object*head) - Remove fuzzy object. "fuzzy_object*head"" is pointer to fuzzy object to be removed.
  • Table of Contents


  • 6) void delete_fuzzy_set(fuzzy_set*head) - Remove fuzzy set. "fuzzy_set*head" is poointer to fuzzy set to be removed.
  • Table of Contents


  • 7) void set_read(fuzzy_object*head, char *names, float *memberships) - Read data from fuzzy object opposite to function set_fill with difference set_read doesn't remove fuzzy object. "fuzzy_object*head" is pointer to fuzzy object to be red, "char *names" (must point to the reserved large enough location) is destination for coping name of fuzzy object and characteristic names in order, "float *memberships" is destination for coping characteristic memberships in order (must point to the reserved large enough location). ALL VECTORS MUST BE PREVIOUSLY DIMENSIONED !
  • Table of Contents


  • 8) void fuzzy_set_read(fuzzy_set*head, char **names, float **memberships, char *f_set_name) - Read data from fuzzy set opposite to function fuzzy_set_fill with difference fuzzy_set_read doesn't remove fuzzy set. Data red from fuzzy set are placed into vectors, a pair for each fuzzy object, pointed by "**names" and "**memberships". "fuzzy_set*head" is pointer to fuzzy set to be red, "char **names" (must point to the reserved large enough location, dimension should be number of fuzzy objects in the set * sizeof(names*)) is pointer on destination for coping name of fuzzy object followed by characteristic names in order for each fuzzy object (for different fuzzy objects different destinations), "float **memberships" is pointer on destination for coping characteristic memberships in order (must point to the reserved large enough location, dimension should be number of fuzzy objects in the set * sizeof(names*)), different destination for different fuzzy objects, "char *f_set_name" is pointer on vector (large enough) to store the set's name. ALL VECTORS MUST BE PREVIOUSLY DIMENSIONED !
  • Table of Contents


  • 9) void fill_set(fuzzy_object *head, char *names, float *memberships) - Opposite to function set_read. Fill fuzzy object with names and memberships. "fuzzy_object*head" is pointer to fuzzy object to be filled, "char *names" is vector consists first name of fuzzy object and then characteristic names in order separated with an ASCII character coded from 1 to 39 or from 59 to 63 or 127, "float *memberships" is vector consists all memberships in the order.
  • Table of Contents


  • 10) void fill_fuzzy_set(fuzzy_set *head, char **names, float **memberships) - Opposite to function fuzzy_set_read. Fill fuzzy objects of the fuzzy set with names and memberships stored in (pair of) vectors (for each fuzzy object) pointed by "**names" and "**memberships". "fuzzy_set*head" is pointer to fuzzy set to be filled, "char **names" is vector consists pointers on separate vector for each fuzzy object consists first name of fuzzy object followed by characteristic names in order separated with an ASCII character coded from 1 to 39 or from 59 to 63 or 127, "float **memberships" is vector consists pointers on separate vector for each fuzzy object consists all memberships in the order.
  • Table of Contents


  • 11) void fill_fuzzy_object_memberships(fuzzy_object *head, float *memberships) - Similar to function fill_set. Fill fuzzy object's characteristics memberships only. "fuzzy_object*head" is pointer to fuzzy object to be filled, " float *memberships" is vector consists all memberships in the order.
  • Table of Contents


  • 12) void fill_fuzzy_set_memberships(fuzzy_set *head, float **memberships) - Similar to function fill_fuzzy_set. Fill fuzzy set's fuzzy objects' characteristics with memberships stored in vectors (for each fuzzy object) pointed by "**memberships". "fuzzy_set*head" is pointer to fuzzy set to be filled, "float **memberships" is vector consists pointers on separate vector for each fuzzy object consists all memberships in the order.
  • Table of Contents


  • 13) enum Bool fuzzy_check_sum(fuzzy_object*head, float border) - Return T=1 if sum of all characteristics membership is from interval (1-border, 1+border), in other case return F=0. "fuzzy_object*head" points fuzzy set, "float border" defines interval around 1.0 for sum acceptance.
  • Table of Contents


  • 14) enum Bool fuzzy_check_membership(fuzzy_object*head) - Return T=1 if each characteristic' membeership function is inside interval [0,1], otherwise return F=0. "fuzzy_object*head" points to fuzzy set.
  • Table of Contents


  • 15) enum check_type fuzzy_object_check(fuzzy_object*head, float border) - Returns Y=0 if sum of all characteristics membership is from interval (1-border, 1+border) and each characteristic' membership function is inside interval [0,1], return S=1 if sum of all characteristics membership is outside interval (1-border, 1+border), return M=2 if any characteristic' membership function is outside interval [0,1], return ALL=3 if sum of all characteristics membership is outside interval (1-border, 1+border) and if any characteristic' membership function is outside interval [0,1]. "fuzzy_object*head" points fuzzy set, "float border" defines interval around 1.0 for sum acceptance.
  • Table of Contents


  • 16) void fuzzy_object_normalisation(fuzzy_object*head) - Normalise characteristics' membership. CCharacteristic of normalised fuzzy set is sum of all characteristics' membership is 1.0. Normalisation is performed by multiplication of each membership with the same factor, while only in a case that all memberships are 0.0 they are added with 1/(number_of_characteristics). "fuzzy_object*head" points to fuzzy set.
  • Table of Contents


  • 17) crisp_set *fill_crisp_set(int number_of_subsets, char *name, int *memberships) - Form and fill crisp_set. "int number_of_subsets" is number of subsets crisp_set posses, "char *name" is vector consists subsets' names in order separated with an ASCII character coded from 1 to 39 or from 59 to 63 or 127 (look out doesn't consist name of crisp_set), "int *memberships" is vector consists all memberships (each membership can be either 0 or 1) in the order.
  • Table of Contents


  • 18) void delete_crisp_set(crisp_set *head) - Remove crisp set. "crisp_set *head" is pointer to crisp set to be removed.
  • Table of Contents


  • 19) fuzzy_set *crisp2fuzzy((char *fuzzy_object_name, int number_of_subsets, char *name, int *crisp_subsets) - Form and fill fuzzy_objectwith the same characteristics names as subsets have and the same membership values (int -> float) names of characteristics as names and memberships of crisp set subsets are. "char *fuzzy_object_name" is pointer to vector consists name of fuzzy_objectseparated with an ASCII character coded from 1 to 39 or from 59 to 63 or 127 , "int number_of_subsets" is number of subsets of crisp set, "char *name" is vector consists subsets' names in order separated with an ASCII character coded from 1 to 39 or from 59 to 63 or 127, "int *crisp_subsets" is pointer to vector where memberships of subsets are stored (membership is either 0 or 1).
  • Table of Contents


  • 20) fuzzy_object *crisp_set2fuzzy(crisp_set crisp, char *name) - Form and fill fuzzy_objectwith the same characteristics names as subsets have and the same membership values (int -> float) names of characteristics as names and memberships of crisp set subsets are. "crisp_set crisp" is crisp_set being transforming to fuzzy_object, "char* name" is pointer to vector consists name of fuzzy_objectseparated with an ASCII character coded from 1 to 39 or from 59 to 63 or 127.
  • Table of Contents


  • 21) crisp_set *fuzzy2crisp(fuzzy_object*head, float border) - Form and fill crisp set from fuzzy_objectand each characteristic' membership is transformed into crisp_set subset's membership using rule if membership < border then crisp membership is F, otherwise is T. "fuzzy_object*head" is pointer on fuzzy_object, "float border" is decision border between T and F (belong to T).
  • Table of Contents


  • 22) char *fuzzy2crisp_defuzzyfication(fuzzy_object*head) - Return pointer to vector with name of thhe characteristic with highest membership, if fuzzy_objectconsists of more than one characteristic with the same the highest membership only the last of them in order name is stored. End of vector is noticed with "#". "fuzzy_object*head" is pointer on fuzzy_object).
  • Table of Contents


  • 23) char *fuzzy_object_defuzzyfication(fuzzy_object*head) - Return pointer to vector with name of thhe characteristic with highest membership, if fuzzy_objectconsists of more than one characteristic with the same the highest membership all of them in order names are stored. "fuzzy_object*head" is pointer on fuzzy_object).
  • Table of Contents


  • 24) enum Bool check_name(char *name1, char *name2) - Return T=1 if name1=name2, otherwise return F=0. "char *name1, char *name2" are pointers to vectors of names, name inside each vector is separated with an ASCII character coded from 1 to 39 or from 59 to 63 or 127.
  • Table of Contents


  • 25) fuzzy_object *fuzzy_AND(fuzzy_object*head1, fuzzy_object*head2) - Return pointer on new fuzzy_objectproduced as intersection ("min" function) of given fuzzy_object-s. "fuzzy_object*head1, fuzzy_object*head2" are pointers on fuzzy_object-s whose intersection we calculate.
  • Table of Contents


  • 26) fuzzy_object *fAND(fuzzy_object*head1, fuzzy_object*head2) - Return pointer on new normalised fuzzy_objectproduced as intersection ("min" function) of given fuzzy_object-s and then normalised. Can be used only when fuzzy_object-s present distribution of fuzzy variable and distribution of intersection is graphical intersection of given fuzzy_object-s distributions. "fuzzy_object*head1, fuzzy_object*head2" are pointers on fuzzy_object-s whose normalised intersection we calculate.
  • Table of Contents


  • 27) fuzzy_object *fuzzy_OR(fuzzy_object*head1, fuzzy_object*head2) - Return pointer on new fuzzy_objectproduced as union ("max" function) of given fuzzy_object-s. "fuzzy_object*head1, fuzzy_object*head2" are pointers on fuzzy_object-s whose union we calculate.
  • Table of Contents


  • 28) fuzzy_object *fOR(fuzzy_object*head1, fuzzy_object*head2) - Return pointer on new normalised fuzzy_objectproduced as union ("max" function) of given fuzzy_object-s and then normalised. Can be used only when fuzzy_object-s present distribution of fuzzy variable and distribution of union is graphical union of given fuzzy_object-s distributions. "fuzzy_object*head1, fuzzy_object*head2" are pointers on fuzzy_object-s whose normalised union we calculate.
  • Table of Contents


  • 29) enum Bool fset_equall_set(fuzzy_object*head1, fuzzy_object*head2) - Return T=1 only if given fuzzy_object-s have the same number of characteristics and the same names of characteristics, otherwise return F=0. Note that order of characteristics and membership values are not checked. "fuzzy_object*head1, fuzzy_object*head2" are pointers on given fuzzy_object-s.
  • Table of Contents


  • 30) enum Bool f_equall(fuzzy_object*head1, fuzzy_object*head2) - Return T=1 only if given fuzzy_object-s have the same number of characteristics, the same names of characteristics and the same membership values of the same characteristic, otherwise return F=0. Note that order of characteristics is not checked. "fuzzy_object*head1, fuzzy_object*head2" are pointers on given fuzzy_object-s.
  • Table of Contents


  • 31) enum Bool f_equall_epsilon(fuzzy_object*head1, fuzzy_object*head2, float epsilon) - Return T=1 only if given fuzzy_object-s have the same number of characteristics, the same names of characteristics and membership values of the same characteristic are different no more than epsilon, otherwise return F=0. Note that order of characteristics is not checked. "fuzzy_object*head1, fuzzy_object*head2" are pointers on given fuzzy_object-s, "float epsilon" presents allowed difference between the same characteristic of given fuzzy_object-s.
  • Table of Contents


  • 32) float f_sum_membership(fuzzy_object*head) - Return sum of all membership values of tthe given fuzzy_object. "fuzzy_object*head" is pointer on given fuzzy_object.
  • Table of Contents


  • 33) float fsubsethood(fuzzy_object*head1, fuzzy_object*head2) - Return measure of subsethood of the 1st fuzzy_objectinside the 2nd fuzzy_objectaccording formula (7) from my MSc these. Return can be also recognised as the measure of conditioning the 2nd fuzzy_objectfrom the 1st fuzzy set. "fuzzy_object*head1" is pointer on the 1st fuzzy_object, "fuzzy_object*head2" is pointer on the 2nd fuzzy set.
  • Table of Contents


  • 34) double divergence(fuzzy_object*head1, fuzzy_object*head2) - Return measure of divergence of given fuzzy_object-s according formula (16) from my MSc these. "fuzzy_object*head1, fuzzy_object*head2" are pointers on given fuzzy_object-s.
  • Table of Contents


  • 35) double entropy_DeLuceTermini(fuzzy_object*head) - Return measure of entropy of given fuzzyy_objectintroduced by De Luce and Termini that is analog information theoretical entropy. "fuzzy_object*head" is pointer to given fuzzy_object.
  • Table of Contents


  • 36) crisp_set *make_inverse(crisp_set *head) - Return pointer on inverse crisp_set (1->0 & 0->1) of given crisp_set. "crisp_set *head" is pointer to given crisp_set.
  • Table of Contents


  • 37) fuzzy_object *inversing(fuzzy_object*head) - Return pointer on inverse fuzzy_object(11.0->0 & 0.0->1.0 & 0.7->0.3 etc.) of given fuzzy_object. "fuzzy_object*head" is pointer to given fuzzy_object.
  • Table of Contents


  • 38) double entropy_using_divergence(fuzzy_object*head) - Return measure of entropy of given fuzzyy_object calculated over divergence. "fuzzy_object*head" is pointer to given fuzzy_object.
  • Table of Contents


  • 39) fuzzy_object *fuzzy_algebraic_product(fuzzy_object*head1, fuzzy_object*head2) - Return pointer on new object produced as algebraic product of given objects. New fuzzy object has membership that is product of (the same characteristic) memberships of given objects. It is valid *fuzzy_algebraic_product(A,B) is subset of *fuzzy_AND(A,B).
  • Table of Contents


  • 40) fuzzy_object *fuzzy_bounded_product(fuzzy_object*head1, fuzzy_object*head2) - Return pointer on new object produced as bounded product of given objects. New fuzzy object has membership = Max[0.0 , suma (the same characteristic) memberships of given objects - 1.0]. It is valid *fuzzy_bounded_product(A,B) is subset of *fuzzy_algebraic_product(A,B).
  • Table of Contents


  • 41) fuzzy_object *fuzzy_algebraic_sum(fuzzy_object*head1, fuzzy_object*head2) - Return pointer on new object produced as algebraic sum of given objects. New fuzzy object has membership that is sum of (the same characteristic) memberships of given objects les their product. It is valid *fuzzy_OR(A,B) is subset of *fuzzy_algebraic_sum(A,B).
  • Table of Contents


  • 42) fuzzy_object *fuzzy_bounded_sum(fuzzy_object*head1, fuzzy_object*head2) - Return pointer on new object produced as bounded sum of given objects. New fuzzy object has membership = min[1.0 , sum (the same characteristic) memberships of given objects]. It is valid *fuzzy_algebraic_sum(A,B) is subset of *fuzzy_bounded_sum(A,B).
  • Table of Contents


  • 43) fuzzy_object *fuzzy_absolute_difference(fuzzy_object*head1, fuzzy_object*head2) - Return pointer on new object produced as absolute difference of given objects. New fuzzy object has membership that is absolute difference of (the same characteristic) memberships of given objects ( m(C)=|m(A)-m(B)| ). "fuzzy_object*head1" is pointer on first fuzzy object, "fuzzy_object*head2" is pointer on second fuzzy object.
  • Table of Contents


  • 44) fuzzy_object *fuzzy_convex_combination(fuzzy_object*head1, fuzzy_object*head2, float lambda) - Return pointer on new object produced as convex combination of given objects ( C=(A,B,l)=l*A+(1-l)*B). Result of convex combination of given objects with real number I (from [0.0,1.0]) is new fuzzy_object with membership = (the same characteristic) membership of the first object * I + (the same characteristic) membership of the second object * (1-I ). "fuzzy_object*head1" is pointer on first fuzzy object, "fuzzy_object*head2" is pointer on second fuzzy object.
  • Table of Contents


  • 45) fuzzy_object *fuzzy_convex_set_combination(fuzzy_object*head1, fuzzy_object*head2, fuzzy_object*head3) - Return pointer on new object produced as convex combination of given objects ( C=(A,B,C)=C*A+(1-C)*B). Result of convex combination of given two objects with third one is new fuzzy_object with membership = (the same characteristic) membership of the first object * (the same characteristic) membership of the third object + (the same characteristic) membership of the second object * (1-(the same characteristic) membership of the third object ). "fuzzy_object*head1" is pointer on first fuzzy object, "fuzzy_object*head2" is pointer on second fuzzy object, "fuzzy_object*head3" is pointer on third fuzzy object.
  • Table of Contents


  • 46) time_slice *setup_fuzzy_batchBP(fuzzy_object *f_s[], int o, int nout, float *W) - forms time_slice for given system and reserve memory area for saving F_w(i,j) for each weight. After all patterns are presented new weight(i,j) = weight(i,j) - learning_rate * F_w(i,j). It is to be called only once for each fuzzy_batchBackpropagation algorithm applying (only for batchBP but not BP) and it must be called before first time calling of fuzzy_batchBP!
  • Table of Contents


  • 47) void delete_fuzzy_batchBP(time_slice *T) - delete time_slice for given system and free memory area reserved for saving F_w(i,j) for each weight. It should be run when we finish with backpropagation algorithm based learning of the neural network.
  • Table of Contents


  • 48) void fuzzy_batchBP(time_slice *T, float *expected_output, float *S) - calculates influence corrections after each input-output observing. Influences between characteristics can be calculated for each time slice before calling function fuzzy_batchBP() and stored in vector (matrix) pointed by *(T->W) (influence from characteristic i to characteristic j is stored in location *(*(T->W)+(i-1)*T->dimension+(j-1)). It must be called after each input-output is observed.
  • Table of Contents


  • 49) void fuzzy_batchBP_adapting_influences(time_slice *T, float correction_weight) - is function, that is to be run after whole set of system observing, that corrects all influents according T->D_w. Note T->D_w is at the end reset to 0.0 so new circle of observing (the same system) can start. correction_weight is constant of correcting of influences. It should be small and made as large as possible up to 1.0, until error starts to diverge.
  • Table of Contents


  • 50) void fuzzy_BP(fuzzy_object *f_s[],int o, int nout, float *expected_output, float *W, float *S, float correction_weight) - changes influence (forward) between charracteristics according to BackPropagation algorithm (Werbos " Propagation throught time", Proceedings of the IEEE, Vol. 78, No. 10, October 1990). Other BP variations can be used simple changing function "void fuzzy_batchBP_adapting_influences" whose main expression can be viewed as New w(i,j) = w(i,j) - correction_weight * (dE/dw(i,j)).
  • Table of Contents


  • 51) time_slice *start_fuzzy_BP_through_time(fuzzy_object *f_s[], int o, int nout, float **W, int Wpast) - reserve memory area for saving time_slice data for the system. After all patterns are presented new weight(i,j) = weight(i,j) - learning_rate * F_w(i,j). It is to be called only once for each fuzzy_BP_through_time algorithm applying and it must be called before first time calling of fuzzy_BP_through_time!
  • Table of Contents


  • 52) void delete_fuzzy_batchBP_through_time(time_slice *T) - free memory area reserved for saving time_slice. It should be run when we finish with backpropagation through time algorithm based learning of the neural network.
  • Table of Contents


  • 53) void fuzzy_BP_through_time(time_slice *T, float *expected_output, float *S) - calculates influence corrections after each input-output observing. It must be called after each input-output is observed.
  • Table of Contents


  • 54) void fuzzy_BP_through_time_adapting_influences(time_slice *T, float correction_weight) - is function, that is to be run after whole set of system observing, that corrects all influents according T->D_w. Note T->D_w is at the end reset to 0.0 so new circle of observing (the same system) can start. correction_weight is constant of correcting of influences. It should be small and made as large as possible up to 1.0, until error starts to diverge.
  • Table of Contents


  • 55) float fuzzy_integral_Sugeno(int number_of_evaluation_items, float lambda, float **items) - returnes value of Sugeno's fuzzy integral for given number_of_evaluation_items of items stored in items[number_of_evaluation_items][2], where *(*(items+i)+j) is (j=0 ==> value; j=1 ==> confidence of that item evaluation (method)) for (i-1)-th item; lambda is Sugeno's lambda defined: g(A+B)=g(A)+g(B)+lambda*g(A)*g(B), where (A+B) means A union B, lambda>-1 and lambda<>0. lambda must satisfy lambda+1=product_over_all_items(1+lambda*item's_(evaluation_method)_confidence), lambda>-1, lambda<>0. Confidences of item evaluation (method) must satisfy (Sugeno's) fuzzy measure properties. Values (stored in items) must satisfy the properties of fuzzy measure.
  • Table of Contents


  • 56) float calculating_lambda(float *confidences, int number_of_confidences) - lambda is defined through Sugeno's fuzzy measure and must be >-1 and <>0. lambda is calculated to make true lambda + 1 = product_over_all_confidences(1 + lambda * confidence) , where '=' means equal within an error < epsilon. Confidences must preserve the properties of fuzzy measure.
  • Table of Contents


  • 57) float calculating_positive_lambda(float *confidences, int number_of_confidences) - lambda is defined through Sugeno's fuzzy measure and must be >-1 and <>0. lambda is calculated to make true lambda + 1 = product_over_all_confidences(1 + lambda * confidence) , where '=' means equal within an error < epsilon. lambda is forced to be positive. Confidences must preserve the properties of fuzzy measure.
  • Table of Contents


  • 58) void *testmalloc(size_t nrbytes) - testmalloc and testfree are introduced tto enable easier analysis of a problem with memory allocation occurence. They enable (by defining TEST_MALLOC (before calling fuzzy library, for example "#define TEST_MALLOC 1") different than 0) printing history of all malloc allocations and freeding of memory. All malloc calls should be replaced with testmalloc ones (instead of "malloc(XXX)" should be written "testmalloc(XXX)"). All free calls should be replaced with testfree ones (instead of "free(XXX)" should be written "testfree(XXX)").
  • Table of Contents


  • 59) void testfree(char *p) - testmalloc and testfree are introduced to enable easier analysis of a problem with memory allocation occurence. They enable (by defining TEST_MALLOC (before calling fuzzy library, for example "#define TEST_MALLOC 1") different than 0) printing history of all malloc allocations and freeding of memory. All malloc calls should be replaced with testmalloc ones (instead of "malloc(XXX)" should be written "testmalloc(XXX)"). All free calls should be replaced with testfree ones (instead of "free(XXX)" should be written "testfree(XXX)").
  • Table of Contents


  • 60) 'T'* MA'T'(int number_of_elements) - where 'T' means type and can be 'C'=charr, 'D'=double, 'F'=float, 'I'=int, 'L'=long, 'S'=short, 'Si'=signed, 'U'=unsigned, 'Cl'=characteristic, 'FO'=fuzzy_object, 'FS'=fuzzy_set, 'CS'=crisp_set, 'EB'=enum Bool, 'ECT'= enum check_type, 'TS'=time_slice or any of previous letters with (one or more, up to 3) prefix 'p' =pointer on. Returns pointer to space to be reserved (allocated)! It deals with memory allocation (testmalloc) request for number_of_elements locations of type 'T'. In the case there is no available memory request is being repeated up to 101 times and if there is still lack of free memory unsucessfull end of process is caused (exit(1)).
  • Table of Contents


  • 61) void exit_handling(int number, int location) - prints message and then exits execution of program; "int number" describes what caused exit and chooses message. Shared with neural network functions library "neuro".
  • Table of Contents


    The BackPropagation (BP) algorithm

  • The BackPropagation (BP) algorithm is in its basic form for calculation of partial derivative of output error of a system with respect to partial influence between its parts.

  • It is necessary that influence is feedforward while all feedback influences are with time delay. Also function of that influence should be known (or at least predicted or choosen for experiment).
    Let us assume a fuzzy system consists of a number of fuzzy objects on input and output and not necessarlly a number of fuzzy objects between them and if also assume that all influence is straightforward while all feedbacks are with time delay and value of all characteristics (object's characteristic) can be presented as a function of weighted sum of other characteristics' values.
    In that case we can apply BP algorithm to find influence of particular weight of between-characteristic influence on output characteristics change according presented input.
    In that way we can experimentally find influence between different (objects) characteristics just choosing input set and set of objects/characteristics of interest for us as output while all functions of between characteristics influence initially set up as pure sum of (a set of) previous characteristics and (a set) of forward characteristics with time delay influences.
    It would be useful for approxima definition of fuzzy system whose elements are known but whose interactions are impossible or hard possible to be definned. (I expect that even restriction of feedforward influence in time slice can be eliminated.)
    After a set of system checking (and if it is possible changing input and output objects) we have a graph of finite elements for particulary between characteristic influence (weight) and real (aproximative) influence can be callculated as integral (problem of constant of integration should be solved possibly with new serial of BP algorithm applying.
    Implemence of the technic can be in fuzzy controll systems or even (with some more work) in system initialisation area.
    In automatic control theory system is very often described by Kalman filter expression: x(t+1)=Fx(t)-GKx^(t), y(t)=Hx(t) or with equivalent expresions in space state.
    Matrix x(t) is usually consists of meaningfull physical (or rarely non-physical) quantities derived from x. In the case we wont for x(t) (or x(s) in state space) vector choose quantity we are not able theoretic derive from actual input x but we can measure them formulating that quantities (not necessary, they can just be interpreted) as fuzzy objects and presenting whole system (preferably in state space) as fuzzy system with appropriate choice of system input and output and connections we can in an iterative procedure using BP algorithm aproximative calculate matrices F,G,K and H.
    That way enable us to describe (even predict) "black box" system using any measurable, or even only observeable, variable. When I mentioned observeable variable I meant variable can't be precisely measured but can be described aproxamative as fuzzy object (over it's characteristic).
  •  Assumptions for applying algorithm:

  • 1) On input we have (we observe) fuzzy_set[X] with X objects consists m characteristics (characteristics) all together.
    2) On output we have (we observe) fuzzy_set[Y] with Y objects consists n characteristics (characteristics) all together.
    3) Between input and output fuzzy sets we can have finite number of fuzzy sets including noone or input and output can belong to the same fuzzy set.
    4) All characteristics influence each other over matrix of weights W(w(i,j)) (w(i,j)=weight of influence of j-th characteristic (characteristic) on i-th one), with condition w(i,j)=0.0 for all j= 5) Each characteristic value, except finite number of characteristics of objects in input fuzzy set, v(i) can be presented v(i)=f(i)(sum(w(i,j)*v(j)),j=1,...,i-1). f(i)' is vector of derivations of f(i). f(i)'=df(i)/d(sum(w(i,j)*v(j)),j=1,...,i-1). f(i)' is presented as vector of real numbers calculated for the moment of observation with dimension=number_of_all_characteristics_in_the_fuzzy_system. For characteristics observed as input f(i)'=0.0.
    6) BP algorithm changes value of influence of one characteristic to another by calculating dOutput_error/dW(i,j) in fuzzy_batchBP and adding to F_w(i,j) (called also D_w(i,j)) in order to calculate SUM(dOutput_error/dW(i,j)) throught all time slices inside the period (time between calling adapting_fuzzy_influence()) used in adapting_fuzzy_influence().
  •  For fuzzy_batchBP, fuzzyBP and fuzzy_BP_through_time following sintax is used:

  •  I) struct time_slice {
    _______________________fuzzy_object **f_s;
    _______________________int dimension;
    _______________________int o;
    _______________________int nout;
    _______________________int counter;
    _______________________int Wpast;
    _______________________float **W;
    _______________________float **BPm;
    _______________________float **x;
    _______________________float *D_w;
    ______________________}
    consists informations about fuzzy_(batch)BP(_through_time) for a particular system (enables us to deal with several systems at time).
    a) **f_s presents vector f_s[o]. Vector f_s consists pointers on first objects from input fuzzy set, than from other fuzzy sets with respect to propagation of their influence, and at the end objects from output fuzzy set (if input and output fuzzy sets are the same one and there is no sets or objects between them, than consists only pointer on one fuzzy set's objects - it means no duplication) whose characteristic-influence is described over matrix W.
    b) dimension presents number of characteristics in the system. It is automatically calculated.
    c) o is total number of objects in the system.
    d) nout is the number of output characteristics in the system (characteristics whose output we compare and they must be at the end of f_s).
    e) counter counts time slices (for use in fuzzy_BP_through_time). It is automatically set up and calculated.
    f) Wpast presents time dimension of W for use in fuzzy_BP_through_time (in other cases it is 0) (for example Wpast=3 means *(W+0) presents actual influences, *(W+1) influence from previous time slice on actuall one and *(W+2) from two slice ago on actual one).
    g) **W is pointer to vectors of characteristic influences: *(W+0) in actuall time, *(W+1) from previous time slice on actual time slice, ... , *(W+i) from i-1 time slice on actual one, ... , *(W+Wpast-1) from Wpast-2 time slice on actual one. Except in fuzzy_BP_through_time only *(W+0) exists and points on vector (*(W+0))[dimension,dimension] with elements (*(W+0))(i,j) presenting influence of j-th characteristic in the system on i-th one. (*(W+0))(i,j)=0.0 for all i h) **BPm is pointer to vector of pointers to BPmemory fpr particular time slice. It is for internall use and is calculated automatically.
    i) **x is pointer to vector of pointers on vector of characteristic values per particular time slice. It is for internall use and is calculated automatically.
    j) *D_w is pointer to vector of weight corrections. It is calculated automatically.

     II) expected_output[nout] is vector of expected output characteristics values respectly (their objects are in order as they are in f_s vector, while characteristics are in order as they are inside objects).

     III) S[o] is vector f'(i)(t) present derivation of function presents all characteristics influence on present characteristic with respect to sum of all characteristics influence. It should be calculated and presented as real number each time before calling fuzzy_(batch)BP(_through_time).

     IV) correction_weight is constant of correcting of influences. It should be small and made as large as possible up to 1.0, until error starts to diverge.

  •  Functions inside library "fuzzy" are:

  • 1) time_slice *setup_fuzzy_batchBP(fuzzy_object *f_s[], int o, int nout, float *W) /* forms time_slice for given system and reserve memory area for saving F_w(i,j) for each weight. After all patterns are presented new weight(i,j) = weight(i,j) - learning_rate * F_w(i,j). It is to be called only once for each fuzzy_batchBackpropagation algorithm applying (only for batchBP but not BP) and it must be called before first time calling of fuzzy_batchBP! */
    2) void delete_fuzzy_batchBP(time_slice *T) /* delete time_slice for given system and free memory area reserved for saving F_w(i,j) for each weight. It should be run when we finish with backpropagation algorithm based learning of the neural network */
    3) void fuzzy_batchBP(time_slice *T, float *expected_output, float *S) /* calculates influence corrections after each input-output observing. Influences between characteristics can be calculated for each time slice before calling function fuzzy_batchBP() and stored in vector (matrix) pointed by *(T->W) (influence from characteristic i to characteristic j is stored in location *(*(T->W)+(i-1)*T->dimension+(j-1)). It must be called after each input-output is observed. */
    4) void fuzzy_batchBP_adapting_influences(time_slice *T, float correction_weight) /* is function, that is to be run after whole set of system observing, that corrects all influents according T->D_w. Note T->D_w is at the end reset to 0.0 so new circle of observing (the same system) can start. correction_weight is constant of correcting of influences. It should be small and made as large as possible up to 1.0, until error starts to diverge. */
    5) void fuzzy_BP(fuzzy_object *f_s[],int o, int nout, float *expected_output, float *W, float *S, float correction_weight) /* changes influence (forward) between characteristics according to BackPropagation algorithm (Werbos " Propagation throught time", Proceedings of the IEEE, Vol. 78, No. 10, October 1990). Other BP variations can be used simple changing function "void fuzzy_batchBP_adapting_influences" whose main expression can be viewed as New w(i,j) = w(i,j) - correction_weight * (dE/dw(i,j)). */
    6) time_slice *start_fuzzy_BP_through_time(fuzzy_object *f_s[], int o, int nout, float **W, int Wpast) /* reserve memory area for saving time_slice data for the system. After all patterns are presented new weight(i,j) = weight(i,j) - learning_rate * F_w(i,j). It is to be called only once for each fuzzy_BP_through_time algorithm applying and it must be called before first time calling of fuzzy_BP_through_time! */
    7) void delete_fuzzy_batchBP_through_time(time_slice *T) /* free memory area reserved for saving time_slice. It should be run when we finish with backpropagation through time algorithm based learning of the neural network */
    8) void fuzzy_BP_through_time(time_slice *T, float *expected_output, float *S) /* calculates influence corrections after each input-output observing. It must be called after each input-output is observed. */
    9) void fuzzy_BP_through_time_adapting_influences(time_slice *T, float correction_weight) /* is function, that is to be run after whole set of system observing, that corrects all influents according T->D_w. Note T->D_w is at the end reset to 0.0 so new circle of observing (the same system) can start. correction_weight is constant of correcting of influences. It should be small and made as large as possible up to 1.0, until error starts to diverge. */

    Table of Contents


    Projects and compiling:

  • Function math.c (math.h) from ANSI library must be included if the library is a part of a project.
  • UNIX: during compilation option "-lm" must be used!
  • Table of Contents




    EXAMPLE of using functions

  • #include <stdio.h>
  •  #include "fuzzy1.h"
  •  main()
  •  {
  •  char name1[8]={'A',' ','1',' ','2',' ','3',' '}, name2[8]={'B',' ','1',' ','2',' ','4',' '}, name3[10]={'C',' ','1',' ','2',' ','3',' ','4',' '}, name4[6]={'1',' ','2',' ','4',' '}, name5[2]={'D',' '}, name6[2]={'E',' '}, name7[8]={'1',' ','2',' ','3',' ','4',' '}, *n;
  •  float membership1[3]={0.3,0.7,0.2}, membership2[3]={0.4,0.3,0.6}, membership3[4]={0.1,0.8,0.2,0.1};
  •  int membership4[4]={0,1,0,1};
  •  int counter;
  •  fuzzy_object *s1, *s2, *s3,*s4, *s5, *s6, *s7, *s8, *s11, *s12, *s13, *s14, *s15, *s16, *s17;
  •  crisp_set *c1, *c2, *c3, *c4;
  •  s1=set_fill(3,name1,membership1);
  •  s2=set_fill(3,name2,membership2);
  •  s3=set_fill(4,name3,membership3);
  •  s4=fAND(s1,s2);
  •  s5=fuzzy_OR(s2,s3);
  •  c4=fill_crisp_set(3,name4,membership4);
  •  s7=crisp_set2fuzzy(c4,name5);
  •  s8=crisp2fuzzy(name6,4,name7,membership4);
  •  s11=fuzzy_algebraic_product(s1,s2);
  •  s12=fuzzy_bounded_product(s1,s2);
  •  s13=fuzzy_algebraic_sum(s1,s2);
  •  s14=fuzzy_bounded_sum(s1,s2);
  •  s15=fuzzy_absolute_difference(s1,s2);
  •  s16=fuzzy_convex_combination(s1,s2,0.3);
  •  s17=fuzzy_convex_set_combination(s1,s2,s3);
  •  c1=fuzzy2crisp(s4,0.5);
  •  c2=fuzzy2crisp(s2,0.33);
  •  c3=make_inverse(c2);
  •  s6=inversing(s5);
  •  printf("\n s1");
  •  set_read(s1,name3,membership2);
  •  printf("\n set name is %c%c",name3[0],(name3[1]));
  •  for(counter=1; counter<=s1->number_of_characteristics; counter++)
  •  printf("\n characteristic name is %c%c; membership is %f",name3[2*counter],name3[2*counter+1], membership2[counter-1]);
  •  printf("\n s2");
  •  printf("\n set name is %c%c",*(s2->m.name),*(s2->m.name+1));
  •  for(s2->actuall=s2->first; s2->actuall!=0; s2->actuall=s2->actuall->follow)
  •  printf("\n characteristic name is %c%c; membership is %f",*(s2->actuall->name),*(s2->actuall->name+1), s2->actuall->membership);
  •  printf("\n s3");
  •  printf("\n set name is %c%c",*(s3->m.name),*(s3->m.name+1));
  •  for(s3->actuall=s3->first; s3->actuall!=0; s3->actuall=s3->actuall->follow)
  •  printf("\n characteristic name is %c%c; membership is %f",*(s3->actuall->name),*(s3->actuall->name+1), s3->actuall->membership);
  •  printf("\n s4");
  •  printf("\n set name is %c%c%c%c%c%c%c%c",*(s4->m.name),*(s4->m.name+1),*(s4->m.name+2),*(s4->m.name+3),*(s4->m.name+4),*(s4->m.name+5),*(s4->m.name+6),*(s4->m.name+7));
  •  for(s4->actuall=s4->first; s4->actuall!=0; s4->actuall=s4->actuall->follow)
  •  printf("\n characteristic name is %c%c; membership is %f",*(s4->actuall->name),*(s4->actuall->name+1), s4->actuall->membership);
  •  n=fuzzy2crisp_defuzzyfication(s4);
  •  printf("\n-->Characteristic %c%c has the highest membership",*(n),*(n+1));
  •  n=fuzzy_object _defuzzyfication(s4);
  •  printf("\n-->The highest membership have characteristics:");
  •  do
  •  { printf(" %c%c;",*(n),*(n+1));
  •  n+=2;
  •  }
  •  while(*n!='#');
  • printf("\n s5");
  •  printf("\n set name is %c%c%c%c%c%c%c",*(s5->m.name),*(s5->m.name+1),*(s5->m.name+2),*(s5->m.name+3),*(s5->m.name+4),*(s5->m.name+5),*(s5->m.name+6));
  •  for(s5->actuall=s5->first; s5->actuall!=0; s5->actuall=s5->actuall->follow)
  •  printf("\n characteristic name is %c%c; membership is %f",*(s5->actuall->name),*(s5->actuall->name+1), s5->actuall->membership);
  •  printf("\n s6");
  •  printf("\n set name is %c%c%c%c%c%c%c",*(s6->m.name),*(s6->m.name+1),*(s6->m.name+2),*(s6->m.name+3),*(s6->m.name+4),*(s6->m.name+5),*(s6->m.name+6));
  •  for(s6->actuall=s6->first; s6->actuall!=0; s6->actuall=s6->actuall->follow)
  •  printf("\n characteristic name is %c%c; membership is %f",*(s6->actuall->name),*(s6->actuall->name+1), s6->actuall->membership);
  •  printf("\n s7");
  •  printf("\n set name is %c%c",*(s7->m.name),*(s7->m.name+1));
  •  for(s7->actuall=s7->first; s7->actuall!=0; s7->actuall=s7->actuall->follow)
  •  printf("\n characteristic name is %c%c; membership is %f",*(s7->actuall->name),*(s7->actuall->name+1), s7->actuall->membership);
  •  printf("\n s8");
  •  printf("\n set name is %c%c",*(s8->m.name),*(s8->m.name+1));
  •  for(s8->actuall=s8->first; s8->actuall!=0; s8->actuall=s8->actuall->follow)
  •  printf("\n characteristic name is %c%c; membership is %f",*(s8->actuall->name),*(s8->actuall->name+1), s8->actuall->membership);
  •  printf("\n s11");
  •  printf("\n set name is %c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c",*(s11->m.name),*(s11->m.name+1),*(s11->m.name+2),*(s11->m.name+3),*(s11->m.name+4),*(s11->m.name+5),*(s11->m.name+6),*(s11->m.name+7),*(s11->m.name+8),*(s11->m.name+9),*(s11->m.name+10),*(s11->m.name+11),*(s11->m.name+12),*(s11->m.name+13),*(s11->m.name+14),*(s11->m.name+15),*(s11->m.name+16),*(s11->m.name+17),*(s11->m.name+18),*(s11->m.name+19),*(s11->m.name+20),*(s11->m.name+21));
  •  for(s11->actuall=s11->first; s11->actuall!=0; s11->actuall=s11->actuall->follow)
  •  printf("\n characteristic name is %c%c; membership is %f",*(s11->actuall->name),*(s11->actuall->name+1), s11->actuall->membership);
  •  printf("\n s12");
  •  printf("\n set name is %c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c",*(s12->m.name),*(s12->m.name+1),*(s12->m.name+2),*(s12->m.name+3),*(s12->m.name+4),*(s12->m.name+5),*(s12->m.name+6),*(s12->m.name+7),*(s12->m.name+8),*(s12->m.name+9),*(s12->m.name+10),*(s12->m.name+11),*(s12->m.name+12),*(s12->m.name+13),*(s12->m.name+14),*(s12->m.name+15),*(s12->m.name+16),*(s12->m.name+17),*(s12->m.name+18),*(s12->m.name+19));
  •  for(s12->actuall=s12->first; s12->actuall!=0; s12->actuall=s12->actuall->follow)
  •  printf("\n characteristic name is %c%c; membership is %f",*(s12->actuall->name),*(s12->actuall->name+1), s12->actuall->membership);
  •  printf("\n s13");
  •  printf("\n set name is %c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c",*(s13->m.name),*(s13->m.name+1),*(s13->m.name+2),*(s13->m.name+3),*(s13->m.name+4),*(s13->m.name+5),*(s13->m.name+6),*(s13->m.name+7),*(s13->m.name+8),*(s13->m.name+9),*(s13->m.name+10),*(s13->m.name+11),*(s13->m.name+12),*(s13->m.name+13),*(s13->m.name+14),*(s13->m.name+15),*(s13->m.name+16),*(s13->m.name+17));
  •  for(s13->actuall=s13->first; s13->actuall!=0; s13->actuall=s13->actuall->follow)
  •  printf("\n characteristic name is %c%c; membership is %f",*(s13->actuall->name),*(s13->actuall->name+1), s13->actuall->membership);
  •  printf("\n s14");
  •  printf("\n set name is %c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c",*(s14->m.name),*(s14->m.name+1),*(s14->m.name+2),*(s14->m.name+3),*(s14->m.name+4),*(s14->m.name+5),*(s14->m.name+6),*(s14->m.name+7),*(s14->m.name+8),*(s14->m.name+9),*(s14->m.name+10),*(s14->m.name+11),*(s14->m.name+12),*(s14->m.name+13),*(s14->m.name+14),*(s14->m.name+15));
  •  for(s14->actuall=s14->first; s14->actuall!=0; s14->actuall=s14->actuall->follow)
  •  printf("\n characteristic name is %c%c; membership is %f",*(s14->actuall->name),*(s14->actuall->name+1), s14->actuall->membership);
  •  printf("\n s15");
  •  printf("\n set name is %c%c%c%c%c%c",*(s15->m.name),*(s15->m.name+1),*(s15->m.name+2),*(s15->m.name+3),*(s15->m.name+4),*(s15->m.name+5));
  •  for(s15->actuall=s15->first; s15->actuall!=0; s15->actuall=s15->actuall->follow)
  •  printf("\n characteristic name is %c%c; membership is %f",*(s15->actuall->name),*(s15->actuall->name+1), s15->actuall->membership);
  •  printf("\n s16");
  •  printf("\n set name is %c%c%c%c%c%c%c",*(s16->m.name),*(s16->m.name+1),*(s16->m.name+2),*(s16->m.name+3),*(s16->m.name+4),*(s16->m.name+5),*(s16->m.name+6));
  •  for(s16->actuall=s16->first; s16->actuall!=0; s16->actuall=s16->actuall->follow)
  •  printf("\n characteristic name is %c%c; membership is %f",*(s16->actuall->name),*(s16->actuall->name+1), s16->actuall->membership);
  •  printf("\n s17");
  •  printf("\n set name is %c%c%c%c%c%c%c",*(s17->m.name),*(s17->m.name+1),*(s17->m.name+2),*(s17->m.name+3),*(s17->m.name+4),*(s17->m.name+5),*(s17->m.name+6));
  •  for(s17->actuall=s17->first; s17->actuall!=0; s17->actuall=s17->actuall->follow)
  •  printf("\n characteristic name is %c%c; membership is %f",*(s17->actuall->name),*(s17->actuall->name+1), s17->actuall->membership);
  •  printf("\n\n c1");
  •  for(counter=0; counter<c1->number_of_subsets; counter++)
  •  printf("\n subset name is %c%c; membership is %d",*(c1->name+counter*2),*(c1->name+counter*2+1), *(c1->memberships+counter));
  •  printf("\n c2");
  •  for(counter=0; counter<c2->number_of_subsets; counter++)
  •  printf("\n subset name is %c%c; membership is %d",*(c2->name+counter*2),*(c2->name+counter*2+1), *(c2->memberships+counter));
  •  printf("\n c3");
  •  for(counter=0; counter<c3->number_of_subsets; counter++)
  •  printf("\n subset name is %c%c; membership is %d",*(c3->name+counter*2),*(c3->name+counter*2+1), *(c3->memberships+counter));
  •  printf("\n c4");
  •  for(counter=0; counter<c4->number_of_subsets; counter++)
  •  printf("\n subset name is %c%c; membership is %d",*(c4->name+counter*2),*(c4->name+counter*2+1), *(c4->memberships+counter));
  •  fill_set(s2,name1,membership1);
  •  printf("\n New s2");
  •  printf("\n set name is %c%c",*(s2->m.name),*(s2->m.name+1));
  •  for(s2->actuall=s2->first; s2->actuall!=0; s2->actuall=s2->actuall->follow)
  •  printf("\n characteristic name is %c%c; membership is %f",*(s2->actuall->name),*(s2->actuall->name+1), s2->actuall->membership);
  •  printf("\n Set s3 has");
  •  if(fset_equall_set(s3,s4)==F) printf("n't");
  •  printf(" the same characteristics as s4 !");
  •  printf("\n Sets s3 and s4 are");
  •  if(f_equall(s3,s4)==F) printf("n't");
  •  printf(" identical !");
  •  printf("\n Sets s3 and s4 are");
  •  if(f_equall_epsilon(s3,s4,0.3)==F) printf("n't");
  •  printf(" identical inside noise of 0.3!");
  •  printf("\n Set s3 is subset of s4 with %f",fsubsethood(s3,s4));
  •  printf("\n Set s4 is subset of s3 with %f",fsubsethood(s4,s3));
  •  printf("\n Divergence between s3 and s4 is %f",divergence(s4,s3));
  •  printf("\n Entropy (De Luce & Termini) of s3 is %f",entropy_DeLuceTermini(s3));
  •  printf("\n Entropy (over divergence) of s3 is %f",entropy_using_divergence(s3));
  •  printf("\n Sum of memberships of all characteristics of s3 is");
  •  if(fuzzy_check_sum(s3,0.001)==F) printf("n't");
  •  printf(" equall 1.0+/-0.001");
  •  printf("\n Each membership of s3 is");
  •  if(fuzzy_check_membership(s3)==F) printf("n't");
  •  printf(" element of R[0,1]");
  •  switch(fuzzy_object _check(s3,0.001))
  •  {
  •  case Y: printf("\n Sum of memberships of all characteristics of s3 is 1.0 +/- 0.001, and each membership is from R[0,1]");
  •  break;
  •  case S: printf("\n Sum of memberships of all characteristics of s3 is >1.001 or <0.999, while each membership is from R[0,1]");
  •  break;
  •  case M: printf("\n Sum of memberships of all characteristics of s3 is1.0 +/- 0.001, while there is membership out of interval R[0,1]");
  •  break;
  •  case ALL: printf("\n Sum of memberships of all characteristics of s3 is>1.001 or <0.999, and there is membership out of interval R[0,1]");
  •  break;
  •  };
  •  delete_fuzzy_object (s1);
  •  delete_fuzzy_object (s2);
  •  delete_fuzzy_object (s3);
  •  delete_fuzzy_object (s4);
  •  delete_fuzzy_object (s5);
  •  delete_fuzzy_object (s6);
  •  delete_fuzzy_object (s7);
  •  delete_crisp_set(c1);
  •  delete_crisp_set(c2);
  •  delete_crisp_set(c3);
  •  delete_crisp_set(c4);
  •  }
  • Table of Contents



    Read it

  • All comments on this library are welcome. Feel free to contact author if there is anything you would like or you need to be added or anything you suggest to change.

  •  This library is for use only in education and research. It is not for commercial use! Written permission from author is necessary for commercial use or for inclusion as a part of project or program or another library!

     Programs, projects, libraries or anything consists this library or its part MUST NOT be sold without author permission!


    Author: Igor Dekovich

  • ph: (-61) (2) 4225 2673
  • mobile: (-61) 042 189 69 84
  •  e-mail: idekovich@yahoo.com

  •  

     

    Table of Contents


    Auckland, 4/4/1995

  • revised 22/11/1995