## 1 Introduction  
Indoor localization has emerged as an indispensable technology for location-based services (LBSs) in indoor situations such as shopping malls, warehouses, conference centers, and so on [1]. Accurate, reliable, and real-time localization forms the essential foundation for autonomous navigation and task allocation [2]. Studies indicate that individuals typically spend 80% to 90% of their time across various indoor situations [3]. Consequently, people's demand for indoor positioning is steadily increasing. In order to achieve reliable indoor locations, indoor localization technology is experiencing increasing development, including RFID [4], WiFi [5], UWB [6], Bluetooth [7], Zigbee [8], ultrasonic [9], and infrared [10] technologies. Due to the extensive deployment of WLAN and wireless access technologies, WiFi has emerged as the predominant solution, favored for its low-cost devices, extensive infrastructure deployment, and relatively high accuracy [11]. WiFi positioning uses a substantial number of already-deployed access points (APs), resulting in its low cost and applicability [12]. In such a positioning system, fingerprint approaches based on received signal strength (RSS) show significant advantages. The RSS fingerprinting-based localization method does not require specific coordinates of the AP or measurement of the angle and distance of the signal receiver, which is feasible in indoor localization [13]. The RSS fingerprinting method is divided into two stages: the offline and online phases [14]. In the offline stage, signal fingerprints are collected systematically to construct a database. In the online stage, these collected signal data are compared with the existing fingerprints in the database to locate the target's physical location. This fingerprint matching process offers high robustness and stability, making it suitable for various complex environments. This paper optimizes the traditional WKNN algorithm with the PSO model in the online WiFi phase. Inertial sensors typically include accelerometers and gyroscopes. These sensors measure acceleration and angular velocity, and combined with appropriate algorithms, they can estimate the movement trajectory and position of an object. Pedestrian dead reckoning (PDR) is an inertial navigation technique that relies on the walking characteristics of pedestrians to estimate their position and movement trajectory [15]. It calculates a person's position by measuring their step count, step length, and direction [16]. However, the integration of acceleration and angular velocity in PDR leads to cumulative errors. Even small measurement errors can accumulate over time, causing the position estimate to gradually deviate from the true location. Given that both WiFi and PDR positioning technologies are implemented on consumer-grade portable mobile devices, their integration has become a prominent area of research. [PERSON] et al. [17] proposed a three-dimensional indoor localization algorithm based on the unscented Kalman filter (UKF), integrating WiFi fingerprinting and PDR data. [PERSON] et al. [18] designed an extended Kalman filter (EKF) data fusion framework that integrates PDR and WiFi positioning. This method significantly reduces the mean positioning error while also lowering computational costs. [PERSON] et al. [19] proposed a PDR and WiFi fusion algorithm based on the federated particle filter (FPF), which enhances pedestrian navigation accuracy through information sharing. Based on the PDR and WiFi fusion algorithm PF, this paper introduces the AO algorithm to further optimize the PF algorithm. The key contributions of this study are summarized as follows:  
1. Considering the insufficient localization accuracy of the WKNN algorithm in WiFi portion, the PSO model is proposed to leverage the PSO to identify the k closest approximate fingerprints and then utilize WKNN to locate the final position.