Is there an inbuilt function I can use to query the lower level objective value when using BilevelJuMP.jl?
For the following example:
using JuMP, BilevelJuMP, Gurobi
model = BilevelModel(Gurobi.Optimizer, mode = BilevelJuMP.SOS1Mode())
@variable(Lower(model), x)
@variable(Upper(model), y)
@objective(Upper(model), Min, 3x + y)
@constraints(Upper(model), begin
x <= 5
y <= 8
y >= 0
end)
@objective(Lower(model), Min, -x)
@constraints(Lower(model), begin
x + y <= 8
4x + y >= 8
2x + y <= 13
2x - 7y <= 0
end)
optimize!(model)
To access the objective values, I use the following function:
upper_level_objective = objective_value(model)
Then, I see that both upper and lower level model are of type JuMP.AbstractModel
, so I tried:
upper_level_objective = objective_value(Upper(model))
lower_level_objective = objective_value(Lower(model))
The above function returns me the correct objective values for both levels. So my questions are (in general):
- Is
objective_value(model) == objective_value(Upper(model))
always? - Is
objective_value(Lower(model))
the correct way to access the lower level objective value?
Thank you!