'Cplex Sum logic

I am very new to CPLEX if anyone can guide me. I have the below code. I want to make sure that in the sum pci is considered and x value should not have values more than nmax,smax and tmax. i.e. if pci = 12 and has 8 entries in North and nmax is 3 for id(pci)=12. x should only pick 3 with max profit. id in Slots, i in allConstraints and pci in North, South & Total are same

forall(<s,id> in Slots: s>0) {

forall( <i,st,e,nmin,nmax,smin,smax,tmin,tmax,ovr> in allConstraints :  i == id)
  {
    sum(<s,l,d,l2,vs,acq,p,dir,pci> in North)x[<l,d,l2,vs,acq,p>] <= nmax;
    sum(<s,l,d,l2,vs,acq,p,dir,pci> in South)x[<l,d,l2,vs,acq,p>] <= smax;
    sum(<s,l,d,l2,vs,acq,p,dir,pci> in Total)x[<l,d,l2,vs,acq,p>] <= tmax;
  } 

}



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source