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

Dd/optimizable #956

Merged
merged 69 commits into from
May 9, 2024
Merged

Dd/optimizable #956

merged 69 commits into from
May 9, 2024

Conversation

ddudt
Copy link
Collaborator

@ddudt ddudt commented Mar 26, 2024

Resolves #860

  • Generalizes FixParameter to work for an OptimizableCollection so collections (like coil sets) can be constrained in optimizations.
  • Replaces inheritance from _FixedObjective and _FixProfile to inherit from FixParameter instead for many of the linear objectives, to reduce redundant code.
  • Other miscellaneous changes to make coil optimization work, like adding FixCurveShift and FixCurveRotation to maybe_add_self_consistency

To-Do:

  • Replace _FixedObjective and _FixProfile with FixParameter
  • Make sure tests pass
  • Add test to check order of residuals with specified modes input

@ddudt ddudt added duplicate funtionality New feature or request to do things the code can't do now. optimization Adding or improving optimization methods coil stuff relating to coils and coil optimization labels Mar 26, 2024
Copy link

codecov bot commented Mar 26, 2024

Codecov Report

Attention: Patch coverage is 98.41270% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 94.94%. Comparing base (082be4e) to head (0aff196).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #956      +/-   ##
==========================================
+ Coverage   94.87%   94.94%   +0.07%     
==========================================
  Files          87       87              
  Lines       21909    21699     -210     
==========================================
- Hits        20786    20603     -183     
+ Misses       1123     1096      -27     
Files Coverage Δ
desc/backend.py 89.67% <ø> (ø)
desc/basis.py 98.34% <100.00%> (ø)
desc/objectives/__init__.py 100.00% <ø> (ø)
desc/objectives/_free_boundary.py 96.86% <ø> (-0.02%) ⬇️
desc/objectives/linear_objectives.py 95.95% <100.00%> (+1.33%) ⬆️
desc/objectives/objective_funs.py 93.94% <100.00%> (+0.17%) ⬆️
desc/optimizable.py 97.82% <100.00%> (+0.02%) ⬆️
desc/optimize/_constraint_wrappers.py 95.73% <100.00%> (+0.01%) ⬆️
desc/utils.py 92.06% <100.00%> (+1.23%) ⬆️
desc/objectives/getters.py 91.30% <90.62%> (+6.37%) ⬆️

Copy link
Contributor

github-actions bot commented Mar 27, 2024

|             benchmark_name             |         dt(%)          |         dt(s)          |        t_new(s)        |        t_old(s)        | 
| -------------------------------------- | ---------------------- | ---------------------- | ---------------------- | ---------------------- |
 test_build_transform_fft_lowres         |     +0.73 +/- 5.10     | +3.71e-03 +/- 2.60e-02 |  5.13e-01 +/- 2.3e-02  |  5.10e-01 +/- 1.2e-02  |
 test_build_transform_fft_midres         |     +0.84 +/- 3.01     | +4.93e-03 +/- 1.76e-02 |  5.89e-01 +/- 1.7e-02  |  5.84e-01 +/- 6.1e-03  |
 test_build_transform_fft_highres        |     +1.93 +/- 2.22     | +1.89e-02 +/- 2.17e-02 |  9.97e-01 +/- 1.8e-02  |  9.78e-01 +/- 1.3e-02  |
 test_equilibrium_init_lowres            |     +3.34 +/- 4.30     | +1.28e-01 +/- 1.64e-01 |  3.95e+00 +/- 1.3e-01  |  3.82e+00 +/- 9.7e-02  |
 test_equilibrium_init_medres            |     +4.86 +/- 3.86     | +2.07e-01 +/- 1.64e-01 |  4.46e+00 +/- 1.5e-01  |  4.25e+00 +/- 7.5e-02  |
 test_equilibrium_init_highres           |     +0.17 +/- 4.26     | +1.02e-02 +/- 2.60e-01 |  6.13e+00 +/- 8.6e-02  |  6.12e+00 +/- 2.5e-01  |
 test_objective_compile_dshape_current   |     -0.17 +/- 2.71     | -5.93e-03 +/- 9.68e-02 |  3.57e+00 +/- 6.7e-02  |  3.58e+00 +/- 7.0e-02  |
 test_objective_compile_atf              |     +0.03 +/- 3.96     | +1.83e-03 +/- 2.78e-01 |  7.02e+00 +/- 1.9e-01  |  7.02e+00 +/- 2.0e-01  |
 test_objective_compute_dshape_current   |     +0.94 +/- 3.00     | +3.94e-05 +/- 1.26e-04 |  4.23e-03 +/- 1.2e-04  |  4.19e-03 +/- 5.1e-05  |
 test_objective_compute_atf              |     -3.34 +/- 2.45     | -6.06e-04 +/- 4.45e-04 |  1.76e-02 +/- 3.5e-04  |  1.82e-02 +/- 2.8e-04  |
 test_objective_jac_dshape_current       |     -7.67 +/- 8.69     | -3.36e-03 +/- 3.80e-03 |  4.04e-02 +/- 1.8e-03  |  4.37e-02 +/- 3.3e-03  |
 test_objective_jac_atf                  |     +0.91 +/- 3.81     | +1.65e-02 +/- 6.91e-02 |  1.83e+00 +/- 5.4e-02  |  1.81e+00 +/- 4.4e-02  |
 test_perturb_1                          |     +9.49 +/- 4.16     | +1.10e+00 +/- 4.83e-01 |  1.27e+01 +/- 3.5e-01  |  1.16e+01 +/- 3.4e-01  |
 test_perturb_2                          |     +7.40 +/- 3.11     | +1.21e+00 +/- 5.09e-01 |  1.75e+01 +/- 2.8e-01  |  1.63e+01 +/- 4.2e-01  |
 test_proximal_jac_atf                   |     +1.17 +/- 1.59     | +8.27e-02 +/- 1.12e-01 |  7.14e+00 +/- 7.6e-02  |  7.06e+00 +/- 8.3e-02  |
-test_proximal_freeb_compute             |    +47.71 +/- 1.83     | +6.19e-02 +/- 2.38e-03 |  1.92e-01 +/- 2.2e-03  |  1.30e-01 +/- 8.8e-04  |
 test_proximal_freeb_jac                 |     +2.11 +/- 1.38     | +1.48e-01 +/- 9.71e-02 |  7.16e+00 +/- 7.7e-02  |  7.01e+00 +/- 5.9e-02  |

desc/objectives/getters.py Outdated Show resolved Hide resolved
@f0uriest f0uriest mentioned this pull request Apr 2, 2024
Copy link
Collaborator

@dpanici dpanici left a comment

Choose a reason for hiding this comment

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

Add ability to fix the parameter of a single member of an OptimizableCollection (either with FixParameter, or FixCollectionParameters)

@dpanici
Copy link
Collaborator

dpanici commented Apr 10, 2024

Look at coil objectives for pytree stuff for nested lists

@dpanici
Copy link
Collaborator

dpanici commented Apr 10, 2024

Tutorial and see how it breaks @dpanici

@ddudt
Copy link
Collaborator Author

ddudt commented Apr 18, 2024

add error checking for FixParameter with OptimizableCollection, etc.

@ddudt ddudt marked this pull request as ready for review May 1, 2024 03:20
@ddudt ddudt requested review from dpanici and f0uriest May 1, 2024 03:20
tests/test_optimizer.py Show resolved Hide resolved
tests/test_examples.py Outdated Show resolved Hide resolved
desc/utils.py Show resolved Hide resolved
desc/optimize/_constraint_wrappers.py Show resolved Hide resolved
desc/objectives/linear_objectives.py Outdated Show resolved Hide resolved
desc/objectives/linear_objectives.py Outdated Show resolved Hide resolved
desc/objectives/linear_objectives.py Outdated Show resolved Hide resolved
desc/objectives/linear_objectives.py Outdated Show resolved Hide resolved
desc/objectives/linear_objectives.py Outdated Show resolved Hide resolved
tests/test_linear_objectives.py Show resolved Hide resolved
@ddudt ddudt requested a review from f0uriest May 2, 2024 23:36
Copy link
Member

Choose a reason for hiding this comment

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

did this actually change?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, I think it was the same change I made to test_freeb_axisym to make sure the R_modes input to FixBoundaryR is a 2D array, not a tuple

f0uriest
f0uriest previously approved these changes May 6, 2024
@ddudt ddudt merged commit d9f4a8d into master May 9, 2024
18 checks passed
@ddudt ddudt deleted the dd/optimizable branch May 9, 2024 04:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
coil stuff relating to coils and coil optimization funtionality New feature or request to do things the code can't do now. optimization Adding or improving optimization methods
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make optimization framework work with OptimizableCollection
4 participants