# Combined Optimization of Maintenance Works and Crews in Railway Networks
## 4 Implementation  
The implementation of the model aims to test the enhanced model presented in the previous section and evaluate its performance. The enhanced model of scheduling maintenance works and crews was programmed in Python 3.7 as a mixed-binary linear programming model and solved using the GUROBI optimization software ([[https://www.gurobi.com/](https://www.gurobi.com/)]([https://www.gurobi.com/](https://www.gurobi.com/))). The most basic elements that must be introduced to implement the mathematical model are presented below. Initially, it should be mentioned that the implementation concerns an ideal railway network where the traffic load of trains is of a low frequency, and each link's length is between 8 and 10 km. For this case study, the length of each link was set equal to \(maxl=\{10\}\). In addition, certain sets were included, such as the links of the line, \(L=\{L1,L2,L3,L4,L5\}\). In terms of maintenance tasks, five were considered, of which two were for long-term/project works \(PA=\{P1,P2\}\), and the other three were short-term/routine works \(RA=\{R3,R4,R5\}\). The overall maintenance tasks' set is \(A=\{1,2,3,4,5\}\). The maintenance planning horizon is T = 1 year or 52 weeks, and one maintenance task corresponds to a duration of one week. This does not preclude two maintenance tasks from being carried out in parallel in the same week. Additionally, \(K=\{1,2,3\}\) is incorporated to illustrate how each project is executed, as stated in the preceding section. Regarding the number of work crews, it is assumed that five crews, \(E=\{1,2,3,4,5\}\), will carry out the maintenance tasks. For the work crews, the set \(LL=\{0,1,2,3,4,5\}\) was formed, which includes the links of operations, adding one more for the depot. The following tables illustrate the input data used for the current case study. First, Table 2 summarizes the frequency of routine tasks performed within a year for each link, and the planning cycle within which each routine work can be rescheduled for execution individually. \begin{table}
\begin{tabular}{c c c c} \hline \hline
**Routine Tasks** & **Links** & **Frequency (Gal)** & **Planning Cycle (Fal)** \\ \hline \multirow{6}{*}{R3} & L1 & 2 & 2 \\ \cline{2-4}  & L2 & 4 & 2 \\ \cline{2-4}  & L3 & 2 & 2 \\ \cline{2-4}  & L4 & 2 & 2 \\ \cline{2-4}  & L5 & 4 & 2 \\ \hline \multirow{6}{*}{R4} & L1 & 13 & 2 \\ \cline{2-4}  & L2 & 13 & 2 \\ \cline{2-4}  & L3 & 4 & 2 \\ \cline{2-4}  & L4 & 13 & 2 \\ \cline{2-4}  & L5 & 4 & 2 \\ \hline \multirow{6}{*}{R5} & L1 & 4 & 2 \\ \cline{2-4}  & L1 & 4 & 2 \\ \cline{2-4}  & L2 & 2 & 2 \\ \cline{2-4}  & L3 & 4 & 2 \\ \cline{2-4}  & L4 & 2 & 2 \\ \cline{2-4}  & L5 & 4 & 2 \\ \hline \hline \end{tabular}  
* Note: \(G_{ul}\)—frequencies per T scheduling period of activities \(a\in RA\) on link \(l\in L\), where \(G_{ul}=0\) if activity \(a\in RA\) is not relevant to the link \(l\in L\); \(F_{ul}\)—\(F_{ul}\)—\(F_{ul}\) = \(ceil(T/Gal)\) is the planning cycle for each routine work \(a\in RA\) at each different link \(l\in L\).  
\end{table} 
Table 2: Routine tasks: frequency and planning cycle. Table 3 presents data regarding which projects will be executed at which link and depicts the earliest and the latest possible starting time of project \(p\in PA\) on link \(l\in L\). It further includes the duration in weeks that each project requires for each option \(K\). In addition, Table 4 summarizes two out of three cost scenarios that involve route cancellation and inefficient resource usage on each link for every project. The third cost is fixed at EUR 100 for each time the line is used.