-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstep_info.py
More file actions
executable file
·76 lines (63 loc) · 2.59 KB
/
Copy pathstep_info.py
File metadata and controls
executable file
·76 lines (63 loc) · 2.59 KB
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
import numpy as np
class StepInfo:
'''
This class is for calculate and find step info from control data system
step data require for calculate fitness function in genetic algorithm
'''
def __init__(self, x_list, y_list, setpoint):
self.x_list = x_list
self.y_list = y_list
self.setpoint = setpoint
self.rise_time_value = 0.9 * self.setpoint
self.rise_time_index = 0
self.error_band = 0.05 * self.setpoint
self.low_band = self.setpoint - self.error_band
self.high_band = self.setpoint + self.error_band
def getRiseTime(self):
#rise time is time for system from the beginning until system get 90% of setpoint
self.rise_time_index = 0
while self.rise_time_index<len(self.y_list):
if self.y_list[self.rise_time_index] >= self.rise_time_value:
break
self.rise_time_index += 1
return self.x_list[self.rise_time_index-1]
def getPeak(self):
#peak value is maximum y data of the system
return np.amax(self.y_list)
def getPeakTime(self):
#peak time is time for system (or index) when system get 'peak' level
l = np.where(self.y_list == np.amax(self.y_list))
index = l[0][0]
return self.x_list[index]
def getOvershoot(self):
#overshoot is percentage of 'peak' level according the last final data of y
y_len = len(self.y_list) - 1
last_y = self.y_list[y_len]
return (self.getPeak() - self.setpoint)/(self.setpoint*1.0)*100
'''
y_len = len(self.y_list) - 1
last_y = self.y_list[y_len]
return (self.getPeak() - last_y)/(last_y*1.0)*100
'''
def getMSE(self):
square_error = []
for step in self.y_list:
square_error.append(self.setpoint-step)
square_error = np.square(square_error)
return np.mean(square_error)
def getSettlingTime(self):
#settling time is range of time when system get atleast 5% of setpoint
flag = []
for i in range (len(self.y_list)):
if self.y_list[i] >= self.low_band and self.y_list[i] <= self.high_band:
flag.append(self.x_list[i])
else:
flag = []
if not flag:
return 0
else:
return flag[0] - self.x_list[0]
def getSteadyStateError(self):
#steady state error is value when system can't reach setpoint in infinite iteration
p = len(self.y_list) -1
return abs(self.y_list[p] - self.setpoint)