nummer92
nummer92

Reputation: 31

Unexpected forall syntax error

So i wanted to run this code:

constraint ctMachine[Machine];
subject to{
forall(i in Machine)
  forall (k in Week)
  ctMachine[i]: sum(j in Product)
    ResourceConsumption[i][j] * Units[j][k]  <= Capacity[i];

But if I do this, I get the error that ctMachine[1] was already assigned, which makes sense. So I tried to put the second for loop after the sum function, like this:

constraint ctMachine[Machine];
subject to{


forall(i in Machine)
  ctMachine[i]: sum(j in Product)
  forall(k in Week)
    ResourceConsumption[i][j] * Units[j][k]  <= Capacity[i];

But then I receive the syntax error, unexpected forall. But how can I do it then. I need the constranint for all k. I am fairly new to linear programming and OPL so I don't have a clue how I can solve this now. Btw I can't just remove the constraint label since I also need that.

Upvotes: 0

Views: 1288

Answers (1)

Alex Fleischer
Alex Fleischer

Reputation: 10062

I would remove

constraint ctMachine[Machine];

and write

forall(i in Machine)
ctMachine: sum(j in Product)
sum(k in Week) ResourceConsumption[i][j] * Units[j][k] <= Capacity[i];

regards

Upvotes: 1

Related Questions