Conversation
|
|
||
| class ShareFamilyCoilParameters(_Objective): | ||
| """ | ||
| Objective enforcing shared parameter values across groups of coils. |
There was a problem hiding this comment.
| Objective enforcing shared parameter values across groups of coils. | |
| Fix specific degrees of freedom to be the same between coils. |
|
|
||
| Parameters | ||
| ---------- | ||
| thing : CoilSet or Coil |
There was a problem hiding this comment.
| thing : CoilSet or Coil | |
| thing : CoilSet or MixedCoilSet |
| return f | ||
|
|
||
|
|
||
| class ShareFamilyCoilParameters(_Objective): |
There was a problem hiding this comment.
I think ShareCoilParameters is a better name for this. We use family only for EquilibriaFamily, not coilsets.
| ---------- | ||
| thing : CoilSet or Coil | ||
| Coil container object. | ||
| groups : list of dict |
There was a problem hiding this comment.
I think if we use the same API as ShareParameters, it would be easier for users. Because I think people don't give names to their coils in general. I was thinking something like,
"""
params : dict
Dict keys are the names of parameters to fix (str), and dict values are the
indices to fix for each corresponding parameter (int array).
Use True (False) instead of an int array to fix all (none) of the indices
for that parameter.
Example
-------
"""
# Let's say we have a MixedCoilSet with
# CoilSet with 3 unique coils and 2 extra single coils
# Something like this will fix the currents of the
# first 2 coils of the coilset as well as second single coil
params = {
"current": {{True, True, False}, False, True},
}
There was a problem hiding this comment.
If the parameter that will be shared is an array, the example usage can be
# For above MixedCoilSet, this will make sure that index 0 of the 3
# coils of the coilset are the same (also index 1, but it can be different than
# index 0)
params = {
"R_n": {{[0, 1], [0, 1], [0, 1]}, False, False},
}| n = len(leaves) | ||
| name = getattr(child, "name", "") or f"family_{i}" | ||
|
|
||
| errorif( |
There was a problem hiding this comment.
I think instead of using the name, we can use the pytree structure to map indices.
|
Try to extend |
|
I have extended |
Memory benchmark result| Test Name | %Δ | Master (MB) | PR (MB) | Δ (MB) | Time PR (s) | Time Master (s) |
| -------------------------------------- | ------------ | ------------------ | ------------------ | ------------ | ------------------ | ------------------ |
test_objective_jac_w7x | -3.78 % | 4.086e+03 | 3.932e+03 | -154.51 | 41.36 | 39.16 |
test_proximal_jac_w7x_with_eq_update | -0.08 % | 6.560e+03 | 6.555e+03 | -5.57 | 157.79 | 163.89 |
test_proximal_freeb_jac | 0.11 % | 1.339e+04 | 1.340e+04 | 14.25 | 87.72 | 87.92 |
test_proximal_freeb_jac_blocked | -0.42 % | 7.747e+03 | 7.715e+03 | -32.80 | 79.92 | 78.19 |
test_proximal_freeb_jac_batched | 0.55 % | 7.659e+03 | 7.702e+03 | 42.49 | 78.60 | 78.70 |
test_proximal_jac_ripple | 2.65 % | 3.675e+03 | 3.772e+03 | 97.32 | 65.57 | 68.40 |
test_proximal_jac_ripple_bounce1d | 0.09 % | 3.916e+03 | 3.919e+03 | 3.34 | 79.35 | 79.17 |
test_eq_solve | 1.39 % | 2.214e+03 | 2.245e+03 | 30.74 | 98.33 | 97.94 |For the memory plots, go to the summary of |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2133 +/- ##
==========================================
- Coverage 94.48% 94.42% -0.06%
==========================================
Files 102 102
Lines 28721 28777 +56
==========================================
+ Hits 27137 27173 +36
- Misses 1584 1604 +20
🚀 New features to boost your workflow:
|
2530536 to
af81b60
Compare
|
Here is a notebook, with an example of a single |
This PR introduces a new objective
ShareFamilyCoilParametersthat enforces equality constraints between selected parameters across groups of coils. The objective allows users to tie parameters (e.g. currents) between coils belonging to the same family or across multiple families, optionally restricted to specific indices.Motivation
In coil optimization problems, it is desirable to:
Description of the approach
The objective:
Example usage
A usage example is provided in stage_two_ShareFamilyCoilParameters.ipynb demonstrating sharing currents between coils.