Untitled 25
Untitled 25
Fuzzification
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")
file:///C:/Users/Dell/Downloads/Untitled25.html 1/15
5/1/24, 3:54 PM Untitled25
# 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
file:///C:/Users/Dell/Downloads/Untitled25.html 2/15
5/1/24, 3:54 PM Untitled25
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
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
# 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
In [ ]: import pandas as pd
# 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
def rule_CFR4(x4):
if x4 > threshold4:
return 'P'
else:
return 'N'
def rule_CFR5(x5):
if x5 > threshold5:
return 'P'
else:
return 'N'
file:///C:/Users/Dell/Downloads/Untitled25.html 6/15
5/1/24, 3:54 PM Untitled25
In [ ]: import pandas as pd
file:///C:/Users/Dell/Downloads/Untitled25.html 7/15
5/1/24, 3:54 PM Untitled25
file:///C:/Users/Dell/Downloads/Untitled25.html 8/15
5/1/24, 3:54 PM Untitled25
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
file:///C:/Users/Dell/Downloads/Untitled25.html 10/15
5/1/24, 3:54 PM Untitled25
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)
# 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
file:///C:/Users/Dell/Downloads/Untitled25.html 11/15
5/1/24, 3:54 PM Untitled25
# 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
# 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
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
file:///C:/Users/Dell/Downloads/Untitled25.html 15/15