# Supporting the Management of Rolling Stock Maintenance with an Ontology-Based Virtual Depot
## 7 Short-Term Scheduling
### Short-Term Scheduling Optimisation
\(E_{m}\): is the maximum number of time units t (e.g., tolerance in days) a maintenance intervention m can be performed earlier. \(L_{m}\): is the maximum number of time units t (days) a maintenance intervention m can be performed late. \(D_{in}\): due date of the maintenance intervention m on unit i. \(S_{in}\): start date of the maintenance intervention m on unit i. **Problem formulation:**\[\min \sum_{i=1}^{N}\sum_{m=1}^{M^{\prime}}max(0,D_{im}-S_{im})*EP_{m}+max(0,S _{im}-D_{im})*TP_{m}\] s.t. \[\mathcal{U}_{lint}==1\quad\forall i\in I,\forall m\in M,\,t\in S_{im} \tag{1}\] \[\sum_{i=1}^{N}U_{lint}\leq CAP_{mt}\quad\forall m\in M,\forall t\in T\] (2) \[\sum_{i=1}^{N}U_{lint}\leq Cap_{gt}\quad\quad\forall m\in g,\forall g \in G,\forall t\in T\] (3) \[S_{im}\geq D_{im}-E_{m},\quad\forall i\in I,\forall m\in M\] (4) \[S_{im}\leq D_{im}+L_{m},\quad\forall i\in I,\forall m\in M\] (5) \[S_{im}\
eq t,\quad\forall i\in I,\forall m\in M,\forall t\in W\] (6) \[\sum_{i=1}^{N}\sum_{m=1}^{M^{\prime}}U_{lint}\leq A_{f}\quad \forall t\in T \tag{7}\]  
The objective function is to minimise the total late/early maintenance costs. **Constraint (1):** changing the binary variable \(U_{lint}\) to 1 when an m maintenance intervention is scheduled at a period t for a unit i. **Constraint (2):** ensuring that only the possible number (depot capacity) of units is sent on a period t for maintenance type m. The information about the available resources is produced by the process discussed in Section 5. For this constraint, the end user can specify a time slot where this restriction should be applicable, such as four days from the first day of the time horizon. **Constraint (3):** ensuring that only the possible number (depot capacity) of units is sent on a period t for maintenance intervention m in group g. Maintenance interventions requiring the same depot fixed resources are grouped in one group. **Constraint (4, 5, 6):** making sure the start date of the maintenance intervention m \(S_{im}\) is in the range \([D_{im}-E_{m},\,D_{im}+L_{m}]\), avoiding the depot non-working days, and \(S_{im}\
eq t\) (i.e., not equals t) when t is a not working time unit. **Constraint (7):** making sure the availability required per period t is guaranteed, where the number of units i sent to maintenance at any period t is less or equal to the availability limit \(A_{f}\). The objective function may include the cost of fleet unavailability, and thus, the constraint **(7)** can be modified to a hard limit stating a maximum number of units \(A_{f}\) that can be out of service at any time; in the objective function, we add a cost of fleet unavailability when \(A_{f}\) is reached. The proposed MIP model was encoded using Python, with the DOCPLEX package, and solved with CPLEX. The choice of CPLEX is motivated by the fact of being one of the best commercial solvers; however, in the future, a more general solution using multiple solvers, such as CPLEX and SCIP [35], will be considered using the Pyomo optimisation modelling language. DOCPLEX provides an easy environment to implement MIP models. Decision variables, constraints, and the objective function are translated directly from the mathematical formulation to the equivalent code. Equivalence constraints are used for binary variables, while normal constraints are used for integer decision variables. Both methods use data extracted from the ontology using OWLready2 and SPARQL queries under Python. The graphical interface is a Matlab GUI calling a kinter, see Figure 10.