-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFunction.py
125 lines (106 loc) · 3.09 KB
/
Function.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
import numpy as np
from matplotlib import pyplot as plt
def gaussian(x, mu, sigma):
r = np.exp(-(x - mu) ** 2 / (2 * sigma ** 2))
return r
def sigmoid(x,a,b):
r=1/(1+np.exp(-a*(x-b)))
return r
def inc(x,a,b):
if (x<=a):
return 0
elif (x>=b):
return 1
else:
return ((x-a)/(b-a))
def dec(x,a,b):
return(1-inc(x,a,b))
def valuevalidate1(ques):
while True:
try:
num1 = int(input(ques))
except ValueError:
print("Invalid input. Please enter a integer number.\n")
continue
if num1 < 0 or num1 >5:
print("Invalid input.Please enter a number range from 0-5.\n")
continue
else:
break
return num1
def valuevalidate2(ques):
while True:
try:
num1 = float(input(ques))
except ValueError:
print("Invalid input. Please enter a number.\n")
continue
if num1 < 15 or num1 >100:
print("Invalid input.Please enter a number range from 15-100.\n")
continue
else:
break
return num1
def valuevalidate3(ques):
while True:
try:
num1 = float(input(ques))
except ValueError:
print("Invalid input. Please enter a number.\n")
continue
if num1 < 0 or num1 >10:
print("Invalid input.Please enter a number range from 0-10.\n")
continue
else:
break
return num1
def valuevalidate4(ques):
while True:
try:
num1 = float(input(ques))
except ValueError:
print("Invalid input. Please enter a number.\n")
continue
if num1 < 15 or num1 >80:
print("Invalid input.Please enter a number range from 15-80.\n")
continue
else:
break
return num1
def valuevalidate5(ques):
while True:
try:
num1 = int(input(ques))
except ValueError:
print("Invalid input. Please enter a number.\n")
continue
if num1 < 0 or num1 >5:
print("Invalid input.You can only select an integer from 0 to 5.\n")
continue
else:
break
return num1
def RuleEvaluate(ip1, ip2, ip3, ip4, op):
ipR = np.fmin(np.fmin(np.fmin(ip1, ip2), ip3 ), ip4)
opR = np.fmin(ipR, op)
return opR
def RuleAggregate(R1, R2, R3, R4, R5):
RA = np.fmax(np.fmax(np.fmax(R1, R2), R3 ), R4)
TRA = np.fmax(R5, RA)
return TRA
# display = np.linspace(0, 1000, 10000)
# # g = gaussian(display, 500, 60)
# # s = sigmoid(display, 0.02, 500)
# incNum = np.zeros_like(display)
# decNum = np.zeros_like(display)
# for i in range(0,len(display)):
# incNum[i] = inc(display[i], 300, 600)
# decNum[i] = dec(display[i], 300, 600)
#
# # print(g[2500])
#
# plt.figure(0)
# plt.plot(display, incNum, label="Very Cold")
# plt.plot(display, decNum, label="Very Cold")
# plt.legend()
# plt.show()