gpt4 book ai didi

How can I get the shadow values of this iteration in Julia JuMP?(如何在Julia Jump中获得此迭代的阴影值?)

转载 作者:bug小助手 更新时间:2023-10-24 19:42:57 26 4
gpt4 key购买 nike



I'm trying to get the shadow values of the constraints in the 'for' loop:

我正在尝试获取‘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)

Does anyone know how to make it print the shadow value of all constraints? D:

有没有人知道如何让它打印所有约束的阴影值?D:


I was trying to develop a economic dispatch problem (I'm new on Julia)

我正试图解决一个经济调度问题(我对朱莉娅是新手)


更多回答
优秀答案推荐

Option 1: use the specialized JuMP syntax to create a container:

选项1:使用专门的跳转语法创建容器:


@constraint(m, c2[i in 1:N], Pmin[i] <= P[i] <= Pmax[i])
dual.(c2)

Option 2: use Julia

选项2:使用Julia


c2 = Any[]
for i in 1:N
push!(c2, @constraint(m, Pmin[i] <= P[i] <= Pmax[i]))
end
dual.(c2)

I'd actually write your model differently though:

不过,我实际上会用不同的方式来写你的模型:


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)


I was trying to develop a economic dispatch problem



You might be interested in the tutorial:

您可能会对本教程感兴趣:


https://jump.dev/JuMP.jl/stable/tutorials/applications/power_systems/#Economic-dispatch

Https://jump.dev/JuMP.jl/stable/tutorials/applications/power_systems/#Economic-dispatch



(I'm new on Julia)



Hi there! The other place to get help for JuMP/Julia related things is http://jump.dev/forum. It's a bit easier to have a back-and-forth conversation there if you have more questions than StackOverflow.

嗨你好啊!另一个获得JUMP/Julia相关内容帮助的地方是http://jump.dev/forum.如果你有比StackOverflow更多的问题,在那里来回交谈会更容易一些。


更多回答

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com