# Ship Scheduling Algorithm Based on Markov-Modulated Fluid Priority Queues
## 3 Problem Modeling and Algorithm Modeling
### Construction of SSA-BMMFPQ  
In SSA-BMMFPQ, the arrival process of ships is reconstructed as a fluid-input process modulated by the state of the anchorage, and the service process should be a fluid-output process with a controllable rate. Considering the situation of multi-priority ships, it is assumed that ships are divided into K priority classes, and the \(k\)+1-th priority class has a higher priority than the \(k\)-th priority class. The CTMC \(\{J(t),t\geq 0\}\) is used to describe the changes in the system state, and its set of states is \(\mathcal{S}=\{S_{1},S_{2},\cdots,S_{n}\}\). In the state \(S_{i}\), the arrival rate of ships of the \(k\)-th class is \(r_{i}^{(k)}\geq 0\), and these arrival rates form the arrival rate matrix \(R^{(k)}=diag\Big{(}r_{i}^{(k)}\Big{)}\). The states in \(\mathcal{S}\) are interconnected through \(Q\), and the probability of transitioning from state \(S_{i}\) to state \(S_{j}\) per unit time is \(q_{ij}\). The \(Q\) in the CTMC is used to describe the dynamic transition characteristics of the system state, recording the rules regarding how quickly the anchorage transitions from one working state to another under different operation situations (such as the entry and exit of ships). \(Q\) further affects the arrival rate matrix \(R^{(k)}\) and reduces the arrival rate \(r_{i}^{(k)}\) of ships. Let \(d\) be a constant, and ships with higher priority are served first. Using a fluid level similar to the length of the ship queue, under the state \(S_{i}\), the rate of change in the length of the queue of ships of the \(k\)-th class can be expressed as  
\[\frac{dL_{k}(t)}{dt}=\left\{\begin{matrix}r_{i}^{(k)}-d,if{\sum_{l>k}}L_{j}(t) =0 andr_{i}^{(k+)}\leq d\\ r_{i}^{(k)},else\end{matrix}\right. \tag{1}\]  
Formula (1) clarifies the dynamic changes in the queue length under different conditions, laying a foundation for the subsequent analysis of the system's stability and performance indicators. In the steady-state condition, all states and parameters of the entire system no longer change with time, which means that the arrival and departure of ships reach stability, and the queue length also tends to be stable. Meanwhile, for the arrival process of ships of the \(k\)-th class, the following relationship exists between \(\lambda^{(k)}\) and \(l\) under steady-state conditions:  
\[\lambda^{(k)}=\pi_{i}R^{(k)}l \tag{2}\]  
When the system operation tends to be stable, the boundary condition  
\[\sum_{k=1}^{K}\lambda^{(k)}<d \tag{3}\]  
needs to be satisfied to ensure that the outflow rate of ships is greater than the inflow rate. Only when this condition is met can the system maintain stable operation and avoid the  
Figure 2: SSA-BMMFPQ framework.  
infinite growth of the queue. At this time, the expected value of the rate of change in the queue length of ships of the \(k\)-th class is 0--that is, the equilibrium condition is satisfied:  
\[\frac{d}{dx}\pi^{(k)}(x)C^{(k)}=\pi^{(k)}(x)Q,\ \ \ C^{(k)}=\frac{1}{d}R^{(k+)}- \mathbf{I} \tag{4}\]  
The boundary condition is  
\[\pi^{(k)}(0)C^{(k)}=p^{(k)}Q,\ \ \ p^{(k)}=0\gg or\gg r_{i}^{(k+)}>d \tag{5}\]  
Through the above equilibrium condition and boundary condition, key performance indicators, such as the queue lengths and waiting times of various types of ships, can be further solved, providing a solid theoretical basis for the optimized scheduling of the system and the rational allocation of resources.