5
$\begingroup$

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}:
$\endgroup$
  • 3
    $\begingroup$ 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. $\endgroup$ – prash Feb 1 at 6:24
  • $\begingroup$ @prash Column 1 newer equals column 3, which is correct. Tried to copy the result in here, but it got messy ;) $\endgroup$ – Ulrich_Peters Feb 1 at 6:33
  • $\begingroup$ 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) $\endgroup$ – LarrySnyder610 Feb 1 at 14:02
2
$\begingroup$

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}
$\endgroup$
1
$\begingroup$

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}:
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.