My Project
Loading...
Searching...
No Matches
include
schedule
ScheduleData.hpp
1
#pragma once
2
3
#include <string>
4
#include <vector>
5
#include <set>
6
#include <optional>
7
#include "json.hpp"
8
9
using
json = nlohmann::json;
10
11
12
// --- TimeBlock ---
13
struct
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 ---
24
struct
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 ---
34
struct
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 ---
44
struct
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 ---
54
struct
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) ---
64
struct
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) ---
76
struct
Schedule
{
77
std::vector<Event> events;
78
79
NLOHMANN_DEFINE_TYPE_INTRUSIVE(
Schedule
, events)
80
};
81
82
83
// --- Constraint ---
84
struct
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 ---
94
enum 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
/*
136
CONSTRAINT DATA STRUCTURE EXAMPLES:
137
138
1. TeacherUnavailable:
139
{
140
"teacherId": "T1",
141
"timeBlocks": ["TB1", "TB2"] OR
142
"days": ["Monday", "Friday"],
143
"timeRanges": [{"start": 800, "end": 1000}]
144
}
145
146
2. RequiredRoomFeature:
147
{
148
"features": ["computers", "projector"],
149
"operator": "AND" | "OR" // All features required vs any feature
150
}
151
152
3. MaxTeachingHours:
153
{
154
"teacherId": "T1",
155
"maxHours": 6,
156
"period": "day" | "week"
157
}
158
159
4. MinBreakBetweenClasses:
160
{
161
"teacherId": "T1",
162
"minBreakMinutes": 15,
163
"applyToConsecutive": true
164
}
165
166
5. GroupSplit:
167
{
168
"groupId": "G1",
169
"maxSubgroupSize": 15,
170
"subjectIds": ["CS", "LAB"] // Optional: only for specific subjects
171
}
172
173
6. ConsecutiveClasses:
174
{
175
"subjectId": "MATH",
176
"groupId": "G1",
177
"consecutiveCount": 2,
178
"preference": "required" | "preferred" | "avoided"
179
}
180
181
7. ClassBefore:
182
{
183
"beforeSubject": "THEORY",
184
"afterSubject": "LAB",
185
"groupId": "G1",
186
"sameDay": true,
187
"maxGapMinutes": 120
188
}
189
190
8. PreferredRoom:
191
{
192
"roomIds": ["R1", "R2"],
193
"priority": 1-10,
194
"subjects": ["CS"] // Optional: only for specific subjects
195
}
196
197
9. MaxClassesPerDay:
198
{
199
"groupId": "G1",
200
"maxClasses": 6,
201
"includeBreaks": false
202
}
203
204
10. Custom:
205
{
206
"type": "application_specific_type",
207
"parameters": { ... } // Application-specific data
208
}
209
*/
Constraint
Definition
ScheduleData.hpp:84
Event
Definition
ScheduleData.hpp:64
Group
Definition
ScheduleData.hpp:34
Room
Definition
ScheduleData.hpp:44
Schedule
Definition
ScheduleData.hpp:76
Subject
Definition
ScheduleData.hpp:24
Teacher
Definition
ScheduleData.hpp:54
TimeBlock
Definition
ScheduleData.hpp:13
Generated by
1.9.8