Esempio n. 1
0
tf = 2. / xi['b']**2

print('{:.2e} & {:.2e} & {:.8f} & {:.5f} & {:d} & {:.2f}'.format(
    np.max(np.abs(L(xi))), np.max(np.abs(H(z, xi))), cost,
    tf.tolist()[0], it, time * 1000))

# Plots
MS = 12

p1 = MakePlot(onp.array([['t', 't']]), onp.array([[r'$x(t)$', r'$y(t)$']]))
p1.fig.subplots_adjust(wspace=0.25, hspace=0.25)
p1.ax[0].plot(t, x(z, xi['xi_x']), label='x(t)', linewidth=2)
p1.ax[1].plot(t, u(z, xi['xi_u']), label='y(t)', linewidth=2)
p1.ax[0].grid(True)
p1.ax[1].grid(True)
p1.FullScreen()
p1.show()
# p1.save('figures/unknownTimeStates')

p2 = MakePlot('t', r'$|Loss|$')
p2.ax[0].plot(t, onp.abs(Lx(z, xi)), 'r*', markersize=MS, label='|$L_x(t)$|')
p2.ax[0].plot(t, onp.abs(Lu(z, xi)), 'kx', markersize=MS, label='|$L_u(t)$|')
p2.ax[0].plot(t, onp.abs(H(z, xi)), 'b+', markersize=MS, label='|$H(t)$|')
p2.ax[0].set_yscale('log')
p2.ax[0].legend()
p2.ax[0].grid(True)
p2.PartScreen(7., 6.)
p2.show()
# p2.save('figures/unknownTimeLoss')
Esempio n. 2
0
u = lambda t,g: g(t)+\
                (t-1.)*(t-2.)/2.*(0.-g(0.))+\
                -t*(t-2.)*(np.pi-g(1.))+\
                t*(t-1.)/2.*(np.exp(1.)-g(2.))

v = lambda t,g: g(t)+\
                (t-1.)*(t-2.)/2.*(0.-g(0.))+\
                -t*(t-2.)*(2.-g(1.))+\
                t*(t-1.)/2.*(-3.-g(2.))

# Create free functions:
gu1 = lambda t: np.sin(10. * t)
gv1 = lambda t: np.cos(7. * t)
gu2 = lambda t: t**2 + t + 5.
gv2 = lambda t: np.exp(t) / (1. + t)
gu3 = lambda t: t % 1
gv3 = lambda t: np.cos(3. * np.sqrt(t)) * t

# Create the plot:
p = MakePlot(r"u(t)", r"v(t)")
p.ax[0].plot(u(t, gu1), v(t, gv1), "r")
p.ax[0].plot(u(t, gu2), v(t, gv2), "g")
p.ax[0].plot(u(t, gu3), v(t, gv3), "b")
p.ax[0].plot([0., np.pi, np.exp(1.)], [0., 2., -3.],
             "k",
             linestyle="None",
             marker=".",
             markersize=10)
p.FullScreen()
p.show()
Esempio n. 3
0
cost = simps(int, t)

print('{:.2e} & {:.2e} & {:.8f} & {:.5f} & {:d} & {:.2f}'.format(
    np.max(np.abs(L(xi, c))), np.max(np.abs(H(z, xi))), cost, tf, iter,
    time * 1000))

# Plots
MS = 12

p1 = MakePlot(onp.array([['t', 't']]), onp.array([[r'$x(t)$', r'$y(t)$']]))
p1.fig.subplots_adjust(wspace=0.25, hspace=0.25)
p1.ax[0].plot(t, x(z, xi['xi_x']), label='x(t)', linewidth=2)
p1.ax[1].plot(t, u(z, xi['xi_u']), label='y(t)', linewidth=2)
p1.ax[0].grid(True)
p1.ax[1].grid(True)
p1.FullScreen()
p1.show()
# p1.save('figures/unknownTimeStates')

p2 = MakePlot('t', r'$|Loss|$')
p2.ax[0].plot(t,
              onp.abs(Lx(z, xi, c)),
              'r*',
              markersize=MS,
              label='|$L_x(t)$|')
p2.ax[0].plot(t,
              onp.abs(Lu(z, xi, c)),
              'kx',
              markersize=MS,
              label='|$L_u(t)$|')
p2.ax[0].plot(t, onp.abs(H(z, xi)), 'b+', markersize=MS, label='|$H(t)$|')