Optimization Method of Locomotive Working Diagram Layout

Rational scheduling of locomotive paths (the locus of the locomotive point in the train working diagram) is an important step in drawing a locomotive working diagram by a computer. But there are some problems in this process, such as the computer usually drawing a locomotive path that overlaps with another locomotive path (in the circumstances, the actual users of the locomotive working diagrams often misread the locomotive planning). At present, there are many studies about assigning sets of locomotives to each train in a preplanned train schedule; in contrast, the studies of visualizing the locomotive planning are relatively rare. Through investigating the locomotive working diagram users, this paper points out that the layout of locomotive paths should put the distance between lines being as large as possible and should put the number of the intersection between lines being as few as possible as the optimization aim which is based to solve the problem of the lines overlap or the problem of the lines beyond the margins for drawing the locomotive paths. This paper also builds the optimization model of locomotive working diagram layout. Based on determining the position of locomotive paths which can be delineated, a genetic algorithm is used to solve the optimizing model of locomotive working diagram layout in this paper. An example of a train working diagram with 36 trains is given at the end of the paper, which indicates that the optimization model of locomotive working diagram layout can better solve the problem of locomotive planning visualization.


Introduction
Chinese railways now not only have the computational ability for automatic train scheduling [1][2][3], but have also made relatively good progress in automatically compiling locomotive scheduling ( [4,5]).Locomotive scheduling involves optimally assigning a set of locomotives to trains while simultaneously satisfying a variety of business constraints and minimizing the total scheduling cost [6][7][8].It is usually composed of twostep process: A assigning sets of locomotives to each train in a preplanned train schedule (it is also commonly referred to as the locomotive planning problem, [9,10]); B visualizing the locomotive planning to the locomotive working diagram (a graphic form of locomotive planning).
Previous research in this field has focused mainly on step 1 (for example, Ghoseiri and Ghannadpour [11] consider the locomotive planning problem with homogeneous locomotives; Nourbakhsh and Ouyang [12] and Raviv and Kaspi [13] study the optimal fueling strategies for locomotives; Piu and Speranza [14] give a comprehensive review on the locomotive planning problem; Xu et al. [15,16] make train timetabling and locomotive planning decisions simultaneously), whereas studies on step 2, which is just as important, remain fairly scarce.
However, addressing the key theme of this paper visualizes the locomotive planning and depends essentially on optimizing the graphic representation of the locomotive planning.Although the problem resembles the train flow diagram (a train flow diagram is a direct graphic form which shows the category, path and number of all kinds of passenger, and freight train flow in railway network, which includes railway network and train flow line [17][18][19]), given the very different approach that needs to be taken in this case, available train flow diagram solutions cannot be adapted to the problem of locomotive planning visualization.
The locomotive path, which includes the train paths and the connection lines (a connection line means a locomotive from an inbound train to an outbound train at the same station in practice), is the locus of the locomotive point in the train working diagram.The difficulty in visualizing locomotive planning is that quantifying the layout of connection lines.Consequently, this paper proposes a method for automatically optimizing locomotive working diagrams based on a detailed investigation into the practices actually employed by those who use the locomotive working diagram.This method can contribute to making better and more systemic automatically generated the locomotive working diagram.

The Position of the Connection Lines
There are three drawing areas in the locomotive working diagram for positioning connection lines (as shown in Figure 1): A the top (hereinafter referred to as "upper section"); B the bottom (hereinafter referred to as "lower section"); C the middle (hereinafter referred to as "middle section").In reality, depending on the situation, areas called "middle section" in this paper may not exist at all or there may be several of them at one time.For simplicity and actuality, this paper assumes that there is only one middle section.In general, as shown in Figure 1, each section is equal in height (Δ in this paper indicates the height of each section), and the line position of each connection line is a series of equally spaced horizontal lines in each section.In this paper, each horizontal line, representing the line positions, is numbered 1, 2 . . .as shown in Figure 1.If  represents the distance between adjacent horizontal lines, then  = Δ/(+1) (where  in the formula is the maximum value of the horizontal lines' number; this value is derived from the train schedule and the locomotive planning and is explained in detail in Section 3.2 of this paper).Generally, a "complete" connection line consists of three segments (as shown in Figure 2): A the initial segment of the connection line is the left vertical line (hereinafter referred to as "LL"); B the middle segment of the connection line is the horizontal line (hereinafter referred to as "ML"); C the end segment of the connection line is the right vertical line (hereinafter referred to as "RL").
The four types shown in Figure 3 show all the possible types of a "complete" connection line.In general, upper sections only display the type shown in Figure 3(a), while lower sections only display the type shown in Figure 3(b).Middle sections may display any of the four types.In order to automatically draw the four types of connection lines according to the locomotive planning on the basic train diagram, the most efficient approach is to confirm a location of the connection lines as drawing the ML of the connection line on the smallest number line position which does not conflict with any ML.In this paper, the above method is referred to as the "smallest distribution" method.However, applying the smallest distribution method to generate locomotive working diagrams by some diagrams editing systems in practice frequently produces cases where the LL or the RL overlap during parallel operation at both ends of a station (as shown in Figure 3(a), two RLs overlap as trains are dispatched simultaneously from this station at each end of the station).This situation will affect the way that locomotive working diagram users interpret the locomotive planning; therefore, to avoid this becoming a problem, overlapping LLs or RLs can be handled in the way illustrated in Figures 3(b which is used to replace one of the connection lines in the parallel operation.The visual impact of these modifications on the locomotive diagram is clear: in Figure 3(b) the spacing between the MLs is larger, whereas in Figure 3(c), there are fewer crossover points between the connection lines.As such, there are two ways to solve the problem, in visualizing the locomotive planning, caused by parallel operations being conducted at both ends of the station.A Maximize the spacing between each line position.B Minimize the number of crossover points between connection lines.According to the data collected for this paper through surveys from the actual users of the locomotive working diagrams, the majority of respondents said that when there were fewer connection lines on the diagram, minimizing crossover points was more important than maximizing the space between lines, whereas the opposite was true when there were a large number of connection lines.Figure 3(d) is an optimized version of the diagram in Figure 3(a), where minimizing crossover points was more important than maximizing the space between lines.In addition, determining the number of the line positions before generating a planning diagram is a precondition to studying the optimization of visualizing the locomotive planning.Therefore, the issue of visualizing the locomotive planning discussed in this paper can be summarized as follows: assuming that the locomotive planning is known, when adding the necessary connection lines to the train diagram, it is necessary to avoid overlapping LLs and RLs due to parallel operations at both ends of a station.To this end, it is necessary to ensure maximum spacing between adjacent MLs and minimize the number of crossover points between connection lines.In order to give this problem a general nature, for the purposes of this study a real-life locomotive planning (results of a train schedule) was used, which means that it was not a cycle diagram.

Symbol Definition.
To facilitate explanations, the count time (start and stop time of the train working diagram) of the locomotive planning in this paper was set to 0:00.The symbol  represents sections where connection lines can be positioned in the locomotive working diagram.In this paper, the value of  is 0, 1, and 2 corresponding to the upper section, the lower section, and the middle section, respectively (if there are two or more middle sections, the value can be further increased).Let   be the number set of the connection lines in the range of  in a certain locomotive working diagram; any "complete" connection line (ℎ ∈   ) may consist of two lines shown in Figure 4 (in this paper, this is referred to as the four "basic lines").For example, the In general, if a connection line does not cross the count time 0:00, it consists of two basic lines in Figure 4, and if a connection line crosses the count time 0:00, it is constituted by one basic line in Figure 4.For convenience, in this paper, all the connection lines across 0:00 will be completed as being formed of two basic lines (generally speaking, there are two ways of completion; each can be chosen arbitrarily), so that all the connection lines will contain the following three attributes: A  ℎ  , time corresponding to LL or start time of connection line ℎ, B  ℎ  , time corresponding to RL or end time of connection line ℎ, and C  ℎ representing the number of the line position of the connection line ℎ.Variables  ℎ ,  ℎ ,  ℎ , and  ℎ are defined as 0-1: if the connection line ℎ contains the types of line shown in Figure 4   is the set of numbered line positions within section , according to the numbering rules of this paper, which define   ∈   as offset multiplier relative to the horizontal line (the center of intermediate train distancing point).
Variable    is defined as 0-1 within section ; if the connection line  and the connection line  have an overlap in time, apply 1; otherwise, apply 0.
Variable    is defined as 0-1; if the connection line  and the connection line  are all in the range of  and    <    <    , apply 1; otherwise, apply 0.
Variable    is defined as 0-1; if the connection line  and the connection line  are all in the range of  and    <    <    , apply 1; otherwise, apply 0.
Define 0-1 variable    ; if the variable is 1, it means that within section , connection line  will select line position   .If the variable is 0, it means that connection line  will not select line position   .Then,  ℎ clearly satisfies the relative formula  ℎ = ∑    ⋅   ℎ .Define the function  = (); when  is true,  = 1, and when  is false,  = 0. Table 1 summarizes the situation for all eight connection line crossover points.

Confirming the Line Positions.
The premise for optimizing the layout of locomotive working diagrams is to confirm the line positions in each section, that is, to determine the largest   in the set   .This can be done following the steps set out as follows.
Step 2. Sort all  ℎ  and  ℎ  within section  in ascending order by time, forming sequence {  }; when the time is the same, in addition to should be ranked first, and in the other situations, the order can be determined randomly.
Step 3. Let  1 = 0, scanning time sequence Step 4.  =  + 1; if the value of  is larger than the number of the line positions on the locomotive working diagram, go to step 5. Otherwise, go to step 2.
Step 5. Construct the number set   of the line positions in the range of , in which max   =  2 ,   ∈   .At this point, the line positions of each drawing area have been determined, and that means the set   is known.

Constraint Conditions. A One connection line can only select one line position:
B Connection lines cannot overlap C When  = 2, if two locomotives are engaged in parallel operations at both ends of a station, this is reflected in the locomotive working diagram; that is, the LL or RL of a certain connection line and the LL or RL of another connection line are at the same time, and it is obvious that the two vertical lines, which are at the same time, cannot overlap in the diagram.
Parameter    is defined as 0-   i j

Objective Function. A Minimum number of connection line crossover points:
min B To improve the visual aspect of locomotive working diagrams, connection lines should occupy the smaller delineable line positions as far as possible:

Model Solution. The model constructed above in this
paper is a nonlinear pure-integer programming model with multiple objects.These two objective functions are incommensurable, which means they have different units and cannot be solved by linear weighting methods effectively.However, these two objective functions can be solved using a delaminating sequence method in order of priority: First, solve the single-object optimized model applying formula (3) as the objective function, and formulae (1) and (2) as constraint conditions.Then, under the conditions of the above calculation results, solve the single-object optimized model, with formula (4) as the objective function, and formulae (1) and (2) as constraint conditions.
It is very difficult to obtain these solutions using this method with of-the-shelf commercially available software (such as Lingo), and even if this kind of software could produce an optimal solution, the computation time required to reach the solution would be too long to be practically viable (take the 4th section of this paper for example; the layout of the connection lines in the middle section was generated by Lingo, with Intel Core i3 CPU and 4G memory, and it still took 4 hours to reach the optimal solution).To this end, the genetic algorithm is used to solve the model in this paper.Although it is impossible to guarantee that the output will be the optimal solution, it is effective enough for practical purposes.The algorithm is described as follows.

Chromosome Encoding and Initialization.
Chromosome encoding uses digital string coding.In the drawing section, each chromosome represents one combination of all the selected line positions selected by connection lines.The number of chromosome genes is equal to the number of connection lines in the drawing area.The genes of each chromosome are sorted according to the given sequence of the connection line numbers, and each gene corresponds to the drawing area of the corresponding connecting line.For example, the chromosome "2, 1, 2" indicates that there are 3 connection lines, and the corresponding solution is  The integer   is defined as the number of chromosomes in the population; at the beginning of the genetic algorithm, the chromosomes need to be initialized.
Step 1. Randomly generate an unmarked integer ℎ   between 1 and ℎ  max .
Step 2. According to the smallest distribution method, draw the connection line ℎ   to the smallest line position label that does not conflict with other connection lines.And the labeling value of the line position was filled in the corresponding position of the chromosome.
Step 4. Verify if all integers in 1-100 are marked or not.If so, turn to Step 5; otherwise, turn to Step 1.
Step 5.The obtained chromosomes are tested and placed into the initial population if the constraints of Section 2 model construction are satisfied.Otherwise, restart the first step to construct a new chromosome.When the initial population reaches the size of a chromosome, the initialization of the population is completed.
When the initial population reaches   chromosomes, the population initialization stage is complete.

Calculation of Chromosome
Fitness.First, calculate the value  defined by the following formula for each chromosome, which reflects the pros and cons of the two objective functions of a certain chromosome: In the formula,  is a sufficiently large real number, set at 10,000 in this paper.
Then the chromosomes are sorted according to their value (ascending) to obtain the chromosomal sequence  1 ,  2 , . . .,    .Then the order-based evaluation function is defined: In the formula,  = 1 means the chromosome is best, and  =   means worst.

Chromosome Selection Process.
The chromosome selection process is based on its fitness; the greater the fitness of a chromosome, the greater the probability that it will be selected.The selection process steps are as follows.
Step 1.For each chromosome   , calculate the cumulative probability   : Step 2. Generate a random number  from the interval (0,    ].
Step 4. Repeat step 2 and step 3 for a total of   times to obtain   replicated chromosomes.The crossover operation uses a partial matching crossover method, so the chromosomes after crossover must be viable.Since chromosome genes are sorted according to the number of connection lines, crossover operations are performed as follows.
Step 3. Generate a random integer  2 between [1, ℎ  max ] randomly, then select a group of parent chromosomes that have not been selected in Step 2, and swap all the genes of these two chromosomes from  2 to the end, as shown in the Figure 5.
If the generation of descendants is viable, they can replace the parent.Otherwise, keep the viable subject and regenerate a new random number and repeat the crossover operation until two viable descendants or a given number of cycles are used up.Only the viable descendant can replace the parent in the chromosome crossover operation.

Chromosome Mutation Operation.
Define   as the probability of mutation operation, which indicates that there is an average of   ⋅  chromosomes in each population mutating.Selecting the parent of a chromosome mutation is similar to parent selection in the crossover operation, and mutation is performed as follows.
Step 2. Exchange the gene at the position  3 with the gene at the position  4 in the chromosome, as shown in Figure 6.
If the chromosome obtained after mutation is viable, the original chromosome will be replaced.Otherwise, repeat Step crossover points in Figure 7 which was drawn manually.The displacement per connection line is 9mm, 2mm more than in Figure 7 (the height of the middle section in the original diagram was 63mm).With regard to the visualization of these examples, the locomotive working diagram generated using the method presented in this paper is clearer and easier to understand and is more relevant and more legible for the purposes of front line staff.

Conclusions
Up until now, there had been little research into the visual representation of locomotive working diagrams.This paper proposes an improved and more systematic planning method to solve some of the problems encountered with computergenerated plans, such as lack of capacity or overlapping of connection lines in locomotive working diagrams, and it also dramatically improves the legibility of locomotive working diagrams.In addition, by adjusting the model slightly, the proposed method could also be applied for other purposes, such as deadhead or light travel, indicating that this method can be very versatile.

e line position 1 Figure 1 :
Figure 1: Line position of connection lines in the cyclic locomotive plan.

Figure 2 :Figure 3 :
Figure 2: The diagrams of the connection line.

Figure 4 :
Figure 4: The basic lines of connection lines.

3 = 1 .
It means that the connection line numbered 1 corresponds to the line position 2, the connection line numbered 2 corresponds to the line position 1, and the connection line numbered 3 corresponds to the line position 2.

Table 1 :
Summary of connection lines and analysis of each type of connection lines crossover point.