-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
better initial guess and fps = 20 for reduced running time #239
base: master
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -349,8 +349,10 @@ def obj_grad(free): | |
) | ||
|
||
# %% | ||
# The initial guess should meet the configuration constrains. It will be | ||
# plotted below. | ||
# The initial guess should meet the configuration constrains. Those below are | ||
# used to get a better initial guess, stored in | ||
# 'ball_rolling_on_spinning_disc_solution.npy'. | ||
|
||
i1b = np.zeros(num_nodes) | ||
i2 = np.linspace(initial_state_constraints[x], | ||
final_state_constraints[x], num_nodes) | ||
|
@@ -361,25 +363,25 @@ def obj_grad(free): | |
i4 = np.zeros(8*num_nodes) | ||
initial_guess = np.hstack((i1,i1a, i1b, i2, i3, i4, 0.01)) | ||
|
||
fig1, ax1 = plt.subplots(14, 1, figsize=(7.25, 0.75*14), sharex=True, | ||
layout='constrained') | ||
prob.plot_trajectories(initial_guess, ax1) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you delete a figure, then the thumbnail figure may change, have you checked that? There will no longer be a figure 7, right? I don't see any reason to delete the figure. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I did not intentionally delete this. No idea what happened. Is this related to the mixed up PRs? |
||
# %% | ||
# This way the maximum number of interations may be changed. | ||
# Default is 3000. | ||
prob.add_option('max_iter', 1000) | ||
|
||
# %% | ||
# Find the optimal solution. | ||
|
||
initial_guess = np.load('ball_rolling_on_spinning_disc_solution.npy') | ||
solution, info = prob.solve(initial_guess) | ||
print('message from optimizer:', info['status_msg']) | ||
print('Iterations needed', len(prob.obj_value)) | ||
print(f'Optimal h = {solution[-1]:.3e} sec') | ||
|
||
# %% | ||
# PLot the objective value. | ||
# This way the solution may be saved for later use. | ||
# ```np.save('ball_rolling_on_spinning_disc_solution.npy', solution)``` | ||
|
||
# %% | ||
# Plot the objective value. | ||
prob.plot_objective_value() | ||
|
||
# %% | ||
|
@@ -466,7 +468,7 @@ def func (x, *args): | |
|
||
# %% | ||
# Animate the system. | ||
fps = 30 | ||
fps = 20 | ||
|
||
def add_point_to_data(line, x, y): | ||
old_x, old_y = line.get_data() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.