forked from OPCODE-Open-Spring-Fest/CPP_Mini_Projects
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
30 lines (24 loc) · 1016 Bytes
/
main.cpp
File metadata and controls
30 lines (24 loc) · 1016 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include "timetable.h"
#include "genetic_algorithm.h"
#include "utils.h"
#include <iostream>
using namespace std;
int main() {
srand(time(nullptr));
cout << "\n=== C++ Timetable Generator (Genetic Algorithm) ===\n";
Timetable base = getUserInput();
int totalRequiredSessions = 0;
for (auto &c : base.courses) totalRequiredSessions += c.sessionsPerWeek;
int totalAvailableSlots = base.numDays * base.slotsPerDay * base.rooms.size();
if (totalRequiredSessions > totalAvailableSlots) {
cerr << "\n❌ Scheduling impossible: Total required sessions ("
<< totalRequiredSessions << ") exceed total available slots ("
<< totalAvailableSlots << ").\n";
cerr << "Try reducing sessions or increasing rooms/days/slots.\n";
return 1;
}
GeneticAlgorithm ga(30, 100, 0.1);
Timetable optimized = ga.run(base, true);
cout << "\nFinal Best Timetable (Conflicts: " << optimized.computeConflicts() << ")\n";
optimized.print();
}