DESC icon indicating copy to clipboard operation
DESC copied to clipboard

Optimize Factorize Linear Constraints

Open YigitElma opened this issue 1 year ago • 3 comments

Resolves #1011

I just made the fix parameter removal a loop such that we remove every explicitly and implicitly fixed parameter before SVD. The self-consistency part can be done on a separate PR, I will test it myself. Some explanation why I did this is here

YigitElma avatar May 15 '24 21:05 YigitElma

eq = get("NCSX")
constraints = get_fixed_boundary_constraints(eq)
constraints = maybe_add_self_consistency(eq, constraints)
constraints = ObjectiveFunction(constraints)

objective = ObjectiveFunction(ForceBalance(eq))
objective = LinearConstraintProjection(objective, constraints)
objective.build(verbose=3)
print(objective._A.shape)
print(objective._Z.shape)
Master Output:  (442, 4320)    (4320, 3878)
PR Output:      (408, 4286)    (4286, 3878)

YigitElma avatar May 15 '24 21:05 YigitElma

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 94.96%. Comparing base (e9a55d5) to head (f3c1729). Report is 1380 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1022      +/-   ##
==========================================
- Coverage   94.96%   94.96%   -0.01%     
==========================================
  Files          87       87              
  Lines       21761    21770       +9     
==========================================
+ Hits        20665    20673       +8     
- Misses       1096     1097       +1     
Files with missing lines Coverage Δ
desc/objectives/utils.py 93.06% <100.00%> (+0.67%) :arrow_up:

... and 3 files with indirect coverage changes

codecov[bot] avatar May 15 '24 22:05 codecov[bot]

|             benchmark_name             |         dt(%)          |         dt(s)          |        t_new(s)        |        t_old(s)        | 
| -------------------------------------- | ---------------------- | ---------------------- | ---------------------- | ---------------------- |
 test_build_transform_fft_lowres         |     -1.67 +/- 5.48     | -8.76e-03 +/- 2.88e-02 |  5.16e-01 +/- 2.8e-02  |  5.25e-01 +/- 7.8e-03  |
 test_build_transform_fft_midres         |     -3.42 +/- 1.22     | -2.06e-02 +/- 7.35e-03 |  5.83e-01 +/- 4.3e-03  |  6.03e-01 +/- 6.0e-03  |
 test_build_transform_fft_highres        |     -1.71 +/- 2.00     | -1.70e-02 +/- 1.99e-02 |  9.78e-01 +/- 5.4e-03  |  9.95e-01 +/- 1.9e-02  |
 test_equilibrium_init_lowres            |     +0.14 +/- 2.32     | +5.39e-03 +/- 8.90e-02 |  3.84e+00 +/- 6.9e-02  |  3.83e+00 +/- 5.6e-02  |
 test_equilibrium_init_medres            |     +1.96 +/- 3.24     | +8.43e-02 +/- 1.39e-01 |  4.38e+00 +/- 1.2e-01  |  4.29e+00 +/- 7.6e-02  |
 test_equilibrium_init_highres           |     +0.09 +/- 1.83     | +5.36e-03 +/- 1.11e-01 |  6.08e+00 +/- 7.7e-02  |  6.07e+00 +/- 8.0e-02  |
 test_objective_compile_dshape_current   |     +1.36 +/- 5.66     | +4.89e-02 +/- 2.04e-01 |  3.65e+00 +/- 2.0e-01  |  3.60e+00 +/- 3.5e-02  |
 test_objective_compile_atf              |     +0.10 +/- 3.12     | +7.18e-03 +/- 2.24e-01 |  7.17e+00 +/- 1.6e-01  |  7.16e+00 +/- 1.6e-01  |
 test_objective_compute_dshape_current   |     -0.24 +/- 2.95     | -8.70e-06 +/- 1.08e-04 |  3.67e-03 +/- 5.1e-05  |  3.68e-03 +/- 9.6e-05  |
 test_objective_compute_atf              |     +0.65 +/- 2.49     | +9.95e-05 +/- 3.83e-04 |  1.55e-02 +/- 3.5e-04  |  1.54e-02 +/- 1.5e-04  |
 test_objective_jac_dshape_current       |     -4.01 +/- 6.00     | -1.72e-03 +/- 2.58e-03 |  4.12e-02 +/- 1.4e-03  |  4.30e-02 +/- 2.1e-03  |
 test_objective_jac_atf                  |     +0.67 +/- 3.52     | +1.28e-02 +/- 6.70e-02 |  1.92e+00 +/- 5.3e-02  |  1.90e+00 +/- 4.2e-02  |
 test_perturb_1                          |     +1.35 +/- 1.65     | +1.72e-01 +/- 2.10e-01 |  1.29e+01 +/- 8.3e-02  |  1.27e+01 +/- 1.9e-01  |
 test_perturb_2                          |     +2.67 +/- 2.31     | +4.69e-01 +/- 4.06e-01 |  1.81e+01 +/- 2.9e-01  |  1.76e+01 +/- 2.9e-01  |
 test_proximal_jac_atf                   |     +1.04 +/- 0.65     | +7.65e-02 +/- 4.80e-02 |  7.40e+00 +/- 4.0e-02  |  7.33e+00 +/- 2.7e-02  |
 test_proximal_freeb_compute             |     +0.84 +/- 1.42     | +1.63e-03 +/- 2.75e-03 |  1.95e-01 +/- 1.3e-03  |  1.94e-01 +/- 2.4e-03  |
 test_proximal_freeb_jac                 |     +0.95 +/- 1.37     | +7.02e-02 +/- 1.01e-01 |  7.45e+00 +/- 4.1e-02  |  7.38e+00 +/- 9.2e-02  |

github-actions[bot] avatar May 15 '24 23:05 github-actions[bot]

we'll wait for the benchmark to run again though as I wonder if it does make a difference. And for a 2nd reviewer as usual

dpanici avatar May 20 '24 17:05 dpanici

@f0uriest If you don't have any concerns, I will merge this in tonight

YigitElma avatar May 24 '24 19:05 YigitElma