# Optimizing the Scheduling of Teaching Activities in a Faculty
## 5 The Development of Theoretical/Practical Contributions
### Implementation Details
#### 5.4.3 Timefold for Timetable Generation  
The main feature of the application is centered around the advanced integration of Timefold for generating timetables. Timefold, a powerful constraint satisfaction solver, simplifies the difficult task of generating university timetables. The approach utilizes optimization algorithms, effectively integrating Java annotations and configurations with Spring Boot [57], as can be seen in Table 4. \begin{table}
\begin{tabular}{p{113.8 pt} p{113.8 pt}} \hline \hline
**Annotation** & **Description** \\ \hline \multirow{3}{*}{\begin{tabular}{} \end{tabular} } & Marks classes as entities manipulated by Timefold to identify an optimal solution. Entities include activities, teachers, and classrooms. \\ \hline \multirow{3}{*}{\begin{tabular}{} \end{tabular} } & Identifies variables subject to change during optimization, such as time slots and rooms for each activity. \\ \hline \multirow{3}{*}{\begin{tabular}{} \end{tabular} } & Designates the class representing the entire problem to solve, with the timetable serving as the planning solution. \\ \hline \multirow{3}{*}{\begin{tabular}{} \end{tabular} } & Configures and initializes the solver, allowing for custom settings such as optimization algorithms and termination conditions. \\ \hline \multirow{3}{*}{\begin{tabular}{} \end{tabular} } & Identifies the attribute representing the score or fitness of the solution, guiding Timefold in refining the timetable. \\ \hline \multirow{3}{*}{\begin{tabular}{} \end{tabular} } & Holds the configured constraint weights and other constraint parameters. \\ \hline \multirow{3}{*}{\
\begin{tabular}{} \end{tabular} } & Timefold Solver can change the annotated object during solving, and the ConstraintProvider (where the constraints are implemented) can select from those too. \\ \hline \multirow{3}{*}{
\begin{tabular}{} \end{tabular} } & The ConstraintProvider can select from those annotated object instances to assign to a @PlanningEntity object. \\ \cline{2-2}  & \\ \hline \hline \end{tabular}
\end{table} 
Table 4: Timefold annotations and configurations. Figure 6: Successful authentication with JWT token response. The integration with Timefold represents an important achievement in the application, providing a powerful and adaptive solution for efficient university timetable generation. Figure 7 represents the utilized domain model for the timetable generation with Timefold annotations. In the development of the automatic timetable generation system, the following Timefold Solver configuration (Table 5) was used to ensure efficient and optimized scheduling. The configuration is followed by the metaheuristics algorithms that occur in two phases: Construction Heuristics and Local Search. The Construction Heuristics phase is creating the best feasible initial using the Strongest Fit Decreasing algorithm that focuses on the most challenging aspects of the timetable, thereby laying a strong foundation for further optimization. Then, to refine the initial solution and avoid getting stuck in local optima, two advanced local search algorithms were employed: Hill Climbing Late Acceptance and Tabu Search. The Strongest Fit Decreasing (SFD) algorithm operates by first sorting lessons, timeslots, and rooms based on specific criteria and then assigning the most \"difficult\" lessons to the most suitable rooms and timeslots. Mathematically, this can be described as follows: Each lesson \(l_{i}\) has an associated difficulty or strength value \(d\) (\(l_{i}\)) based on the duration of the lesson. Each timeslot \(t_{j}\) has an associated importance score \(imp\) (\(t_{j}\)), such as the interval between start and end times, and each room \(r_{k}\) has a capacity value \(C\) (\(r_{k}\)). Sort the lessons \(L\), timeslots \(T\), and rooms \(R\) such that \(d(l_{1})\ \geq\ d(l_{2})\ \geq\...\ \geq d(l_{n})\), \(imp(t_{1})\ \geq\ imp(t_{2})\ \geq\...\ \geq\ imp(t_{p})\)_and_\(C(r_{1})\ \geq\ C(r_{2})\ \geq\...\ \geq\ C(r_{m})\).