For the following BilevelJumP
model, I want to set the start value for variable x
's even indices:
using JuMP, BilevelJuMP, Gurobi
a = [1.0, 0.0, 1.0, 1.0, 0.0, 0.0]
model = BilevelModel(Gurobi.Optimizer, mode = BilevelJuMP.SOS1Mode())
@variable(Lower(model), x[i=1:6], start = (mod(i,2) == 0) ? a[i] : nothing)
I get the following error:
ERROR: MethodError: no method matching Float64(::Nothing)
Closest candidates are:
(::Type{T})(::AbstractChar) where T<:Union{AbstractChar, Number} at char.jl:50
(::Type{T})(::Base.TwicePrecision) where T<:Number at twiceprecision.jl:243
(::Type{T})(::Complex) where T<:Real at complex.jl:37
One way to make it work is I guess as follows:
using JuMP, BilevelJuMP, Gurobi
a = [1.0, 0.0, 1.0, 1.0, 0.0, 0.0]
model = BilevelModel(Gurobi.Optimizer, mode = BilevelJuMP.SOS1Mode())
@variable(Lower(model), x1[i=2:2:6], start = a[i])
@variable(Lower(model), x2[i=1:2:5])
However, why did the first approach not work? It looks more cleaner to me. Thanks!