Are the members of S already known, before the optimization problem is sent to the solver? (In other words, is S part of the problem data?) Then you can use an AMPL `check`

statement to confirm that S is not equal to N:

```
param n > 0;
set N = 1..n;
set S within N;
check: card(S) < n;
```

If after the data is read, S turns out to be the same as N, then the `solve`

command will report an error.

If instead you want the members of S to be determined by the solver, then that is a harder situation. AMPL does not have set-valued variables, so you would have to reformulate the problem — most likely, using n binary (zero-one) AMPL variables. To get more help in this case, you would have to give more details of the problem you are trying to solve.