コード例 #1
0
def plot_system():
    x1 = Type1FuzzyVariable(0, 100, 100, 'x1')
    x1.generate_sets(2)

    x2 = Type1FuzzyVariable(0, 100, 100, 'x2')
    x2.generate_sets(3)

    y = Type1FuzzyVariable(0, 100, 100, 'y')
    y.generate_sets(2)

    system = FuzzySystem()
    system.add_input_variable(x1)
    system.add_input_variable(x2)
    system.add_output_variable(y)

    system.plot_system()
コード例 #2
0
def create_fuzzy_system(input_data_info, output_data_info, res=100):

    f_system = FuzzySystem()

    for idx, row in input_data_info.iterrows():

        var = Type1FuzzyVariable(row['min_value'], row['max_value'], res,
                                 row['variable_name'])
        var.generate_sets(5)
        f_system.add_input_variable(var)

    for idx, row in output_data_info.iterrows():
        var = Type1FuzzyVariable(row['min_value'], row['max_value'], res,
                                 row['variable_name'])
        var.generate_sets(5)

        f_system.add_output_variable(var)

    return f_system
コード例 #3
0
temp = FuzzyInputVariable('Temperature', 10, 40, 100)
temp.add_triangular('Cold', 10, 10, 25)
temp.add_triangular('Medium', 15, 25, 35)
temp.add_triangular('Hot', 25, 40, 40)

humidity = FuzzyInputVariable('Humidity', 20, 100, 100)
humidity.add_triangular('Wet', 20, 20, 60)
humidity.add_trapezoidal('Normal', 30, 50, 70, 90)
humidity.add_triangular('Dry', 60, 100, 100)

motor_speed = FuzzyOutputVariable('Speed', 0, 100, 100)
motor_speed.add_triangular('Slow', 0, 0, 50)
motor_speed.add_triangular('Moderate', 10, 50, 90)
motor_speed.add_triangular('Fast', 50, 100, 100)

system = FuzzySystem()
system.add_input_variable(temp)
system.add_input_variable(humidity)
system.add_output_variable(motor_speed)

system.add_rule({'Temperature': 'Cold', 'Humidity': 'Wet'}, {'Speed': 'Slow'})

system.add_rule({
    'Temperature': 'Cold',
    'Humidity': 'Normal'
}, {'Speed': 'Slow'})

system.add_rule({
    'Temperature': 'Medium',
    'Humidity': 'Wet'
}, {'Speed': 'Slow'})
コード例 #4
0
input_var.add_triangular('CE', 25, 50, 75)
input_var.add_triangular('B1', 50, 75, 100)
input_var.add_triangular('B2', 75, 100, 100)

# adding an age linguistic variable
input2_var = Type1FuzzyVariable(0, 100, 100, 'Humidity')
input2_var.add_triangular('S2', 0, 0, 25)
input2_var.add_triangular('S1', 0, 25, 50)
input2_var.add_triangular('CE', 25, 50, 75)
input2_var.add_triangular('B1', 50, 75, 100)
input2_var.add_triangular('B2', 75, 100, 100)

output_var = Type1FuzzyVariable(0, 100, 100, 'Speed')
output_var.add_triangular('L2', 0, 0, 25)
output_var.add_triangular('L1', 0, 25, 50)
output_var.add_triangular('M', 25, 50, 75)
output_var.add_triangular('H1', 50, 75, 100)
output_var.add_triangular('H2', 75, 100, 100)

system = FuzzySystem()
system.add_input_variable(input_var)
system.add_input_variable(input2_var)
system.add_output_variable(output_var)

ante = {'Temperature': 'S2', 'Humidity': 'S2'}
cons = {'Speed': 'H2'}

system.add_rule(ante, cons)

print(system)
コード例 #5
0
    in_dict = dict({'Steering':mean_steer[i]}) # mean steering value
    
    # FUZZY SYSTEM SET UP : defintion of the shape functions
    steering = FuzzyInputVariable('Steering',0,0.50,400)
    steering.add_trapezoidal('Very small curve',0.21,0.35,0.5,0.5)
    steering.add_trapezoidal('Small curve',0.1,0.18,0.24,0.45)
    steering.add_triangular('Large curve',0.01,0.11,0.21)
    steering.add_triangular('Straight',0,0,0.1)
    
    speed = FuzzyOutputVariable('Speed', 0, 80, 400) # mm/s
    speed.add_triangular('Very slow', 0, 0, 30)
    speed.add_triangular('Slow', 15, 32, 49)
    speed.add_triangular('Moderate', 30, 52, 74)
    speed.add_triangular('Fast', 65, 80, 80)
    
    system = FuzzySystem()
    system.add_input_variable(steering)
    system.add_output_variable(speed)
    
    system.add_rule(
    		{ 'Steering':'Very small curve'},{'Speed':'Very slow'})
    system.add_rule(
    		{ 'Steering':'Small curve'},{'Speed':'Slow'})
    system.add_rule(
    		{ 'Steering':'Large curve'},{'Speed':'Moderate'})
    system.add_rule(
    		{ 'Steering':'Straight'},{'Speed':'Fast'})

    # OUTPUT EVALUATION
    out_dict = system.evaluate_output(in_dict)
    v_out = np.array(list(out_dict.values())) # - Fuzzy Output Velocity Vector
コード例 #6
0
x2 = FuzzyInputVariable('x2', 0, 100, 100)
x2.add_triangular('S', 0, 25, 50)
x2.add_triangular('M', 25, 50, 75)
x2.add_triangular('L', 50, 75, 100)

y = FuzzyOutputVariable('y', 0, 100, 100)
y.add_triangular('S', 0, 25, 50)
y.add_triangular('M', 25, 50, 75)
y.add_triangular('L', 50, 75, 100)

z = FuzzyOutputVariable('z', 0, 100, 100)
z.add_triangular('S', 0, 25, 50)
z.add_triangular('M', 25, 50, 75)
z.add_triangular('L', 50, 75, 100)

system = FuzzySystem()
system.add_input_variable(x1)
system.add_input_variable(x2)
system.add_output_variable(y)
system.add_output_variable(z)

system.add_rule({'x1': 'S', 'x2': 'S'}, {'y': 'S', 'z': 'L'})

system.add_rule({'x1': 'M', 'x2': 'M'}, {'y': 'M', 'z': 'M'})

system.add_rule({'x1': 'L', 'x2': 'L'}, {'y': 'L', 'z': 'S'})

system.add_rule({'x1': 'S', 'x2': 'M'}, {'y': 'S', 'z': 'L'})

system.add_rule({'x1': 'M', 'x2': 'S'}, {'y': 'S', 'z': 'L'})