# A Study on the Design and Control of the Overhead Hoist Railway-Based Transportation System
## 4 Control Algorithms
### Algorithm of the Whole System  
The decision issue is how to carry out transport tasks quickly. In addition, the shuttles must avoid each other during the operation process. The feasible routes that the shuttle uses for delivering goods can be considered a closed circle, and the shuttles can only move in two directions. Therefore, optimizing the system in terms of running time and power consumption is a very difficult task. Considering the consumed energy, it is uncertain whether the system can execute a certain task successfully. Moreover, based on the number of stations and the number of shuttles in the whole system, we will require different types of control algorithms to operate all the shuttles.  
There are two requirements:  
1. Pre-orders need to be processed as soon as possible to avoid long waiting times for delivery.
2. The shuttles that need to change batteries should be given priority changing to avoid the situation of running out of batteries, which can become an obstacle on the route. Because of these two conditions, we will establish four rules that match the requirements of the system: 1. Rule 1: If two shuttles meet on the route, the shuttle with the lower priority must avoid the other. 2. Rule 2: Each shuttle can only carry out one task at a time. Shuttles must go through four stages on each mission. The task must go through four stages from the request to the completion of delivery. Shuttles approaching mission completion will be selected for the task. 3. Rule 3: When operating the entire system, it goes through two processes: * Process 1: Change the state of the shuttle and upload completed missions to MySQL; * Process 2: Find new locations. 4. Rule 4: The system's shuttles will be reset before it enters another new process. There are seven statuses for the shuttles, and each has a different priority level. The algorithm will determine the next location for each shuttle based on the status's priority. The priority for each status is as follows.  
The initial status of shuttles will define in Table 2. The system will determine the travel routes for the shuttles from the current time until it changes its status. We will show an overview of how the algorithm works in Figure 7 and Table 3. We are still contending that the energy consumed by the shuttle when moving simultaneously is the same.  
As shown in Figures 8-10, there are only two missions to undertake, namely, \"Delivery at Station 2\" and \"Take goods at Station 1\". The figures and tables demonstrate how shuttles are chosen to carry out the work. If shuttle B is chosen to perform all missions in 0 s, it would save energy for the entire system. However, the algorithm cannot select it because it simply calculates until the system changes. From 0 to 5 s, the state of the system is the same as the one shown in Table 3; the algorithm will calculate the position of the shuttles during that time, but after 5 s, the algorithm will not be able to calculate because the state of  
In any state of the system, the algorithm always tries to choose the better energy-saving solution. As shown in Figure 10 and Table 5, at the time 45 s, the system's state changes; Shuttle B is free, and the distance from B to station 1 is closer than that of shuttle A. As a result, Shuttle B is selected to get the goods, and Shuttle A is stopped. The control algorithm of the system is presented in the form of pseudocode Algorithm 1 and the flow chart in Figure 11.