## 3 Methods
### K-Prototypes Algorithm  
Since the variables involved in trip chains include both categorical data, such as gender and mode of transportation, as well as numerical data, such as travel distance and travel time, clustering methods like K-means for numerical data and K-modes for categorical data are no longer suitable for clustering trip chains in this study [63]. The K-prototypes algorithm is a well-established method for clustering mixed data types [64]. It builds upon the framework of the K-means algorithm while integrating features of the K-modes algorithm. By adjusting parameters, it balances the relative importance of categorical and numerical data during the clustering process. This approach is both simple and highly efficient, making it widely used in clustering tasks that involve mixed datasets. Let \(X=\left\{x_{1},x_{2},\ldots,x_{n}\right\}\) denote the set of intercity trip chains, which comprise \(n\) pieces of data. Each \(x_{i}\) is characterized by attribute \(A=\left\{a_{1},a_{2},\ldots a_{m_{r}},a_{m_{r+1}},\ldots a_{m_{r}+m_{c}}\right\}\), where the first \(m_{r}\) attribute is numerical, and the subsequent attributes are categorical. Let \(V=\left\{v_{j}|1\leqslant j\leqslant m\right\}\) denote the set of values for all attributes, where \(v_{j}\) is the set of values for attribute \(a_{j}\  
where \(K\) is the number of clusters. \(p_{l}(v_{j}^{t})\) denotes the proportion of value \(v_{j}^{t}(1\leqslant t\leqslant n_{j})\) in cluster \(C_{l}\)\((l=1,\;2,\ldots,K)\), as outlined in Equation (7). \[ \begin{split} p_{l}(v_{j}^{t})=\Big{|}\Big{\{}\{x_{i}\big{|}f(x_{ i},a_{j})=v_{j}^{t},x_{i}\in C_{l}\}\Big{|}\big{/}\Big{|}C_{l}\Big{|}\\ 0\leq p_{l}(v_{j}^{n_{j}})\leqslant 1\\ \sum_{t=1}^{n_{j}}p_{l}(v_{j}^{t})=1\end{split}  \tag{7}\]  
Let \(Z=\{z_{1},z_{2},\cdots,z_{k}\}\) denote the set of cluster centers, where \(z_{l}\) is the center of cluster \(C_{l}\). For each center \(z_{l}(1\leq l\leq k)\), the following conditions apply:  
\[f(z_{l},a_{j})=\left\{ \begin{array}{l}\sum\limits_{x_{i}\in C_{l}}f(x_{i}, a_{j})\\ \frac{x_{i}\in C_{l}}{|C_{l}|},\;1\leqslant j\leqslant m_{r}\\ v_{j}^{t^{\prime}},\;m_{r}<j\leqslant m\end{array} \right. \tag{8}\]  
where \(v_{j}^{t^{\prime}}\) denotes the most frequent value of attribute \(a_{j}\) within cluster \(C_{l}\). The dissimilarity between \(x_{i}\) and cluster center \(z_{l}\) is calculated as follows:  
\[ \begin{split} D(x_{i},z_{l})=D_{r}(x_{i},z_{l})+\gamma D_{c}(x_{ i},z_{l})\\ D_{r}(x_{i},z_{l})=\sum\limits_{j=1}^{m_{r}}(f(x_{i},a_{j})-f(z_{l},a_{j}))^{ 2}\\ D_{c}(x_{i},z_{l})=\sum\limits_{j=m_{r}+1}^{m}\delta(f(x_{i},a_{j}),f(z_{l}, a_{j}))\end{split}  \tag{9}\]  
where \(D_{r}(x_{i},z_{l})\) is the dissimilarity for numerical attributes, \(D_{c}(x_{i},z_{l})\) is the dissimilarity for categorical attributes, and \(\gamma\) is a weight that controls the contributions of numerical and categorical attributes. \(\delta(x,y)\) is defined as follows:  
\[\delta(x,y)= \begin{cases}1,&x=y\\ 0,&x\
eq y\end{cases}  \tag{10}\]  
The objective function of the K-prototypes algorithm can be defined as follows:  
\[F=\sum\limits_{l=1}^{k}\sum\limits_{i=1}^{n}w_{li}D(x_{i},z_{l}) \tag{11}\]  
The value of \(w_{li}\) is 0 or 1, where 1 indicates that \(x_{i}\) is assigned to cluster \(l\), and 0 indicates that \(x_{i}\) is assigned to cluster \(l\). Each data is partitioned and assigned to only one cluster. In summary, the steps for implementing the K-prototypes algorithm are as follows:  
Step 1: Randomly select K pieces of data from dataset \(X=\{x_{1},x_{2},\ldots,x_{n}\}\) as the initial cluster centers. The initial cluster center set is \(Z=\{z_{1},z_{2},\cdots,z_{k}\}\). Step 2: Calculate the distance \(D(x_{i},z_{l})\) between \(x_{i}\) and \(Z_{l}\), which is the cluster center. Step 3: According to the minimum value of \(D(x_{i},z_{l})\), assign \(x_{i}\) to the corresponding cluster where \(Z_{l}\) is located.