Advertisement
toweber

fuzzy_inference

Sep 9th, 2021
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.88 KB | None | 0 0
  1. import numpy as np
  2. # import ipdb
  3.  
  4. def inference_mamdani_nm(P,ux,uy):
  5.     """
  6.    onde:
  7.    - P é a premissa
  8.    - ux é a função de pertinência do antencedente
  9.    - uy é a função de pertinência do consequente
  10.    - retornará Q
  11.    """
  12.     antecedente_max = np.max(np.minimum(P[:],ux[:]))    
  13.     Q = np.minimum(antecedente_max,uy[:]) #implicação
  14.     return Q
  15.  
  16.  
  17. X = [2, 3, 4, 5, 6]
  18. Y = [10, 20, 30, 40, 50]
  19.  
  20. u_xmedio = [0, 0.5, 1, 0.5, 0]   # funcao de pertinencia para variável linguística x com valor médio
  21. u_yalto  = [0, 0, 0, 0.5,  1]      # funcao de pertinencia para variável linguística y com valor alto
  22.  
  23. u_xmedio = np.array(u_xmedio)
  24. u_yalto = np.array(u_yalto)
  25.  
  26. # Inferência Fuzzy
  27.  
  28. #Assuma que x = 4        ... depois tentem para x = 3
  29. A_l = np.array([0, 0, 1, 0, 0])
  30.  
  31. # B_l = ?
  32.  
  33. B_l = inference_mamdani_nm(A_l,u_xmedio,u_yalto)
  34.  
  35. print(B_l)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement