# A Study on the Design and Control of the Overhead Hoist Railway-Based Transportation System
## 4 Control Algorithms
### Find a New Location for the Shuttles
#### 4.4.3 A Method for Finding a Solution
The control algorithm for this problem is introduced as Figure 17 and the details of the system before changing status to \"Find the direction of the system\" at the time \(t_{0}\) is shown in Table 9.  
```
1:Begin Find the direction for each shuttle:
2:for (CHECK-shuttle) = Highest priority shuttle: Lowest priority shuttle do
3:if CHECK-shuttle had been set the direction then
4: Change to the next priority shuttle;
5:else
6: Step 1: Change to the next priority shuttle;
7: Step 2: Create a group of shuttles to move in the nearest direction found in Step 1;
8: Rules for creating groups:
9: Step 1:
10: Set the (last-shuttle) = CHECK-shuttle
11: Add the CHECK-shuttle into \"group\"
12: Step 2:
13:if distance between last-shuttle and the shuttle next to it \(\leq\) \"safe distance\" then
14: Add the shuttle which is next to the last shuttle into \"group\";
15: Set (last-shuttle) = the shuttle has just been added
16:else
17: End find the \"group\"
18:endif
19: Step 3: Check the \"stuck\" with the higher priority shuttles if the group goes in the intended direction
20:if \"no stuck\" then
21: Set the direction of all shuttles in the group in the same as the direction found in Step 1;
22: Set the priority of all shuttles in the group as the same as the priority of the CHECK-shuttle;
23: ADD all shuttles in group into \"had-run\" list;
24: Change to check the next priority shuttle;
25:else
26:if (Have a station which was not be selected before coming to the jam position) then
27: Set that Station will be used for CHECK-shuttle avoiding;
28: Set the direction of all shuttles in the group in the same as the direction found in Step 1;
29: Set the priority of all shuttles in the group as the same as the priority of the CHECK-shuttle;
30: Change to check the next priority shuttle;
31:else
32: Set direction of CHECK-shuttle is \"non-run\";
33: ADD all CHECK-shuttle in the group into \"had-run\" list;
34: Change to check the next priority shuttle;
35:endif
36:endif
37:endif
38:endfor
39:End
```  
**Algorithm 5** Find the direction for each shuttlesFigure 18 illustrates all the possible situations that the delivery system can encounter. Table 10 is the entire information of the shuttles. Here is how the algorithm solves the problem: we apply the above algorithm as introduced in Figure 18 with the operation condition as introduced in Table 10. With every cycle, the system will search for the travel direction for the shuttle that has not yet set the highest priority. First turn: Shuttle 1 with the highest priority that has not been set in the travel direction. Step 1: The nearest direction to Station A is clockwise;  
Step 2: Follow the clockwise direction, the next shuttle is shuttle 6, but;  
Step 3: If the \"group of Shuttle 1\" moves, the shuttles will not collide with each other because there are no shuttles with higher priority than Shuttle 1. So, Shuttle 1's direction is set to clockwise. Figure 17: The flow chart for “Find the direction for each shuttles”. \begin{table}
\begin{tabular}{|p{56.9 pt} p{56.9 pt} p{56.9 pt} p{56.9 pt} p{56.9 pt}|} \hline
**Priority** & **Shuttle** & **State of Shuttle** & **Mission** & **Direction** \\ \hline
1 & 1 & Need charge shuttle & Go charge at Station A & Not set \\
2 & 2 & Delivery shuttle & Delivery at Station D & Not set \\
3 & 3 & Delivery shuttle & Delivery at Station F & Not set \\
4 & 4 & Free shuttle & Get good at Station E & Not set \\
5 & 5 & Free shuttle & Get good at Station B & Not set \\
6 & 6 & Free shuttle & Don’t have mission & Not set \\
7 & 7 & Free shuttle & Don’t have mission & Not set \\ \hline \end{tabular}
\end{table} 
Table 9: Details of the system before changing status to “Find the direction of the system” at the time \(t_{0}\). Figure 18: The sytems at the time \(t_{0}\).