Skip to content

Unique names don't require underscores #161

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from

Conversation

matbesancon
Copy link
Contributor

All models end up marking each variable group with _$i, even though the variables themselves are often in containers.

This typically ends up with a double indexing scheme in JuMP:

: π[6]_1 ≥ -8006.0
 : π[5]_1 ≥ -8005.0

This PR adapts it to avoid the _i if the variable name is unique

@codecov
Copy link

codecov bot commented May 23, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.76%. Comparing base (14edeae) to head (a00761a).
Report is 9 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #161      +/-   ##
==========================================
+ Coverage   94.73%   94.76%   +0.02%     
==========================================
  Files          13       13              
  Lines         703      707       +4     
==========================================
+ Hits          666      670       +4     
  Misses         37       37              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@@ -149,6 +149,7 @@ function add_dual_variable(
func = get_function(primal_model, ci)
set = get_set(primal_model, ci)
for (i, vi) in enumerate(vis)
unique_var = length(vis) == 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be moved one line above outside the for loop

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -176,9 +178,14 @@ function set_dual_variable_name(
i::Int,
ci_name::String,
prefix::String,
unique_var::Bool = false,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need a default value if we set this value everywhere we use this function. Otherwise that just adds a chance to forget to set this and have a silent bug

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was to avoid breaking things but fine with no default

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine, we can always tag v0.6, we haven't hit v1 yet

@@ -176,9 +178,14 @@ function set_dual_variable_name(
i::Int,
ci_name::String,
prefix::String,
unique_var::Bool,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about ; ensure_unique::Bool = true,.

If this is a public method, then we don't need to break things. Appending a false isn't very informative for the caller.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good. It's not super important since this is internal anyway

@joaquimg
Copy link
Member

replaced by #184

@joaquimg joaquimg closed this Apr 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants