Documentation
¶
Overview ¶
Package conflictcalc holds the pure schedule-conflict math: normalising an ancode pair into a stable key, ranking a conflict's proximity (how close in time two of a student's exams ended up), classifying two placed exams by their absolute times and durations, and diffing a freshly generated conflict list against the saved one. All functions are I/O-free over graph/model types; the DB access and aggregation stay in the plexams package.
Index ¶
Constants ¶
const ( Overlap = "OVERLAP" TooClose = "TOO_CLOSE" SameDay = "SAME_DAY" NextDay = "NEXT_DAY" )
Proximity labels, worst (closest in time) to mildest. Two exams closer than NextDay count as a conflict; NextDay and farther are acceptable.
Overlap – the exams (incl. NTA time) run at the same time, or leave a student less
than the travel/break buffer (examGapMinutes) between them: impossible.
TooClose – same day, start times closer than notTooCloseMinutes: undesirable.
SameDay – same day, but far enough apart.
NextDay – consecutive calendar day.
Variables ¶
This section is empty.
Functions ¶
func DiffAgainstSaved ¶
func DiffAgainstSaved(generated, saved []*model.ExamScheduleConflict) []*model.ExamScheduleConflict
DiffAgainstSaved tags each generated conflict with its status relative to the saved-plan conflicts — "new", "worse", "better" or "unchanged" — and returns the resolved ones (present in the saved plan, gone in the generated one), tagged "resolved". Both lists are keyed on the ancode pair (Ancode1 < Ancode2). The generated conflicts are mutated in place (DiffStatus set).
func NormPair ¶
NormPair returns the two ancodes in ascending order. Ratings, decisions and canShareSlot are stored order-independently, so this is the canonical pair key.
func ProximityRank ¶
ProximityRank orders a proximity label from worst (OVERLAP) to mildest, so two plans' conflicts can be compared ("got worse / better") and a conflict list sorted worst-first. Unknown/empty labels rank 0.
func TimeProximity ¶ added in v1.224.0
func TimeProximity(startA, endA, startB, endB time.Time, examGapMinutes, notTooCloseMinutes int) (int, string)
TimeProximity classifies two of a student's placed exams by their absolute start/end times (end = start + duration incl. NTA), returning a rank (higher = worse) and label. examGapMinutes is the required travel/break buffer between two exams; a smaller gap (including a real overlap) is an OVERLAP. notTooCloseMinutes is the start-to-start distance below which two same-day exams are flagged TOO_CLOSE. Rank 0 / "" means far enough apart to not count as a conflict.
Types ¶
This section is empty.