# AMPL implement constraint

I'm trying to implement the following in AMPL:

$$i \in [N], j \in[N] \backslash \{i\}, t \in [T]$$

I have so far written the following:

subject to Con{i in PP,t in TT, j in PP : j != i}:


but it does not feel correct, is it? I also have a question about implementing this: $$i \neq j,t$$ in a constraint, i'm only getting one to work:

subject to {i in PP,t in TT, j in PP : j != i}:

• Load your model and data such that they don't use the solve command. Then do a displayon the set operations that you want to validate. example you could try display {i in PP,t in TT, j in PP : j != i}; to check if you are getting the correct selection from the sets. Feb 1 '20 at 6:24
• @prash Column 1 newer equals column 3, which is correct. Tried to copy the result in here, but it got messy ;) Feb 1 '20 at 6:33
• Your first constraint syntax looks correct to me. Are you getting an error, or you're just second-guessing yourself? For your second question, I am not sure what you are asking. Your constraint looks the same as the first one (except that you are missing a constraint name) Feb 1 '20 at 14:02

This looks most like the math (and avoids checking for every $$(i,j,t)$$ a logical condition that depends only on $$i$$ and $$j$$):

{i in PP, j in PP diff {i}, t in TT}


Try the following syntax:

subject to cons {i in PP,t in TT, j in PP : j diff i}:


Or

subject to cons {i in PP,t in TT, j in PP : j<>i}: