Tests to segue2 Test HS (20000): 1. no presentations. Restricted to 3 teachers: 1, 2, 10001. teacher 10001 initially has period 5 on Tuesdays excluded. Same set of sessions were used throughout the year: standard sessions. 2. More excluded periods for 10001: Tuesday 1,2 5,6 Now session maps look like this: availableSessions for teacher id: 1 0 : {} 1 : {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11} 2 : {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11} 3 : {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11} 4 : {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11} 5 : {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11} 6 : {} TeacherInfo:---- createAvailableSessionLists createAvailableSessions: teacher id: 2 availableSessions for teacher id: 2 0 : {} 1 : {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11} 2 : {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11} 3 : {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11} 4 : {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11} 5 : {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11} 6 : {} TeacherInfo:---- createAvailableSessionLists createAvailableSessions: teacher id: 10001 availableSessions for teacher id: 10001 0 : {} 1 : {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11} 2 : {4, 5, 6, 7} 3 : {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11} 4 : {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11} 5 : {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11} 6 : {} and found sessions look like this: Session info printed as: TeacherId : ClassPeriod : SessionIndex : SessionId Found sessions for Sunday: -- None. -- Found sessions for Monday: [1:1:0:1] [2:1:1:2] [10001:2:2:3] Found sessions for Tuesday: [2:2:2:3] [1:2:3:4] [10001:3:4:5] Found sessions for Wednesday: [2:1:0:1] [1:1:1:2] [10001:2:2:3] Found sessions for Thursday: [1:1:0:1] [2:1:1:2] [10001:2:2:3] Found sessions for Friday: [1:1:0:1] [2:1:1:2] [10001:2:2:3] Found sessions for Saturday: -- None. -- Results look OK. 3. I now disable period 3 for 10001. This should force afternoon sessions on Tuesdays. Results: Oops: period 4 is sessions 6 and 7, which are still morning. I will try enabling period 5 and disabling period 4: Results: availableSessions for teacher id: 10001 0 : {} 1 : {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11} 2 : {8, 9} 3 : {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11} 4 : {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11} 5 : {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11} 6 : {} and found sessions: Found sessions for Sunday: -- None. -- Found sessions for Monday: [2:1:0:1] [1:1:1:2] [10001:2:2:3] Found sessions for Tuesday: [1:5:9:10] [2:6:10:11] Found sessions for Wednesday: [1:1:0:1] [2:1:1:2] [10001:2:2:3] Found sessions for Thursday: [2:1:0:1] [1:1:1:2] [10001:2:2:3] Found sessions for Friday: [2:1:0:1] [1:1:1:2] [10001:2:2:3] Found sessions for Saturday: -- None. -- Now, this seems like giving up too easily: seems that, in any case: session 8 and 9 for 10001 could have been used to make 3 found sessions on Tuesdays. As a matter of fact, this was a problem in the algorithm for finding sessions. I think I have corrected it, but it makes the algorithm considerably less efficient; we'll have to see how it does with a lot of opted-in teachers. 4. I am retesting with speaker id 10268: previously it had been 2. I deleted all the other presentations for 10268: they were all for school 20002, but still. Now I'm going to first try disabling (disallowing) period 5 for teacher 1. Results: availableSessions for teacher id: 1 0 : {} 1 : {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11} 2 : {0, 1, 2, 3, 4, 5, 6, 7, 10, 11} 3 : {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11} 4 : {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11} 5 : {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11} 6 : {} and found sessions: Session info printed as: TeacherId : ClassPeriod : SessionIndex : SessionId Found sessions for Sunday: -- None. -- Found sessions for Monday: [1:1:0:1] [2:1:1:2] [10001:2:2:3] Found sessions for Tuesday: [10001:5:9:10] [1:6:10:11] [2:6:11:12] Found sessions for Wednesday: [2:1:0:1] [1:1:1:2] [10001:2:2:3] Found sessions for Thursday: [1:1:0:1] [2:1:1:2] [10001:2:2:3] Found sessions for Friday: [1:1:0:1] [2:1:1:2] [10001:2:2:3] Found sessions for Saturday: -- None. -- 5. Now I'll schedule a presentation on a Tuesday for teacher 1 during 6th period, which should knock it out of consideration for this speaker, and give us only two found sessions on Tuesdays. I accidentally added it for teacher 2 instead, which already had 5th period disabled. Here are the results: availableSessions for teacher id: 1 0 : {} 1 : {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11} 2 : {0, 1, 2, 3, 4, 5, 6, 7, 10, 11} 3 : {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11} 4 : {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11} 5 : {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11} 6 : {} TeacherInfo:---- createAvailableSessionLists createAvailableSessions: teacher id: 2 availableSessions for teacher id: 2 0 : {} 1 : {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11} 2 : {0, 1, 2, 3, 4, 5, 6, 7, 10, 11} 3 : {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11} 4 : {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11} 5 : {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11} 6 : {} TeacherInfo:---- createAvailableSessionLists createAvailableSessions: teacher id: 10001 availableSessions for teacher id: 10001 0 : {} 1 : {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11} 2 : {8, 9} 3 : {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11} 4 : {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11} 5 : {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11} 6 : {} found sessions: Session info printed as: TeacherId : ClassPeriod : SessionIndex : SessionId Found sessions for Sunday: -- None. -- Found sessions for Monday: [2:1:0:1] [1:1:1:2] [10001:2:2:3] Found sessions for Tuesday: [1:4:6:7] [2:4:7:8] Found sessions for Wednesday: [1:1:0:1] [2:1:1:2] [10001:2:2:3] Found sessions for Thursday: [2:1:0:1] [1:1:1:2] [10001:2:2:3] Found sessions for Friday: [2:1:0:1] [1:1:1:2] [10001:2:2:3] Found sessions for Saturday: -- None. -- -- OK, here's what I notice: this arrangement should have been possible: teacher 10001 session index 9 teacher 1 or 2: 10 teacher 1 or 2: 11 or same with 8,9,10. But instead the algorithm found 2 in the morning. Well it turns out the algorithm is smarter than I am: teacher 2 is knocked out of the afternoon, because the speaker has a presentation! So the algorithm finds only 2 sessions in the afternoon, and defaults to the morning sessions, as it is programmed to do. Works right so far... 6) Now I'll move that presentation to teacher 1. results: teacher sessions look the same, but: createTeacherSessionLists: assuming week day calculation for dayIndex: 2 createTeacherSessionLists: lowerSessionLimit: 0 upperSessionLimit: 12 teacher 1 excluded from afternoon list because no afternoon sessions available. teacher 10001 excluded from morning list because no morning sessions available. ---------------------- findWeekDayConsecutiveSessions ---------------------------------------------------------- SchoolTeachersCalendarInfo.findWeekDayConsecutiveSessions: looking for morning sessions. on a Tuesday only 2 morning sessions found: looking for afternoon sessions. ---------------------- findWeekDayConsecutiveSessions ---------------------------------------------------------- SchoolTeachersCalendarInfo.findWeekDayConsecutiveSessions: looking for afternoon sessions. on a Tuesday Did no better or worse in the afternoon: taking morning sessions. Morning sessions found: 2 Afternoon sessions found: 0 found sessions: Session info printed as: TeacherId : ClassPeriod : SessionIndex : SessionId Found sessions for Sunday: -- None. -- Found sessions for Monday: [2:1:0:1] [1:1:1:2] [10001:2:2:3] Found sessions for Tuesday: [1:4:6:7] [2:4:7:8] Found sessions for Wednesday: [2:1:0:1] [1:1:1:2] [10001:2:2:3] Found sessions for Thursday: [2:1:0:1] [1:1:1:2] [10001:2:2:3] Found sessions for Friday: [2:1:0:1] [1:1:1:2] [10001:2:2:3] Found sessions for Saturday: -- None. -- 7) Testing for max monthly sessions reached: I'm going to set max for teacher 1 to 2 per month. He already has 1, so this should have absolutely no effect. This was detected: 20080101 : 153 : --- First day of month: : pres. count for month: 1 A sample Tuesday is unaffected: 20080108 : 160 : Enabled : Tuesday : 2 sessions found: [1:4] [2:4] But, on the week of the presentation: ---- First day of week Teacher 1 is at the monthly max: 2 : pres. count for week: 1 Presentations for this week: 20080129:1:6 Teacher: 1 is at weekly limit. Found teacher's session(s) in found sessions... Removing sessions for 1 from session list for weekDayIndex 1 Removing sessions for 1 from session list for weekDayIndex 2 Removing sessions for 1 from session list for weekDayIndex 3 Removing sessions for 1 from session list for weekDayIndex 4 Removing sessions for 1 from session list for weekDayIndex 5 Recomputing found sessions for this week. ---------------------- findWeekDayConsecutiveSessions ---------------------------------------------------------- SchoolTeachersCalendarInfo.findWeekDayConsecutiveSessions: looking for morning sessions. on a Tuesday findWeekDayConsecutiveSessions: there are not enough teachers with available sessions: returning. ... morning sessions not found, now looking for AFTERNOON sessions. ---------------------- findWeekDayConsecutiveSessions ---------------------------------------------------------- SchoolTeachersCalendarInfo.findWeekDayConsecutiveSessions: looking for afternoon sessions. on a Tuesday afternoon sessions not found. ... and the resulting found sessions for the week: Session info printed as: TeacherId : ClassPeriod : SessionIndex : SessionId Found sessions for Sunday: -- None. -- Found sessions for Monday: [2:4:6:7] [10001:4:7:8] Found sessions for Tuesday: -- None. -- Found sessions for Wednesday: [2:4:6:7] [10001:4:7:8] Found sessions for Thursday: [2:4:6:7] [10001:4:7:8] Found sessions for Friday: [2:4:6:7] [10001:4:7:8] Found sessions for Saturday: -- None. -- Using weekly set of found sessions. ...so teacher 1 got taken out of consideraton completely, not because of the monthly limit directly, but because it had forced the weekly limit. So inadvertently I tested the weekly limit test. Previously we had only [1:4] [2:4] on Tuesday, and with teacher 1 out, and teacher 10001 not being considered because of no morning sessions, that left only 2, which wasn't enough to get the minimum number of sessions. That's what it looks like to me: I could be missing something. 8) Now I'm going to schedule another presentation for teacher 1 during January 2008, but on a different week, and that should knock out teacher 1 not just for those two weeks but for the entire month. I schedule one for 20080109 (Wednesday) for session id 6, which is not in the standard found sessions, so it shouldn't affect those. Here are the results: standard found sessions: Session info printed as: TeacherId : ClassPeriod : SessionIndex : SessionId Found sessions for Sunday: -- None. -- Found sessions for Monday: [1:1:0:1] [2:1:1:2] [10001:2:2:3] Found sessions for Tuesday: [1:4:6:7] [2:4:7:8] Found sessions for Wednesday: [1:1:0:1] [2:1:1:2] [10001:2:2:3] Found sessions for Thursday: [1:1:0:1] [2:1:1:2] [10001:2:2:3] Found sessions for Friday: [1:1:0:1] [2:1:1:2] [10001:2:2:3] Found sessions for Saturday: -- None. -- first day of January 2008: 20080101 : 153 : --- First day of month: Teacher 1 is at the monthly max: 2 : pres. count for month: 2 Teacher 1 is at monthly limit. Found teacher's session(s) in found sessions... Removing sessions for 1 from session list for weekDayIndex: 1 Removing sessions for 1 from session list for weekDayIndex: 2 Removing sessions for 1 from session list for weekDayIndex: 3 Removing sessions for 1 from session list for weekDayIndex: 4 Removing sessions for 1 from session list for weekDayIndex: 5 Recomputing monthly found sessions... Session info printed as: TeacherId : ClassPeriod : SessionIndex : SessionId Found sessions for Sunday: -- None. -- Found sessions for Monday: [2:4:6:7] [10001:4:7:8] Found sessions for Tuesday: -- None. -- Found sessions for Wednesday: [2:4:6:7] [10001:4:7:8] Found sessions for Thursday: [2:4:6:7] [10001:4:7:8] Found sessions for Friday: [2:4:6:7] [10001:4:7:8] Found sessions for Saturday: -- None. -- ... I note that teacher 1 is not present in the monthly set of found sessions. On the first day of the week of the 9th (the first presentation): ---- First day of week Teacher 1 is at the monthly max: 2 : pres. count for week: 1 Presentations for this week: 20080109:1:3 Teacher: 1 is at weekly limit. ...teacher not found in sessions, so avoiding recompute. Cool: it doesn't waste its time recomputing! On the first day of the week of the 29th (second presentation): ---- First day of week Teacher 1 is at the monthly max: 2 : pres. count for week: 1 Presentations for this week: 20080129:1:6 Teacher: 1 is at weekly limit. ...teacher not found in sessions, so avoiding recompute. Pointing to monthly found sessions for this week. Using monthly set of found sessions. Found sessions being used this week: Session info printed as: TeacherId : ClassPeriod : SessionIndex : SessionId Found sessions for Sunday: -- None. -- Found sessions for Monday: [2:4:6:7] [10001:4:7:8] Found sessions for Tuesday: -- None. -- Found sessions for Wednesday: [2:4:6:7] [10001:4:7:8] Found sessions for Thursday: [2:4:6:7] [10001:4:7:8] Found sessions for Friday: [2:4:6:7] [10001:4:7:8] Found sessions for Saturday: -- None. -- Looks good. Now, does it return to using the standard (yearly) set of found sessions after January? First day of February 2008: --- First day of month: : pres. count for month: 0 Pointing to standard set of found sessions. Enabled : Friday : 2 sessions found: [2:4] [10001:4] 20080202 : 185 : Disabled 20080203 : 186 : ---- First day of week : pres. count for week: 0 Setting current found sessions to monthly found sessions. Using standard set of found sessions. Found sessions being used this week: Session info printed as: TeacherId : ClassPeriod : SessionIndex : SessionId Found sessions for Sunday: -- None. -- Found sessions for Monday: [1:1:0:1] [2:4:6:7] [10001:4:7:8] Found sessions for Tuesday: [1:4:6:7] [2:4:7:8] Found sessions for Wednesday: [1:1:0:1] [2:4:6:7] [10001:4:7:8] Found sessions for Thursday: [1:1:0:1] [2:4:6:7] [10001:4:7:8] Found sessions for Friday: [1:1:0:1] [2:4:6:7] [10001:4:7:8] Found sessions for Saturday: -- None. -- Looks like it. The first actual week: ---- First day of week : pres. count for week: 0 Setting current found sessions to monthly found sessions. Using standard set of found sessions. Found sessions being used this week: Session info printed as: TeacherId : ClassPeriod : SessionIndex : SessionId Found sessions for Sunday: -- None. -- Found sessions for Monday: [1:1:0:1] [2:4:6:7] [10001:4:7:8] Found sessions for Tuesday: [1:4:6:7] [2:4:7:8] Found sessions for Wednesday: [1:1:0:1] [2:4:6:7] [10001:4:7:8] Found sessions for Thursday: [1:1:0:1] [2:4:6:7] [10001:4:7:8] Found sessions for Friday: [1:1:0:1] [2:4:6:7] [10001:4:7:8] Found sessions for Saturday: -- None. -- Disabled 20080211 : 194 : Enabled : Monday : 3 sessions found: [1:1] [2:4] [10001:4] 20080212 : 195 : Enabled : Tuesday : 2 sessions found: [1:4] [2:4] 20080213 : 196 : Enabled : Wednesday : 3 sessions found: [1:1] [2:4] [10001:4] 20080214 : 197 : Enabled : Thursday : 3 sessions found: [1:1] [2:4] [10001:4] 20080215 : 198 : Enabled : Friday : 3 sessions found: [1:1] [2:4] [10001:4] 20080216 : 199 : Disabled 20080217 : 200 : OK: that looks good. 9) Now I'm going to do a timing test: I'm going to enable a bunch of teachers and see how fast the web version shows the screens. I enabled 12 teachers at the Test High School, and tried scheduling a presentation. The calendar appeared in 5 seconds or so. Really fast; I didn't notice any slowdown. Probably, with so many opted-in teachers, it found sessions without any problem, so even though it potentially had more to search through, it found what it needed quite quickly. So that looks great. 10) I put the opted-in teachers back to the original 3: 1,2, and 10001. Tuesday gets only 2 found sessions because speaker 10268 has presentations for teacher 1 in the afternoon (period 6), so 2 morning sessions are chosen, presumably (I forgot to check this) because it finds 2 in the morning, 2 in the afternoon, and takes the morning by default. I changed the speaker id to 2, and now it finds 3 afternoon sessions for Tuesdays. On the first day of January 2008 (there are 2 presentations for teacher 1 in January): 20080101 : 153 : --- First day of month: Teacher 1 is at the monthly max: 2 : pres. count for month: 2 Teacher 1 is at monthly limit. Found teacher's session(s) in found sessions... Removing sessions for 1 from session list for weekDayIndex: 1 Removing sessions for 1 from session list for weekDayIndex: 2 Removing sessions for 1 from session list for weekDayIndex: 3 Removing sessions for 1 from session list for weekDayIndex: 4 Removing sessions for 1 from session list for weekDayIndex: 5 Recomputing monthly found sessions... ---------------------- findWeekDayConsecutiveSessions ---------------------------------------------------------- SchoolTeachersCalendarInfo.findWeekDayConsecutiveSessions: looking for morning sessions. on a Tuesday findWeekDayConsecutiveSessions: there are not enough teachers with available sessions: returning. ... morning sessions not found, now looking for AFTERNOON sessions. ---------------------- findWeekDayConsecutiveSessions ---------------------------------------------------------- SchoolTeachersCalendarInfo.findWeekDayConsecutiveSessions: looking for afternoon sessions. on a Tuesday afternoon sessions not found. and the monthly found sessions are: Session info printed as: TeacherId : ClassPeriod : SessionIndex : SessionId Found sessions for Sunday: -- None. -- Found sessions for Monday: [2:4:6:7] [10001:4:7:8] Found sessions for Tuesday: -- None. -- Found sessions for Wednesday: [2:4:6:7] [10001:4:7:8] Found sessions for Thursday: [2:4:6:7] [10001:4:7:8] Found sessions for Friday: [2:4:6:7] [10001:4:7:8] Found sessions for Saturday: -- None. -- during the week of the first presentation (jan 9): ---- First day of week Teacher 1 is at the monthly max: 2 : pres. count for week: 1 Presentations for this week: 20080109:1:3 Teacher: 1 is at weekly limit. ...teacher not found in sessions, so avoiding recompute. Pointing to monthly found sessions for this week. Using monthly set of found sessions. Found sessions being used this week: Session info printed as: TeacherId : ClassPeriod : SessionIndex : SessionId Found sessions for Sunday: -- None. -- Found sessions for Monday: [2:4:6:7] [10001:4:7:8] Found sessions for Tuesday: -- None. -- Found sessions for Wednesday: [2:4:6:7] [10001:4:7:8] Found sessions for Thursday: [2:4:6:7] [10001:4:7:8] Found sessions for Friday: [2:4:6:7] [10001:4:7:8] Found sessions for Saturday: -- None. -- ... of course teacher 1 has been taken out of the sessions for the entire month, so no recompute is necessary. I'll try removing one of those presentations, which will affect only the week of the presentation, not the entire month. Here goes: I deleted the 20080109 presentation. Results: --- First day of month: : pres. count for month: 1 tuesday sessions: Found sessions for Tuesday: [10001:5:9:10] [2:6:10:11] [1:6:11:12] -- week of 20080109: ---- First day of week : pres. count for week: 0 Setting current found sessions to monthly found sessions. Using standard set of found sessions. -- week of 20080129: ---- First day of week Teacher 1 is at the monthly max: 2 : pres. count for week: 1 Presentations for this week: 20080129:1:6 Teacher: 1 is at weekly limit. Found teacher's session(s) in found sessions... Removing sessions for 1 from session list for weekDayIndex 1 Removing sessions for 1 from session list for weekDayIndex 2 Removing sessions for 1 from session list for weekDayIndex 3 Removing sessions for 1 from session list for weekDayIndex 4 Removing sessions for 1 from session list for weekDayIndex 5 Recomputing found sessions for this week. Found sessions: Session info printed as: TeacherId : ClassPeriod : SessionIndex : SessionId Found sessions for Sunday: -- None. -- Found sessions for Monday: [2:4:6:7] [10001:4:7:8] Found sessions for Tuesday: -- None. -- Found sessions for Wednesday: [2:4:6:7] [10001:4:7:8] Found sessions for Thursday: [2:4:6:7] [10001:4:7:8] Found sessions for Friday: [2:4:6:7] [10001:4:7:8] Found sessions for Saturday: -- None. -- Using weekly set of found sessions. -- why none on Tuesday? this is all it said: ---------------------- findWeekDayConsecutiveSessions ---------------------------------------------------------- SchoolTeachersCalendarInfo.findWeekDayConsecutiveSessions: looking for morning sessions. on a Tuesday findWeekDayConsecutiveSessions: there are not enough teachers with available sessions: returning. ... morning sessions not found, now looking for AFTERNOON sessions. ---------------------- findWeekDayConsecutiveSessions ---------------------------------------------------------- SchoolTeachersCalendarInfo.findWeekDayConsecutiveSessions: looking for afternoon sessions. on a Tuesday afternoon sessions not found. standard (monthly & yearly) Tuesday sessions look like this: 20080108 : 160 : Enabled : Tuesday : 3 sessions found: [10001:5] [2:6] [1:6] (Found sessions for Tuesday: [10001:5:9:10] [2:6:10:11] [1:6:11:12]) .. teacher 1 is out for this entire week, so why wouldn't [10001:5:9:10] [2:6:10:11] work? is there some problem with the algorithm not returning the min sessions? OK: yes, there was a problem with the algorithm: "minSessionsFound" wasn't getting set, but was getting tested for, so it was false when there really were 2 sessions (the minimum) found. So I disabled that boolean variable and just tested for the size of the foundSessions list instead. Results: Found sessions for Tuesday: [10001:5:9:10] [2:6:10:11] Another patch... I don't see a reason to go back and test, because the test for the size is the same: or is it? Could it prematurely return the minimum number of sessions in some cases? Maybe: this is a danger. Note: I discovered that this patch breaks the first patch I made, the one to use passes, because it quits too soon: I only did that test for the boolean to escape another loop. It made the test too general. So I made some more modifications, and am testing them. It seems that the second problem still exists: I used speaker id 10268: one presentation scheduled on Tuesday 20080129 for session id 12 (period 6) for teacher 1 The week of 20080129 there were no Tuesday sessions found. Teacher 1 is out of consideration that whole week because the weekly max is met. But that leaves teachers 2 and 10001. 10001 has only period 5, and teacher 2 has everything except period 5. So it seems to me that 2 sessions could be found. I must debug. OK: new fix: I kind of combined the two fixes: I did the test for the size of the found sessions, but didn't break because of it: I just saved the sessions. Then I avoided any early returns, and so at the end I checked to see if a set of saved "found minimum sessions" had a size equal to the minimum number of sessions, and if so, I returned those. I tested for: speaker 10268, who had a presentation for teacher 1 on 20080129 (Tuesday), during 6th period. found 2 alternate sessions on Tuesday during that week: formerly none were found. also tested: speaker 2, who had no presentations. formerly only 2 Tuesday sessions were found in the standard set: now 3 are found. On the week of the presentation (20080129), 2 Tuesday sessions are found. That all looks good, I think. 11) I disabled all sessions on Wednesdays for teacher 1, and reran the application. Teacher 1's sessions disappeared from Wednesday sessions. 12) I chose a day, 23 April, and disabled that for teacher 1: ordinarily the free sessions were: 20080423 : 266 : Enabled : Wednesday : 3 sessions found: [1:1] [2:1] [10001:2] After disabling the date: 20080423 : 266 : Enabled : Wednesday : date excluded by teacher(s): 1:Removing teacher: 1 sessions from list. ---------------------- findWeekDayConsecutiveSessions ---------------------------------------------------------- SchoolTeachersCalendarInfo.findWeekDayConsecutiveSessions: looking for morning sessions. on a Wednesday passCountDown: 1 foundSessions size: 2 --- but found minimum number of sessions, so returning those. : 2 sessions still found. : 2 sessions found: [10001:4] [2:4] -- You would think that it could just use the other sessions: [2:1] [10001:2], but it doesn't do it that way: it removes the teacher id and completely recomputes the free sessions for that day. So I guess what it came up with is OK. -- The real problem is, it keeps that set of Wednesday sessions for the rest of the year! Evidently it modified the actual set of week tables, instead of making a copy for that week, or that day. So for the next week we see this: 20080427 : 270 : ---- First day of week : pres. count for week: 0 Setting current found sessions to monthly found sessions. Using standard set of found sessions. Found sessions being used this week: Session info printed as: TeacherId : ClassPeriod : SessionIndex : SessionId Found sessions for Sunday: -- None. -- Found sessions for Monday: [1:1:0:1] [2:1:1:2] [10001:2:2:3] Found sessions for Tuesday: [2:4:6:7] [1:4:7:8] Found sessions for Wednesday: [10001:4:6:7] [2:4:7:8] Found sessions for Thursday: [1:1:0:1] [2:1:1:2] [10001:2:2:3] Found sessions for Friday: [1:1:0:1] [2:1:1:2] [10001:2:2:3] Found sessions for Saturday: -- None. -- -- Note: only two sessions on Wednesday, and no sessions with teacher 1. First day of the next month (May 2008): 20080501 : 274 : --- First day of month: : pres. count for month: 0 Pointing to standard set of found sessions. Enabled : Thursday : 3 sessions found: [1:1] [2:1] [10001:2] 20080502 : 275 : Enabled : Friday : 3 sessions found: [1:1] [2:1] [10001:2] 20080503 : 276 : Disabled 20080504 : 277 : ---- First day of week : pres. count for week: 0 Setting current found sessions to monthly found sessions. Using standard set of found sessions. Found sessions being used this week: Session info printed as: TeacherId : ClassPeriod : SessionIndex : SessionId Found sessions for Sunday: -- None. -- Found sessions for Monday: [1:1:0:1] [2:1:1:2] [10001:2:2:3] Found sessions for Tuesday: [2:4:6:7] [1:4:7:8] Found sessions for Wednesday: [10001:4:6:7] [2:4:7:8] Found sessions for Thursday: [1:1:0:1] [2:1:1:2] [10001:2:2:3] Found sessions for Friday: [1:1:0:1] [2:1:1:2] [10001:2:2:3] Found sessions for Saturday: -- None. -- -- It says it's using the standard set, but note: 2 Wednesday sessions, no teacher 1. So somehow the yearly standard set of week sessions got changed. I need to check this.... I found a note at the bottom of the routine that handles the single day processing (handleDayExcludedTeachers), which suggested cloning the day's found sessions because when they are added to the hash list they might change later. That is, if a fixed address which is reused is added, and new and different stuff is added to that fixed address, then the previously added info will change too. So I added a clone, but to the currentWeekFoundSessions. That doesn't seem to have helped: it still changed the set of weekly sessions being used. What I need to do is recognize, either at the beginning of the week, or just return the sessions for that day and not modify the week's settings. Let me see... -- OK, I think I fixed that, by saving the original day sessions and replacing them afterwards. I'm not sure I like this fix: it might be better to use a set of day sessions, which are either the originals or the recomputed set. But for now, the problem looks fixed. 13) I'm going to disable that same day for teacher 2, and see what happens. There's no way that enough sessions can be found: this test should also be done with more enabled teachers. But for this situation: 20080423 : 266 : Enabled : Wednesday : date excluded by teacher(s): 2:Removing teacher: 2 sessions from list. ---------------------- findWeekDayConsecutiveSessions ---------------------------------------------------------- SchoolTeachersCalendarInfo.findWeekDayConsecutiveSessions: looking for morning sessions. on a Wednesday passCountDown: 1 foundSessions size: 2 --- but found minimum number of sessions, so returning those. : 2 sessions still found. : 2 sessions found: [10001:4] [1:4] -- Note that this did not work: it ignored that teacher 1 also had the date excluded. Either it's not in the list, or it didn't go through the whole list. Let me see... OK, I think I found the problem: I wasn't changing "previousDate" so it was always the original value of 0. A new list would get created for the same date, and have only one teacher in it: the last one. After the correction I see: 20080423 : 266 : Enabled : Wednesday : date excluded by teacher(s): 1:Removing teacher: 1 sessions from list. 2:Removing teacher: 2 sessions from list. ---------------------- findWeekDayConsecutiveSessions ---------------------------------------------------------- SchoolTeachersCalendarInfo.findWeekDayConsecutiveSessions: looking for morning sessions. on a Wednesday findWeekDayConsecutiveSessions: there are not enough teachers with available sessions: returning. ---------------------- findWeekDayConsecutiveSessions ---------------------------------------------------------- SchoolTeachersCalendarInfo.findWeekDayConsecutiveSessions: looking for afternoon sessions. on a Wednesday findWeekDayConsecutiveSessions: there are not enough teachers with available sessions: returning. : no sessions after teacher removal. : 3 sessions found: [1:1] [2:1] [10001:2] -- Looks great up until the end, then: what? three sessions found? It just said no teacher sessions! I'm not sure if this is a bogus message or what. Let me see... ... Maybe it's from that restoration of the original sessions. Let me check some more... Yes, it's just something like that. I'll think about it more in the morning. (20080204 3 AM)