Skip to content
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

docstrings as per #348, backend=numpy, additional state variables #384

Merged
merged 5 commits into from
Feb 26, 2025

Conversation

Peter230655
Copy link
Contributor

@Peter230655 Peter230655 commented Feb 25, 2025

  • using backend='numpy' reduced running time on my PC from anout 13 sec to about 7 sec.
  • storing the solution in .csv, the accuracy of fmt='%.2f' may be too inaccurate. Here I needed fmt='%.12f'
  • added additional state variables to make it more realistic: at the final point, not only the speed of the load, but also its acceleration must be zero. So, I use $h_i = \dfrac{d^2}{dt^2}(\textrm{position}_i \textrm{of load})$ and set $h_i(t_f) = 0$

----------

- Show the use of ``opty's variable node time interval`` feature to solve a
relatively simple problem.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

remove monospaced phrase

Copy link
Contributor Author

@Peter230655 Peter230655 Feb 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean remove the double backwards strokes?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

done

@moorepants
Copy link
Member

moorepants commented Feb 26, 2025

No thumbnail is showing:
image

@Peter230655
Copy link
Contributor Author

Peter230655 commented Feb 26, 2025

No thumbnail is showing: image

Strange: when I do ...make html it shows a thumbnail - and it is the latest version, I can see that the backstrokes are removed.
image

@moorepants
Copy link
Member

make html locally depends on the cached prior runs of make html. So it may not reflect a clean build.

@Peter230655
Copy link
Contributor Author

Peter230655 commented Feb 26, 2025

make html locally depends on the cached prior runs of make html. So it may not reflect a clean build.

Would this even be so if I turn off my PC and turn it back on?
Would it use cached version on a simulation even if I changed something in that simulation?
(I get the feel, if I changed something, it runs again...)

I forced it to run it: I changed the program so it could not use the solution given. It could tell it was recalculating, also the running time shown was much longer.
Still it seems I got a thumbnail
image

@moorepants
Copy link
Member

moorepants commented Feb 26, 2025

Would this even be so if I turn off my PC and turn it back on?

No, that's not how it works.

When you run make html it creates a new directory: opty/docs/examples. You have to delete that directory to "clear the cache". Also running make clean deletes all other sphinx generated output. After both those things you can run make html again for a fresh build (will take time).

@Peter230655
Copy link
Contributor Author

Would this even be so if I turn off my PC and turn it back on?

No, that's not how it works.

When you run make html it creates a new directory: opty/docs/examples. You have to delete that directory to "clear the cache". Also running make clean deletes all other sphinx generated output. After both those things you can run make html again for a fresh build (will take time).

I did as you explained: deleted the directory opty/docs/examples and ran make clean.
Then I ran make html - and as you said, it may have run 20 min or so.
But again I got a thumbnail.
NB:
I did not change anything in the printing part of the code, EXCEPT I now use MathJaxRepr to print the eoms.

@moorepants
Copy link
Member

The thumbnail does not show on readthedocs, so it has to be figured out.

@Peter230655
Copy link
Contributor Author

The thumbnail does not show on readthedocs, so it has to be figured out.

But how can I try things, if it shows with make html ?

@moorepants
Copy link
Member

You can try lots of things, but I don't know the answer to every single reason things don't work. I search the internet and try things until enough clues come together to figure out what is going on. All I know at the moment is that the thumbnail does not display correctly when doing a clean build on read the docs and that is the mechanism we publish the official documentation website. Why that is different on your local computer, I don't know. Mostly because I don't have 100% information about what happens on your computer.

@Peter230655
Copy link
Contributor Author

My problem is: how can I test the effect of a change I make? I cannot push every change for you to see what has happened!
Can I do a build on read the docs without pushing it?
As regards searching the internet, I would not know what to search for.

@moorepants
Copy link
Member

My problem is: how can I test the effect of a change I make? I cannot push every change for you to see what has happened!

Yes, you have to learn to debug on your own :)

Can I do a build on read the docs without pushing it?

No, it is a cloud service we use and you can only look at the error logs it produces.

As regards searching the internet, I would not know what to search for.

I don't know either, but I try until something works.

@Peter230655
Copy link
Contributor Author

My problem is: how can I test the effect of a change I make? I cannot push every change for you to see what has happened!

Yes, you have to learn to debug on your own :)

Can I do a build on read the docs without pushing it?

No, it is a cloud service we use and you can only look at the error logs it produces.

So a simulation may work with opty/docs make html, it may pass your 13 tests - and still not work right?

As regards searching the internet, I would not know what to search for.

I don't know either, but I try until something works.

@moorepants
Copy link
Member

So a simulation may work with opty/docs make html, it may pass your 13 tests - and still not work right?

Yes.

@moorepants
Copy link
Member

computation time summary:
    - ../examples-gallery/advanced/plot_car_around_pylons.py:                             89.45 sec   0.0 MB
    - ../examples-gallery/advanced/plot_ball_rolling_on_spinning_disc.py:                 71.70 sec   0.0 MB
    - ../examples-gallery/advanced/plot_park2004.py:                                      70.09 sec   0.0 MB
    - ../examples-gallery/advanced/plot_sit_to_stand.py:                                  69.38 sec   0.0 MB
    - ../examples-gallery/intermediate/plot_drone.py:                                     67.70 sec   0.0 MB
    - ../examples-gallery/intermediate/plot_parallel_park.py:                             63.32 sec   0.0 MB
    - ../examples-gallery/beginner/plot_sliding_block.py:                                 61.46 sec   0.0 MB
    - ../examples-gallery/beginner/plot_pendulum_swing_up_fixed_duration.py:              59.10 sec   0.0 MB
    - ../examples-gallery/beginner/plot_pendulum_swing_up_variable_duration.py:           55.38 sec   0.0 MB
    - ../examples-gallery/advanced/plot_one_legged_time_trial.py:                         45.35 sec   0.0 MB
    - ../examples-gallery/intermediate/plot_mississippi_steamboat.py:                     44.22 sec   0.0 MB
    - ../examples-gallery/advanced/plot_human_gait.py:                                    41.11 sec   0.0 MB
    - ../examples-gallery/advanced/plot_particle_in_tube.py:                              40.50 sec   0.0 MB
    - ../examples-gallery/advanced/plot_car_in_garage.py:                                 31.28 sec   0.0 MB
    - ../examples-gallery/intermediate/plot_countersteer.py:                              28.54 sec   0.0 MB
    - ../examples-gallery/beginner/plot_betts_10_103_104.py:                              21.56 sec   0.0 MB
    - ../examples-gallery/beginner/plot_betts_10_7.py:                                    20.48 sec   0.0 MB
    - ../examples-gallery/beginner/plot_betts_10_50.py:                                   13.94 sec   0.0 MB
    - ../examples-gallery/intermediate/plot_non_contiguous_parameter_identification.py:   10.77 sec   0.0 MB
    - ../examples-gallery/beginner/plot_vyasarayani.py:                                   10.24 sec   0.0 MB
    - ../examples-gallery/intermediate/plot_crane_moving_a_load.py:                       10.22 sec   0.0 MB
    - ../examples-gallery/beginner/plot_betts2003.py:                                      9.84 sec   0.0 MB
    - ../examples-gallery/intermediate/plot_two_link_pendulum_on_a_cart.py:                9.70 sec   0.0 MB
    - ../examples-gallery/advanced/model_park2004.py:                                      0.00 sec   0.0 MB

@moorepants moorepants merged commit 96aef31 into csu-hmc:master Feb 26, 2025
13 checks passed
@Peter230655 Peter230655 deleted the crane-moving-load branch February 26, 2025 19:36
@Peter230655
Copy link
Contributor Author

computation time summary:
    - ../examples-gallery/advanced/plot_car_around_pylons.py:                             89.45 sec   0.0 MB
    - ../examples-gallery/advanced/plot_ball_rolling_on_spinning_disc.py:                 71.70 sec   0.0 MB
    - ../examples-gallery/advanced/plot_park2004.py:                                      70.09 sec   0.0 MB
    - ../examples-gallery/advanced/plot_sit_to_stand.py:                                  69.38 sec   0.0 MB
    - ../examples-gallery/intermediate/plot_drone.py:                                     67.70 sec   0.0 MB
    - ../examples-gallery/intermediate/plot_parallel_park.py:                             63.32 sec   0.0 MB
    - ../examples-gallery/beginner/plot_sliding_block.py:                                 61.46 sec   0.0 MB
    - ../examples-gallery/beginner/plot_pendulum_swing_up_fixed_duration.py:              59.10 sec   0.0 MB
    - ../examples-gallery/beginner/plot_pendulum_swing_up_variable_duration.py:           55.38 sec   0.0 MB
    - ../examples-gallery/advanced/plot_one_legged_time_trial.py:                         45.35 sec   0.0 MB
    - ../examples-gallery/intermediate/plot_mississippi_steamboat.py:                     44.22 sec   0.0 MB
    - ../examples-gallery/advanced/plot_human_gait.py:                                    41.11 sec   0.0 MB
    - ../examples-gallery/advanced/plot_particle_in_tube.py:                              40.50 sec   0.0 MB
    - ../examples-gallery/advanced/plot_car_in_garage.py:                                 31.28 sec   0.0 MB
    - ../examples-gallery/intermediate/plot_countersteer.py:                              28.54 sec   0.0 MB
    - ../examples-gallery/beginner/plot_betts_10_103_104.py:                              21.56 sec   0.0 MB
    - ../examples-gallery/beginner/plot_betts_10_7.py:                                    20.48 sec   0.0 MB
    - ../examples-gallery/beginner/plot_betts_10_50.py:                                   13.94 sec   0.0 MB
    - ../examples-gallery/intermediate/plot_non_contiguous_parameter_identification.py:   10.77 sec   0.0 MB
    - ../examples-gallery/beginner/plot_vyasarayani.py:                                   10.24 sec   0.0 MB
    - ../examples-gallery/intermediate/plot_crane_moving_a_load.py:                       10.22 sec   0.0 MB
    - ../examples-gallery/beginner/plot_betts2003.py:                                      9.84 sec   0.0 MB
    - ../examples-gallery/intermediate/plot_two_link_pendulum_on_a_cart.py:                9.70 sec   0.0 MB
    - ../examples-gallery/advanced/model_park2004.py:                                      0.00 sec   0.0 MB

Looks line using the solution to skip solve(...) and backend='numpy' has seriously reduced running times.

@Peter230655
Copy link
Contributor Author

computation time summary:
    - ../examples-gallery/advanced/plot_car_around_pylons.py:                             89.45 sec   0.0 MB
    - ../examples-gallery/advanced/plot_ball_rolling_on_spinning_disc.py:                 71.70 sec   0.0 MB
    - ../examples-gallery/advanced/plot_park2004.py:                                      70.09 sec   0.0 MB
    - ../examples-gallery/advanced/plot_sit_to_stand.py:                                  69.38 sec   0.0 MB
    - ../examples-gallery/intermediate/plot_drone.py:                                     67.70 sec   0.0 MB
    - ../examples-gallery/intermediate/plot_parallel_park.py:                             63.32 sec   0.0 MB
    - ../examples-gallery/beginner/plot_sliding_block.py:                                 61.46 sec   0.0 MB
    - ../examples-gallery/beginner/plot_pendulum_swing_up_fixed_duration.py:              59.10 sec   0.0 MB
    - ../examples-gallery/beginner/plot_pendulum_swing_up_variable_duration.py:           55.38 sec   0.0 MB
    - ../examples-gallery/advanced/plot_one_legged_time_trial.py:                         45.35 sec   0.0 MB
    - ../examples-gallery/intermediate/plot_mississippi_steamboat.py:                     44.22 sec   0.0 MB
    - ../examples-gallery/advanced/plot_human_gait.py:                                    41.11 sec   0.0 MB
    - ../examples-gallery/advanced/plot_particle_in_tube.py:                              40.50 sec   0.0 MB
    - ../examples-gallery/advanced/plot_car_in_garage.py:                                 31.28 sec   0.0 MB
    - ../examples-gallery/intermediate/plot_countersteer.py:                              28.54 sec   0.0 MB
    - ../examples-gallery/beginner/plot_betts_10_103_104.py:                              21.56 sec   0.0 MB
    - ../examples-gallery/beginner/plot_betts_10_7.py:                                    20.48 sec   0.0 MB
    - ../examples-gallery/beginner/plot_betts_10_50.py:                                   13.94 sec   0.0 MB
    - ../examples-gallery/intermediate/plot_non_contiguous_parameter_identification.py:   10.77 sec   0.0 MB
    - ../examples-gallery/beginner/plot_vyasarayani.py:                                   10.24 sec   0.0 MB
    - ../examples-gallery/intermediate/plot_crane_moving_a_load.py:                       10.22 sec   0.0 MB
    - ../examples-gallery/beginner/plot_betts2003.py:                                      9.84 sec   0.0 MB
    - ../examples-gallery/intermediate/plot_two_link_pendulum_on_a_cart.py:                9.70 sec   0.0 MB
    - ../examples-gallery/advanced/model_park2004.py:                                      0.00 sec   0.0 MB

Looks line using the solution to skip solve(...) and backend='numpy' has seriously reduced running times.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants