julia中JuMP不能被正常调用


#1


#2

请使用markdown的code block将你的 完整 代码粘贴上来。


#4

this is my code,thanks:

using Pkg
Pkg.add("MathOptInterface")
using Pkg
Pkg.add("JuMP")
using Pkg
Pkg.add("Interact")
using Pkg
Pkg.add("Gadfly")
const g_max = [1000,1000]
const g_min = [0,300]
const c_g = [50,100]
const c_g0 = [1000,0]
const c_w = 50
const d = 1500
const w_f = 200
function opt_ed(g_max,g_min,c_g,c_w,d,w_f)
ed = Model()
@defVar(ed,0 < g[i=1:2] <= g_max[i])
@defVar(ed,0 <= w <= w_f)
@setObjective(ed,Min,sum(c_g[i]*g[i],i = 1:2) + c_w*w)
for i in 1:2
    @addConstraint(ed,g[i] <= g_max[i])
    @addConstraint(ed,g[i] >= g_min[i])
@addConstraint(ed,w <= w_f)
@addConstraint(ed,sum(g([i],i = 1:2) + w == d))
end
solve(ed)
(g_opt,w_opt,ws_opt,obj) = solved(g_max,g_min,c_g,c_w,d,w_f);
println("\n")
println("Dispatch of Generators: ", g_opt[i=1:2], " MW")
println("Dispatch of Wind: ", w_opt, " MW")
println("Wind spillage: ", w_f-w_opt, " MW")
println("\n")
println("Total cost: ", obj, "\$")
end