Safe Haskell | None |
---|---|
Language | Haskell2010 |
AUTHOR
- Dr. Alistair Ward
DESCRIPTION
- Describes a
Map
ofTimetableForWeek
. - This is the shape of a generic timetable, from which specific instances; indexed by either student-bodies, teacher-ids or location-ids; can be built.
- It doesn't reference the parameters of the specific problem, or the means by which a solution is obtained.
Synopsis
- type Timetable observerId timeslotId resourceIds level = Map observerId (TimetableForWeek timeslotId resourceIds level)
- type AugmentMarkup = Bool
- type GenericTimetableToMarkup locationId minimumContrastRatio teacherId timeslotId timetable = AugmentMarkup -> GenericTimetableToMarkup' locationId minimumContrastRatio teacherId timeslotId timetable
- type Booking observerId timeslotId resourceIds level = (Coordinates observerId timeslotId, Lesson resourceIds level)
- newtype Wrapper observerId timeslotId resourceIds level = MkWrapper {
- deconstruct :: Timetable observerId timeslotId resourceIds level
- tag :: String
- calculateAverageAbsoluteDeviationOfFreeLessonsPerDay :: (Ix timeslotId, Resource resource, Fractional average, Ord observerId) => ResourceMap observerId resource -> Timetable observerId timeslotId resourceIds level -> average
- calculateUtilisationRatioByObserverId :: (Ix timeslotId, HumanResource resource, Fractional teachingRatio, Ord observerId) => ResourceMap observerId resource -> NTimeslots -> Timetable observerId timeslotId resourceIds level -> Map observerId teachingRatio
- locateUnallocatedAvailableUnreservedCoordinates :: (Ix timeslotId, Resource resource, Ord observerId) => Map (Time timeslotId) (Set observerId) -> ResourceMap observerId resource -> Timetable observerId timeslotId resourceIds level -> Vector observerId timeslotId
- findGeneralisedLessonRunlengthsByTimeslotIdByDayByObserverId :: (Ix timeslotId, Enum timeslotId, Eq resourceIds, Eq level) => Timetable observerId timeslotId resourceIds level -> Map observerId (GeneralisedLessonRunlengthByTimeslotIdByDay timeslotId resourceIds level)
- findGeneralisedLessonRunlengthsByCoordinates :: (Ix timeslotId, Enum timeslotId, Eq resourceIds, Eq level) => Timetable observerId timeslotId resourceIds level -> [(Coordinates observerId timeslotId, GeneralisedLessonRunlength resourceIds level)]
- findSeparatedEqualLessonsWithinAnyDayByObserverId :: (Ix timeslotId, Ord level, Ord resourceIds) => Timetable observerId timeslotId resourceIds level -> Map observerId (LessonRunlengths resourceIds level)
- findSeparatedEqualLessonRunlengthsByStartingTimeslotIdByLessonByDayByObserverId :: (Ix timeslotId, Ord level, Ord resourceIds) => Timetable observerId timeslotId resourceIds level -> Map observerId (RunlengthsByTimeslotIdByLessonByDay resourceIds level timeslotId)
- countLessons :: Ix timeslotId => Timetable observerId timeslotId resourceIds level -> NTimeslots
- countUnallocatedAvailableTimeslots :: (Ix timeslotId, Resource resource, Ord observerId) => ResourceMap observerId resource -> Timetable observerId timeslotId resourceIds level -> NTimeslots
- extractLessons :: Ix timeslotId => Timetable observerId timeslotId resourceIds level -> [Lesson resourceIds level]
- extractCoordinates :: Ix timeslotId => Timetable observerId timeslotId resourceIds level -> [Coordinates observerId timeslotId]
- extractDistinctLessons :: (Ix timeslotId, Ord resourceIds, Ord level) => Timetable observerId timeslotId resourceIds level -> Set (Lesson resourceIds level)
- extractSynchronousLessonsAt :: Ix timeslotId => Time timeslotId -> Timetable observerId timeslotId resourceIds level -> [Lesson resourceIds level]
- calculateMeanFreePeriodCompliance :: (Ix timeslotId, HumanResource humanResource, Resource humanResource, Fractional ratio, Ord observerId) => ResourceMap observerId humanResource -> (humanResource -> TimeSet timeslotId) -> Timetable observerId timeslotId resourceIds level -> ratio
- mkFreeTimetable :: (Ix timeslotId, Enum timeslotId, Ord observerId) => [observerId] -> Interval timeslotId -> Timetable observerId timeslotId resourceIds level
- getMaybeLesson :: (Ix timeslotId, Ord observerId) => Coordinates observerId timeslotId -> Timetable observerId timeslotId resourceIds level -> GeneralisedLesson resourceIds level
- getBookedCoordinates :: Booking observerId timeslotId resourceIds level -> Coordinates observerId timeslotId
- getBookedLesson :: Booking observerId timeslotId resourceIds level -> Lesson resourceIds level
- defineTimeslot :: (Ix timeslotId, Ord observerId) => GeneralisedBooking observerId timeslotId resourceIds level -> Timetable observerId timeslotId resourceIds level -> Timetable observerId timeslotId resourceIds level
- undefineTimeslot :: (Ix timeslotId, Ord observerId) => Coordinates observerId timeslotId -> Timetable observerId timeslotId resourceIds level -> Timetable observerId timeslotId resourceIds level
- undefineTimeslots :: (Ix timeslotId, Foldable foldable, Ord observerId) => Timetable observerId timeslotId resourceIds level -> foldable (Coordinates observerId timeslotId) -> Timetable observerId timeslotId resourceIds level
- undefineTimeslotsFor :: (Ix timeslotId, Foldable foldable, Ord observerId) => observerId -> Timetable observerId timeslotId resourceIds level -> foldable (Time timeslotId) -> Timetable observerId timeslotId resourceIds level
- purge :: (Ix timeslotId, Enum timeslotId, Ord observerId) => Timetable observerId timeslotId resourceIds level -> Timetable observerId timeslotId resourceIds level
- isDefinedTimeslot :: (Ix timeslotId, Ord observerId) => Coordinates observerId timeslotId -> Timetable observerId timeslotId resourceIds level -> Bool
- areMergeableWith :: (Ix timeslotId, Eq resourceIds, Eq level, ResourceUser resourceIds) => Booking timeslotId resourceIds level -> Timetable observerId timeslotId resourceIds level -> Bool
- hasMatchingLessonAt :: (Ix timeslotId, Ord observerId) => (Lesson resourceIds level -> Bool) -> Coordinates observerId timeslotId -> Timetable observerId timeslotId resourceIds level -> Bool
- isBookedWith :: (Ix timeslotId, Eq level, Eq resourceIds, Ord observerId) => Booking observerId timeslotId resourceIds level -> Timetable observerId timeslotId resourceIds level -> Bool
- toGeneralisedBooking :: Booking observerId timeslotId resourceIds level -> GeneralisedBooking observerId timeslotId resourceIds level
Types
Type-synonyms
type Timetable observerId timeslotId resourceIds level = Map observerId (TimetableForWeek timeslotId resourceIds level) Source #
- A map of weekly timetables, indexed by the observer-Id for whom it is intended.
- One can visualise this as a 3-D structure, indexed by observer-Id, day, & timeslot-Id, optionally defining a lesson at each coordinate.
- The type of the observer-Id & of the resource-Ids referenced in each lesson, depend on the perspective from which the polymorphic timetable was designed to be viewed: if viewed by a student, then the observer-Id is a student-body, & the resource-Ids are location-Id & teacher-Id; if viewed by a teacher, then the observer-Id is a teacher-Id, & the resource-Ids are location-Id & student-body; if viewed by a location, then the observer-Id is a location-Id, & the resource-Ids are student-body & teacher-Id.
type AugmentMarkup = Bool Source #
Whether to augment the marked-up output with supplementary information.
type GenericTimetableToMarkup locationId minimumContrastRatio teacherId timeslotId timetable = AugmentMarkup -> GenericTimetableToMarkup' locationId minimumContrastRatio teacherId timeslotId timetable Source #
For use when converting any timetable-view to XHTML.
type Booking observerId timeslotId resourceIds level = (Coordinates observerId timeslotId, Lesson resourceIds level) Source #
A lesson qualified by the coordinates at which it is booked.
newtype Wrapper observerId timeslotId resourceIds level Source #
A dummy type on which to hang instance-definitions.
MkWrapper | |
|
Instances
(Ix timeslotId, XmlPickler level, XmlPickler observerId, XmlPickler resourceIds, XmlPickler timeslotId, Ord observerId, Show level) => XmlPickler (Wrapper observerId timeslotId resourceIds level) Source # | |
Defined in WeekDaze.Model.Timetable |
Constants
Functions
calculateAverageAbsoluteDeviationOfFreeLessonsPerDay :: (Ix timeslotId, Resource resource, Fractional average, Ord observerId) => ResourceMap observerId resource -> Timetable observerId timeslotId resourceIds level -> average Source #
- Calculates the average over all observer-Ids, of the average over the days in the week on which the observer is actually available, of the absolute deviation (https://en.wikipedia.org/wiki/Absolute_deviation#Average_absolute_deviation), in the number of free-periods.
- CAVEAT: includes in the count, those time-slots allocated for meetings.
calculateUtilisationRatioByObserverId :: (Ix timeslotId, HumanResource resource, Fractional teachingRatio, Ord observerId) => ResourceMap observerId resource -> NTimeslots -> Timetable observerId timeslotId resourceIds level -> Map observerId teachingRatio Source #
The number of lessons booked for each observer, relative to the required limit of their teaching-time;
based on calculateUtilisationRatio
.
locateUnallocatedAvailableUnreservedCoordinates Source #
:: (Ix timeslotId, Resource resource, Ord observerId) | |
=> Map (Time timeslotId) (Set observerId) | Those observerIds booked for a meeting, indexed by time. |
-> ResourceMap observerId resource | The resources, from which one can determine availability. |
-> Timetable observerId timeslotId resourceIds level | |
-> Vector observerId timeslotId |
Locates unallocated coordinates in the specified timetable, omitting any days on which the observerId is unavailable, & any coordinates reserved by the observerId for a meeting.
findGeneralisedLessonRunlengthsByTimeslotIdByDayByObserverId :: (Ix timeslotId, Enum timeslotId, Eq resourceIds, Eq level) => Timetable observerId timeslotId resourceIds level -> Map observerId (GeneralisedLessonRunlengthByTimeslotIdByDay timeslotId resourceIds level) Source #
Finds runlengths of consecutive equal generalised (i.e. potentially undefined) lessons, & the run-length of each sequence, indexed by observerId, day & timeslotId.
findGeneralisedLessonRunlengthsByCoordinates :: (Ix timeslotId, Enum timeslotId, Eq resourceIds, Eq level) => Timetable observerId timeslotId resourceIds level -> [(Coordinates observerId timeslotId, GeneralisedLessonRunlength resourceIds level)] Source #
Calls findGeneralisedLessonRunlengthsByTimeslotIdByDayByObserverId
, & flattens the results.
findSeparatedEqualLessonsWithinAnyDayByObserverId :: (Ix timeslotId, Ord level, Ord resourceIds) => Timetable observerId timeslotId resourceIds level -> Map observerId (LessonRunlengths resourceIds level) Source #
Finds runlengths of separated equal lessons, within the timetable for any single day.
findSeparatedEqualLessonRunlengthsByStartingTimeslotIdByLessonByDayByObserverId :: (Ix timeslotId, Ord level, Ord resourceIds) => Timetable observerId timeslotId resourceIds level -> Map observerId (RunlengthsByTimeslotIdByLessonByDay resourceIds level timeslotId) Source #
- Finds runlengths of separated equal lessons, within the timetable for any single day; separated unallocated time-slots don't count.
- Returns a map indexed by observerId, of arrays indexed by day, of lists associated by common lesson, of lists associated by starting timeslotId, of runlengths.
countLessons :: Ix timeslotId => Timetable observerId timeslotId resourceIds level -> NTimeslots Source #
Counts the number of lessons booked.
countUnallocatedAvailableTimeslots :: (Ix timeslotId, Resource resource, Ord observerId) => ResourceMap observerId resource -> Timetable observerId timeslotId resourceIds level -> NTimeslots Source #
- Counts the total number of unallocated time-slots, across all observers in one week (i.e. the whle timetable); discounting those when the observer is unavailable.
- CAVEAT: this function takes no account of the possibility that when the observer represents a student-body, some time-slots may be allocated to unsupervised study, & the remainder must be multiplied by the number of members in the student-body.
extractLessons :: Ix timeslotId => Timetable observerId timeslotId resourceIds level -> [Lesson resourceIds level] Source #
Extracts the lessons from the specified timetable, by discarding the coordinates at which each was booked.
extractCoordinates :: Ix timeslotId => Timetable observerId timeslotId resourceIds level -> [Coordinates observerId timeslotId] Source #
Extract the list of all coordinates in the specified timetable.
extractDistinctLessons :: (Ix timeslotId, Ord resourceIds, Ord level) => Timetable observerId timeslotId resourceIds level -> Set (Lesson resourceIds level) Source #
Extracts the set of distinct lessons from the specified timetable.
extractSynchronousLessonsAt :: Ix timeslotId => Time timeslotId -> Timetable observerId timeslotId resourceIds level -> [Lesson resourceIds level] Source #
- Extracts a core of synchronous events, by drilling through the timetable for all observer-Ids, at the specified time.
- The observer-ids are discarded, rendering the results anonymous.
- CAVEAT: performance-hotspot.
calculateMeanFreePeriodCompliance Source #
:: (Ix timeslotId, HumanResource humanResource, Resource humanResource, Fractional ratio, Ord observerId) | |
=> ResourceMap observerId humanResource | A map of resources by observerId. |
-> (humanResource -> TimeSet timeslotId) | A function which returns the times of the meetings, for all groups of which this human-resource is a member. |
-> Timetable observerId timeslotId resourceIds level | |
-> ratio |
Calculates the mean, over those days on which the resource is available, of the ratio of those free (neither booked with a lesson, not reserved for a meeting) time-slots which comply with the specified preference, to the total number of free time-slots.
Constructor
mkFreeTimetable :: (Ix timeslotId, Enum timeslotId, Ord observerId) => [observerId] -> Interval timeslotId -> Timetable observerId timeslotId resourceIds level Source #
- Constructor.
- Creates an unallocated weekly timetable, for each of the specified list of generic observer-Ids; i.e. locations, student-bodies or teacher-ids.
- Each daily timetable has the specified list of timeslots-Ids, into which a lesson can be booked.
Accessors
getMaybeLesson :: (Ix timeslotId, Ord observerId) => Coordinates observerId timeslotId -> Timetable observerId timeslotId resourceIds level -> GeneralisedLesson resourceIds level Source #
Get any lesson booked at the specified coordinates.
getBookedCoordinates :: Booking observerId timeslotId resourceIds level -> Coordinates observerId timeslotId Source #
Accessor.
getBookedLesson :: Booking observerId timeslotId resourceIds level -> Lesson resourceIds level Source #
Accessor.
Mutators
defineTimeslot :: (Ix timeslotId, Ord observerId) => GeneralisedBooking observerId timeslotId resourceIds level -> Timetable observerId timeslotId resourceIds level -> Timetable observerId timeslotId resourceIds level Source #
Overwrites any lesson defined at the specified coordinates.
undefineTimeslot :: (Ix timeslotId, Ord observerId) => Coordinates observerId timeslotId -> Timetable observerId timeslotId resourceIds level -> Timetable observerId timeslotId resourceIds level Source #
Undefine the lesson, at the specified coordinates.
:: (Ix timeslotId, Foldable foldable, Ord observerId) | |
=> Timetable observerId timeslotId resourceIds level | |
-> foldable (Coordinates observerId timeslotId) | The coordinates to undefine. |
-> Timetable observerId timeslotId resourceIds level |
- Undefines each lesson, at the specified list of coordinates.
- CAVEAT: if all the coordinates have the same observerId, then
undefineTimeslotsFor
should be more efficient.
:: (Ix timeslotId, Foldable foldable, Ord observerId) | |
=> observerId | Identifies the single observer, in whose timetableForWeek all unwanted lessons exist. |
-> Timetable observerId timeslotId resourceIds level | |
-> foldable (Time timeslotId) | The times of lessons to undefine. |
-> Timetable observerId timeslotId resourceIds level |
Undefines each lesson, at the specified list of times, within the timetableForWeek for the specified observerId.
purge :: (Ix timeslotId, Enum timeslotId, Ord observerId) => Timetable observerId timeslotId resourceIds level -> Timetable observerId timeslotId resourceIds level Source #
Undefine the whole timetable.
Predicates
isDefinedTimeslot :: (Ix timeslotId, Ord observerId) => Coordinates observerId timeslotId -> Timetable observerId timeslotId resourceIds level -> Bool Source #
True if a booking has been made at the specified coordinates in the timetable.
areMergeableWith :: (Ix timeslotId, Eq resourceIds, Eq level, ResourceUser resourceIds) => Booking timeslotId resourceIds level -> Timetable observerId timeslotId resourceIds level -> Bool Source #
- Check whether all the lessons currently booked for the specified time, are compatible with the specified lesson.
- To pass, any synchronous lesson-definitions must either be identical to the proposed lesson, or use neither of its resources.
- CAVEAT: it doesn't check whether the ability-stream of the student-body matches those for the existing bookings.
- CAVEAT: performance-hotspot.
:: (Ix timeslotId, Ord observerId) | |
=> (Lesson resourceIds level -> Bool) | Determines the suitability of any lesson at the specified coordinates. |
-> Coordinates observerId timeslotId | The coordinates at which to look for a lesson. |
-> Timetable observerId timeslotId resourceIds level | |
-> Bool |
True if a booking already exists in the timetable which matches the specified predicate.
:: (Ix timeslotId, Eq level, Eq resourceIds, Ord observerId) | |
=> Booking observerId timeslotId resourceIds level | The coordinates & lesson to match. |
-> Timetable observerId timeslotId resourceIds level | |
-> Bool |
True if the specified booking already exists in the timetable.
Translation
toGeneralisedBooking :: Booking observerId timeslotId resourceIds level -> GeneralisedBooking observerId timeslotId resourceIds level Source #
Transform a booking, into a generalised booking.