Types
TimetableSolver.SubjectCounts
— TypeSubjectCounts
Type for counting the number of times each subject appears in a timetable.
Alias for OrderedDict{String, Int}
.
TimetableSolver.Division
— TypeDivision
Type for representing a division of a timetable.
Constructors
Division(grade::Int, section::Int)
Division(grade::Int, section::Int, section_str::String)
Fields
grade::Int
: The grade of the division.section::Int
: The section of the division.section_str::String
: The section of the division as a string.__str__::String
: The precomputed string representation of the division.
TimetableSolver.Division
— MethodDivision(grade::Int, section::Int)
Return a division with the given grade and section. section_str
is inferred as the nth letter of the alphabet, where n=section
.
Call the second constructor with section_str
as the third argument.
TimetableSolver.Division
— MethodDivision(grade::Int, section::Int, section_str::String)
Return a division with the given grade, section, section string and precomputed string representation.
TimetableSolver.Teacher
— TypeTeacher
Type for representing a teacher in the timetable.
Constructors
Teacher(name::String, id::String, subjects::Vector{String}, grades::Vector{Int})
Fields
name::String
: The name of the teacher.id::String
: The unique id of the teacher.subjects::Vector{String}
: The subjects taught by the teacher.grades::Vector{Int}
: The grades taught by the teacher.__str__::String
: The precomputed string representation of the teacher.
TimetableSolver.Teacher
— MethodTeacher(name::String, id::String, subjects::Vector{String}, grades::Vector{Int})
Return a teacher with the given name, id, subjects, grades and precomputed string representation.
TimetableSolver.Period
— TypePeriod
Mutable type for representing a period in the timetable. Empty period is initialized with nothing
as both arguments.
Fields
subject::Union{String,Nothing}
: The subject of the period.teacher::Union{Teacher,Nothing}
: The teacher of the period.
TimetableSolver.Timetable
— TypeTimetable
Mutable type for representing a timetable.
Constructors
Timetable(numperiods::Vector{Int}, subjectcounts::SubjectCounts, teachers::Vector{Teacher}, division::Division)
Fields
numperiods::Vector{Int}
: The number of periods in each row.subjectcounts::SubjectCounts
: The number of times subjects must occur in the timetable, in total.subjects::Vector{String}
: The subjects in the timetable.teachers::Vector{Teacher}
: The teachers in the timetable.subjectteachers::OrderedDict{String, Vector{Teacher}}
: The teachers teaching each subject.teacher_strs::OrderedDict{String, Teacher}
: The teachers' string representations mapped to objects.division::Division
: The division of the timetable.data::Vector{Vector{Period}}
: The timetable data, as a vector of vectors of periods.
Notes
- Only fields
numperiods
,subjectcounts
,teachers
anddivision
are passed. The rest are inferred. - See the constructor for the same.
TimetableSolver.Timetable
— MethodTimetable(numperiods::Vector{Int}, subjectcounts::SubjectCounts, teachers::Vector{Teacher}, division::Division)
Return a timetable with the given number of periods, subject counts, teachers and division.
Notes
- Fields
subjects
,subjectteachers
,teacher_strs
anddata
are inferred. data
stores the actual vector of vectors of periods, initialized with (nothing
,nothing
) as arguments.
TimetableSolver.get_subjectteachers
— Methodget_subjectteachers(subjects::Vector{String}, teachers::Vector{Teacher})
Return an OrderedDict mapping subjects to valid teachers, based on subjects
and teachers
.
Base.string
— MethodBase.string(tt::Timetable)::String
Base.string
method for type Timetable.
Return a pretty table representation of the timetable.
Notes
- Use the
PrettyTables
library to return a table-like string. - Rows are numbered from 1 to
length(data)
and columns are numbered P1, P2 ... to longest row in data (max(length.(data)...)
). - Column 1 header is the division name.
- Call division and teacher's
Base.string
method for string representation.
TimetableSolver.Schedule
— TypeSchedule
Mutable type for representing a schedule, i.e., a collection of timetables.
Constructors
Schedule(timetables...)
Fields
data::OrderedDict{String,Timetable}
: The timetables in the schedule mapped to their division's string representation.
TimetableSolver.Schedule
— MethodSchedule(timetables...)
Return a schedule instance using the given timetables.
Notes
data
is an OrderedDict mapping division's string representation to the timetable.
Base.string
— MethodBase.string(s::Schedule)::String
Base.string
method for type Schedule.
Return pretty table representation of the timetables.
Notes
- Call the
Base.string
method for each timetable in the schedule and fill newlines in between.
TimetableSolver.modify!
— Methodmodify!(s::Schedule, var::String, val::String)
Modify schedule s
by replacing the value of the field var
with val
.
Notes
- Modify the schedule
s
in place. - Both
var
andval
are strings. - Call
modify!()
on the correct timetable ins
with the same arguments.
TimetableSolver.modify!
— Methodmodify!(tt::Timetable, var::String, val::String)
Modify timetable tt
by replacing the value of the field var
with val
.
Notes
- Modify the timetable
tt
in place. - Both
var
andval
are strings. - Row, period and type of variable are inferred by splitting
var
at"_"
, and taking last 3 elements. - If
type == "subject"
then the subject of the corresponding row and period is set toval
. - If
type == "teacher"
then the teacher of the corresponding row and period is set toval
(after getting teacher object from teacher string usingtt.teacher_strs
).