2

I'm trying to add a constraint to a JuMP model in Julia as follows:

@constraint(m, sum{z[i,j]>=2, i in N, j in K})

where N and K are two sets.

But, when I debug it, I get the following error message.

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

Can someone please help me to resolve this error?

2
  • 2
    Does `@constraint(m, sum{z[i,j], i in N, j in K}>=2) work? Why is the inequality inside the sum? Commented Jun 14, 2017 at 7:48
  • Perfect!! Thank you so much Lyndon... :) It worked... Many thanks again! Commented Jun 14, 2017 at 7:50

1 Answer 1

2

I believe you meant to write: @constraint(m, sum{z[i,j], i in N, j in K}>=2)

The inequality should be outside the sum. Because you want the sum of all values, to be at least 2.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.