# Minimization of Material Waste Through Maintenance Interval Optimization in Transport Systems
## 3 Materials and Methods
### Detailed Description of the Main Forecasting Algorithm  
The algorithm is run and executed automatically every day to update the mileage of rail vehicles. The daily execution of the algorithm allows it to be based on the latest data (circulation). If a specific vehicle does not have an assigned circulation, the algorithm relies on the average daily mileage for that type of vehicle, so the \(\hat{M}\) predicted mileage will be approximate. If a specific rail vehicle has an assigned circulation, it will be considered in the mileage prediction, while if no circulation is assigned, the algorithm will use the average daily mileage depending on the type of vehicle. Key information about the algorithm:  
* It is run once per day;
* It updates data in the \(M_{daily}\) (Vehicle Mileage By Day) table starting from the date of the last recorded mileage in the ExploitationData table for a given vehicle;
* The algorithm repeats in a loop for each vehicle from the VehicleToAnalyzeMileage array and for each day within the range defined by the number of days to analyze (\(k\)) starting from the current day;
* The result of the algorithm's operation is the completion of mileage data for each day--the total \(\hat{M}\) predicted mileage of the vehicle for that day;
* The ExploitationData table does not need to contain data for all vehicles used by the algorithm; initial data for each vehicle should be supplemented when the vehicle is entered into the database;
* As input data, the algorithm uses a list of vehicle tasks for determined period, current services list, and vehicle type. The algorithm runs once daily and updates the daily mileage table in the database. As input, the algorithm takes a list of locomotives in the form of the VehicleToAnalyzeMileage array and the number of days since the last technical review of any type (\(k\)), for which data in the database table \(M_{daily}\) (Vehicle Mileage By Day) are updated. The algorithm starts by clearing the table. The algorithm returns data to a table in the database as a result of the operation. The operation of the algorithm can be described in the following steps:  
Step 1: The algorithm begins by clearing the table. This table stores the vehicle mileage data for a given day. Based on the algorithm below, the values in this table are filled in for the subsequent analyzed days. Auxiliary variables are also defined:  
\[z=0;\ T_{date}=T_{now};\ T_{stop}=T_{now}+k;\ I_{road}=False \tag{13}\]  
where \(z\) is an index corresponding to the locomotive in the VehicleToAnalyzeMileage [z] table, \(T_{date}\)--the current date in the iteration (initially equal to the current day, \(T_{now}\)), \(T_{stop}\) is the end date for analysis (where \(k\) is the number of days to analyze), \(I_{road}\) (Is On Road)--a Boolean value indicating whether the vehicle is on the road. Step 2: The algorithm checks if there are still vehicles left to analyze by counting the remaining cases in the input matrix. If the value returned is False, the algorithm terminates (STOP). If the value is True, the algorithm proceeds to Step 3. Step 3: The completion date of the technical review for the specified rail vehicle is read and assigned to variables used in the algorithm. A check is then performed to determine if the last known mileage of the vehicle is more recent than the mileage recorded during the technical review, and the necessary data updates are made. Step 4A: A condition is checked to determine if there are still days left for analysis. If the value returned is False, the variable values change:  
\[z=z+1;\ M_{i}=0;\ \hat{M}=0 \tag{14}\]  
and the algorithm returns to Step 2. If the value is True, the algorithm continues to Step 4B. Step 4B: It is checked whether entries have already been added to the database (i.e., if the table is being updated), and if so, whether the \(\hat{M}\) predicted mileage for the current day has a value of null (indicating that it can be updated).