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

added documentation for categories #2028

Closed
wants to merge 1 commit into from

Conversation

matbesancon
Copy link
Contributor

JuMP @variable can be odd for newcomers because there seems to be bindings that don't exist:

@variable(m, x[1:10], Bin)

JuMP.Bin # not found
?JuMP.Bin # not found either

This allows having a short docstring for these categories

@matbesancon
Copy link
Contributor Author

matbesancon commented Aug 15, 2019

These haven't been exported, so users still need the fully qualified JuMP.PSD to find them

@codecov
Copy link

codecov bot commented Aug 15, 2019

Codecov Report

Merging #2028 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff           @@
##           master   #2028   +/-   ##
======================================
  Coverage    91.5%   91.5%           
======================================
  Files          33      33           
  Lines        4215    4215           
======================================
  Hits         3857    3857           
  Misses        358     358
Impacted Files Coverage Δ
src/sets.jl 83.33% <ø> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0565f26...cdd1f5d. Read the comment docs.

1 similar comment
@codecov
Copy link

codecov bot commented Aug 15, 2019

Codecov Report

Merging #2028 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff           @@
##           master   #2028   +/-   ##
======================================
  Coverage    91.5%   91.5%           
======================================
  Files          33      33           
  Lines        4215    4215           
======================================
  Hits         3857    3857           
  Misses        358     358
Impacted Files Coverage Δ
src/sets.jl 83.33% <ø> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0565f26...cdd1f5d. Read the comment docs.


Binary variable category, used in the `@variable` macro.
"""
Bin
Copy link
Member

Choose a reason for hiding this comment

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

I didn't know you could declare variables like this!

But, maybe we should make it a type? Because it still has this:

julia> JuMP.Bin
ERROR: UndefVarError: Bin not defined

We also don't really want to declare an Int JuMP-local variable. It would get exported and might cause all sorts of issues.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a bizarre trickery, it's documented, but not an identifier. You get it in REPL auto-completion, but raises UndefVar

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can make them types indeed

@mlubin
Copy link
Member

mlubin commented Aug 15, 2019

I agree that the use of Bin and Int can be a bit confusing in the macros, but we cannot export Int in any case because of the conflict with the name in Base.

These haven't been exported, so users still need the fully qualified JuMP.PSD to find them

All symbols without preceding underscores are exported from JuMP:
https://github.com/JuliaOpt/JuMP.jl/blob/0565f26eb5aca10c92516143f8a40280257b49b9/src/JuMP.jl#L757-L758

I've thought about @variable(model, x, :Bin) and @variable(model, x, :Int). Which is more confusing for new users, Julia symbol syntax with a colon or seemingly referring to undefined bindings like Bin?

@matbesancon
Copy link
Contributor Author

Which is more confusing for new users, Julia symbol syntax with a colon or seemingly referring to undefined bindings like Bin?

I would say symbols are less confusing, they can experiment with them in the REPL, get typeof(:Int) and then check the documentation for Symbol.

The fact that Int is among the categories is even more confusing in the current state, because users might think the last argument passed is a type

@blegat
Copy link
Member

blegat commented Aug 15, 2019

PSD should be replaced by PSDCone(). In fact, we should allow any MOI.AbstractVectorSet and then reshape just like with @constraint. We could do the same for Int and Bin. We expect MOI.ZeroOne() and JuMP.Bin() just redirects to it

@matbesancon
Copy link
Contributor Author

So what should do here?

@odow
Copy link
Member

odow commented Aug 23, 2019

The problem with :Int is that there is a distinction between JuMP provided types like :Int and :Bin, and extension types (like SDDP.State).

@matbesancon
Copy link
Contributor Author

This may be personal but I find it less of a problem than Bin because you know there is "something" (an identifier) which is Int, while you need to understand how macro operate to get that Bin doesn't exist

@matbesancon
Copy link
Contributor Author

bump here?

@odow
Copy link
Member

odow commented Apr 3, 2020

I think we're going to punt on this until we come up with a better solution. Exporting a symbol for Bin is weird because we don't for Int. And we won't be changing the syntax before JuMP 1.0. So maybe just close?

@odow
Copy link
Member

odow commented Apr 6, 2020

Closing until we come up with a better solution in the future.

@odow odow closed this Apr 6, 2020
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.

None yet

4 participants