# \#sets-and-indexing

**URL:** https://discuss.ampl.com/tag/sets-and-indexing/8.md

[Latest](https://discuss.ampl.com/latest.md) · [Categories](https://discuss.ampl.com/categories.md) · [Tags](https://discuss.ampl.com/tags.md)

---

## [Implementing nested sets](https://discuss.ampl.com/t/implementing-nested-sets/2126)

<div class="topic-metadata">

**Author:** [@nickgessner\_9](https://discuss.ampl.com/u/nickgessner_9)\
**Replies:** 1\
**Last updated:** [May 5, 2025, 8:30pm UTC](https://discuss.ampl.com/t/implementing-nested-sets/2126 "2025-05-05T20:30:52Z")

</div>

Hello all together. I’m trying to implement the set Mik and Mjk, as you can see in the picture attached. I already implemented the other sets as follows: param N; set mathN := 1..N; param K; set mathK := 1..K; i…

---

## [Request for Support in Fixing the Errors](https://discuss.ampl.com/t/request-for-support-in-fixing-the-errors/2062)

<div class="topic-metadata">

**Author:** [@Davids\_David2](https://discuss.ampl.com/u/Davids_David2)\
**Replies:** 1\
**Last updated:** [February 19, 2025, 8:45pm UTC](https://discuss.ampl.com/t/request-for-support-in-fixing-the-errors/2062 "2025-02-19T20:45:40Z")

</div>

Dear Team, I am writing to request support with my model. I am trying to simulate a small system for a public call center, where multiple phone rooms are available, and people arrive to make calls. When a person arrives…

---

## [Grouping houly data into days to find max parameter values](https://discuss.ampl.com/t/grouping-houly-data-into-days-to-find-max-parameter-values/2042)

<div class="topic-metadata">

**Author:** [@mcaballero305](https://discuss.ampl.com/u/mcaballero305)\
**Replies:** 1\
**Last updated:** [January 27, 2025, 12:24am UTC](https://discuss.ampl.com/t/grouping-houly-data-into-days-to-find-max-parameter-values/2042 "2025-01-27T00:24:28Z")

</div>

Hi, I am trying to upload data from a csv file to define sets and parameters. I have a.mod and .run file that works to return max parameter volume when I have just one index column (Hour). But when I try to add another …

---

## [Unexpected behavior from defined set](https://discuss.ampl.com/t/unexpected-behavior-from-defined-set/2005)

<div class="topic-metadata">

**Author:** [@Andy\_Felt](https://discuss.ampl.com/u/Andy_Felt)\
**Replies:** 2\
**Last updated:** [December 11, 2024, 3:32pm UTC](https://discuss.ampl.com/t/unexpected-behavior-from-defined-set/2005 "2024-12-11T15:32:42Z")

</div>

Hi AMPL experts! I’m running into unexpected behavior. I have the following definitions: param timeInterval default 5; set minutes := 0..59 by timeInterval; set hours := 800..1500 by 100; set timeSlots := setof{h in h…

---

## [AMPL duplicate member "x" for set "y", how to fix it](https://discuss.ampl.com/t/ampl-duplicate-member-x-for-set-y-how-to-fix-it/474)

<div class="topic-metadata">

**Author:** [@Ares\_Inglada\_Grano](https://discuss.ampl.com/u/Ares_Inglada_Grano)\
**Replies:** 3\
**Last updated:** [April 6, 2023, 3:05pm UTC](https://discuss.ampl.com/t/ampl-duplicate-member-x-for-set-y-how-to-fix-it/474 "2023-04-06T15:05:16Z")

</div>

I 'm working with AMPL. In the “.mod” I have declared a set like this: set path\_intersections; It consists of rows of two numbers, the first one is the number of the path, and the second one the number of the intersectio…

---

## [Why do I get an “invalid subscript discarded” message when I display an AMPL parameter?](https://discuss.ampl.com/t/why-do-i-get-an-invalid-subscript-discarded-message-when-i-display-an-ampl-parameter/59)

<div class="topic-metadata">

**Author:** [@megrobert](https://discuss.ampl.com/u/megrobert)\
**Replies:** 0\
**Last updated:** [December 15, 2021, 5:38pm UTC](https://discuss.ampl.com/t/why-do-i-get-an-invalid-subscript-discarded-message-when-i-display-an-ampl-parameter/59 "2021-12-15T17:38:35Z")

</div>

Either a data table gave values for the parameter with incorrect subscripts, or the parameter’s indexing set changed, causing some previously valid subscripts to become invalid. For example, in the diet.mod + diet.dat ex…

---

## [Why doesn’t AMPL interpret the expression T..1 as I expect?](https://discuss.ampl.com/t/why-doesn-t-ampl-interpret-the-expression-t-1-as-i-expect/64)

<div class="topic-metadata">

**Author:** [@megrobert](https://discuss.ampl.com/u/megrobert)\
**Replies:** 0\
**Last updated:** [December 15, 2021, 5:46pm UTC](https://discuss.ampl.com/t/why-doesn-t-ampl-interpret-the-expression-t-1-as-i-expect/64 "2021-12-15T17:46:12Z")

</div>

In general, AMPL interprets a..b as {a, a+1, a+2, ..., b-1, b} . Thus when T is greater than one, T..1 is an empty set. To specify the ordered set that goes from T down to 1 , write T..1 by -1 .

---

## [Why does “set S := 50 .. 70” give me a set of only 3 members?](https://discuss.ampl.com/t/why-does-set-s-50-70-give-me-a-set-of-only-3-members/63)

<div class="topic-metadata">

**Author:** [@megrobert](https://discuss.ampl.com/u/megrobert)\
**Replies:** 0\
**Last updated:** [December 15, 2021, 5:45pm UTC](https://discuss.ampl.com/t/why-does-set-s-50-70-give-me-a-set-of-only-3-members/63 "2021-12-15T17:45:39Z")

</div>

You have declared set S in your model and set S := 50 .. 70 in your data. Set expressions are not recognized in AMPL’s data mode, however. Instead AMPL tries to recognize 50 .. 70 as a space-delimited list of members of S…

---

## [I have declared “set S” and “param b {S}”. How do I write an AMPL expression for the arg min of b\[i\] — that is, the s in S such that b\[s\] equals the minimum of b\[i\] over al](https://discuss.ampl.com/t/i-have-declared-set-s-and-param-b-s-how-do-i-write-an-ampl-expression-for-the-arg-min-of-b-i-that-is-the-s-in-s-such-that-b-s-equals-the-minimum-of-b-i-over-al/62)

<div class="topic-metadata">

**Author:** [@megrobert](https://discuss.ampl.com/u/megrobert)\
**Replies:** 0\
**Last updated:** [December 15, 2021, 5:44pm UTC](https://discuss.ampl.com/t/i-have-declared-set-s-and-param-b-s-how-do-i-write-an-ampl-expression-for-the-arg-min-of-b-i-that-is-the-s-in-s-such-that-b-s-equals-the-minimum-of-b-i-over-al/62 "2021-12-15T17:44:12Z")

</div>

There’s no specific arg min operator in AMPL. However, proceeding directly from the definition, you can define the arg min explicitly by a set expression like {s in S: b\[s\] = min {i in S} b\[i\]} This expression gives a …

---

## [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)

<div class="topic-metadata">

**Author:** [@megrobert](https://discuss.ampl.com/u/megrobert)\
**Replies:** 0\
**Last updated:** [December 15, 2021, 5:42pm UTC](https://discuss.ampl.com/t/how-can-i-get-ampl-to-index-over-the-power-set-consisting-of-all-subsets-of-a-set/61 "2021-12-15T17:42:17Z")

</div>

AMPL can index model components by objects (numbers and character strings) but not by sets of objects. Hence you can’t model a power set directly. You may be able to get the same effect, however, by constructing a number…

---

## [How can I apply AMPL’s ordered-set functions to pairs and higher-dimensional objects?](https://discuss.ampl.com/t/how-can-i-apply-ampl-s-ordered-set-functions-to-pairs-and-higher-dimensional-objects/60)

<div class="topic-metadata">

**Author:** [@megrobert](https://discuss.ampl.com/u/megrobert)\
**Replies:** 0\
**Last updated:** [December 15, 2021, 5:40pm UTC](https://discuss.ampl.com/t/how-can-i-apply-ampl-s-ordered-set-functions-to-pairs-and-higher-dimensional-objects/60 "2021-12-15T17:40:19Z")

</div>

AMPL does not define any ordering on pairs, triples, or objects of higher dimension. Thus next , prev , and other functions that apply to objects in ordered sets cannot be applied to pairs, triples, or tuples of higher d…
