How to declare a binary variable in a robust model?

Why is it that whenever I try to compile a binary variable, Julia returns this error to me?

 In @variable(ModeloD,b[A],lower_bound = 0,Bin): Unrecognized keyword argument lower_bound

Is there a different way of putting the major and minor signs in binary variables in a robust model?

I’ve tried to use all of these and the error continues: <=,> =,. <=,.> =, Lower_bound = 0, upper bound = 0

using JuMP, JuMPeR, GLPKMathProgInterface
ModeloD = RobustModel(solver = GLPKSolverLP())
a = 1:4
A = a
@variable(ModeloD,b[A], lower_bound=0, Bin)

I believe that you should just remove the lower_bound=0 argument. There are only two values, so a lower bound does not make any sense. The documentation makes no mention of allowing lower bounds for binary values.

1 Like

A binary variable has implicit bounds of [0, 1].

However, for future reference, the syntax is

model = Model()
@variable(model, x, Bin, lower_bound = 0)
# or
@variable(model, y >= 0, Bin)

The difference is that @RaquelSantos is using the old version of JuMP, where the syntax is just @variable(model, y >= 0, Bin).

julia> using JuMP, JuMPeR

julia> model = RobustModel();
julia> @variable(model, x >= 0, Bin)
x

julia> A = 1:4
1:4

julia> @variable(model, y[A], Bin, lowerbound=0)
y[i] ∈ {0,1} ∀ i ∈ {1,2,3,4}
3 Likes