def plot_strategy(ab, mealy): """Plot strategic transitions on PPP. Assumes that mealy is feasible for ab. @type ab: L{AbstractPwa} or L{AbstractSwitched} @type mealy: L{transys.MealyMachine} """ proj_mealy = project_strategy_on_partition(ab.ppp, mealy) ax = plot_partition(ab.ppp, proj_mealy, color_seed=0) return ax
def plot_trajectory(ppp, x0, u_seq, ssys, ax=None, color_seed=None): """Plots a PropPreservingPartition and the trajectory generated by x0 input sequence u_seq. See Also ======== C{plot_partition}, plot @type ppp: L{PropPreservingPartition} @param x0: initial state @param u_seq: matrix where each row contains an input @param ssys: system dynamics @param color_seed: see C{plot_partition} @return: axis object """ if ax is None: ax, fig = newax() plot_partition(plot_numbers=False, ax=ax, show=False) A = ssys.A B = ssys.B if ssys.K is not None: K = ssys.K else: K = np.zeros(x0.shape) x = x0.flatten() x_arr = x0 for i in range(u_seq.shape[0]): x = np.dot(A, x).flatten() +\ np.dot(B, u_seq[i, :] ).flatten() +\ K.flatten() x_arr = np.vstack([x_arr, x.flatten()]) ax.plot(x_arr[:,0], x_arr[:,1], 'o-') return ax