# \[AMPL 24723\] Generate all subsets of a universal set in AMPL

**URL:** <https://discuss.ampl.com/t/ampl-24723-generate-all-subsets-of-a-universal-set-in-ampl/669>\
**Category:** Google Group Mirror\
**Created:** [August 2, 2023, 6:49pm UTC](https://discuss.ampl.com/t/ampl-24723-generate-all-subsets-of-a-universal-set-in-ampl/669 "2023-08-02T18:49:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![yacj\_gmail.com](https://avatars.discourse-cdn.com/v4/letter/y/d6d6ee/32.png) [@yacj\_gmail.com](https://discuss.ampl.com/u/yacj_gmail.com)\
**Post date:** [August 2, 2023, 6:49pm UTC](https://discuss.ampl.com/t/ampl-24723-generate-all-subsets-of-a-universal-set-in-ampl/669/1 "2023-08-02T18:49:07Z")

</div>

I am needing to write a general way to construct a set that contains all the subsets of a universal set.

For example: Let A be the universal set, and S be the set containing all the subsets of A.

A = {a1, a2, a3}  
S = {{∅}, {a1}, {a2}, {a3}, {a1, a2}, {a1, a3}, {a2, a3}, {a1, a2, a3}}

How can I construct the set S in a general way?

---

<div class="post-metadata">

**Author:** ![AMPL\_Google\_Group](https://avatars.discourse-cdn.com/v4/letter/a/9dc877/32.png) [@AMPL\_Google\_Group](https://discuss.ampl.com/u/AMPL_Google_Group)\
**Post date:** [August 2, 2023, 9:46pm UTC](https://discuss.ampl.com/t/ampl-24723-generate-all-subsets-of-a-universal-set-in-ampl/669/2 "2023-08-02T21:46:17Z")

</div>

See [How can I get AMPL to index over the “power set” consisting of all subsets of a set?](https://discuss.ampl.com/t/how-can-i-get-ampl-to-index-over-the-power-set-consisting-of-all-subsets-of-a-set/61) in our new [AMPL User Forum](https://discuss.ampl.com/).
