2

I am trying to build a fuzzy decsion making module in python using skfuzzy ctrl library. I am defining one antecedent and 5 consequents. But the thing is I am unable to define my own triangular membership function for the antecedent. Code is given below.

# Import libraries
import math as M
import numpy as np
import matplotlib.pyplot as plt
import serial
import time
import skfuzzy as fuzz
x_pos = ctrl.Antecedent(np.arange(-0.25, 0.25, 0.001),'x_pos')

# x_serv = np.arange(0, 11, 1)
L1 = ctrl.Consequent(np.arange(0, 100, 0.001),'L1')
L2 = ctrl.Consequent(np.arange(0, 100, 0.001),'L2')
R1 = ctrl.Consequent(np.arange(0, 100, 0.001),'R1')
R2 = ctrl.Consequent(np.arange(0, 100, 0.001),'R2')
T = ctrl.Consequent(np.arange(0, 100, 0.001),'T')

I tried it this way but as expected it shows errors.

x_pos['left']=fuzz.trimf(x_pos,[-0.25,-0.25,0])
x_pos['center']=fuzz.trimf(x_pos,[-0.1,0,0.1])
x_pos['right']=fuzz.trimf(x_pos,[0,0.25,0.25])

Is there anyway I can define my own antecedent without using the automf function. The automf function doesn't provide me the flexibility to define my own antecedent. Thank you.

CR7
  • 21
  • 5

1 Answers1

-1

I am not sure about what do you want, however, you can define the labels in your Antecedent using automf, for example:

names = ['nb', 'ns', 'ze', 'ps', 'pb']
x_pos.automf(names=names)
omar
  • 1,541
  • 3
  • 21
  • 36