Randomization of two arrays with dependencies between them

In reply to nedicm:

Then you don’t need nested foreach loops. You can use the min/max array reduction methods ‘with’ clause as an iterator.

constraint c3 { pos.max() with (pos[item.index] - neg[item.index]) 
              - pos.min() with (pos[item.index] - neg[item.index])
              <= relative_c; }

Also, you need to be careful with overflow/underflow. You might have to cast your subtraction to 13 bits.