Add a name mapping to DualNames - #236
Open
joaquimg wants to merge 1 commit into
Open
Conversation
Closes #114. The names of the dual objects are derived from the names of the primal objects they come from. Until now the only available transformation was to prepend a fixed prefix, which gives names such as `dualaffine_cons[1]` where one would rather read `α[1]`. `DualNames` gains a `mapping` field, a vector of `"from" => "to"` pairs. Each entry replaces the leading `"from"` of a primal name with `"to"`, so the index part of a container name is preserved: dualize(model; dual_names = DualNames(; mapping = ["affine_cons" => "α"])) # λ : α[1] + α[2] + α[3] == 1 Entries are tried in order and the first match is applied. The prefixes are the fallback, so a mapping can cover only part of the model. `DualNames` is now built with keyword arguments. The positional constructors are kept for backwards compatibility, and the field names are unchanged. Two behaviour changes worth noting: * `is_empty(::DualNames)` now checks the fields instead of comparing against the `EMPTY_DUAL_NAMES` sentinel. `DualNames` is mutable, so that comparison was an identity check, which made any explicitly built `DualNames()` enable the naming. A `DualNames` with no prefix and no mapping now names nothing. `test_JuMP_dualize.jl` relied on the old behaviour to get the default prefixes of the parameters and of the quadratic slacks, and now asks for them explicitly. * The naming of each family of dual object goes through its own internal function, so the prefix is selected at the call site instead of being looked up from a `Symbol`.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #236 +/- ##
==========================================
+ Coverage 95.22% 95.38% +0.16%
==========================================
Files 17 17
Lines 858 888 +30
==========================================
+ Hits 817 847 +30
Misses 41 41 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
joaquimg
added this pull request to stack #238
September 9, 2026 22:36
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.
Closes #114.