本文整理汇总了Python中skfuzzy.trimf函数的典型用法代码示例。如果您正苦于以下问题:Python trimf函数的具体用法?Python trimf怎么用?Python trimf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了trimf函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, lowest=0, highest=40, step=0.5):
super(ControlTemperature, self).__init__()
self.lowest = lowest
self.highest = highest
self.step = step
self.temp = np.arange(lowest, highest, step)
self.temp_err = np.arange(-50, 50, 0.1)
self.temp_roc = np.arange(-30, 30, 0.1) # degress c per minute
self.chill_out = np.arange(-100, 100, 1)
# self.heat_out = np.arange(0, 100, 1)
#Current Temperature
self.te_too_cold = fuzz.trapmf(self.temp_err, [-40, -30, -1.5, -1])
self.te_cold = fuzz.trimf(self.temp_err, [-1.5, -1, -0.5])
self.te_optimal = fuzz.trimf(self.temp_err, [-0.5, 0, 0.5])
self.te_hot = fuzz.trimf(self.temp_err, [0.5, 1, 1.5])
self.te_too_hot = fuzz.trapmf(self.temp_err, [1, 1.5, 30, 40])
#Temperature Rate of Change (deg C per minute)
self.tr_cooling_quickly = fuzz.trapmf(self.temp_roc, [-20, -10, -0.5, -0.25])
# Output - Chiller
self.co_off = fuzz.trimf(self.chill_out, [0, 0, 5])
self.co_low = fuzz.trimf(self.chill_out, [5, 20, 40])
self.co_medium = fuzz.trimf(self.chill_out, [20, 40, 60])
self.co_high = fuzz.trapmf(self.chill_out, [40, 60, 100, 100])
# Output - Heater
self.ho_off = fuzz.trimf(self.chill_out, [-5, 0, 0])
self.ho_low = fuzz.trimf(self.chill_out, [-40, -20, -5])
self.ho_medium = fuzz.trimf(self.chill_out, [-60, -40, -20])
self.ho_high = fuzz.trapmf(self.chill_out, [-100, -100, -60, -40])
开发者ID:chrisdpa,项目名称:brumulus,代码行数:33,代码来源:ControlTemperature.py
示例2: test_tipping_problem
def test_tipping_problem():
# The full tipping problem uses many of these methods
food = ctrl.Antecedent(np.linspace(0, 10, 11), 'quality')
service = ctrl.Antecedent(np.linspace(0, 10, 11), 'service')
tip = ctrl.Consequent(np.linspace(0, 25, 26), 'tip')
food.automf(3)
service.automf(3)
# Manual membership function definition
tip['bad'] = fuzz.trimf(tip.universe, [0, 0, 13])
tip['middling'] = fuzz.trimf(tip.universe, [0, 13, 25])
tip['lots'] = fuzz.trimf(tip.universe, [13, 25, 25])
# Define fuzzy rules
rule1 = ctrl.Rule(food['poor'] | service['poor'], tip['bad'])
rule2 = ctrl.Rule(service['average'], tip['middling'])
rule3 = ctrl.Rule(service['good'] | food['good'], tip['lots'])
# The control system - defined both possible ways
tipping = ctrl.ControlSystem([rule1, rule2, rule3])
tipping2 = ctrl.ControlSystem()
tipping2.addrule(rule2)
tipping2.addrule(rule3)
tipping2.addrule(rule1)
tip_sim = ctrl.ControlSystemSimulation(tipping)
tip_sim2 = ctrl.ControlSystemSimulation(tipping2)
# Inputs added both possible ways
inputs = {'quality': 6.5, 'service': 9.8}
for key, value in inputs.items():
tip_sim.input[key] = value
tip_sim2.inputs(inputs)
# Compute the system
tip_sim.compute()
tip_sim2.compute()
# Ensure both methods of defining rules yield the same results
for val0, val1 in zip(tip_sim.output.values(),
tip_sim2.output.values()):
tst.assert_allclose(val0, val1)
# Verify against manual computation
tst.assert_allclose(tip_sim.output['tip'], 19.8578, atol=1e-2, rtol=1e-2)
开发者ID:duongtrung,项目名称:scikit-fuzzy,代码行数:48,代码来源:test_controlsystem.py
示例3: membership_f
def membership_f(mf, x, abcd):
"""
Returns y values corresponding to type of type of Membership fn.
arguments:
mf - string containing type of Membership function
x - x axis values
"""
if mf == "zmf":
return fuzz.zmf(x, abcd[0], abcd[1]) # zmf(x, a, b)
elif mf == "trimf":
return fuzz.trimf(x, abcd[0:3]) # trimf(x, abc)
elif mf == "dsigmf":
return fuzz.dsigmf(x, abcd[0], abcd[1], abcd[2], abcd[3]) # dsigmf(x, b1, c1, b2, c2)
elif mf == "gauss2mf":
return fuzz.gauss2mf(x, abcd[0], abcd[1], abcd[2], abcd[3]) # gauss2mf(x, mean1, sigma1, mean2, sigma2)
elif mf == "gaussmf":
return fuzz.gaussmf(x, abcd[0], abcd[1]) # gaussmf(x, mean, sigma)
elif mf == "gbellmf":
return fuzz.gbellmf(x, abcd[0], abcd[1], abcd[2]) # gbellmf(x, a, b, c)
elif mf == "piecemf":
return fuzz.piecemf(x, abcd[0:3]) # piecemf(x, abc)
elif mf == "pimf":
return fuzz.pimf(x, abcd[0], abcd[1], abcd[2], abcd[3]) # pimf(x, a, b, c, d)
elif mf == "psigmf":
return fuzz.psigmf(x, abcd[0], abcd[1], abcd[2], abcd[3]) # psigmf(x, b1, c1, b2, c2)
elif mf == "sigmf":
return fuzz.sigmf(x, abcd[0], abcd[1]) # sigmf(x, b, c)
elif mf == "smf":
return fuzz.smf(x, abcd[0], abcd[1]) # smf(x, a, b)
elif mf == "trapmf":
return fuzz.trapmf(x, abcd) # trapmf(x, abcd)
开发者ID:aniket11bh,项目名称:auvpysim,代码行数:31,代码来源:fuzzy.py
示例4: rangeToMF
def rangeToMF(range, type):
"""
Translate the range into a list of x_values and an MF function.
range : list/tuple
range to translate to MF
type : string
type of MF:
'sing' - singleton MF
'gauss' - gaussian MF function (mean, standard deviation)
'tri' - triangular MF function
'trap' - trapezoidal MF function
"""
c = 100 #number of x points
minR = float(min(range))
maxR = float(max(range))
if type == 'sing': #singleton
c = 10 #special short mf for singleton
if maxR == minR:
#print "SAME R"
ran = max(abs(0.15*minR),0.0001)
xrange = [minR-ran, minR+ran, ran/c]
Xs = [minR-2.*ran, minR-1.*ran, minR, minR+1.*ran, minR+2.*ran,]
Ys = [0.0, 0.0, 1.0, 0.0, 0.0]
else:
ran = abs(maxR-minR)
xrange = [minR, maxR, ran/c]
Xs, Ys = singleton_to_fuzzy(sum(range)/len(range), xrange)
elif type == 'gauss': #gaussian MF
std_range = (1./4.) #0.25
if minR == maxR: ran = max(0.0001,abs(0.05*minR))#0.05
else: ran = abs(maxR - minR) #check for min=max and get range
Xs = np.arange(minR - 0.5*ran, maxR + 0.5*ran, 2*ran/c)
Ys = fuzz.gaussmf(Xs, sum(range)/len(range), std_range*(ran)) #gaussian mf with 4sigma = range (to 97.7% "certainty")
elif type == 'tri': #triangular MF
if minR == maxR:
ran = max(abs(0.2*minR),0.001)
xrange = [0.9*minR, 1.1*maxR, ran/c,]
Xs, Ys = singleton_to_fuzzy(sum(range)/len(range), xrange)
else:
Xs = np.arange(0.9*minR, 1.1*maxR, (1.1*maxR-0.9*minR)/c) #create fuzzy MF for output
Ys = fuzz.trimf(Xs, [minR, sum(range)/len(range), maxR])
elif type == 'trap': #trapezoidal MF
if minR == maxR:
ran = max(abs(0.2*minR),0.001)
xrange = [0.9*minR, 1.1*maxR, ran/c,]
Xs, Ys = singleton_to_fuzzy(sum(range)/len(range), xrange)
else:
Xs = np.arange(0.9*minR, 1.1*maxR, (1.1*maxR-0.9*minR)/c) #create fuzzy MF for output
Ys = fuzz.trapmf(Xs, [minR, minR, maxR, maxR])
else:
raise StandardError("Unknown type of membership function: %s" % type)
return [np.asarray(Xs), np.asarray(Ys)] #create MF
开发者ID:pattersoniv,项目名称:FFAS,代码行数:60,代码来源:fuzzy_operations.py
示例5: __init__
def __init__(self):
# Generate universe functions
self.distance = np.arange(0.,181.,1.)
self.acceleration = np.arange(0.,0.1,0.01)
# Generate Distance membership functions
self.near = fuzz.trapmf(self.distance, (-1.,-1.,20.,65.))
self.medium = fuzz.trapmf(self.distance,(35.,80.,120.,135.))
self.far = fuzz.trapmf(self.distance,(105.,170.,180.,200.))
# Generate Acceleration membership functions
self.slow = fuzz.trimf(self.acceleration, (-1.,0.,0.05))
self.normal = fuzz.trapmf(self.acceleration,(0.02,0.035,0.04,0.07))
self.fast = fuzz.trapmf(self.acceleration,(0.06,0.085,0.1,0.2))
# Fuzzy relation
self.R1 = fuzz.relation_product(self.near,self.slow)
self.R2 = fuzz.relation_product(self.medium,self.normal)
self.R3 = fuzz.relation_product(self.far,self.fast)
# Combine the fuzzy relation
self.R_combined = np.fmax(self.R1, np.fmax(self.R2, self.R3))
self.thetaOne = 0.0
self.thetaTwo = 0.0
self.InputDistanceAngle = 0.0
self.OutputAcceleration = 0.0
self.visualize = True
开发者ID:ansrivas,项目名称:gameailab,代码行数:32,代码来源:fuzzyControl.py
示例6: test_tipping_problem
def test_tipping_problem():
# The full tipping problem uses many of these methods
food = Antecedent(np.linspace(0, 10, 11), 'quality')
service = Antecedent(np.linspace(0, 10, 11), 'service')
tip = Consequent(np.linspace(0, 25, 26), 'tip')
food.automf(3)
service.automf(3)
# Manual membership function definition
tip['bad'] = trimf(tip.universe, [0, 0, 13])
tip['middling'] = trimf(tip.universe, [0, 13, 25])
tip['lots'] = trimf(tip.universe, [13, 25, 25])
# Define fuzzy rules
rule1 = Rule(food['poor'] | service['poor'], tip['bad'])
rule2 = Rule(service['average'], tip['middling'])
rule3 = Rule(service['good'] | food['good'], tip['lots'])
# The control system - defined both possible ways
tipping = ControlSystem([rule1, rule2, rule3])
tipping2 = ControlSystem()
tipping2.addrule(rule2)
tipping2.addrule(rule3)
tipping2.addrule(rule1)
tip_sim = ControlSystemSimulation(tipping)
tip_sim2 = ControlSystemSimulation(tipping2)
# Inputs added both possible ways
inputs = {'quality': 6.5, 'service': 9.8}
for key, value in inputs.items():
tip_sim.input[key] = value
tip_sim2.inputs(inputs)
# Compute the system
tip_sim.compute()
tip_sim2.compute()
assert tip_sim.output == tip_sim2.output
tst.assert_allclose(tip_sim.output['tip'], 20.244508118433625)
开发者ID:Raghavaraman,项目名称:scikit-fuzzy,代码行数:43,代码来源:test_controlsystem.py
示例7: test_lambda_cut_series
def test_lambda_cut_series():
x = np.arange(21) - 10
mfx = fuzz.trimf(x, [-2, 3, 5])
expected = np.array([[ 0. , -2., 5.],
[ 0.25, 0., 4.],
[ 0.5 , 1., 4.],
[ 0.75, 2., 3.],
[ 1. , 3., 3.]])
assert_allclose(expected, fuzz.lambda_cut_series(x, mfx, 5))
开发者ID:Komper111,项目名称:Fuzzy_NAO_emotions,代码行数:11,代码来源:test_defuzz.py
示例8: __init__
def __init__(self):
# Generate universe variables
distance = ctrl.Antecedent(np.arange(-440, 441, 1), 'distance') # paddle.x - ball.x
paddle_speed = ctrl.Consequent(np.arange(-12,13,4), 'speed') # paddle.x +=paddle_speed
# Auto-membership function population is possible with .automf(3, 5, or 7)
# Generate fuzzy membership functions
distance['far right'] = fuzz.trimf(distance.universe, [-440, -250, -110])
distance['close right'] = fuzz.trimf(distance.universe, [-200, -10, 0])
distance['close left'] = fuzz.trimf(distance.universe, [0, 10, 200])
distance['far left'] = fuzz.trimf(distance.universe, [200, 440, 440])
paddle_speed.automf(7)
rule1 = ctrl.Rule(distance['far left'], paddle_speed['dismal'])
rule2 = ctrl.Rule(distance['close left'], paddle_speed['dismal'])
rule3 = ctrl.Rule(distance['close right'], paddle_speed['excellent'])
rule4 = ctrl.Rule(distance['far right'], paddle_speed['excellent'])
# rule5 = ctrl.Rule(distance['above'], paddle_speed['average'])
paddle_ctrl = ctrl.ControlSystem([rule1, rule2, rule3, rule4])
self.agent = ctrl.ControlSystemSimulation(paddle_ctrl)
开发者ID:ElchinValiyev,项目名称:GameAI,代码行数:23,代码来源:fuzzy_agent.py
示例9: __init__
def __init__(self):
# Generate universe variables
distance = ctrl.Antecedent(np.arange(-8, 9, 1), 'distance')
trajectory = ctrl.Consequent(np.arange(-2, 3, 1), 'trajectory')
# Auto-membership function population is possible with .automf(3, 5, or 7)
distance.automf(3)
# Custom membership functions can be built interactively with a familiar,
# Pythonic API
trajectory['low'] = fuzz.trimf(trajectory.universe, [-2, -2, -2])
trajectory['medium'] = fuzz.trimf(trajectory.universe, [0, 0, 2])
trajectory['high'] = fuzz.trimf(trajectory.universe, [0, 2, 2])
rule1 = ctrl.Rule(distance['poor'], trajectory['low'])
rule2 = ctrl.Rule(distance['average'], trajectory['medium'])
rule3 = ctrl.Rule(distance['good'], trajectory['high'])
# Pass inputs to the ControlSystem using Antecedent labels with Pythonic API
# Note: if you like passing many inputs all at once, use .inputs(dict_of_data)
trajectoryping_ctrl = ctrl.ControlSystem([rule1, rule2, rule3])
self.agent = ctrl.ControlSystemSimulation(trajectoryping_ctrl)
开发者ID:ElchinValiyev,项目名称:GameAI,代码行数:23,代码来源:fuzzy_trajectory.py
示例10: test_lambda_cut
def test_lambda_cut():
x = np.arange(21) - 10
mfx = fuzz.trimf(x, [-2, 3, 5])
# fuzz.lambda_cut test
expected = np.r_[0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0]
result = fuzz.lambda_cut(mfx, 0.33)
assert_allclose(expected, result)
# fuzz.arglcut test
expected = np.r_[10, 11, 12, 13, 14]
result = fuzz.arglcut(mfx, 0.33)
assert len(result) == 1
assert_allclose(expected, result[0])
开发者ID:Komper111,项目名称:Fuzzy_NAO_emotions,代码行数:16,代码来源:test_defuzz.py
示例11: membership_f
def membership_f(mf, x, abc = [0,0,0], a = 1, b = 2, c = 3, d = 4, abcd = [0,0,0,0]):
return {
'trimf' : fuzz.trimf(x, abc), # trimf(x, abc)
'dsigmf' : fuzz.dsigmf(x, a, b, c, d), # dsigmf(x, b1, c1, b2, c2)
'gauss2mf': fuzz.gauss2mf(x, a, b, c, d), # gauss2mf(x, mean1, sigma1, mean2, sigma2)
'gaussmf' : fuzz.gaussmf(x, a, b), # gaussmf(x, mean, sigma)
'gbellmf' : fuzz.gbellmf(x, a, b, c), # gbellmf(x, a, b, c)
'piecemf' : fuzz.piecemf(x, abc), # piecemf(x, abc)
'pimf' : fuzz.pimf(x, a, b, c, d), # pimf(x, a, b, c, d)
'psigmf' : fuzz.psigmf(x, a, b, c, d), # psigmf(x, b1, c1, b2, c2)
'sigmf' : fuzz.sigmf(x, a, b), # sigmf(x, b, c)
'smf' : fuzz.smf(x, a, b), # smf(x, a, b)
'trapmf' : fuzz.trapmf(x, abcd), # trapmf(x, abcd)
'zmf' : fuzz.zmf(x, a, b), # zmf(x, a, b)
}[mf]
开发者ID:icyflame,项目名称:fuzzy-control,代码行数:16,代码来源:fuzzy.py
示例12: throttle_command
def throttle_command(speed_read):
# Universe of discourse
speed = np.arange(60,150,.1)
throttle_value = np.arange(0,1,0.01)
# Input membership functions
too_slow = fuzz.trapmf(speed,[60,60,80,85])
slow = fuzz.trimf(speed,[83,90,97])
cruise = fuzz.trimf(speed,[95,100,105])
fast = fuzz.trimf(speed,[103,110,117])
too_fast = fuzz.trapmf(speed,[115,120,150,150])
# Output membership functions
very_low = fuzz.trimf(throttle_value,[0,0,0.15])
low = fuzz.trimf(throttle_value,[0.1,0.25,0.4])
medium = fuzz.trimf(throttle_value,[0.35,0.5,0.65])
high = fuzz.trimf(throttle_value,[0.6,0.75,0.9])
very_high = fuzz.trimf(throttle_value,[0.85,1,1])
# membership values
speed_cat_too_slow = fuzz.interp_membership(speed,too_slow,speed_read)
speed_cat_slow = fuzz.interp_membership(speed,slow,speed_read)
speed_cat_cruise = fuzz.interp_membership(speed,cruise,speed_read)
speed_cat_fast = fuzz.interp_membership(speed,fast,speed_read)
speed_cat_too_fast = fuzz.interp_membership(speed,too_fast,speed_read)
# If part of rules
rule1 = speed_cat_too_slow
rule2 = speed_cat_slow
rule3 = speed_cat_cruise
rule4 = speed_cat_fast
rule5 = speed_cat_too_fast
# Then part of rules
imp1 = np.fmin(rule1,very_high)
imp2 = np.fmin(rule2,high)
imp3 = np.fmin(rule3,medium)
imp4 = np.fmin(rule4,low)
imp5 = np.fmin(rule5,very_low)
aggregate_membership = np.fmax(imp1,np.fmax(imp2,np.fmax(imp3,np.fmax(imp4,imp5))))
return fuzz.defuzz(throttle_value,aggregate_membership,'centroid')
开发者ID:jbm950,项目名称:python_xplane,代码行数:44,代码来源:speedcontrollerexample.py
示例13: test_bisector
def test_bisector():
x = np.arange(6)
mfx = fuzz.trimf(x, [0, 5, 5])
expected = 3.53553390593274
# Test both triangle code paths
assert_allclose(expected, fuzz.defuzz(x, mfx, 'bisector'))
assert_allclose(5 - expected, fuzz.defuzz(x, 1 - mfx, 'bisector'))
# Test singleton input
y = np.r_[2]
mfy = np.r_[0.33]
assert_allclose(y, fuzz.defuzz(y, mfy, 'bisector'))
# Test rectangle code path
mfx = fuzz.trapmf(x, [2, 2, 4, 4])
assert_allclose(3., fuzz.defuzz(x, mfx, 'bisector'))
开发者ID:duongtrung,项目名称:scikit-fuzzy,代码行数:17,代码来源:test_defuzz.py
示例14: load_rules
def load_rules(self, filename):
with open(filename, 'r') as jsonfile:
rules = json.loads(jsonfile.read())
self.actions = rules['actions']
self.state = rules['state']
self.rules = rules['results']
self.x = np.arange(self.state['min'], self.state['max'])
for subset, parts in self.rules.items():
aggregated = []
points = []
for n, v in parts.items():
print n
if v['mf'] == 'tri':
mf = fuzz.trimf(self.x, v['shp'])
if v['mf'] == 'trap':
mf = fuzz.trapmf(self.x, v['shp'])
elif v['mf'] == 'gbell':
mf = fuzz.gbellmf(self.x, v['shp'])
aggregated.append(mf)
points.append(v['pts'])
self.rules[subset] = (aggregated, points)
开发者ID:trevstanhope,项目名称:python-qlearn,代码行数:21,代码来源:q_learn.py
示例15: membership_f
def membership_f(mf, x, abc=[0, 0, 0], a=1, b=2, c=3, d=4, abcd=[0, 0, 0, 0]):
"""
Returns y values corresponding to type of type of Membership fn.
arguments:
mf - string containing type of Membership function
x - x axis values
abc - list containing triangular edge point x-values
"""
return {
"trimf": fuzz.trimf(x, abc), # trimf(x, abc)
"dsigmf": fuzz.dsigmf(x, a, b, c, d), # dsigmf(x, b1, c1, b2, c2)
"gauss2mf": fuzz.gauss2mf(x, a, b, c, d), # gauss2mf(x, mean1, sigma1, mean2, sigma2)
"gaussmf": fuzz.gaussmf(x, a, b), # gaussmf(x, mean, sigma)
"gbellmf": fuzz.gbellmf(x, a, b, c), # gbellmf(x, a, b, c)
"piecemf": fuzz.piecemf(x, abc), # piecemf(x, abc)
"pimf": fuzz.pimf(x, a, b, c, d), # pimf(x, a, b, c, d)
"psigmf": fuzz.psigmf(x, a, b, c, d), # psigmf(x, b1, c1, b2, c2)
"sigmf": fuzz.sigmf(x, a, b), # sigmf(x, b, c)
"smf": fuzz.smf(x, a, b), # smf(x, a, b)
"trapmf": fuzz.trapmf(x, abcd), # trapmf(x, abcd)
"zmf": fuzz.zmf(x, a, b), # zmf(x, a, b)
}[mf]
开发者ID:kshitijgoel007,项目名称:Control_auv,代码行数:22,代码来源:fuzzy.py
示例16: paramsToMF
def paramsToMF(params):
"""
Translate the piecewise params list of x_values to an MF function. Assumes a
list of length:
1 - singleton MF
2 - gaussian MF function (mean, standard deviation)
3 - triangular MF function
4 - trapezoidal MF function
"""
c = 100.0
if len(params) == 1: #singleton
c = 50 #special short MF for singleton
xrange = [0.9*params[0], 1.1*params[0], 2*0.2*params[0]/c]
x, y = singleton_to_fuzzy(params[0], xrange)
if len(params) == 2: #gaussian MF
#print "PARAMS:", params
if params[1] == 0.0: v = 0.01*params[0]
else: v = params[1]
x = np.arange( params[0] - 6*v,
params[0] + 6*v,
(14.0*v/c) ) #use 6 sigmas
y = fuzz.gaussmf(x, params[0], params[1])
elif len(params) == 3: #triangular MF
if max(params) == min(params): prange = max(params)
else: prange = max(params) - min(params)
x = np.arange( min(params), max(params),prange/c)
y = fuzz.trimf(x, params)
elif len(params) == 4: #trapezoidal MF
if max(params) == min(params): prange = max(params)
else: prange = max(params) - min(params)
x = np.arange( min(params), max(params),prange/c)
y = fuzz.trapmf(x, params)
return [np.asarray(x), np.asarray(y)] #create MF
开发者ID:pattersoniv,项目名称:FFAS,代码行数:37,代码来源:fuzzy_operations.py
示例17:
import numpy as np
import skfuzzy as fuzz
from skfuzzy import control as ctrl
fused_estimation = ctrl.Antecedent(np.arange(0, 11, 1), 'fused_estimation')
kde_result = ctrl.Antecedent(np.arange(0, 11, 1), 'kde_result')
current = ctrl.Antecedent(np.arange(0, 11, 1), 'current')
pov = ctrl.Consequent(np.arange(0, 11, 1), 'pov')
fused_estimation['low'] = fuzz.trimf(fused_estimation.universe, [0, 0, 5])
fused_estimation['medium'] = fuzz.trimf(fused_estimation.universe, [2, 5, 8])
fused_estimation['high'] = fuzz.trimf(fused_estimation.universe, [5, 8, 10])
kde_result['low'] = fuzz.trimf(kde_result.universe, [0, 0, 5])
kde_result['medium'] = fuzz.trimf(kde_result.universe, [2, 5, 8])
kde_result['high'] = fuzz.trimf(kde_result.universe, [5, 10, 10])
current['low'] = fuzz.trimf(current.universe, [0, 0, 5])
current['medium'] = fuzz.trimf(current.universe, [2, 5, 8])
current['high'] = fuzz.trimf(current.universe, [5, 10, 10])
pov['low'] = fuzz.trimf(pov.universe, [0, 0, 5])
pov['medium'] = fuzz.trimf(pov.universe, [2, 5, 8])
pov['high'] = fuzz.trimf(pov.universe, [5, 10, 10])
proportional=1
if proportional==1:
开发者ID:wishful-project,项目名称:examples,代码行数:31,代码来源:fuzzy.py
示例18:
# -*- coding: utf-8 -*-
"""
Created on Sun Jul 10 22:10:02 2016
@author: meza
"""
import skfuzzy as fuzz
import numpy as np
import matplotlib.pyplot as plt
x=np.arange(11)
print x
mfx=fuzz.trimf(x, [0, 5,10])
print mfx
plt.plot(x,mfx)
plt.grid('on')
plt.show()
开发者ID:moisesStevend,项目名称:TestFuzzyLogic,代码行数:20,代码来源:testFuzzy2.py
示例19:
"""
if temperature is hot then ice cream parlor is crowded.
if temperature is moderate then ice cream parlor is busy.
if temperature is cool then ice cream parlor is quiet.
"""
import numpy as np
import skfuzzy as fuzz
import matplotlib.pyplot as plt
#Univerese functions
temp = np.arange(30, 101, 1)
customers = np.arange(0,36, 1)
#Membership function for heat
t_hot = fuzz.trimf(temp, [65, 100, 100])
t_mod = fuzz.trimf(temp, [30, 65, 100])
t_cool = fuzz.trapmf(temp, [20, 20, 30, 65])
#Membership function for customers
c_crowded = fuzz.trimf(customers, [24, 35, 35])
c_busy = fuzz.trimf(customers, [0, 24, 35])
c_quiet = fuzz.trimf(customers, [0, 0, 24])
"""Visualise system"""
# Visualize membership functions for temperature
'''fig, ax = plt.subplots()
ax.plot(temp, t_hot, 'r', temp, t_mod, 'm', temp, t_cool, 'b')
开发者ID:NPSDC,项目名称:Modeling,代码行数:31,代码来源:trialFuzzy.py
示例20:
are defined in scikit-fuzzy as follows
"""
import numpy as np
import skfuzzy as fuzz
import matplotlib.pyplot as plt
# Generate universe variables
# * Quality and service on subjective ranges [0, 10]
# * Tip has a range of [0, 25] in units of percentage points
x_qual = np.arange(0, 11, 1)
x_serv = np.arange(0, 11, 1)
x_tip = np.arange(0, 26, 1)
# Generate fuzzy membership functions
qual_lo = fuzz.trimf(x_qual, [0, 0, 5])
qual_md = fuzz.trimf(x_qual, [0, 5, 10])
qual_hi = fuzz.trimf(x_qual, [5, 10, 10])
serv_lo = fuzz.trimf(x_serv, [0, 0, 5])
serv_md = fuzz.trimf(x_serv, [0, 5, 10])
serv_hi = fuzz.trimf(x_serv, [5, 10, 10])
tip_lo = fuzz.trimf(x_tip, [0, 0, 13])
tip_md = fuzz.trimf(x_tip, [0, 13, 25])
tip_hi = fuzz.trimf(x_tip, [13, 25, 25])
# Visualize these universes and membership functions
fig, (ax0, ax1, ax2) = plt.subplots(nrows=3, figsize=(8, 9))
ax0.plot(x_qual, qual_lo, 'b', linewidth=1.5, label='Bad')
ax0.plot(x_qual, qual_md, 'g', linewidth=1.5, label='Decent')
ax0.plot(x_qual, qual_hi, 'r', linewidth=1.5, label='Great')
开发者ID:mscross,项目名称:scikit-fuzzy,代码行数:31,代码来源:plot_tipping_problem.py
注:本文中的skfuzzy.trimf函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论