# \[AMPL 25008\] doubt writing the code

**URL:** <https://discuss.ampl.com/t/ampl-25008-doubt-writing-the-code/1013>\
**Category:** Google Group Mirror\
**Created:** [March 24, 2024, 10:04am UTC](https://discuss.ampl.com/t/ampl-25008-doubt-writing-the-code/1013 "2024-03-24T10:04:33Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![4er](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.ampl.com/4er/32/530_2.png) [@4er](https://discuss.ampl.com/u/4er)\
**Post date:** [March 25, 2024, 7:15pm UTC](https://discuss.ampl.com/t/ampl-25008-doubt-writing-the-code/1013/2 "2024-03-25T19:15:02Z")

</div>

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:

```auto
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.

---

_[View the full topic](https://discuss.ampl.com/t/ampl-25008-doubt-writing-the-code/1013)._
