I have tried to add a soft constraint penalty to my objective function.

My soft constraint is this:

sum((i,j,p,t), x(i,j,p,t)-r(i,j,p,t)) =e= 6000

And then the penalty is added in my objective function like this at the end:

- sum((i,j,p,t),penalty(p,j,i)*r(i,j,p,t))

The x variable is an amount of product that is being transported. The soft constraint is going to add a penalty cost (penalty(p,j,i) if the amount of x goes above 6000.

How do I make sure that the subscripts (i,j,p,t) are equal to the same subscripts in in the x variable which is already determined by other hard constraints?