Skip to content
Open
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
13 changes: 10 additions & 3 deletions examples-gallery/beginner/plot_pendulum_swing_up_fixed_duration.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
---------

- Show the use of opty with likely the simplest example possible.
- Show how to use variable bounds.


Introduction
Expand Down Expand Up @@ -84,8 +85,14 @@
)

# %%
# Limit the torque to a maximum magnitude.
bounds = {T(t): (-2.0, 2.0)}
# Limit the torque using variable bounds.
third = int(num_nodes/3)
low_T = np.full(num_nodes, -3.0)
low_T[third: 2*third] = -1.0
hi_T = np.full(num_nodes, 3.0)
hi_T[third: 2*third] = 1.0

bounds = {T(t): (low_T, hi_T)}

# %%
# Create an optimization problem.
Expand All @@ -111,7 +118,7 @@

# %%
# Plot the optimal state and input trajectories.
_ = prob.plot_trajectories(solution)
_ = prob.plot_trajectories(solution, show_bounds=True)

# %%
# Plot the constraint violations.
Expand Down
Loading