weekdaze-0.0.0.3: A school-timetable problem-solver.

Safe HaskellNone
LanguageHaskell2010

WeekDaze.Model.TimetableForDay

Contents

Description

AUTHOR
Dr. Alistair Ward
DESCRIPTION
  • Define the data-structure, required to hold a single day's bookings, for any observer-id.
  • It doesn't reference the parameters of the specific problem, or the means by which a solution is obtained.
Synopsis

Types

Type-synonyms

type TimetableForDay timeslotId resourceIds level = Array timeslotId (GeneralisedLesson resourceIds level) Source #

  • The ordered sequence of time-slots within a single unspecified day.
  • The sequence of time-slots are contiguous; double lessons are representated by consecutive duplicate lesson-definitions, free-periods are represented by Nothing.
  • Each time-slot has a specific unspecified start-time & probably a constant duration; but that depends on the school, so no such assumption is made here.

type Association timeslotId resourceIds level = (timeslotId, GeneralisedLesson resourceIds level) Source #

The association on which TimetableForDay is based.

type Booking timeslotId resourceIds level = (timeslotId, Lesson resourceIds level) Source #

A lesson qualified by the time-slot at which it is booked.

type GeneralisedLessonRunlength resourceIds level = Code (GeneralisedLesson resourceIds level) Source #

A runlength-encoded list of generalised (i.e. potentially undefined) lesson.

type GeneralisedLessonRunlengthByTimeslotId timeslotId resourceIds level = [(timeslotId, GeneralisedLessonRunlength resourceIds level)] Source #

An association-list keyed by the starting timeslotId, of runlength-encoded generalised (i.e. potentially undefined) lessons.

type LessonRunlengths resourceIds level = [Code (Lesson resourceIds level)] Source #

A runlength-encoded list of lessons.

type RunlengthsByTimeslotIdByLesson resourceIds level timeslotId = [(Lesson resourceIds level, [(timeslotId, NTimeslots)])] Source #

A list associated by lesson, of lists associated by timeslotId.

Constants

Functions

measureRunlengthAt Source #

Arguments

:: (Ix timeslotId, Enum timeslotId, Eq resourceIds, Eq level) 
=> timeslotId

The identifier of the time-slot at which to measure the run-length of equal lessons.

-> TimetableForDay timeslotId resourceIds level 
-> (Interval timeslotId, NTimeslots) 
  • Defines the (lower & upper) bounds, & measures the span-length, of adjacent lessons, equal to that referenced.
  • CAVEAT: if an undefined time-slot is referenced, then the run-length of undefined time-slots will be measured.

boundRunlengthAt Source #

Arguments

:: (Ix timeslotId, Enum timeslotId, Eq resourceIds, Eq level) 
=> timeslotId

The identifier of the time-slot at which to measure the run-length of equal lessons.

-> TimetableForDay timeslotId resourceIds level 
-> Interval timeslotId 

Defines the timeslotId-interval, delimiting the span of adjacent lessons, equal to that referenced.

countRunlengthAt Source #

Arguments

:: (Ix timeslotId, Enum timeslotId, Eq resourceIds, Eq level) 
=> timeslotId

The identifier of the time-slot at which to measure the run-length of equal lessons.

-> TimetableForDay timeslotId resourceIds level 
-> NTimeslots 

Measures the length of the span of adjacent lessons, equal to that referenced.

countUnallocatedTimeslots :: Ix timeslotId => TimetableForDay timeslotId resourceIds level -> NTimeslots Source #

  • Counts the time-slots which haven't been yet booked.
  • CAVEAT: doesn't account for the availability of the resource, or whether any time-slots has been reserved for meetings.

bisectAt :: Ix timeslotId => timeslotId -> TimetableForDay timeslotId resourceIds level -> ([Association timeslotId resourceIds level], [Association timeslotId resourceIds level]) Source #

  • Bisect the association-list extracted from the TimetableForDay, at the specified timeslotId, to form two lists, those before & those after the specified time-slot.
  • The list of earlier time-slots is reversed, as though looking backwards from the specified time-slot.
  • CAVEAT: the association at the specified timeslotId isn't returned in either half.

extractAdjacentBookings :: Ix timeslotId => timeslotId -> TimetableForDay timeslotId resourceIds level -> [Booking timeslotId resourceIds level] Source #

  • Get any lessons immediately adjacent to the specified time-slot.
  • The relevance is that adjacent lessons can typically be replicated, to form a longer duration lesson, but duplication of a non-adjacent one, would leave an awkward gap.

locateUnallocatedTimeslots :: Ix timeslotId => TimetableForDay timeslotId resourceIds level -> [timeslotId] Source #

  • Identifies unallocated time-slots.
  • CAVEAT: doesn't account for the availability of the resource, or whether any time-slots has been reserved for meetings.

findGeneralisedLessonRunlengths :: (Ix timeslotId, Eq resourceIds, Eq level) => TimetableForDay timeslotId resourceIds level -> GeneralisedLessonRunlengths resourceIds level Source #

  • Measures run-lengths of consecutive equal generalised (i.e. potentially undefined) lessons.
  • Includes consecutive unallocated time-slots & trivial sequences of length one.
  • CAVEAT: the coordinates of each runlength aren't explicit; see findGeneralisedLessonRunlengthsByTimeslotId.

findGeneralisedLessonRunlengthsByTimeslotId :: (Ix timeslotId, Enum timeslotId, Eq resourceIds, Eq level) => TimetableForDay timeslotId resourceIds level -> GeneralisedLessonRunlengthByTimeslotId timeslotId resourceIds level Source #

Calls findGeneralisedLessonRunlengths & derives the coordinates of the start of each runlength.

findSeparatedEqualLessons :: (Ix timeslotId, Ord resourceIds, Ord level) => TimetableForDay timeslotId resourceIds level -> LessonRunlengths resourceIds level Source #

  • Finds separated equal lessons; separated unallocated time-slots don't qualify.
  • CAVEAT: discards the coordinates at which each lesson was booked.

findSeparatedEqualSubjectLessons :: (Ix timeslotId, Eq resourceIds, Ord level) => TimetableForDay timeslotId resourceIds level -> LessonRunlengths resourceIds level Source #

  • Finds separated lessons of equal subject.
  • CAVEAT: discards the coordinates at which each lesson was booked.

findSeparatedEqualLessonRunlengthsByStartingTimeslotIdByLesson :: (Ix timeslotId, Ord resourceIds, Ord level) => TimetableForDay timeslotId resourceIds level -> RunlengthsByTimeslotIdByLesson resourceIds level timeslotId Source #

  • Finds runlengths of separated equal lessons; separated unallocated time-slots don't qualify.
  • Returns a list associated by the common lesson, of lists associated by starting timeslotId, of runlengths.

measureFreePeriodCompliance Source #

Arguments

:: (Ix timeslotId, Fractional ratio) 
=> FreePeriodPreference 
-> Set timeslotId

The timeslotIds of meetings, for the groups of which this observer is a member.

-> TimetableForDay timeslotId resourceIds level 
-> ratio 

Measure the ratio of those free (neither reserved for a meeting nor booked with a lesson) time-slots which comply with the specified preference, to the total number of free time-slots.

spanRunlengthAt Source #

Arguments

:: (Ix timeslotId, Enum timeslotId, Eq resourceIds, Eq level) 
=> timeslotId

The identifier of the time-slot at which to measure the run-length of equal lessons.

-> TimetableForDay timeslotId resourceIds level 
-> [timeslotId] 

Returns the list of timeslotIds where lessons equal to that referenced, are booked.

Accessors

getTimeslotId :: Association timeslotId resourceIds level -> timeslotId Source #

Accessor.

getMaybeLesson :: Association timeslotId resourceIds level -> GeneralisedLesson resourceIds level Source #

Accessor.

getBookedLesson :: Booking timeslotId resourceIds level -> Lesson resourceIds level Source #

Accessor.

Constructor

mkFreeTimetableForDay :: (Ix timeslotId, Enum timeslotId) => Interval timeslotId -> TimetableForDay timeslotId resourceIds level Source #

Constructor. Create an unallocated timetable, for any single day.

Mutators

defineTimeslot :: Ix timeslotId => Association timeslotId resourceIds level -> TimetableForDay timeslotId resourceIds level -> TimetableForDay timeslotId resourceIds level Source #

Define a single lesson in the timetable.

Predicates

isSubjectBooked :: Eq level => Subject level -> TimetableForDay timeslotId resourceIds level -> Bool Source #

True if the specified subject has already been booked at any time-slot in today's timetable.

isDefined :: Association timeslotId resourceIds level -> Bool Source #

True if the time-slot has been booked.

Translation

xpickle :: (Ix timeslotId, XmlPickler level, XmlPickler resourceIds, XmlPickler timeslotId, Show level) => PU (TimetableForDay timeslotId resourceIds level) Source #

Defines a pickler to convert the specified timetable to, or from, XML.