diff --git a/examples-gallery/pendulum_swing_up_variable_duration_solution.npy b/examples-gallery/pendulum_swing_up_variable_duration_solution.npy new file mode 100644 index 0000000..b9a7eec Binary files /dev/null and b/examples-gallery/pendulum_swing_up_variable_duration_solution.npy differ diff --git a/examples-gallery/plot_pendulum_swing_up_variable_duration.py b/examples-gallery/plot_pendulum_swing_up_variable_duration.py index d876f4f..c0b0a5b 100644 --- a/examples-gallery/plot_pendulum_swing_up_variable_duration.py +++ b/examples-gallery/plot_pendulum_swing_up_variable_duration.py @@ -78,11 +78,18 @@ def obj_grad(free): initial_guess = np.zeros(prob.num_free) # %% -# Find the optimal solution. +# Find the optimal solution. Initial guess is stored in the file +# ```pendulum_swing_up_variable_duration_solution.npy``` + +initial_guess = np.load('pendulum_swing_up_variable_duration_solution.npy') solution, info = prob.solve(initial_guess) print(info['status_msg']) print(info['obj_val']) +# %% +# Here the better initial conditions are saved and stored +# ```np.save('pendulum_swing_up_variable_duration_solution', solution)``` + # %% # Plot the optimal state and input trajectories. prob.plot_trajectories(solution) @@ -125,9 +132,10 @@ def animate(i): time_text.set_text(time_template.format(i*interval_value)) return line, time_text - -ani = animation.FuncAnimation(fig, animate, range(num_nodes), - interval=int(interval_value*1000), +time = list(time) +time[-5:] = [time[-1]] * 5 +ani = animation.FuncAnimation(fig, animate, range(0, int(num_nodes), 5), + interval=int(interval_value*1000*5), blit=True, init_func=init) plt.show()