-
Notifications
You must be signed in to change notification settings - Fork 0
/
ex2_jet_engine_ct_DS.py
72 lines (59 loc) · 1.92 KB
/
ex2_jet_engine_ct_DS.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
# IMPORTS FROM INSTALLS
import time
import sympy as sp
import numpy as np
# IMPORTS FROM TOOL
from src.functions.parallel_ct_DS import parallel_ct_DS
from src.functions.ct_DS import ct_DS
# ========================= Parameters =========================
if __name__ == '__main__':
dim = 2 # dimension of state space
# Initial set
L_initial = np.array([0.1, 0.1])
U_initial = np.array([0.5, 0.5])
# Unsafe set
L_unsafe1 = np.array([0.7, 0.7])
U_unsafe1 = np.array([1, 1])
# combine unsafe regions
L_unsafe = np.array([L_unsafe1])
U_unsafe = np.array([U_unsafe1])
# State space
L_space = np.array([0.1, 0.1])
U_space = np.array([1, 1])
# ========================= Symbolic Variables =========================
x = sp.symbols(f'x1:{dim + 1}') # Create x1, x2, ..., x_degree symbols
# ========================= Dynamics =========================
f1 = -x[1] - 3 / 2 * (x[0] ** 2) - 1 / 2 * (x[0] ** 3)
f2 = x[0]
# Define the vector field
f = np.array([f1, f2])
fixed_params = {
'dim': dim,
'L_initial': L_initial,
'U_initial': U_initial,
'L_unsafe': L_unsafe,
'U_unsafe': U_unsafe,
'L_space': L_space,
'U_space': U_space,
'x': x,
'f': f,
'solver': "mosek",
'gam': None,
'lam': None,
'l_degree': None,
# Add other fixed parameters here
}
# List of degree values
max_degree_value = 6
single_degree_value = 2
start = time.time()
### Uncomment this line to run the parallel implementation
#result = parallel_ct_DS(max_degree_value, **fixed_params)
### Uncomment this line to run the serial implementation
result = ct_DS(single_degree_value,**fixed_params)
end = time.time()
print("elapsed time:", end-start)
if result == None:
print("Results dictionary is empty.")
else:
print(result)