0% found this document useful (0 votes)
11 views15 pages

Untitled 25

Uploaded by

Amnah Aziza
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views15 pages

Untitled 25

Uploaded by

Amnah Aziza
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

5/1/24, 3:54 PM Untitled25

Fuzzification

Input Membership Function


In [ ]: import pandas as pd
import numpy as np

# Coefficients for Type 1 CFIS


a1 = 1.000 + 0.600j
a1_2= 0.6j
a2 = 0.100j
a2_2 = 0.100 - 0.500j
a3 = 0.800 - 0.600j
a4 = 3.200 - 1.400j
a4_2 = -2.200 + 1.600j
a3_2 = -0.100
a5 = 13.100 + 7.000j
a5_2 = -8.8 -9.6j
a6 = 0.600 + 0.100j
a6_1 = 0
a6_2 = 0
# Define the input membership function for Type 1 CFIS
def type_2_membership_function(x, a1,a2, L):
"""
Compute the membership function for Type 1 CFIS.

Parameters:
x: Input value.
a: Complex coefficient.
L: Normalization factor.

Returns:
Membership value.
"""
return (a1 * x + a2 * x**2) / L
# Define the input membership function for the superplasticizer input variable
def superplasticizer_membership_function(x, a0, a1, a2, L):
"""
Compute the membership function for the superplasticizer input variable.

Parameters:
x: Input value.
a0, a1, a2: Complex coefficients.
L: Normalization factor.

Returns:
Membership value.
"""
return (a0 + a1 * x + a2 * x**2) / L
# Load data from CSV file
data = pd.read_csv("slump_test.data")

# Extract input variables from the data


cement_to_water_ratio = data['Cement'] / data['Water']
slag_to_water_ratio = data['Slag'] / data['Water']

file:///C:/Users/Dell/Downloads/Untitled25.html 1/15
5/1/24, 3:54 PM Untitled25

fly_ash_to_water_ratio = data['Fly ash'] / data['Water']


coarse_aggregate = data['Coarse Aggr.'] * 0.001
fine_aggregate = data['Fine Aggr.'] * 0.001
superplasticizer = data['SP']

# Compute L for each row (maximum of x1, x2, x3, x4, x5, x6)
L_values = np.maximum.reduce([cement_to_water_ratio, slag_to_water_ratio, fly_as
coarse_aggregate, fine_aggregate, superplasticize

# Compute membership values for each input variable


membership_values_cement = type_2_membership_function(cement_to_water_ratio, a1,
membership_values_slag = type_2_membership_function(slag_to_water_ratio, a2,a2_2
membership_values_fly_ash = type_2_membership_function(fly_ash_to_water_ratio, a
membership_values_coarse_aggregate = type_2_membership_function(coarse_aggregate
membership_values_fine_aggregate = type_2_membership_function(fine_aggregate, a5
membership_values_superplasticizer = superplasticizer_membership_function(superp

# Print the computed membership values


print("Membership values for Cement to Water Ratio:")
print(membership_values_cement)
print("\nMembership values for Slag to Water Ratio:")
print(membership_values_slag)
print("\nMembership values for Fly Ash to Water Ratio:")
print(membership_values_fly_ash)
print("\nMembership values for Coarse Aggregate:")
print(membership_values_coarse_aggregate)
print("\nMembership values for Fine Aggregate:")
print(membership_values_fine_aggregate)
print("\nMembership values for Superplasticizer:")
print(membership_values_superplasticizer)

file:///C:/Users/Dell/Downloads/Untitled25.html 2/15
5/1/24, 3:54 PM Untitled25

Membership values for Cement to Water Ratio:


0 0.144444+0.199333j
1 0.075463+0.086279j
2 0.056564+0.064654j
3 0.047633+0.054445j
4 0.070000+0.071400j
...
98 0.190922+0.282958j
99 0.190466+0.281881j
100 0.194253+0.288621j
101 0.204192+0.310141j
102 0.174211+0.279339j
Length: 103, dtype: complex128

Membership values for Slag to Water Ratio:


0 0.001694-0.004132j
1 0.005710-0.021653j
2 0.004273-0.016196j
3 0.003598-0.013638j
4 0.002592-0.007868j
...
98 0.004644-0.015454j
99 0.004633-0.015408j
100 0.003316-0.009974j
101 0.000593-0.000152j
102 0.000000+0.000005j
Length: 103, dtype: complex128

Membership values for Fly Ash to Water Ratio:


0 0.041667-0.033333j
1 0.061358-0.053056j
2 0.046236-0.040014j
3 0.038763-0.033520j
4 0.048079-0.039273j
...
98 0.121052-0.110309j
99 0.121257-0.110547j
100 0.119293-0.107905j
101 0.111515-0.098928j
102 0.077242-0.066876j
Length: 103, dtype: complex128

Membership values for Coarse Aggregate:


0 0.121658+0.004661j
1 0.094514-0.003597j
2 0.070980-0.002940j
3 0.059824-0.002611j
4 0.107936+0.007089j
...
98 0.136408+0.015703j
99 0.136961+0.014784j
100 0.140146+0.012631j
101 0.145475+0.006573j
102 0.120416-0.011636j
Name: Coarse Aggr., Length: 103, dtype: complex128

Membership values for Fine Aggregate:


0 0.537653+0.035662j
1 0.406272-0.010046j
2 0.304704-0.006167j

file:///C:/Users/Dell/Downloads/Untitled25.html 3/15
5/1/24, 3:54 PM Untitled25

3 0.256589-0.004430j
4 0.480972+0.044955j
...
98 0.620860+0.070736j
99 0.621675+0.068311j
100 0.630292+0.067864j
101 0.639995+0.064547j
102 0.507668-0.021934j
Name: Fine Aggr., Length: 103, dtype: complex128

Membership values for Superplasticizer:


0 0.066667+0.011111j
1 0.050000+0.008333j
2 0.037500+0.006250j
3 0.031579+0.005263j
4 0.060000+0.010000j
...
98 0.077922+0.012987j
99 0.077922+0.012987j
100 0.078947+0.013158j
101 0.080000+0.013333j
102 0.062500+0.010417j
Name: SP, Length: 103, dtype: complex128

Output Membership Function


In [ ]: # Define the output membership functions μP(k) and μN(k)
def output_membership_function_positive(k):
"""
Compute the membership function μP(k) for positive values of k.

Parameters:
k: Output value.

Returns:
Membership value.
"""
if k >= 0:
return k / (1 + k)
else:
return 0

def output_membership_function_negative(k):
"""
Compute the membership function μN(k) for negative values of k.

Parameters:
k: Output value.

Returns:
Membership value.
"""
if k >= 0:
return 0
else:
return -k / (1 - k)

# Example usage:
# Extract output variable (comprehensive strength) from the data

file:///C:/Users/Dell/Downloads/Untitled25.html 4/15
5/1/24, 3:54 PM Untitled25

comprehensive_strength = data['Compressive Strength (28-day)(Mpa)']

# Iterate through each value in the Series and apply the output membership funct
membership_values_positive = comprehensive_strength.apply(output_membership_func
membership_values_negative = comprehensive_strength.apply(output_membership_func

# Print the computed membership values


print("Membership values for positive output (μP(k)):")
print(membership_values_positive)

print("\nMembership values for negative output (μN(k)):")


print(membership_values_negative)

Membership values for positive output (μP(k)):


0 0.972215
1 0.976270
2 0.976641
3 0.976787
4 0.964055
...
98 0.980381
99 0.980480
100 0.980583
101 0.980068
102 0.979908
Name: Compressive Strength (28-day)(Mpa), Length: 103, dtype: float64

Membership values for negative output (μN(k)):


0 0
1 0
2 0
3 0
4 0
..
98 0
99 0
100 0
101 0
102 0
Name: Compressive Strength (28-day)(Mpa), Length: 103, dtype: int64

In [ ]: import pandas as pd

# Load the slump dataset


slump_data = pd.read_csv("slump_test.data")

# Define input variables based on the provided information


x1 = slump_data['Cement'] / slump_data['Water']
x2 = slump_data['Slag'] / slump_data['Water']
x3 = slump_data['Fly ash'] / slump_data['Water']
x4 = slump_data['Coarse Aggr.'] * 0.001
x5 = slump_data['Fine Aggr.'] * 0.001
x6 = slump_data['SP']

# Define threshold values (you need to define appropriate threshold values based
threshold1 = 0.7
threshold2 = 0.8
threshold3 = 0.6
threshold4 = 150
threshold5 = 80

file:///C:/Users/Dell/Downloads/Untitled25.html 5/15
5/1/24, 3:54 PM Untitled25

threshold6 = 0.4

# Define the fuzzy rules for the concrete mixing dataset


def rule_CFR1(x1, x6):
if x1 > threshold1 and x6 > threshold6:
return 'P' # High firing strength
else:
return 'N' # Low firing strength

def rule_CFR2(x2, x6):


if x2 > threshold2 and x6 > threshold6:
return 'P'
else:
return 'N'

def rule_CFR3(x3, x6):


if x3 > threshold3 and x6 > threshold6:
return 'P'
else:
return 'N'

def rule_CFR4(x4):
if x4 > threshold4:
return 'P'
else:
return 'N'

def rule_CFR5(x5):
if x5 > threshold5:
return 'P'
else:
return 'N'

# Compute the firing strengths using the defined rules


slump_data['Firing Strength CFR1'] = slump_data.apply(lambda row: rule_CFR1(row[
slump_data['Firing Strength CFR2'] = slump_data.apply(lambda row: rule_CFR2(row[
slump_data['Firing Strength CFR3'] = slump_data.apply(lambda row: rule_CFR3(row[
slump_data['Firing Strength CFR4'] = slump_data.apply(lambda row: rule_CFR4(row[
slump_data['Firing Strength CFR5'] = slump_data.apply(lambda row: rule_CFR5(row[

# Print the updated dataset with firing strengths


print(slump_data)

file:///C:/Users/Dell/Downloads/Untitled25.html 6/15
5/1/24, 3:54 PM Untitled25

No Cement Slag Fly ash Water SP Coarse Aggr. Fine Aggr. \


0 1 273.0 82.0 105.0 210.0 9.0 904.0 680.0
1 2 163.0 149.0 191.0 180.0 12.0 843.0 746.0
2 3 162.0 148.0 191.0 179.0 16.0 840.0 743.0
3 4 162.0 148.0 190.0 179.0 19.0 838.0 741.0
4 5 154.0 112.0 144.0 220.0 10.0 923.0 658.0
.. ... ... ... ... ... ... ... ...
98 99 248.3 101.0 239.1 168.9 7.7 954.2 640.6
99 100 248.0 101.0 239.9 169.1 7.7 949.9 644.1
100 101 258.8 88.0 239.6 175.3 7.6 938.9 646.0
101 102 297.1 40.9 239.9 194.0 7.5 908.9 651.8
102 103 348.7 0.1 223.1 208.5 9.6 786.2 758.1

SLUMP(cm) FLOW(cm) Compressive Strength (28-day)(Mpa) \


0 23.0 62.0 34.99
1 0.0 20.0 41.14
2 1.0 20.0 41.81
3 3.0 21.5 42.08
4 20.0 64.0 26.82
.. ... ... ...
98 0.0 20.0 49.97
99 2.0 20.0 50.23
100 0.0 20.0 50.50
101 27.5 67.0 49.17
102 29.0 78.0 48.77

Firing Strength CFR1 Firing Strength CFR2 Firing Strength CFR3 \


0 P N N
1 P P P
2 P P P
3 P P P
4 N N P
.. ... ... ...
98 P N P
99 P N P
100 P N P
101 P N P
102 P N P

Firing Strength CFR4 Firing Strength CFR5


0 N N
1 N N
2 N N
3 N N
4 N N
.. ... ...
98 N N
99 N N
100 N N
101 N N
102 N N

[103 rows x 16 columns]

In [ ]: import pandas as pd

# Compute firing strength for each rule


firing_strength_CFR1 = membership_values_cement * membership_values_superplastic
firing_strength_CFR2 = membership_values_slag * membership_values_superplasticiz

file:///C:/Users/Dell/Downloads/Untitled25.html 7/15
5/1/24, 3:54 PM Untitled25

firing_strength_CFR3 = membership_values_fly_ash * membership_values_superplasti


firing_strength_CFR4 = membership_values_coarse_aggregate
firing_strength_CFR5 = membership_values_fine_aggregate

# Print the firing strength for each rule


print("Firing Strength CFR1:")
print(firing_strength_CFR1)

print("\nFiring Strength CFR2:")


print(firing_strength_CFR2)

print("\nFiring Strength CFR3:")


print(firing_strength_CFR3)

print("\nFiring Strength CFR4:")


print(firing_strength_CFR4)

print("\nFiring Strength CFR5:")


print(firing_strength_CFR5)
# Aggregate the firing strengths using multiplication
aggregated_firing_strength = firing_strength_CFR1 * firing_strength_CFR2 * firin

# Add the aggregated firing strength to the dataset


slump_data['Aggregated Firing Strength'] = aggregated_firing_strength
print(aggregated_firing_strength)
print(slump_data)

file:///C:/Users/Dell/Downloads/Untitled25.html 8/15
5/1/24, 3:54 PM Untitled25

Firing Strength CFR1:


0 0.007415+0.014894j
1 0.003054+0.004943j
2 0.001717+0.002778j
3 0.001218+0.001970j
4 0.003486+0.004984j
...
98 0.011202+0.024528j
99 0.011181+0.024438j
100 0.011538+0.025342j
101 0.012200+0.027534j
102 0.007978+0.019273j
Length: 103, dtype: complex128

Firing Strength CFR2:


0 1.588533e-04-2.566446e-04j
1 4.659444e-04-1.035042e-03j
2 2.614472e-04-5.806330e-04j
3 1.854030e-04-4.117508e-04j
4 2.341818e-04-4.461488e-04j
...
98 5.625714e-04-1.143893e-03j
99 5.611223e-04-1.140474e-03j
100 3.930072e-04-7.437737e-04j
101 4.943876e-05-4.269624e-06j
102 -5.176714e-08+3.115264e-07j
Length: 103, dtype: complex128

Firing Strength CFR3:


0 0.003148-0.001759j
1 0.003510-0.002141j
2 0.001984-0.001212j
3 0.001401-0.000854j
4 0.003277-0.001876j
...
98 0.010865-0.007023j
99 0.010884-0.007039j
100 0.010838-0.006949j
101 0.010240-0.006427j
102 0.005524-0.003375j
Length: 103, dtype: complex128

Firing Strength CFR4:


0 0.121658+0.004661j
1 0.094514-0.003597j
2 0.070980-0.002940j
3 0.059824-0.002611j
4 0.107936+0.007089j
...
98 0.136408+0.015703j
99 0.136961+0.014784j
100 0.140146+0.012631j
101 0.145475+0.006573j
102 0.120416-0.011636j
Name: Coarse Aggr., Length: 103, dtype: complex128

Firing Strength CFR5:


0 0.537653+0.035662j
1 0.406272-0.010046j
2 0.304704-0.006167j

file:///C:/Users/Dell/Downloads/Untitled25.html 9/15
5/1/24, 3:54 PM Untitled25

3 0.256589-0.004430j
4 0.480972+0.044955j
...
98 0.620860+0.070736j
99 0.621675+0.068311j
100 0.630292+0.067864j
101 0.639995+0.064547j
102 0.507668-0.021934j
Name: Fine Aggr., Length: 103, dtype: complex128
0 1.130417e-09-3.655288e-10j
1 7.689922e-10-7.036447e-10j
2 7.726641e-11-7.060704e-11j
3 1.948422e-11-1.776389e-11j
4 5.341231e-10-2.835097e-10j
...
98 3.625427e-08-1.189926e-08j
99 3.610162e-08-1.232353e-08j
100 2.558365e-08-8.313134e-09j
101 1.344543e-09+1.027889e-09j
102 -1.596983e-12+2.078968e-12j
Length: 103, dtype: complex128
No Cement Slag Fly ash Water SP Coarse Aggr. Fine Aggr. \
0 1 273.0 82.0 105.0 210.0 9.0 904.0 680.0
1 2 163.0 149.0 191.0 180.0 12.0 843.0 746.0
2 3 162.0 148.0 191.0 179.0 16.0 840.0 743.0
3 4 162.0 148.0 190.0 179.0 19.0 838.0 741.0
4 5 154.0 112.0 144.0 220.0 10.0 923.0 658.0
.. ... ... ... ... ... ... ... ...
98 99 248.3 101.0 239.1 168.9 7.7 954.2 640.6
99 100 248.0 101.0 239.9 169.1 7.7 949.9 644.1
100 101 258.8 88.0 239.6 175.3 7.6 938.9 646.0
101 102 297.1 40.9 239.9 194.0 7.5 908.9 651.8
102 103 348.7 0.1 223.1 208.5 9.6 786.2 758.1

SLUMP(cm) FLOW(cm) Compressive Strength (28-day)(Mpa) \


0 23.0 62.0 34.99
1 0.0 20.0 41.14
2 1.0 20.0 41.81
3 3.0 21.5 42.08
4 20.0 64.0 26.82
.. ... ... ...
98 0.0 20.0 49.97
99 2.0 20.0 50.23
100 0.0 20.0 50.50
101 27.5 67.0 49.17
102 29.0 78.0 48.77

Firing Strength CFR1 Firing Strength CFR2 Firing Strength CFR3 \


0 P N N
1 P P P
2 P P P
3 P P P
4 N N P
.. ... ... ...
98 P N P
99 P N P
100 P N P
101 P N P
102 P N P

file:///C:/Users/Dell/Downloads/Untitled25.html 10/15
5/1/24, 3:54 PM Untitled25

Firing Strength CFR4 Firing Strength CFR5 Aggregated Firing Strength


0 N N 1.130417e-09-3.655288e-10j
1 N N 7.689922e-10-7.036447e-10j
2 N N 7.726641e-11-7.060704e-11j
3 N N 1.948422e-11-1.776389e-11j
4 N N 5.341231e-10-2.835097e-10j
.. ... ... ...
98 N N 3.625427e-08-1.189926e-08j
99 N N 3.610162e-08-1.232353e-08j
100 N N 2.558365e-08-8.313134e-09j
101 N N 1.344543e-09+1.027889e-09j
102 N N -1.596983e-12+2.078968e-12j

[103 rows x 17 columns]

In [ ]: # Define the output membership functions μP(k) and μN(k)


def output_membership_function_positive(k):
"""
Compute the membership function μP(k) for positive values of k.

Parameters:
k: Output value.

Returns:
Membership value.
"""
if k >= 0:
return k / (1 + k)
else:
return 0

def output_membership_function_negative(k):
"""
Compute the membership function μN(k) for negative values of k.

Parameters:
k: Output value.

Returns:
Membership value.
"""
if k >= 0:
return 0
else:
return -k / (1 - k)

# Extract output variable (comprehensive strength) from the data


comprehensive_strength = data['Compressive Strength (28-day)(Mpa)']

# Iterate through each value in the Series and apply the output membership funct
membership_values_positive = comprehensive_strength.apply(output_membership_func
membership_values_negative = comprehensive_strength.apply(output_membership_func

# Compute consequent functions by multiplying firing strength with output member


consequent_function_positive_CFR1 = firing_strength_CFR1 * membership_values_pos
consequent_function_positive_CFR2 = firing_strength_CFR2 * membership_values_pos
consequent_function_positive_CFR3 = firing_strength_CFR3 * membership_values_pos
consequent_function_positive_CFR4 = firing_strength_CFR4 * membership_values_pos
consequent_function_positive_CFR5 = firing_strength_CFR5 * membership_values_pos

file:///C:/Users/Dell/Downloads/Untitled25.html 11/15
5/1/24, 3:54 PM Untitled25

consequent_function_negative_CFR1 = firing_strength_CFR1 * membership_values_neg


consequent_function_negative_CFR2 = firing_strength_CFR2 * membership_values_neg
consequent_function_negative_CFR3 = firing_strength_CFR3 * membership_values_neg
consequent_function_negative_CFR4 = firing_strength_CFR4 * membership_values_neg
consequent_function_negative_CFR5 = firing_strength_CFR5 * membership_values_neg

# Aggregate consequent functions by taking the sum


aggregated_consequent_positive = (consequent_function_positive_CFR1 + consequent
consequent_function_positive_CFR3 + consequent
consequent_function_positive_CFR5)

aggregated_consequent_negative = (consequent_function_negative_CFR1 + consequent


consequent_function_negative_CFR3 + consequent
consequent_function_negative_CFR5)

# Print the aggregated consequent functions


print("Aggregated Consequent Function (Positive):")
print(aggregated_consequent_positive)

print("\nAggregated Consequent Function (Negative):")


print(aggregated_consequent_negative)

Aggregated Consequent Function (Positive):


0 0.651416+0.051723j
1 0.495765-0.011595j
2 0.370779-0.007931j
3 0.311807-0.006191j
4 0.574485+0.052739j
...
98 0.764597+0.100783j
99 0.766012+0.097414j
100 0.777804+0.096238j
101 0.791855+0.090384j
102 0.628696-0.017317j
Length: 103, dtype: complex128

Aggregated Consequent Function (Negative):


0 0.0+0.0j
1 0.0+0.0j
2 0.0+0.0j
3 0.0+0.0j
4 0.0+0.0j
...
98 0.0+0.0j
99 0.0+0.0j
100 0.0+0.0j
101 0.0+0.0j
102 0.0+0.0j
Length: 103, dtype: complex128

In [ ]: L_values = np.maximum.reduce([cement_to_water_ratio, slag_to_water_ratio, fly_as


coarse_aggregate, fine_aggregate, superplasticize
# Calculate the limits of the aggregated consequent functions
limit_positive = aggregated_consequent_positive.iloc[-1] # Limit as k approache
limit_negative = aggregated_consequent_negative.iloc[0] # Limit as k approache

# Calculate k0
k0 = L_values* (limit_positive - limit_negative)

file:///C:/Users/Dell/Downloads/Untitled25.html 12/15
5/1/24, 3:54 PM Untitled25

# Print the value of k0


print("Value of k0:", k0)

Value of k0: [ 5.65826309-0.15584906j 7.54435079-0.20779874j 10.05913438-0.27706


499j
11.94522208-0.32901468j 6.28695899-0.17316562j 5.65826309-0.15584906j
11.31652618-0.31169812j 3.77217539-0.10389937j 3.77217539-0.10389937j
3.77217539-0.10389937j 6.28695899-0.17316562j 4.40087129-0.12121593j
3.77217539-0.10389937j 3.77217539-0.10389937j 4.40087129-0.12121593j
9.43043848-0.25974843j 3.77217539-0.10389937j 6.91565489-0.19048218j
6.28695899-0.17316562j 5.65826309-0.15584906j 6.28695899-0.17316562j
6.28695899-0.17316562j 6.91565489-0.19048218j 6.91565489-0.19048218j
6.91565489-0.19048218j 7.54435079-0.20779874j 6.28695899-0.17316562j
3.77217539-0.10389937j 3.77217539-0.10389937j 3.77217539-0.10389937j
3.14347949-0.08658281j 3.77217539-0.10389937j 4.40087129-0.12121593j
5.65826309-0.15584906j 3.77217539-0.10389937j 8.17304669-0.22511531j
5.02956719-0.1385325j 7.54435079-0.20779874j 4.40087129-0.12121593j
6.91565489-0.19048218j 6.91565489-0.19048218j 6.91565489-0.19048218j
6.91565489-0.19048218j 3.77217539-0.10389937j 3.77217539-0.10389937j
3.77217539-0.10389937j 5.65826309-0.15584906j 5.65826309-0.15584906j
3.77217539-0.10389937j 3.77217539-0.10389937j 5.65826309-0.15584906j
6.91565489-0.19048218j 6.91565489-0.19048218j 6.28695899-0.17316562j
5.02956719-0.1385325j 7.54435079-0.20779874j 6.28695899-0.17316562j
6.91565489-0.19048218j 3.77217539-0.10389937j 3.77217539-0.10389937j
5.65826309-0.15584906j 4.40087129-0.12121593j 6.28695899-0.17316562j
5.65826309-0.15584906j 3.77217539-0.10389937j 7.54435079-0.20779874j
7.54435079-0.20779874j 8.17304669-0.22511531j 3.77217539-0.10389937j
3.77217539-0.10389937j 5.65826309-0.15584906j 6.28695899-0.17316562j
6.28695899-0.17316562j 3.77217539-0.10389937j 3.77217539-0.10389937j
3.77217539-0.10389937j 6.91565489-0.19048218j 5.65826309-0.15584906j
2.76626195-0.07619287j 2.89200113-0.07965619j 2.95487072-0.08138784j
3.0806099 -0.08485115j 5.78400227-0.15931237j 3.33208826-0.09177778j
3.45782744-0.09524109j 3.58356662-0.0987044j 3.89791457-0.10736268j
5.5953935 -0.1541174j 4.08652334-0.11255765j 4.08652334-0.11255765j
4.21226252-0.11602097j 4.46374088-0.12294759j 5.21817596-0.14372747j
4.65234965-0.12814256j 4.65234965-0.12814256j 4.71521924-0.12987422j
4.65234965-0.12814256j 5.21817596-0.14372747j 4.84095842-0.13333753j
4.84095842-0.13333753j 4.77808883-0.13160587j 4.71521924-0.12987422j
6.03548063-0.166239j ]

In [ ]: # Calculate the limits of the aggregated consequent functions


limit_positive = aggregated_consequent_positive.iloc[-1] # Limit as k approache
limit_negative = aggregated_consequent_negative.iloc[0] # Limit as k approache

# Calculate k0
k0 = L_values * (limit_positive - limit_negative)

print(k0)

file:///C:/Users/Dell/Downloads/Untitled25.html 13/15
5/1/24, 3:54 PM Untitled25

[ 5.65826309-0.15584906j 7.54435079-0.20779874j 10.05913438-0.27706499j


11.94522208-0.32901468j 6.28695899-0.17316562j 5.65826309-0.15584906j
11.31652618-0.31169812j 3.77217539-0.10389937j 3.77217539-0.10389937j
3.77217539-0.10389937j 6.28695899-0.17316562j 4.40087129-0.12121593j
3.77217539-0.10389937j 3.77217539-0.10389937j 4.40087129-0.12121593j
9.43043848-0.25974843j 3.77217539-0.10389937j 6.91565489-0.19048218j
6.28695899-0.17316562j 5.65826309-0.15584906j 6.28695899-0.17316562j
6.28695899-0.17316562j 6.91565489-0.19048218j 6.91565489-0.19048218j
6.91565489-0.19048218j 7.54435079-0.20779874j 6.28695899-0.17316562j
3.77217539-0.10389937j 3.77217539-0.10389937j 3.77217539-0.10389937j
3.14347949-0.08658281j 3.77217539-0.10389937j 4.40087129-0.12121593j
5.65826309-0.15584906j 3.77217539-0.10389937j 8.17304669-0.22511531j
5.02956719-0.1385325j 7.54435079-0.20779874j 4.40087129-0.12121593j
6.91565489-0.19048218j 6.91565489-0.19048218j 6.91565489-0.19048218j
6.91565489-0.19048218j 3.77217539-0.10389937j 3.77217539-0.10389937j
3.77217539-0.10389937j 5.65826309-0.15584906j 5.65826309-0.15584906j
3.77217539-0.10389937j 3.77217539-0.10389937j 5.65826309-0.15584906j
6.91565489-0.19048218j 6.91565489-0.19048218j 6.28695899-0.17316562j
5.02956719-0.1385325j 7.54435079-0.20779874j 6.28695899-0.17316562j
6.91565489-0.19048218j 3.77217539-0.10389937j 3.77217539-0.10389937j
5.65826309-0.15584906j 4.40087129-0.12121593j 6.28695899-0.17316562j
5.65826309-0.15584906j 3.77217539-0.10389937j 7.54435079-0.20779874j
7.54435079-0.20779874j 8.17304669-0.22511531j 3.77217539-0.10389937j
3.77217539-0.10389937j 5.65826309-0.15584906j 6.28695899-0.17316562j
6.28695899-0.17316562j 3.77217539-0.10389937j 3.77217539-0.10389937j
3.77217539-0.10389937j 6.91565489-0.19048218j 5.65826309-0.15584906j
2.76626195-0.07619287j 2.89200113-0.07965619j 2.95487072-0.08138784j
3.0806099 -0.08485115j 5.78400227-0.15931237j 3.33208826-0.09177778j
3.45782744-0.09524109j 3.58356662-0.0987044j 3.89791457-0.10736268j
5.5953935 -0.1541174j 4.08652334-0.11255765j 4.08652334-0.11255765j
4.21226252-0.11602097j 4.46374088-0.12294759j 5.21817596-0.14372747j
4.65234965-0.12814256j 4.65234965-0.12814256j 4.71521924-0.12987422j
4.65234965-0.12814256j 5.21817596-0.14372747j 4.84095842-0.13333753j
4.84095842-0.13333753j 4.77808883-0.13160587j 4.71521924-0.12987422j
6.03548063-0.166239j ]

In [ ]: k1 = np.square(k0)
defuzzified_output = abs(k1)
# Print the defuzzified output value k1
print("Defuzzified output value:",defuzzified_output)
array_shape = k1.shape
print(array_shape)

file:///C:/Users/Dell/Downloads/Untitled25.html 14/15
5/1/24, 3:54 PM Untitled25

Defuzzified output value: [ 32.04023012 56.9604091 101.26294952 142.79658116 3


9.55583966
32.04023012 128.16092048 14.24010228 14.24010228 14.24010228
39.55583966 19.38236143 14.24010228 14.24010228 19.38236143
89.00063923 14.24010228 47.86256598 39.55583966 32.04023012
39.55583966 39.55583966 47.86256598 47.86256598 47.86256598
56.9604091 39.55583966 14.24010228 14.24010228 14.24010228
9.88895991 14.24010228 19.38236143 32.04023012 14.24010228
66.84936902 25.31573738 56.9604091 19.38236143 47.86256598
47.86256598 47.86256598 47.86256598 14.24010228 14.24010228
14.24010228 32.04023012 32.04023012 14.24010228 14.24010228
32.04023012 47.86256598 47.86256598 39.55583966 25.31573738
56.9604091 39.55583966 47.86256598 14.24010228 14.24010228
32.04023012 19.38236143 39.55583966 32.04023012 14.24010228
56.9604091 56.9604091 66.84936902 14.24010228 14.24010228
32.04023012 39.55583966 39.55583966 14.24010228 14.24010228
14.24010228 47.86256598 32.04023012 7.65801056 8.37001567
8.73788498 9.4973571 33.48006268 11.11123536 11.9656415
12.8516923 15.20526476 31.33218059 16.71234225 16.71234225
17.75661642 19.94009877 27.25001794 21.6607778 21.6607778
22.25015981 21.6607778 27.25001794 23.45265733 23.45265733
22.84745299 22.25015981 36.45466183]
(103,)

file:///C:/Users/Dell/Downloads/Untitled25.html 15/15

You might also like