我正在尝试获取“for”循环中约束的影子值:
using JuMP
using GLPK
CI = [30, 70];
d = 170;
Pmin = [ 0, 0];
Pmax = [100, 150];
N = length(CI)
m = Model(GLPK.Optimizer)
@variable(m, 0 <= P[1:N] )
@objective(m, Min, sum(CI[i] * P[i] for i in 1:N))
@constraint(m, c1, sum(P[1:N]) == d)
for i in 1:N
@constraint(m, Pmin[i] <= P[i] <= Pmax[i])
end
optimize!(m)
有谁知道如何让它打印所有约束的影子值?达:
我试图开发一个经济调度问题(我是 Julia 的新手)
选项1:使用专门的JuMP语法创建容器:
@constraint(m, c2[i in 1:N], Pmin[i] <= P[i] <= Pmax[i])
dual.(c2)
选项 2:使用 Julia
c2 = Any[]
for i in 1:N
push!(c2, @constraint(m, Pmin[i] <= P[i] <= Pmax[i]))
end
dual.(c2)
实际上我会以不同的方式编写你的模型:
using JuMP
using HiGHS
CI = [30.0, 70.0]
d = 170
Pmin = [0.0, 0.0]
Pmax = [100.0, 150.0]
N = length(CI)
model = Model(HiGHS.Optimizer)
@variable(model, Pmin[i] <= P[i = 1:N] <= Pmax[i])
@objective(model, Min, CI' * P)
@constraint(model, c1, sum(P) == d)
optimize!(model)
reduced_cost.(P)
我正在尝试开发一个经济调度问题
您可能对本教程感兴趣:
https://jump.dev/JuMP.jl/stable/tutorials/applications/power_systems/#Economic-dispatch
(我是朱莉娅的新手)
你好!另一个获得 JuMP/Julia 相关帮助的地方是 http://jump.dev/forum。如果您有比 StackOverflow 更多的问题,在那里进行来回对话会更容易一些。