-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfeasibility.py
More file actions
208 lines (180 loc) · 6.69 KB
/
feasibility.py
File metadata and controls
208 lines (180 loc) · 6.69 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
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
### This collection of functions is the backbone of the feasibility check for the SAIL Hackathon
### These methods should help finding feasible query points for the Challenge
def is_feasible(x1, x2, x3, x4, x5, x6, x7, x8):
if not is_feasible0(x1):
return False
if not is_feasible1(x1, x2):
return False
if not is_feasible2(x1, x2, x3):
return False
if not is_feasible3(x1, x2, x4):
return False
if not is_feasible4(x1, x2, x5):
return False
if not is_feasible5(x1, x2, x6):
return False
if not is_feasible6(x1, x2, x7):
return False
if not is_feasible7(x1, x2, x8):
return False
return True
# Feasibility function for Engine speed
# Simple unique lower and upper bound
def is_feasible0(x1):
return 650 <= x1 <= 2250
# Feasibility function for Engine load
# Unique lower bound with piecewise linear upper bound dependent on Engine speed
def is_feasible1(x1, x2):
if 650 <= x1 <= 2250:
if x1 < 1200:
y_upper = (x1 - 650) * 70 / 550 + 100
return x2 <= y_upper
elif x1 < 1600:
return x2 <= 170
else:
y_upper = 170 + (x1 - 1600) * (-35 / 650)
return x2 <= y_upper
return False
### All functions from here on are dependent on the Engine speed and Engine load
### and therefore have two subfunctions
# Feasibility function for Railpressure
def is_feasible2(x1, x2, x3):
def speed_feasibility(x1, x3):
if 650 <= x1 < 1400:
y_upper = (x1 - 650) * 1200 / 1150 + 1500
y_lower = 500
elif 1400 <= x1 < 1800:
y_lower = (x1 - 1400) * 500 / 850 + 500
y_upper = (x1 - 650) * 1200 / 1150 + 1500
elif 1800 <= x1 <= 2250:
y_lower = (x1 - 1400) * 500 / 850 + 500
y_upper = 2700
else:
return False
return x3 >= y_lower and x3 <= y_upper
def load_feasibility(x2, x3):
if 0 <= x2 < 25:
return x3 >= 500 and x3 <= 2700
elif 25 <= x2 <= 175:
y_upper = 2700
y_lower = (x2 - 25) * 500 / 150 + 500
return x3 <= y_upper and x3 >= y_lower
return False
return speed_feasibility(x1, x3) and load_feasibility(x2, x3)
# Feasibility function for Air supply
def is_feasible3(x1, x2, x4):
def load_feasibility(x2, x4):
if 0 <= x2 < 25:
y_lower = x2 * 40 / 25 + 50
return x4 >= y_lower and x4 <= 1400
elif 25 <= x2 < 100:
y_lower = (x2 - 25) * 90 / 75 + 90
return x4 >= y_lower and x4 <= 1400
elif 100 <= x2 <= 175:
y_lower = (x2 - 100) * 370 / 75 + 180
return x4 >= y_lower and x4 <= 1400
return False
def speed_feasibility(x1, x4):
if 650 <= x1 <= 2250:
y_upper = (x1 - 650) * 900 / 1600 + 500
y_lower = (x1 - 650) * 150 / 1600 + 50
return x4 <= y_upper and x4 >= y_lower
return False
return load_feasibility(x2, x4) and speed_feasibility(x1, x4)
# Feasibility function for crank angle
def is_feasible4(x1, x2, x5):
def speed_feasibility(x1, x5):
if 650 <= x1 < 1400:
return -10 <= x5 <= 7.5
elif 1400 <= x1 <= 2250:
y_lower = -10
y_upper = (x1 - 1400) * 7.5 / 850 + 7.5
return y_lower <= x5 <= y_upper
return False
def load_feasibility(x2, x5):
if 0 <= x2 < 25:
y_upper = 12
y_lower = (x2 - 0) * (-6) / 25 - 4
return y_lower <= x5 <= y_upper
elif 25 <= x2 < 150:
return -10 <= x5 <= 12
elif 150 <= x2 <= 175:
y_upper = 12
y_lower = (x2 - 150) * 10 / 25 - 10
return y_lower <= x5 <= y_upper
return False
return speed_feasibility(x1, x5) and load_feasibility(x2, x5)
# Feasibility function for Intake pressure
def is_feasible5(x1, x2, x6):
def speed_feasibility(x1, x6):
if 650 <= x1 < 2250:
y_upper = 3200
y_lower = (x1 - 650) * 100 / 1600 + 900
return x6 <= y_upper and x6 >= y_lower
return False
def load_feasibility(x2, x6):
if 0 <= x2 < 75:
y_lower = x2 * (1000 - 900) / (75) + 900
return y_lower <= x6 <= 3000
elif 75 <= x2 < 100:
y_lower = (x2 - 75) * (1500 - 1000) / (125 - 75) + 1000
return y_lower <= x6 <= 3000
elif 100 <= x2 < 125:
y_upper = (x2 - 100) * (3300 - 3000) / (125 - 100) + 3000
y_lower = (x2 - 75) * (1500 - 1000) / (125 - 75) + 1000
return y_lower <= x6 <= y_upper
elif 125 <= x2 <= 175:
y_upper = 3300
y_lower = (x2 - 125) * (2500 - 1500) / (175 - 125) + 1500
return x6 <= y_upper and x6 >= y_lower
return False
return speed_feasibility(x1, x6) and load_feasibility(x2, x6)
# Feasibility function for Back pressure
def is_feasible6(x1, x2, x7):
def speed_feasibility(x1, x7):
if 650 <= x1 <= 2250:
y_upper = 4000
y_lower = (x1 - 650) * (250) / (1600) + 900
return x7 <= y_upper and x7 >= y_lower
return False
def load_feasibility(x2, x7):
if 0 <= x2 < 75:
y_lower = (x2) * (100) / (75) + 900
y_upper = 4000
return x7 <= y_upper and x7 >= y_lower
elif 75 <= x2 < 175:
y_lower = (x2 - 75) * (500) / (50) + 1000
y_upper = 4000
return x7 <= y_upper and x7 >= y_lower
else:
return False
return x7 <= y_upper and x7 >= y_lower
return speed_feasibility(x1, x7) and load_feasibility(x2, x7)
# Feasibility function for Intake temperature
def is_feasible7(x1, x2, x8):
def speed_feasibility(x1, x8):
if 650 <= x1 <= 2250:
y_upper = (90 - 70)* (x1 - 650) / (2250 - 650) + 70
y_lower = 38
return y_lower <= x8 <= y_upper
return False
def load_feasibility(x2, x8):
if 0 <= x2 < 75:
y_lower = 38
y_upper = (80 - 70) * (75 - x2) / 75 + 70
elif 75 <= x2 < 110:
y_lower = 38
y_upper = (90 - 70) * (x2 - 75) / (110 - 75) + 70
elif 110 <= x2 < 125:
y_lower = 38
y_upper = 90
elif 125 <= x2 <= 150:
y_lower = 38
y_upper = (70 - 90) * (x2 - 125) / (175 - 125) + 90
elif 150 <= x2 <= 175:
y_lower = (60 - 38) * (x2 - 150) / (175 - 150) + 38
y_upper = (70 - 90) * (x2 - 125) / (175 - 125) + 90
else:
return False
return x8 <= y_upper and x8 >= y_lower
return speed_feasibility(x1, x8) and load_feasibility(x2, x8)