Repository navigation
Coil length/curvature losses, normB_axis sampling, custom_loss scaling - #138
Open
rogeriojorge wants to merge 11 commits into
Open
rogeriojorge wants to merge 11 commits into
rogeriojorge wants to merge 11 commits into
Conversation
eduardolneto
self-requested a review
October 10, 2026 19:48
Contributor
|
@rogeriojorge We can take the target scaling of length cost function. Maybe we can add by target as an option for the future. Using augmented lgarangian ethod one can constraint each coild mean curvature to be exactly the target and not only some sum. Dor the sum we can do a separated function? |
Member
Author
|
Went back to the two-sided target sum((L/L0-1)^2): the one-sided cap broke parity with SIMSOPT's CurveLength penalty in examples/comparisons_simsopt/losses.py, and the ValueError broke max_coil_length=0. Now L0<=0 returns 0 (disabled). Still summed to a scalar. Merged main. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Four objective/loss bugs:
loss_coil_lengthdivided by its defaultmax_coil_length=0(inf/NaN) and was two-sided,(L/Lmax - 1)^2, so coils shorter than the cap were penalized. It is now a one-sided cap,sum(max(L/Lmax - 1, 0)^2), returns a scalar, and raisesValueErrorwhen no positive cap is given.loss_coil_curvaturereturned one value per coil; it now sums to a scalar (the per-coil value is unchanged, sojnp.sum(...)callers are unaffected).normB_axisusedlinspace(0, 2pi, n)with the endpoint, sampling phi=0 twice and biasingloss_normB_axis_average; nowendpoint=False.custom_loss.__mul__built a new loss withoutdependencies, so3 * losscould not be evaluated (starting_dofsraisedKeyError); the scaled loss now shares the original's dependencies.Tests (fail on main, pass here;
JAX_ENABLE_X64=1 pytest -n 2 tests/test_objective_functions.py tests/test_multiobjectives.py):test_coil_length_loss_is_a_one_sided_cap(circles of radius 1 and 2; only the long coil is penalized; no-cap raises)test_coil_curvature_loss_is_scalar(exact value 0.25^2 * 2pi)test_normB_axis_samples_one_full_period_without_duplicatestest_custom_loss_scalar_multiplication_keeps_dependenciesOn main: 4 failed. With this branch: all pass.
Overlap: #119 sets the example's
max_coil_lengthto 42, which is compatible with the new check (main's example still passes 0 and would now get an explicit error instead of NaN). Merges cleanly with #119 and #133.