How to define a single anonymous binary variable in JuMP 0.19

#1

Until JuMP 0.18 I was able to do

using JuMP
m = Model()
x = @variable(m, category = :Bin)

With 0.19 I get:

julia> using JuMP

julia> m = Model()
A JuMP Model
Feasibility problem with:
Variables: 0
Model mode: AUTOMATIC
CachingOptimizer state: NO_OPTIMIZER
Solver name: No optimizer attached.

julia> x = @variable(m, Bin)
ERROR: LoadError: In `@variable(m, Bin)`: Ambiguous variable name Bin detected. Use the "category" keyword argument to specify a category for an anonymous variable.
Stacktrace:
 [1] error(::String, ::String) at .\error.jl:42
 [2] _macro_error(::Symbol, ::Tuple{Symbol,Symbol}, ::String) at C:\Users\Daniel\.julia\packages\JuMP\jnmGG\src\macros.jl:1086
 [3] (::getfield(JuMP, Symbol("#_error#66")){Tuple{Symbol,Symbol}})(::String) at C:\Users\Daniel\.julia\packages\JuMP\jnmGG\src\macros.jl:1322
 [4] @variable(::LineNumberNode, ::Module, ::Vararg{Any,N} where N) at C:\Users\Daniel\.julia\packages\JuMP\jnmGG\src\macros.jl:1336
in expression starting at REPL[10]:1

julia> x = @variable(m, category = Bin)
ERROR: UndefVarError: Bin not defined
Stacktrace:
 [1] top-level scope at C:\Users\Daniel\.julia\packages\JuMP\jnmGG\src\macros.jl:300

julia> x = @variable(m, category = :Bin)
ERROR: In `@variable(m, category = :Bin)`: Unrecognized keyword argument category
Stacktrace:
 [1] error(::String, ::String) at .\error.jl:42
 [2] _macro_error(::Symbol, ::Tuple{Symbol,Expr}, ::String) at C:\Users\Daniel\.julia\packages\JuMP\jnmGG\src\macros.jl:1086
 [3] (::getfield(JuMP, Symbol("#_error#66")){Tuple{Symbol,Expr}})(::String) at C:\Users\Daniel\.julia\packages\JuMP\jnmGG\src\macros.jl:1322
 [4] #build_variable#58(::Base.Iterators.Pairs{Symbol,Symbol,Tuple{Symbol},NamedTuple{(:category,),Tuple{Symbol}}}, ::Function, ::getfield(JuMP, Symbol("#_error#66")){Tuple{Symbol,Expr}}, ::VariableInfo{Float64,Float64,Float64,Float64}) at C:\Users\Daniel\.julia\packages\JuMP\jnmGG\src\macros.jl:1080
 [5] (::getfield(JuMP, Symbol("#kw##build_variable")))(::NamedTuple{(:category,),Tuple{Symbol}}, ::typeof(build_variable), ::Function, ::VariableInfo{Float64,Float64,Float64,Float64}) at .\none:0
 [6] top-level scope at C:\Users\Daniel\.julia\packages\JuMP\jnmGG\src\macros.jl:300
#2

x=@variable(m,binary=true)

2 Likes
#3

Thanks!