My Project
Loading...
Searching...
No Matches
ScheduleData.hpp
1#pragma once
2
3#include <string>
4#include <vector>
5#include <set>
6#include <optional>
7#include "json.hpp"
8
9using json = nlohmann::json;
10
11
12// --- TimeBlock ---
13struct TimeBlock {
14 std::string id;
15 std::string day; // e.g. "Monday"
16 int start; // e.g. 800 (8:00)
17 int end; // e.g. 945 (9:45)
18 int duration; // minutes
19
20 NLOHMANN_DEFINE_TYPE_INTRUSIVE(TimeBlock, id, day, start, end, duration)
21};
22
23// --- Subject ---
24struct Subject {
25 std::string id;
26 std::string name;
27 float hoursPerWeek; // np. 3.0
28 int difficultyLevel; // np. 1-5
29
30 NLOHMANN_DEFINE_TYPE_INTRUSIVE(Subject, id, name, hoursPerWeek, difficultyLevel)
31};
32
33// --- Group ---
34struct Group {
35 std::string id;
36 std::string name;
37 int size;
38 std::string parentGroupId; // Null if no parent group
39
40 NLOHMANN_DEFINE_TYPE_INTRUSIVE(Group, id, name, size, parentGroupId)
41};
42
43// --- Room ---
44struct Room {
45 std::string id;
46 std::string name;
47 int capacity;
48 std::set<std::string> features;
49
50 NLOHMANN_DEFINE_TYPE_INTRUSIVE(Room, id, name, capacity, features)
51};
52
53// --- Teacher ---
54struct Teacher {
55 std::string id;
56 std::string name;
57 std::vector<std::string> subjects;
58 std::vector<int> availableTimeBlocks; // ids of TimeBlocks
59
60 NLOHMANN_DEFINE_TYPE_INTRUSIVE(Teacher, id, name, subjects, availableTimeBlocks)
61};
62
63// --- Event (Class) ---
64struct Event {
65 std::string id;
66 std::string subjectId;
67 std::string teacherId;
68 std::string groupId;
69 std::string roomId;
70 std::string timeBlockId;
71
72 NLOHMANN_DEFINE_TYPE_INTRUSIVE(Event, id, subjectId, teacherId, groupId, roomId, timeBlockId)
73};
74
75// --- Schedule (output) ---
76struct Schedule {
77 std::vector<Event> events;
78
79 NLOHMANN_DEFINE_TYPE_INTRUSIVE(Schedule, events)
80};
81
82
83// --- Constraint ---
84struct Constraint {
85 std::string importance; // "Critical", "Important", "Optional"
86 std::string description; // Human-readable description
87 ConstraintType type; // Type of constraint
88 json data; // Type-specific constraint data
89
90 NLOHMANN_DEFINE_TYPE_INTRUSIVE(Constraint, importance, description, type, data)
91};
92
93// --- Constraint Type ---
94enum class ConstraintType {
95 // Time-based constraints
96 TeacherUnavailable, // Teacher not available at specific times
97 TeacherPreferred, // Teacher prefers specific times
98 GroupUnavailable, // Group not available at specific times
99
100 // Resource constraints
101 RequiredRoomFeature, // Class requires specific room features
102 PreferredRoom, // Class prefers specific room
103 ForbiddenRoom, // Class cannot use specific room
104 MinimumRoomCapacity, // Room must have minimum capacity
105
106 // Teacher constraints
107 MaxTeachingHours, // Teacher max hours per day/week
108 MinBreakBetweenClasses, // Minimum break time between classes
109 SameTeacherForSubject, // Same teacher for all instances of subject
110 TeacherSubjectMatch, // Teacher must be qualified for subject
111
112 // Group constraints
113 MaxClassesPerDay, // Group max classes per day
114 GroupSplit, // Group can be split into subgroups
115 GroupMerge, // Multiple groups can attend together
116
117 // Schedule patterns
118 ConsecutiveClasses, // Classes should be consecutive
119 AvoidConsecutive, // Classes should not be consecutive
120 SameDayClasses, // Multiple instances on same day
121 SpreadAcrossWeek, // Distribute classes across week
122
123 // Dependencies
124 ClassBefore, // Class A must be before class B
125 ClassAfter, // Class A must be after class B
126 SameTimeSlot, // Classes must be at same time
127
128 // Custom constraints
129 Custom // For application-specific constraints
130};
131
132// --- Constraint Data Structures ---
133// Each constraint type uses specific JSON structure in the 'data' field
134
135/*
136CONSTRAINT DATA STRUCTURE EXAMPLES:
137
1381. TeacherUnavailable:
139{
140 "teacherId": "T1",
141 "timeBlocks": ["TB1", "TB2"] OR
142 "days": ["Monday", "Friday"],
143 "timeRanges": [{"start": 800, "end": 1000}]
144}
145
1462. RequiredRoomFeature:
147{
148 "features": ["computers", "projector"],
149 "operator": "AND" | "OR" // All features required vs any feature
150}
151
1523. MaxTeachingHours:
153{
154 "teacherId": "T1",
155 "maxHours": 6,
156 "period": "day" | "week"
157}
158
1594. MinBreakBetweenClasses:
160{
161 "teacherId": "T1",
162 "minBreakMinutes": 15,
163 "applyToConsecutive": true
164}
165
1665. GroupSplit:
167{
168 "groupId": "G1",
169 "maxSubgroupSize": 15,
170 "subjectIds": ["CS", "LAB"] // Optional: only for specific subjects
171}
172
1736. ConsecutiveClasses:
174{
175 "subjectId": "MATH",
176 "groupId": "G1",
177 "consecutiveCount": 2,
178 "preference": "required" | "preferred" | "avoided"
179}
180
1817. ClassBefore:
182{
183 "beforeSubject": "THEORY",
184 "afterSubject": "LAB",
185 "groupId": "G1",
186 "sameDay": true,
187 "maxGapMinutes": 120
188}
189
1908. PreferredRoom:
191{
192 "roomIds": ["R1", "R2"],
193 "priority": 1-10,
194 "subjects": ["CS"] // Optional: only for specific subjects
195}
196
1979. MaxClassesPerDay:
198{
199 "groupId": "G1",
200 "maxClasses": 6,
201 "includeBreaks": false
202}
203
20410. Custom:
205{
206 "type": "application_specific_type",
207 "parameters": { ... } // Application-specific data
208}
209*/
Definition ScheduleData.hpp:84
Definition ScheduleData.hpp:64
Definition ScheduleData.hpp:34
Definition ScheduleData.hpp:44
Definition ScheduleData.hpp:76
Definition ScheduleData.hpp:24
Definition ScheduleData.hpp:54
Definition ScheduleData.hpp:13