Application of Kronecker algebra in railway operation

Original scientific paper We present a methodology for dispatching trains which prevents deadlocks and includes possible limitation of the available energy provided by the power supply. Our approach applies Kronecker algebra to manipulate matrices. Generally blocking of trains occurs due to a lack of some resource which can be either infrastructure or energy. Our method can also be used to calculate travel times in a rough way. Thereby blocking time is included in the calculated travel time. To model the movements of trains in a railway system we use graphs, which are represented by adjacency matrices. We assume that the edges in a graph are labelled by elements of a semiring. Usually two or more distinct train route graphs refer to the same track section to model synchronization. Our approach can be used to model a complex railway system. For example, if additional trains have to be scheduled, power stations or interconnection lines fail or are not available due to maintenance, our model can be used to calculate the impact on the travel times of the trains in the system.


Introduction
We present a graph-based method on a fine-grained level for dispatching trains which prevents deadlocks, calculates the travel time of trains, and includes possible limitations of the available energy provided by the power supply.The routes of trains are modelled by graphs, whereby track sections may be part of routes of several trains.We assume that at the same time only one single train occupies a track section.If an operational standard allows entry in an occupied block ("permissive driving"), our approach can deal with this issue as well by finescaling the track section.Our model employs semaphores in the sense of computer science to guarantee that only one train enters a train section.These semaphores are modelled by simple graphs.
Graphs can be represented by matrices.Interestingly, simple matrix operations can be used to model concurrency and synchronization via semaphores [1], [2], [3].These matrix operations are known as Kronecker sum and Kronecker product.With help of these operations we build a graph describing the overall railway system.
By traversing the resulting graph we compute the travel time of the trains within the network.Blocking among trains occurs due to sharing of train sections, connections, and overtaking.
Blocking time is incorporated into the calculated travel time.
Shared resources other than track sections can also be modelled.In particular, so-called counting semaphores can be used to model discrete power resources.For example, a counting semaphore of size four allows four -operations before it blocks.
If we discretise energy into standardized packages e.g. 1 MW•h, we can model a power station or substation capable of producing e.g.20 MW by a counting semaphore of size 20.Of course, a more fine-grained approach is viable too.So we may discretise energy into 100 kW•h or even 10 kW•h steps.
In comparison to simulation tools we determine all possible train movements within the railway system, we find blocking situations and calculate the travel time for each train at once.Thus our approach does not need several simulation runs to find all possible solutions (including blocking situations).Common simulation tools calculate only a single result in one simulation run and so they cannot ensure the detection of blocking situations, which might be present in the given railway system.
In [4] Banker's algorithm is modified such that it can be employed for deadlock analysis in railway systems.Since Banker's algorithm has been designed for standard computer systems it is not well-suited for railway systems.For example it may prohibit allocating a resource (track section) although a potential deadlock can be bypassed.In contrast to our approach both track sections and switches have to be modelled.
In [5] Movement Consequence Analysis (MCA) and Dynamic Route Reservation (DRR) are introduced for deadlock analysis.Both are rule-based methods for which correctness cannot be proved.It delivers false positives.
A comprehensive analysis of methods and algorithms used in railway systems can be found in [6].

Basics of Kronecker algebra
This article is based on, [3], [7], [8], and [9], which are concerned with the timing analysis of concurrent Technical Gazette 24, 1(2017), 21-30 programs and the deadlock and travel time analysis for railway systems.Instead of using processors or threads as in [7], we will discuss operations with trains and instead of shared memory, track sections are used for our purpose.For the synchronization of the trains on a track section, semaphores in the sense of computer science (cf.[10]) are used.Thus a train can enter or reserve a track section only if it is not blocked by another train using the semaphore of the track section.Blocking may occur only in succession of semaphore calls.
To model the movements of trains in a railroad system we use graphs, which are represented by adjacency matrices.We assume that the edges in a graph are labelled by elements of a semiring.Definitions and properties of the semiring can be found in [11] and [1].Our semiring consists of a set of labels ℒ representing semaphore calls denoted by   and   (cf.[10]).
Usually two or more distinct train route graphs refer to the same track section to model synchronization.

Modelling synchronization and interleavings
Kronecker product and Kronecker sum form Kronecker algebra.In the following we define both operations.From now on we use matrices out of ℳ = � = � , �� , ∈ ℒ� only.

Definition 1 (Kronecker product)
Given a m-by-n matrixA and a p-by-q matrix B, their Kronecker product denoted by ⨂ is a mp-by-nq block matrix defined by Kronecker product allows to model synchronization (cf.[12], [1], and [3]).
Definition 2 (Kronecker sum) Given a matrix A of order m and a matrix B of order n, their Kronecker sum denoted by ⨁is a matrix of order mn defined by where   and   denote identity matrices of order m and n respectively.

Representation of railway systems
In general, a railroad system consists of a finite number of trains and track sections which are represented by graphs.As already mentioned the graphs are represented by adjacency matrices and the track sections are represented by binary semaphores in the sense of computer science.The matrices have entries which are referred to as labels  ∈ ℒ.
Formally, the system model consists of the tuple 〈, , ℒ〉 , where  is the set of graph adjacency matrices describing routes of trains,  refers to the set of adjacency matrices describing track sections (semaphores) and the labels in  ∈  and  ∈  are elements of ℒ, respectively.The matrices are manipulated by using Kronecker algebra.
As already mentioned, there is a correspondence between matrices and graphs.In general a directed labelled graph  = 〈, ,   〉 consists of a set of labelled nodes, a set of labelled edges  ⊆  ×  and an entry node   ∈  .The sets  and  are constructed out of the elements of 〈, , ℒ〉.
In this article we label graph nodes simply by positive integers.Correspondence between graphs and matricesfrequently called adjacency matrices -is as follows: If there exists an edge labelled from node  to node , then the corresponding adjacency matrix  has  , = .If there is no edge between node  and node , then  , = 0.
The following example illustrates some interleavings of two train routes in a railway system and how Kronecker sum handles it.

Synchronization and interleavings -an example
Let the matrices The graphs of matrices  and  are shown in Fig. 1.Now interpret  and  as being train routes and ,, , and  as being actions of the trains with the following meaning: All possible timing interleavings by executing  and  are shown in Tab. 1 and the graph represented by the adjacency matrix ⨁ is depicted in Fig. 2. Now assume that   and   denote the same track section.It is clear that in this case the temporal interleavings of Table 1 are no more valid.The trains have to synchronize in order to perform their actions correctly.This can be modelled by Kronecker product and an additional matrix of the form where  denotes the action "Enter the track section" and  means "Train has left the track section".The correct system behaviour can be described by the matrix  = (⨁)⨂.As a result the graph will be decomposed into sub-graphs (Figure 3).Clearly only the part reachable from the entry node is responsible for the system behaviour, the others can safely be ignored.Since node 1 is the entry node, we see that now the trains enter the track section one after the other.Note that the two paths in the sub-graph correctly mirror the two cases where  enters the track section before  and vice versa.A proof that Kronecker product models synchronization correctly can be found in [1].

System model
We model a general railway system  by a set of track sections  = {  | 1 ≤  ≤ }.Each track section   is modelled by matrix In addition, a railway system consists of a set of trains The set of routes is denoted by  = �  � 1 ≤  ≤ }.The behaviour of railway system 〈, , 〉is modelled by where during the evaluation of the Kronecker product we let   =   •   and   =   •   .The different paths in the graph corresponding to matrix  mirror all possible behaviours of the railway system in terms of temporal interleavings of the actions of trains, namely entering and leaving track sections.Special cases like overtaking or waiting for other trains, which need some additional semaphores are discussed in the later examples.From the discussion above and from [1] it is clear that deadlocks appear as purely structural properties of the underlying graph.Deadlocks manifest themselves as non-final nodes with no successors [2].A final node corresponds to the destination of a route.A final node of a railway system corresponds to the state, where all trains have reached their destinations.

Travel time analysis
Travel time is discussed in detail in [3].Each node of the graph is assigned a variable and an equation is setup based on the predecessors of the node.A variable is represented by a vector, where each component of the vector corresponds to a train.The equations are used to calculate the travel time.
where the th component of vector ( → ) is the time assigned to edge  →  and edge  →  is mapped to train .The other components of ( → ) are zero.The set of predecessor nodes of node  is referred to as ().
Let  be a synchronizing node.In addition, let  and   be the trains where the edges  →  and  →  are mapped to.Then for  ≠ and where the first term considers the incoming -edge and the second one the incoming edge of train   .
The system of equations can be solved easily by inserting one equation into another.In this section we give a small example on creating a graph and the equations for the calculation of the travel time.For the example the railroad system in Figure 4 is used with three trains  1 ,  2 and  3 .The routes of the three involved trains are given in Table 2.The travel time for each operation is given in brackets.

Train
Routes (time Value) The matrices for the three routes are set up as follows: � for 1 ≤  ≤ 5.

Resulting Matrix and Graph
The order of the resulting matrix can be computed by multiplying the order of the involved matrices, i.e., the order of the matrices   and the order of the matrices   .
In our example the resulting matrix will have order 6912 = 6 • 6 • 6 • 2 5 .Due to synchronization only a small part of the resulting graph is reachable from the entry node.Figure 5 illustrates the resulting graph of the given example.In the example we use the time values in Table 2 for entering and leaving the track sections.To keep the example and the graph simple, we have assigned the travel time values to the  operations.The travel times for the three trains are shown in the right column of Table 2.

Figure 5 Resulting graph of example 1
To increase readability we distinguish the following node types: • Diamond nodes denote deadlocks or nodes from which only deadlocks can be reached.Deadlock analysis for railway systems via our approach is studied in [2].• Solid nodes denote safe states.A state is safe if all trains can perform their actions without having to take into account the moves of the other trains in the system, provided that the track section which they are to enter is not occupied by another train.If a track section is occupied by another train, the movement of the train wanting to enter may be delayed (blocked) but no deadlock can occur.• From dotted nodes both diamond and solid nodes can be reached.
• Filled nodes are synchronizing nodes (at least two trains must be synchronized).
When calculating the travel time, an equation for each node is set up.As there are a lot of nodes in our example, we present equations for one non-synchronizing node (5846) and for one synchronizing node (5890) only:

Explanation of the equations
5846 : To get the travel time for node  5846 , the travel time of each predecessor plus the travel time of the connecting-edge are computed.So we get the travel time for each incoming edge.The maximum of these values is taken as the travel time for node  5846 .For example node  4696 is connected to  5846 by an edge labeled as 1 . 4 , which means that train  1 executes  4 .As a result  4 is used in the first vector of the equation for  1 .Because there are no other trains involved in the transition from  4696 to  5846 , the other values of the vector are set to 0. The same procedure is done for node  5813 , which is connected to  5846 by an edge labelled with  3 . 5 and thus the vector will have value 0 for the first and second train, and  5 for the third one.
5890 : As described in Eq. ( 8) and ( 9), there is a difference between trains which should be synchronized with others and trains which act independently (at the current node).For independent trains, the equation is set up as for non-synchronizing nodes (first and third line in the vector for node  5890 ).The second line, which describes the travel time for train  2 will use the travel time value of the third train  3 because  2 has to be synchronized with  3 and thus train  2 has to wait for  3 .If there are any other incoming edges with an action from train  2 , then their travel time values would also be considered in the equation and the maximum of these values would be taken as the train's travel time at the current node.
For this example Kronecker algebra calculations produce a graph with 44 nodes and thus 44 equations must be set up.After creating the equations for each node, the travel time for each node can be computed by inserting one equation into another.

Energy awareness 6.1 Modelling with counting semaphores
As explained in the previous sections, for shared resources like track sections, where only one train is allowed to enter or reserve the section, binary semaphores are used.Shared resources other than track sections can also be modelled.In particular, so-called counting semaphores can be used to model discrete power resources.For example, a counting semaphore of size four allows four p-operations before it blocks, e.g. the following trace is allowed for such a semaphore , , , , , , , , , , , , ,  while the trace , , , , , , , , , ,  leads to blocking.A counting semaphore of size four can be found in Figure 6, its matrix representation is If we quantise energy into standardised packages e.g. 1 MW•h, we can model a power station or substation capable of producing e.g.20 MW by a counting semaphore of size 20.Of course, a more fine-grained approach is viable too.So we may quantise energy into 100 kW•h or even 10 kW•h steps.
We assume that it is known a priori how much energy each train needs for each track section.Now in our model, a train acquires amounts of power from the power station before it enters a certain track section by issuing exactly the number of -operations that correspond to the amount of power it will need.On leaving the track section, the train will issue the same number of  -operations to release its power needs.Modelling available energy and required energy in this way ensures that a train needing more energy than can be delivered by the power station, is blocked, i.e., it stops and will continue its travel when enough energy is available (e.g. because another train has released its energy needs).The same approach can be used to model limited interconnection capacities and to avoid accumulating current peaks due to simultaneous train departures.

Kronecker algebra based dispatching
Due to the information calculated by using Kronecker algebra the dispatching can be planned or modified, based on Of course, avoidance of headway-conflicts reduces consumption of energy (cf.[13] and [14]).

Example 2a (without energy modelling)
We give an example consisting of a simple railroad system with two trains which is illustrated in Fig. 7.The routes of the two trains read as follows: The travel times for the two trains are shown in Tab. 3. Fig. 8 illustrates the resulting graph of the example after applying Kronecker algebra.Now we add energy consumption to the trains, where train  1 needs two energy units for track section  1 and  2 and one for  3 and  4 . 1 needs two units for track section  5 and  6 and one for  7 and  8 .
So the extended routes for the two trains will be: where  9 models reservation of one single energy unit and  9 its release.Fig. 9 illustrates the resulting graph when a maximum capacity of four energy units is available and thus both trains can travel along their routes without constraints.Figure 10 shows the result if only three energy units are available and thus only one train can start travelling over its first two track sections and after the release of one energy unit, the second one can start.

Example 2c (modelling less energy available)
Now we add another constraint: The two trains should do a synchronization when train  1 is at track section three and  2 is a track section seven, respectively.In other words, the two trains have to wait for each other before they go on.To ensure synchronization for connections or overtaking, artificial track section has to be inserted into the routes.Adding the artificial track sections 10 and 11 to our routes, we get the following "routes": Fig. 11 and Fig. 12 show the resulting graphs with additional energy constraints (four and three available energy units).In this section, we presented a simple example with two trains, then we added energy awareness to the example and at least, we added a constraint implied by a connection between the two trains.
Tab. 4 shows the results (travel time, number of nodes) for the example.We see that additional constraints (e.g.connections between trains) result in a more accurately defined issue and thus the resulting graphs are smaller.8 Railway analysis by using Kronecker algebra We have developed an algorithm [6] to reduce the graph and to calculate the travel time, which consists of several steps: 1. Read data: The necessary data of each train (e.g.route, time values) is read.2. Kronecker algebra: Apply Kronecker algebra to manipulate the given matrices.3. Get the relevant nodes: The algorithm starts at the first node and traverses the graph downwards until no successors can be reached.All reached nodes are stored in a map.Each node is checked and if it is a synchronizing node, it is stored in a different map including the necessary synchronizing information (involved trains, track section).This information is called synchronizing condition.The algorithm starts at the final node and traverses the graph upwards until the start node is reached.Some synchronizing nodes are not relevant for the computation of the travel time and thus, these nodes are removed from the synchronizing nodes map and considered as non-synchronizing nodes.In more detail, a synchronizing node can be considered as non-synchronizing node for the travel time calculation, if one of its successors contains the same synchronizing conditions.In this case the synchronization could be done in the successor.After applying Kronecker algebra there may exist chains of synchronizing nodes in the resulting graph with the same synchronizing conditions at each node.
Step 4 eliminates all of them but the last one and thus the calculation is much easier and faster.Fig. 13 and Fig. 14 illustrate the elimination of unnecessary synchronizing nodes.In our examples we have used integer values for travel time values.Extensions of our model, e.g. with decimal values or taking braking and acceleration time into account in case of blocking are possible, but not discussed here.

Conclusion
We have presented a graph-based method for calculating travel time of trains, finding deadlocks and taking into account energy considerations within a railway network on a fine-grained level.Kronecker algebra is applied to manipulate matrices and to create graphs, which can be represented by adjacency matrices.Our approach can be used to model complex railway systems including aspects of being deadlock-free, being conflict-free, and being minimal in terms of energy consumption.

•Figure 1 Figure 2
Figure 1 C and D Table 1Timing interleavings Interleavings a b c d a c b d a c d b c a b d c a d b c d a b

. ( 6 )
Let the vector  = � 1 , . .,   , … ,   � T .We write  () =   to denote the  th component of vector .Definition 3 Let  = � 1 , … ,   � T and  = � 1 , … ,   �  .Then we define max(, ) ≔ �max( 1 ,  1 ), … ,max�  ,   �� T Synchronizing nodes are nodes where blocking occurs.These nodes have an incoming edge labelled by a semaphore -operation, an outgoing edge labeled by a operation of the same semaphore, and these edges are part of different trains.In this case the train with the operation has to wait until the other train's -operation is finished.Definition 4 A synchronizing node is a node s such that • there exists an edge   = (, ) with label   and • there exists an edge   = (, ) with label   , where  denotes the same semaphore and   and   are mapped to different trains.Definition 5 (Setting up equations) If  is a nonsynchronizing node, then

⎞
The matrices for the five track sections have the form   = � 0     0

Figure 6
Figure 6 Counting semaphore of size four

•
the avoidance of deadlocks, • the avoidance of headway-conflicts, • taking the travel time into account, and • the availability and the consumption of energy.

Figure 8 Figure 9
Figure 8 Resulting graph of example 2a

Figure 15
Figure 15 Reduced graph In Tab. 5 information on several examples is gathered, the number of nodes, the number of relevant nodes (including entry-node and final-node) for travel time calculation and the running time of the algorithm (Processor: Intel Core i7 CPU 870@2.93GHz× 8, Memory: 4 GB).The timing behaviour of our algorithm is linear in the number of nodes in the graph.

Table 2
Trains, routes, and travel time

Table 5
Examples and their running time