I am trying to run a code using the
dual function from JuMP inside a loop, but I’m not getting the results I expected.
The code is a bit extensive, so I’ll try to put here the most relevant parts of the model for my question:
xx = [@variable(sub, [1:T, 1:nGen, 1:K+1]) for i = 1:3] @constraints(sub, begin DualFisherg, xx .== xk DualFisherup, xx .== xk DualFisherdn, xx .== xk end) for ω =2:S for t=1:T JuMP.set_normalized_rhs(eq35_bal3[t,3], d_hat[t, ω]) JuMP.set_normalized_rhs(eq36_bal3[t,3], d[t, ω]) for i=1:nGen for k=1:K if t > 1 JuMP.set_normalized_coefficient(eqld1[t,i,k], xx[t, i, k], -d[t-k, ω]) JuMP.set_normalized_coefficient(eqld2[t,i,k], xx[t, i, k], -d[t-k, ω]) JuMP.set_normalized_coefficient(eqld3[t,i,k], xx[t, i, k], -d[t-k, ω]) end end end end status = optimize!(sub) Q += JuMP.objective_value(sub)/S λg += JuMP.dual.(DualFisherg)./S λup += JuMP.dual.(DualFisherup)./S λdn += JuMP.dual.(DualFisherdn)./S end
In this code,
S is the number of scenarios I’m using. So, when I have more than one scenario, I change the right-hand side and the coefficients of some constraints, optimize the model, and update the objective value and the duals of three constraints.
The values of
λg in this code are being updated correctly when I have more than one scenario, but the other values (
λdn) are not. Any ideas why this happens?