## 4 Materials and Methods
### Mathematical Background of the Proposed Model  
_Step 1._ The particle contains a large number of data, the most important of which is the \"encoded particle\" matrix. This matrix is made up of the analyzed ships that represent the rows of the matrix and the associated time intervals that represent the columns of the matrix. Based on the entry table of the sailing schedule, the state in which the ship can be in terms of loading is determined. When the ship is not available for charging, it is assigned a mark of \"\(-1\)\". When it is available for charging and is not being charged, it is assigned a mark of \"0\". When it is being charged, it is assigned a mark of \"1\". The schedule matrix \"encoded particle\" size \(mxn\) in which \(m\) represents number of ferries and \(n\) number of time slots is defined as follows:  
\[N_{m}=\left\{1,\ldots,m\right\};N_{n}=\left\{1,\ldots,n\right\}\]  
\[M=\left\{M_{ij},i\in\left\{1,\ldots,m\right\},j\in\left\{1,\ldots,n\right\}:M _{ij}\in\left\{-1,0,1\right\}\right\} \tag{4}\]  
The input matrix of the daily sailing schedule, the state in which the ship can be in terms of charging, is created by introducing the auxiliary \(f\) function with the following equation:  
\[f:\left\{1,\ldots,m\right\}x\left\{1,\ldots,n\right\}\rightarrow\left\{-1,0,1\right\}:f(i,j)=\left\{ \begin{array}{c}1\text{ }if\text{ }ship\text{ }i\text{ }charges\text{ }in\text{ }interval\text{ }j\\ 0\text{ }if\text{ }ship\text{ }i\text{ }is\text{ }in\text{ }part\text{ }and\text{ }not\text{ }charging\text{ }in\text{ }interval\text{ }j\\ -1\text{ }if\text{ }ship\text{ }i\text{ }is\text{ }not\text{ }in\text{ }in\text{ }part\text{ }in\text{ }interval\text{ }j\end{array} \right.\]  
\[M=\leftStep 2: Function \(f\) translates pairs of natural numbers in which the first value is between 1 and \(m\) and the second is between 1 and \(n\), into a number from columns \(-1\), 0, 1.  
The change in matrix position is defined as follows:  
\[M_{k-1}^{g*}\ldots\textit{the best global schedule in previous iteration }(k-1)\]  
\[M_{k-1}^{i*}\ldots\textit{the best local schedule in previous iteration }(k-1)\]  
\[M_{k-1}\ldots\textit{actual particle schedule in previous iteration }(k-1)\]  
Step 3: The difference in the global optimum (in our case, minimum) is calculated as follows:  
\[\Delta M_{g}=M_{k-1}^{g*}-M_{k-1} \tag{6}\]  
The difference in the local optimum is calculated as follows:  
\[\Delta M_{l}=M_{k-1}^{l*}-M_{k-1} \tag{7}\]  
Step 4: Relative differences in power between the actual schedule and global optimum are calculated as follows:  
\[\varepsilon_{g}=\frac{P_{k-1}-P_{k-1}^{g*}}{P_{k-1}} \tag{8}\]  
Step 5: Relative differences in power between the actual schedule and local optimum are calculated as follows:  
\[\varepsilon_{l}=\frac{P_{k-1}-P_{k-1}^{l*}}{P_{k-1}} \tag{9}\]  
Step 6: The probability of a schedule change is calculated, i.e., displacement to global and local optimum in which \(p_{d,\,g}\) probability of displacement toward global best and \(p_{d,\,l}\) probability of displacement toward local best, is calculated as follows:  
\[p_{d,g}=w_{g}.\frac{P_{k-1}-P_{k-1}^{g*}}{P_{k-1}} \tag{10}\]  
\[p_{d,l}=w_{l}.\frac{P_{k-1}-P_{k-1}^{l*}}{P_{k-1}} \tag{11}\]  
where \(w_{g}\) represents the global weight and \(w_{l}\) represent local weight. Step 7: The PSO algorithm's weight factors are important parameters controlling the particle's movement [34]. A higher weight factor increases the possibility of searching for a particle so that it leaves the area of the local optimum. On the other hand, a lower weight factor increases the capabilities of the particle in local search [35].