Unexpected behavior from defined set

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 hours, m in minutes} (h + m);
set times := {days, timeSlots};
set schedule within {grades, days, st in timeSlots, et in timeSlots: st <= et - timeInterval};
set scheduleTimes{(g,d,st,et) in schedule} := {(d,t) in {days, timeSlots}: t <= et - timeInterval and t >= st}; 

In my mind, each indexed set scheduleTimes should be comprised of ordered pairs like (M, 845). (The timeSlots st and et are start times and end times for an interval.)
But, for some really simple data, I don’t get ordered pairs.

ampl: display scheduleTimes;
set scheduleTimes[5,M,845,900] := 845 850 855;   <--- These are just timeSlots

If I manually enter a diplay command like the following, I get the expected behavior:

ampl: display {(d,t) in {days, timeSlots}: t <= 900 - timeInterval and t >= 845};
set {d in days, t in timeSlots: t <= 900 - timeInterval && t >= 845}  :=
(M,845)   (M,855)   (T,850)   (W,845)   (W,855)   (R,850)   (F,845)   (F,855)
(M,850)   (T,845)   (T,855)   (W,850)   (R,845)   (R,855)   (F,850);  <--- Ordered pairs

Any thoughts? Happy to send the whole model and data file, if it would be helpful. They are still quite small.

Thanks,
Andy

Nevermind! It was my intention that the d’s in the definition of scheduleTimes would match, but that was perhaps assuming too much. If I change it to the following, it works:
set scheduleTimes{(g,d,st,et) in schedule} :=
{dd in days, t in timeSlots :dd==d and t <= et - timeInterval and t >= st};

Thanks! Resolved

P.s. If you have suggestions on how to simplify this messy swamp of definitions, I’m all ears.

Because d is defined in the indexing expression at the beginning of the set statement,

set scheduleTimes {(g,d,st,et) in schedule} := 
  {(d,t) in {days,timeSlots}: t <= et - timeInterval and t >= st}; 

the expression (d,t) in {days,timeSlots} defines a one-dimensional “slice” though the first dimension of {days,timeSlots}. So when you display scheduleTimes you see one-dimensional sets of timeslots. However, you could instead use the more general setof operator here to specify a set of pairs:

set scheduleTimes {(g,d,st,et) in schedule} := 
  setof {(d,t) in {days, timeSlots}: t <= et - timeInterval and t >= st} (d,t); 

This can be further simplified to

set scheduleTimes {(g,d,st,et) in schedule} := 
  setof {t in timeSlots: t <= et - timeInterval and t >= st} (d,t);