Hi there,
I am trying to extract shadow prices out of a MIQP model. In order to do this I want to “fix” the mixed integer variables after a first solving and then extract the duals.
Here’s a minimal working example:
using JuMP
using Gurobi
model = Model(Gurobi.Optimizer)
@variable(model, x, Bin)
@variable(model, y)
@constraint(model, x * y >= 1)
@constraint(model, c1, x + y <= 6)
@objective(model, Max, y)
optimize!(model)
solution = Dict(v => value(v) for v in all_variables(model))
for v in all_variables(model)
is_binary(v) || continue
unset_binary(v)
fix(v, solution[v]; force=true)
end
new_model = copy(model)
set_optimizer(new_model, Gurobi.Optimizer)
set_optimizer_attribute(new_model, "QCPDual", 1)
optimize!(new_model)
JuMP.shadow_price(new_model[:c1])
However, for larger and more difficult models, QCPDual is not guaranteed to compute duals according to this post.
I was thinking if there is an option to get fully rid of the binary/integer variables and replace those by the result values in order to end up with a full LP. Is there a way to e.g. iterate through my constraints by using e.g. all_constraints(model; include_variable_in_set_constraints=true)
replace the variables and afterwards delete the variables from the model?
In the end I would hope to get then a model in this case which looks like this:
max(y)
s.t.
1 * y >= 1
1 + y <= 6
So far I was not able to figure this out…