Is there anyway i can define a JuMP variable in two different ranges?
Say the first range is between 3:6 and the second one between 9:12.
Is there anyway i can define a JuMP variable in two different ranges?
Say the first range is between 3:6 and the second one between 9:12.
No. But you can write a reformulation like:
@variable(model, range_variable)
x = @variable(model, [1:2])
z = @variable(model, [1:2], Bin)
@constraints(model, begin
3z[1] <= x[1]
x[1] <= 6z[1]
9z[2] <= x[2]
x[2] <= 12z[2]
z[1] + z[2] == 1
range_variable == x[1] + x[2]
end)
Thank you for the tip! I’m going to try that!