Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 13 additions & 25 deletions examples/cartpole.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,7 @@ def plot_loss(J_hist):
plt.show(block=False)


def plot_path(Z,
encoding=ENCODING,
indices=None,
reality=None,
std_scale=1.0,
legend=True):
def plot_path(Z, encoding=ENCODING, indices=None, reality=None, std_scale=1.0, legend=True):
if not PLOT:
return

Expand Down Expand Up @@ -75,18 +70,12 @@ def plot_path(Z,

for i in range(1, 4):
j = std_scale * i
plt.gca().fill_between(
t.flat, (mean - j * std).flat, (mean + j * std).flat,
color=colors[index],
alpha=1.0 / (i + 1))
plt.gca().fill_between(t.flat, (mean - j * std).flat, (mean + j * std).flat,
color=colors[index],
alpha=1.0 / (i + 1))

if legend:
plt.legend(
bbox_to_anchor=(0.0, 1.0, 1.0, 0.7),
loc="upper left",
ncol=4,
mode="expand",
borderaxespad=0.)
plt.legend(bbox_to_anchor=(0.0, 1.0, 1.0, 0.7), loc="upper left", ncol=4, mode="expand", borderaxespad=0.)

plt.xlim(0, N)
plt.axhline(0, linestyle="--", color="#333333", linewidth=0.25)
Expand Down Expand Up @@ -152,15 +141,14 @@ def on_iteration(iteration, state, Z, U, J_opt):
)

controller.train()
Z, U, state = controller.fit(
U,
encoding=ENCODING,
n_iterations=50,
on_iteration=on_iteration,
on_trial=on_trial,
max_trials=20,
u_min=UMIN,
u_max=UMAX)
Z, U, state = controller.fit(U,
encoding=ENCODING,
n_iterations=50,
on_iteration=on_iteration,
on_trial=on_trial,
max_trials=20,
u_min=UMIN,
u_max=UMAX)

plt.figure()
plot_loss(J_hist)
Expand Down
354 changes: 226 additions & 128 deletions notebooks/known_dynamics/cartpole.ipynb

Large diffs are not rendered by default.

364 changes: 332 additions & 32 deletions notebooks/known_dynamics/double_cartpole.ipynb

Large diffs are not rendered by default.

429 changes: 275 additions & 154 deletions notebooks/known_dynamics/pendulum.ipynb

Large diffs are not rendered by default.

111 changes: 80 additions & 31 deletions notebooks/known_dynamics/rendezvous.ipynb

Large diffs are not rendered by default.

Loading