Alternatively Bool can be called as constructor, Bool(0)
I’m not sure this answers your question though, as you seem to be using i to construct a range for indexing something in the code you posted (i.e. you would have 1:1 if i == true and 1:0 if i == false due to type promotion)
Here is the documentation for a binary variable: Variables · JuMP
Here is the documentation for variable containers: Variables · JuMP
Avoiding the i issue, you code will make a vector of binary variables, where d[i] in {0, 1} .
using JuMP
model = Model()
@variable(model, d[1:2], Bin)
is_binary(d[1]) # true
is_binary(d[2]) # true
If you really want i to be the index, and for it to be in {0, 1}, that doesn’t make sense. Do you want 0 variables or 1 variable? If you just want a variable called i to be 0 or 1, use:
using JuMP
model = Model()
@variable(model, i, Bin)
p.s. You should also post in the Optimization (Mathematical) - JuliaLang category if you’re posting about JuMP. It makes the post a little more visible to the people interested in optimization.