43 lines
1.3 KiB
Python
43 lines
1.3 KiB
Python
from src.OptAlgorithm.OptAlgorithm import OptAlgorithm
|
|
from src.utils import read_json
|
|
|
|
from matplotlib import pyplot as plt, use
|
|
|
|
from numpy import cos, sin, sqrt, cbrt, arcsin, linspace, array
|
|
|
|
if __name__ == "__main__":
|
|
|
|
tq = 1
|
|
ts = linspace(0, tq, 200000)
|
|
|
|
operator_params = read_json("params/operator_params.json")
|
|
system_params = read_json("params/system_params.json")
|
|
|
|
non_array_operator_params = {}
|
|
i = 1
|
|
for key, value in operator_params.items():
|
|
if hasattr(value, "__len__"):
|
|
if len(value) > i:
|
|
non_array_operator_params[key] = value[i]
|
|
else:
|
|
non_array_operator_params[key] = value[0]
|
|
else:
|
|
non_array_operator_params[key] = value
|
|
|
|
non_array_system_params = {}
|
|
for key, value in system_params.items():
|
|
if hasattr(value, "__len__"):
|
|
if len(value) > i:
|
|
non_array_system_params[key] = value[i]
|
|
else:
|
|
non_array_system_params[key] = value[0]
|
|
else:
|
|
non_array_system_params[key] = value
|
|
|
|
|
|
opt = OptAlgorithm(non_array_operator_params, non_array_system_params)
|
|
Xs = array([opt.getVar("X1", t) for t in ts])
|
|
|
|
|
|
plt.plot(ts, Xs)
|
|
plt.show() |