Avoiding set domain errors

Top  Previous  Next

When summing etc over sets one must control all the sets in the expression or a domain error arises.  Sets are controlled in some mixture of the following four ways (calculate.gms).

Sets may be completely operated over by the sum, prod etc.

 mZ=sum(I,mr(i)*xvar.l(i));

 Obj.. z22=e= sum(I,mr(i)*xvar(i));

 

Sets may be operated over by the equation definition

 mX(Zzz)=sum(I,ar(zzz,i)*ma(i));

 Resource(j).. z2(j)=e= sum(I,jr(I,j)*xvar(i));

 

Sets may be operated over by Control Structures (loop, for, etc.)

 Loop(zzz, z22=z22+sum(I,ar(zzz,i)*mr(i)));

 

Specific set elements may be specified.

 Z22=sum(I,ar('z1',i)*mr(i));