Moreover, I think the format that you provided for writing the constraint should be reformulated as follows. This is because when I use your format, I face an error like “Uncontrolled set entered as constant.”
I think the if-test in your loop is never true. If you add p(c) it actually does something.
The attached example does the same thing in a marginally better way. moosavi.gms (518 Bytes)
BTW, it seems like your formulation of the con(j) constraint is good. Seems right to me.