Arseny Grinchenko
Arseny Grinchenko

Reputation: 29

Constraints in Julia

I'm switching from AMPL to Julia right now, and while I've checked the JuMP manual on constraints, I didn't see there an answer to my question (in case I've missed it - I'm sorry :))

If I have a variable representing a production:

g[i,j]

Where i - is the number of possible producers and j - is the number of months. And a constant representing a total demand for each month:

d[j]

How should I construct my constraint, if I want the model to fulfill monthly demand? Right now I have this, but it doesn't seem to work for me:

for j in 1:6
    @constraint(model,sum(g[i,j] for i in 1:50) == d[j])
end

Thank you!

Upvotes: 0

Views: 134

Answers (1)

JKHA
JKHA

Reputation: 1896

I suggest you to look at JuMP's documentation about constraint containers here.

@constraint(model, myConstraintName[j=1:6], sum(g[i,j] for i in 1:50) == d[j])

Upvotes: 1

Related Questions