Repository navigation
fix(optimization): update linked configurations that own no variable - #1129
Merged
HarrisonKramer merged 1 commit intoNov 10, 2026
Merged
HarrisonKramer merged 1 commit into
HarrisonKramer merged 1 commit into
Conversation
update_optics() only refreshed the optics that own a variable, so a configuration that contributes operands but no variable kept its stale values: its pickups were never applied and its operands did not respond to the variables. Update the variable-owning optics first, then every other optic referenced by an operand, each optic once per call, so that a derived configuration reads an already-updated source.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Collaborator
|
Hi @lyn1dev, thanks for the fix and the test. It follows the approach in the issue exactly. Merging now. Best, |
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.
Summary
OptimizationProblem.update_optics()updated only the optics that own a variable. Aconfiguration that contributes operands but no variable was therefore never refreshed:
its pickups to its source configuration were never applied, so its operand was constant
and the optimizer silently ignored it.
update_optics()now updates the variable-owning optics first and then every other opticreferenced by
operand.input_data["optic"], each optic once per call. Updating the sourcefirst means a derived configuration's pickups read the current variable values. No public
signature changes; a problem whose operands only use the optics that own variables does
exactly the same work as before.
Related issue
Fixes #1120
How I verified this
30.0 30.0afterupdate_optics(); before thechange it printed
30.0 22.01359.tests/test_multiconfig.py: a radius variable on a baseCookeTripletand anf2operand on a configuration derived from it (no variable of its own, pickups to thebase). The optimizer moves the base radius from 22.0136 to 19.9184, the derived
configuration's radius equals the base radius afterwards (its pickups were applied), and
the operand reaches its 45.0 target. I checked the numbers by comparing the two radii and
the operand value against the target rather than only trusting the optimizer's status.
update_optics()is reverted, andpasses with it, so it guards the fix rather than the optimizer.
MPLBACKEND=Agg .venv/Scripts/python.exe -m pytest -v tests/test_multiconfig.py:8 passed (NumPy and PyTorch).
MPLBACKEND=Agg .venv/Scripts/python.exe -m pytest -q tests/optimization/:736 passed, 10 skipped.
MPLBACKEND=Agg .venv/Scripts/python.exe -m pytest -q tests/test_ml.py: 18 passed;MPLBACKEND=Agg .venv/Scripts/python.exe -m pytest -q tests/diagnostics: 116 passed.ruff check optiland/: all checks passed.ruff format --checkon the changed files:already formatted.
mypy optiland/: success, no issues in 612 source files.python -m venv .venv, thenpip install -e "." --group devandpip install torchfor the PyTorch backend, becauseuvwas not available here.Checklist
AI assistance