在 JuMP 中添加约束
add a constraint in JuMP
我正在尝试向 Julia 中的 JuMP 模型添加约束,如下所示:
@constraint(m, sum{z[i,j]>=2, i in N, j in K})
其中N和K是两组。
但是,当我调试它时,我收到以下错误消息。
LoadError: In @constraint(m,sum{z[i,j] >= 2,i in N,j in K}): Constraints must be in one of the following forms:
expr1 <= expr2
expr1 >= expr2
expr1 == expr2
lb <= expr <= ub
while loading /Users/user/Dropbox/Model/ip.jl, in expression starting on line 51
in include_string(::String, ::String) at loading.jl:441
in include_string(::String, ::String) at sys.dylib:?
in include_string(::Module, ::String, ::String) at eval.jl:34
in (::Atom.##59#62{String,String})() at eval.jl:73
in withpath(::Atom.##59#62{String,String}, ::String) at utils.jl:30
in withpath(::Function, ::String) at eval.jl:38
in macro expansion at eval.jl:71 [inlined]
in (::Atom.##58#61{Dict{String,Any}})() at task.jl:60
有人可以帮我解决这个错误吗?
我相信你的意思是写:
@constraint(m, sum{z[i,j], i in N, j in K}>=2)
不等式应该在和之外。
因为您希望所有值的总和至少为 2。
我正在尝试向 Julia 中的 JuMP 模型添加约束,如下所示:
@constraint(m, sum{z[i,j]>=2, i in N, j in K})
其中N和K是两组。
但是,当我调试它时,我收到以下错误消息。
LoadError: In @constraint(m,sum{z[i,j] >= 2,i in N,j in K}): Constraints must be in one of the following forms:
expr1 <= expr2
expr1 >= expr2
expr1 == expr2
lb <= expr <= ub
while loading /Users/user/Dropbox/Model/ip.jl, in expression starting on line 51
in include_string(::String, ::String) at loading.jl:441
in include_string(::String, ::String) at sys.dylib:?
in include_string(::Module, ::String, ::String) at eval.jl:34
in (::Atom.##59#62{String,String})() at eval.jl:73
in withpath(::Atom.##59#62{String,String}, ::String) at utils.jl:30
in withpath(::Function, ::String) at eval.jl:38
in macro expansion at eval.jl:71 [inlined]
in (::Atom.##58#61{Dict{String,Any}})() at task.jl:60
有人可以帮我解决这个错误吗?
我相信你的意思是写:
@constraint(m, sum{z[i,j], i in N, j in K}>=2)
不等式应该在和之外。 因为您希望所有值的总和至少为 2。