Skip to content
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

Add name keyword to macros #2643

Closed
odow opened this issue Jul 9, 2021 · 8 comments
Closed

Add name keyword to macros #2643

odow opened this issue Jul 9, 2021 · 8 comments
Labels
good first issue This issue is recommended for new users, it does not require a thorough understanding of the package Status: Help Wanted Help is welcome on this issue Type: Feature request

Comments

@odow
Copy link
Member

odow commented Jul 9, 2021

Motivated by https://discourse.julialang.org/t/getting-started-mip-variables-and-datastructure/63766/6

It would be nice to have

model = Model()
@variable(model, x[i=1:3], name="x_$(i)")

Currently there is

model = Model()
julia> @variable(model, x[i=1:3], base_name="x_$(i)")
3-element Vector{VariableRef}:
 x_1[1]
 x_2[2]
 x_3[3]

which isn't quite the same thing.

@odow odow added Type: Feature request good first issue This issue is recommended for new users, it does not require a thorough understanding of the package Status: Help Wanted Help is welcome on this issue labels Jul 9, 2021
@jd-foster
Copy link
Collaborator

jd-foster commented Jul 9, 2021

At the risk of over-complicating things since the issue is originally about variable naming, if this approach was used consistently in @constraint too, then it might be used to address the ambiguity in "naming when broadcasting" as discussed in #1166. It also seems possible to address #1936 if a function (returning a string) can know about the constraint (base) name and the index. (Really getting into the weeds, potentially addresses #2171 too....)

@odow
Copy link
Member Author

odow commented Jul 9, 2021

At the risk of over-complicating things since the issue is originally about variable naming

It's worth thinking about this holistically prior to JuMP 1.0 in order to make sure we get it right. The number of open issues around naming suggests that the design could do with improvements.

@odow
Copy link
Member Author

odow commented Oct 8, 2021

Having thought about this more, I don't think we need this. It's added complexity, and will lead to confusion between name and base_name. It's not hard to loop over variables and set their name to something else if you don't like JuMP's default names.

@odow odow closed this as completed Oct 8, 2021
@jd-foster
Copy link
Collaborator

Is it worth adding your nice answer in https://discourse.julialang.org/t/how-to-register-the-name-of-anonymous-variable-to-certain-model/69273/2 to the documentation somewhere?

@odow
Copy link
Member Author

odow commented Oct 11, 2021

@jd-foster
Copy link
Collaborator

Looks like it's all covered there. I thought the dot points might serve as a good recap all together at the end of the section e.g. "In summary, ..." but may be too repetitive.

@odow
Copy link
Member Author

odow commented Oct 11, 2021

Open a PR if you have suggestions for improvements. The recap might be good at the end of the first section?

@jd-foster
Copy link
Collaborator

OK, will have a read through again and see if it would help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue This issue is recommended for new users, it does not require a thorough understanding of the package Status: Help Wanted Help is welcome on this issue Type: Feature request
Development

No branches or pull requests

2 participants