# Issue interpreting sets of constraints in AMPL

I'm new to AMPL and am trying to model the following constraints.

\begin{align}y_{ij3}&\le\sum_\ell X_{j\ell2}\quad(m=2,k=3)\\y_{ijk}&\le\sum_\ell\sum_mx_{j\ell m},\quad\forall i\in I,\forall j\in J,k=1,2.\end{align}

I'm not sure if I am on the right track. This is what I have so far:

subject to C1 {i in DEMAND, j in FACILITY}: Y[i,j,"CO"] <= sum{l in SIZE} X[j,l,"TRI"] ;

subject to C2_1 {i in DEMAND, j in FACILITY}: Y[i,j,"EL"] <= sum{l in SIZE,m in TECH} X[j,l,m] ;

subject to C2_2 {i in DEMAND, j in FACILITY}: Y[i,j,"TH"] <= sum{l in SIZE, m in TECH} X[j,l,m] ;


I modelled the second constraint in two parts. The relevant sets are as follows:

set ENERGY:= EL CO TH; #k

set TECH := COG TRI; #m

• Welcome to OR.SE. Your code looks more or less OK -- but what exactly is your question? Did you try the code, and did you get any errors? – LarrySnyder610 Nov 14 '19 at 2:51

model;

• thank you, I can now see that I interchanged "CO" and "TH". However, for your second constraint, since the constraint is indexed over only $k=1,2$. Would it be appropriate to model it the way you did? My thinking is that way there will be double counting on the index $k=3$ which is already captured in constraint $1$. – george Nov 14 '19 at 17:50