TODO [ex999.0]ΒΆ

../../_images/sphx_glr_fig-solution-exercise-constraints-b-alssm_001.png

Out:

--DUMP--
 β””-Alssm : stacked-so, A: (3, 3), C: (1, 3), label: None
  β””-Alssm : sinusoidal, A: (2, 2), C: (1, 2), label: cosine model
  β””-Alssm : polynomial, A: (1, 1), C: (1, 1), label: const number

--PRINT--
 A =
[[ 0.95105652 -0.30901699  0.        ]
 [ 0.30901699  0.95105652  0.        ]
 [ 0.          0.          1.        ]]
C =
[[1. 0. 1.]]

import matplotlib.pyplot as plt
import numpy as np
from scipy.signal import find_peaks

import lmlib as lm

OMEGA = .1*np.pi # sinusoidal frequency

# ------------ Evaluate ALSSM -------------
js = np.arange(-np.int(1.0*np.pi/OMEGA), np.int(1.0*np.pi/OMEGA)+1) # ALSSM evaluation range

alssm_cos = lm.AlssmSin(omega=OMEGA, rho=1, label='cosine model')
alssm_const = lm.AlssmPoly(poly_degree=0, label='const number')
alssm = lm.AlssmStackedSO((alssm_cos, alssm_const))

x0s = [[1, 0, 1]] # ALSSM initial state vectors for sine
ys = alssm.eval(x0s, js)

# Printing Model to Console
print("--DUMP--\n", alssm.dump_tree())
print("--PRINT--\n", alssm)

# ------------ Plot ALSSM -------------
fig, ax = plt.subplots(1,1, figsize=(4,3))
ax.set_title('ALSSM Evaluation $s_i(x_0)$')
ax.plot(js, ys[0,:,0], '.-', lw=.5, label='$x_0 = '+str(x0s)+'^\mathrm{T}$')
ax.set( xlabel='Evaluation index $i$')

plt.legend()
plt.show()

Total running time of the script: ( 0 minutes 0.133 seconds)

Gallery generated by Sphinx-Gallery