## 3 System Methodology
### HMM for Predicting Transportation Costs and CO\({}_{2}\) Emissions  
HMMs are probabilistic models widely used in various fields, including predictive modeling. HMMs are particularly effective in scenarios where underlying processes involve hidden states that influence observed outcomes. In the context of multimodal transportation, HMMs can be employed to model the dynamic nature of transportation costs and CO\({}_{2}\) emissions. An HMM consists of a set of hidden states, observable symbols emitted from these states, and transition probabilities between states. In the transportation domain, hidden states may represent different operating conditions, and observable symbols could correspond to cost and emission levels. Let us define the components of an HMM for predicting transportation costs (TC) and CO\({}_{2}\) emissions (CE).  
* Hidden States: \(S=\{S_{1},S_{2},\ldots,S_{N}\}\), representing different operating conditions (e.g., normal operation, peak demand, maintenance).
* Observable Symbols: \(O=\{o_{1},o_{2},\ldots,o_{M}\}\), indicating levels of transportation costs and CO\({}_{2}\) emissions.
* State Transition Probabilities: \(a_{ij}=P\left(q_{t}=S_{j}\mid q_{t-1}=S_{i}\right)\), where \(q_{t}\) represents the hidden state at time \(t\).
* Emission Probabilities: \(b_{j}(k)=P\left(o_{k}att\mid q_{t}=S_{j}\right)\), where \(b_{j}(k)\) is the probability of observing symbol \(o_{k}\) when in state \(S_{j}\).
* Initial State Probabilities: \(\pi_{i}=P(q_{1}=S_{i})\), representing the probability of starting in state \(S_{i}\).  
Given a sequence of observed symbols \(=o_{1},o_{2},\ldots,o_{T}\), the goal is to find the most likely sequence of hidden states \(S=S_{1},S_{2},\ldots,S_{T}\) that generated the observed sequence. This is achieved through the Viterbi algorithm,  
\[\delta_{t}(j)=max_{i}\big{[}\delta_{t-1}(i)\cdot a_{ij}\big{]}\cdot b_{j}(o_{ t}) \tag{19}\]\[\psi_{t}(j)=argmax_{i}\big{[}\delta_{t-1}(i)\cdot a_{ij}\big{]} \tag{20}\]  
The most likely state sequence is then obtained by backtracking through the computed values. Training the HMM involves estimating the model parameters \((a_{ij},\ b_{j}(k),\pi_{i})\) based on historical data. The expectation-maximization (EM) algorithm is commonly employed for this purpose.  
Let \(Q=\{q_{1},q_{2},\ldots,q_{T}\}\) represent the hidden state sequence corresponding to observed symbols \(O\). The EM algorithm iteratively maximizes the expected log-likelihood:  
\[Q(\lambda\mid O)=\sum_{Q}P(Q\mid O,\lambda)\cdot logP(O,Q\mid\lambda) \tag{21}\]  
where \(\lambda\) represents the set of model parameters.  
The update equations for the HMM parameters are as follows:  
* Transition Probabilities: \(a_{ij}=\frac{\sum_{t=2}^{T}\xi_{t}(i,j)}{\sum_{t=1}^{T}\tau_{t}(i)}\);
* Emission Probabilities: \(b_{j}(k)=\frac{\sum_{t=1}^{T}\gamma_{t}(j)\cdot\delta(\alpha-k)}{\sum_{t=1}^{ T}\tau_{t}(i)}\);
* Initial State Probabilities: \(\pi_{i}=\gamma_{1}(i)\).  
Here, \(\xi_{t}(i,j)\) is the probability of transitioning from state \(S_{i}\) to \(S_{j}\) at time \(t\), \(\gamma_{t}(i)\) is the probability of being in state \(S_{i}\) at time \(t\), and \(\delta(\cdot)\) is the Kronecker delta function.  
By utilizing historical data, the HMM is trained to capture the underlying patterns in transportation costs and CO\({}_{2}\) emissions, enabling accurate predictions in real-time scenarios. This approach enhances the system's ability to anticipate changes, optimize resource allocation, and improve overall decision-making in the multimodal transportation network.