Train Scheduling Problems

Source: Internet
Author: User
Train is an important means of transportation in human production and life. A train is traveling on a railway line. There are railway stations in some places on the railway. The railway station usually has some branch railway branches that are forked from the main trunk line for the train to stop, so as to allow passengers to or unload goods. The Railway Branch has a certain length, and the train has a certain length, and the length of each train is equal.

Suppose there is a small station on a east-west Railway. The station has only one branch road for the railway to dock, and the branch road can accommodate up to M trains (M <= 3 ). To ensure smooth train operation, the station only allows the train to enter the East Station and exit from the West Station. First, the train must exit first. Otherwise, the train in the station will be congested.

The railway station is busy with tasks. Every day, there are n (n <= 250) trains heading from the east to the west. They are required to enter the railway station at the scheduled time and make some time stops at the station. In order to meet the requirements of each incoming train, the scheduling of small stations must be carried out in an orderly manner. Before starting daily work on the station, the staff must read the application for all trains and decide which trains are accepted. For trains that cannot meet the requirements, the station must inform them in advance and ask them to change their route so as not to affect normal railway transportation. Because the arrival time of a train is negligible, the station allows several trains to enter and exit at the same time. The station staff can arrange the order of these trains at will. The principle of small stations is to satisfy the requirements of applying for trains as much as possible.

Your task is to help the staff check the arrival application of all trains on a certain day, and decide the maximum number of trains that can meet the requirements and the number of these trains.

Problem Analysis:

This is an optimization problem, that is, the maximum value that a small station can accept a train application.

Extreme situations:

If the first train requested to enter the station requires a day to stop, then if the request is accepted, the station can serve as a train at most.

If every m trains require both inbound and outbound traffic, and the departure time in front of the M train is equal to the arrival time of the M train in the back, then, the small station can meet the requirements of all N trains.

Condition:

1,Trains that enter the station at the same time can be arranged in any order.

2,Station train first-in-first-out.

3,Trains that require simultaneous departure can also be arranged in any order.

The main idea of solving this problem is to find the minimum value. Because trains are sequential, it can be seen as the minimum value of a directed graph.


Describes several situations. The source point of the directed graph is uncertain, because several trains may submit the first application at the same time, or the first requested train may not be optimal.Algorithm.

Therefore, this algorithm uses each vertex as the source point and then deletes them one by one.

1,Each edge is assigned a value of 1 as the weight. The more vertices there are, the more arcs there are. This indicates that more trains are accepted, and the larger the value is. The weight of each vertex is 0.

2,The final graph is a graph with only one source and one ending vertex, And the outbound and inbound degrees of all vertices in the middle must be 1.


3,

Create a directed graph with each vertex as the Source Vertex. Every two vertex can be reached as long as the two vertices are reachable (for example, requests from train 1 are accepted, and requests from train 2, 3, and 4 are acceptable ), there is an arc between them, and each arc has an initial weight of 1.

4,In the figure, the vertices are distributed from left to right based on the timeline (based on the time when the inbound request occurred ).

5,Based on a certain method, we eliminate as few arcs (unreasonable) as possible from each graph and finally obtain the minimum value.

6,The arc elimination method is to calculate the right of each vertex. Its right is the right of one of its precursor vertices, plus the right of the arc between them. If the vertex has multiple inbound degrees, a maximum value is retained to delete other incoming arcs.

For example, a timeline is used to scan the first graph. 1 There is no inbound arc, the weight remains unchanged, and the value remains 0.

2There is an inbound arc from 1, then add 1 to 1.

3There are two degrees of arc, from 1 to 0 + 1, the right is 1; from 2 to 1 + 1, to 2. Therefore, the arc from 1 to 3 is deleted, and the path with high weight is retained.

4There are three degrees of arc, from 1, 0 + 1 = 1, from 2, 1 + 1 = 2, from 3 2 + 1 = 3.

Therefore, the arc from 3 to 4 is retained.

Finally, the scheduling sequence is 1-2-3-4. The entire graph is the final 4 right, 3.

7,In the end, compare the weights of all graphs with the largest values. The scheduling sequence and train number are obtained.

8,The number of vertices in each graph is not necessarily the same. If you select a Source Vertex, you can only accept other vertices that meet the conditions by using timeline scanning. Consider the maximum number of trains at the station.


If the path that meets the conditions is greater than the station capacity, the weight of the path that cannot be accommodated must be infinite (for example, 1000 ). For example, if a request is sent from 1 to 2, 3, and 4 at the same time, if the five vehicles are in the conflict zone, you must exclude one of the two or three vehicles.

Algorithm analysis:

This algorithm has high time and space complexity. It is not a high-quality algorithm.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.