[AMPL 24534] How to write this constrain in AMPL

Good afternoon,

I would need help with the syntax in AMPL of the following code line, the one I attach in the following doc. (I have no idea about how to write the sum of( i E I : g E Gi) )

All of the param, var, and sets that appear in the constrain are written in my code.

I’d apreciate a lot your help.

I do not know how you defined your AMPL sets, parameters, and variables, so I cannot say exactly how you should write the objective. But the following is the general idea, which you can adapt to your needs. Suppose that you write the definitions like this:

set G;
set P;
set K;

set I;
set Gsub {I} within G;
set Psub {I} within P;

param NUI {G,P,K};
var a {I,P,K} >= 0;

The the constraint can be defined in this way:

subject to YourConstraint {g in G, p in P, k in K}:
   sum {i in I: g in Gsub[i] and p in Psub[i]} a[i,p,k] <= NUI[g,p,k];

A statement like “set Gsub {I} within G” defines a separate set Gsub[i] for each member i of G, and also says that each Gsub[i] must be a subset of G. (If you follow the mathematical statement exactly, you would have a set G and subsets G[i], but AMPL requires a different name to be used for the subsets.) There’s a detailed introduction to sets like Gsub[i] in section 6.5 Indexed collections of sets in the AMPL book.