K-Nearest Neighbors for Smart Solution Transportation: Prediction Distance Travel and Optimization of Fuel Usage and Charging Recommendations for ICE Vehicles Based in Surabaya

Authors

  • Farid Baskoro State University of Surabaya
  • Widi Aribowo State University of Surabaya
  • Hisham Shehadeh Yarmouk University
  • Hewa Majeed Zangana Duhok Polytechnic University
  • Wahyu Sasongko Putro Nanyang Technological University
  • Sri Dwiyanti State University of Surabaya
  • Aristyawan Putra Nurdiansyah State University of Surabaya

DOI:

https://doi.org/10.12928/biste.v8i2.15068

Keywords:

Haversine, KNN, Gas Station, Surabaya, Transportation

Abstract

Surabaya ranks 9th in Southeast Asia and 44th globally in the TomTom Traffic Index, with an average travel time of ±22 minutes for a 10 km distance, longer than Jakarta’s ±20 minutes. Given these traffic conditions, this study examines the application of the K-Nearest Neighbors (KNN) algorithm to predict vehicle travel distance based on remaining fuel consumption and provides recommendations for the nearest Gas Station (SPBU) based on the predicted distance. The study seeks to provide accurate distance predictions and recommend the nearest Gas Station (SPBU) for users based on fuel consumption and the predicted route, helping to navigate Surabaya’s congested traffic efficiently. The data used includes various levels of fuel consumption: 0.02, 0.06, 0.10, 0.14, 0.16, 0.20, and 0.24 liters for engines of 110, 125, and 150 cc. The model evaluation results, using three metrics: MAE, MAPE, and RMSE show that KNN performs excellently at low fuel consumption levels. At a consumption rate of 0.02 liters, the model produces a low MAE of 0.347, MAPE of 31.21%, and RMSE of 0.40, indicating minimal prediction error. The model's performance remains consistent at a consumption of 0.06 liters with MAE of 0.330, MAPE of 9.90%, and RMSE of 0.41, demonstrating a high level of accuracy. Technically, the implementation of this model can help reduce traffic congestion by directing vehicles to the nearest gas stations, thereby minimizing sudden stops on the road, improving traffic flow, and reduce wasted time spent searching for distant gas stations.

References

Y. Chen et al., “Fast density peak clustering for large scale data based on kNN,” Knowledge-Based Syst., vol. 187, p. 104824, 2020, https://doi.org/10.1016/j.knosys.2019.06.032.

D. Xu, Y. Wang, P. Peng, S. Beilun, Z. Deng, and H. Guo, “Real-time road traffic state prediction based on kernel-KNN,” Transp. A Transp. Sci., vol. 16, no. 1, pp. 104–118, 2020, https://doi.org/10.1080/23249935.2018.1491073.

J. Miao, Y. Liu, Q. Yin, G. Zhang, and Y. Yuan, “Research on the Influence of Signal Sampling Frequency on Soft Fault Diagnosis Accuracy of DC/DC Converters,” CPSS Trans. Power Electron. Appl., vol. 8, no. 1, pp. 33–41, 2023, https://doi.org/10.24295/CPSSTPEA.2023.00004.

O. Kherif, Y. Benmahamed, M. Teguar, A. Boubakeur, and S. S. M. Ghoneim, “Accuracy Improvement of Power Transformer Faults Diagnostic Using KNN Classifier With Decision Tree Principle,” IEEE Access, vol. 9, pp. 81693–81701, 2021, https://doi.org/10.1109/ACCESS.2021.3086135.

E. A. Hassan, A. M. Mohamed, F. A. Eltaib, A. M. S. Khaled, and et al., “Determinants of Nursing Students’ Satisfaction with Blended Learning,” BMC Nurs., vol. 23, no. 1, p. 766, 2024, https://doi.org/10.1186/s12912-024-02393-y.

S. Uddin, I. Haque, H. Lu, M. A. Moni, and E. Gide, “Comparative performance analysis of K-nearest neighbour (KNN) algorithm and its different variants for disease prediction,” Sci. Rep., vol. 12, no. 1, p. 6256, 2022, https://doi.org/10.1038/s41598-022-10358-x.

S. Zhang, “Cost-sensitive KNN classification,” Neurocomputing, vol. 391, pp. 234–242, 2020, https://doi.org/https://doi.org/10.1016/j.neucom.2018.11.101.

L. Xiong and Y. Yao, “Study on an adaptive thermal comfort model with K-nearest-neighbors (KNN) algorithm,” Build. Environ., vol. 202, p. 108026, 2021, https://doi.org/10.1016/j.buildenv.2021.108026.

H. Durani, M. Sheth, M. Vaghasia, and S. Kotech, “Smart Automated Home Application using IoT with Blynk App,” Proc. Int. Conf. Inven. Commun. Comput. Technol. ICICCT 2018, pp. 393–397, 2018, https://doi.org/10.1109/ICICCT.2018.8473224.

N. Ukey, Z. Yang, B. Li, G. Zhang, Y. Hu, and W. Zhang, “Survey on Exact kNN Queries over High-Dimensional Data Space,” Sensors, vol. 23, no. 2, 2023, https://doi.org/10.3390/s23020629.

S. Zhang, “Challenges in KNN Classification,” IEEE Trans. Knowl. Data Eng., vol. 34, no. 10, pp. 4663–4675, 2022, https://doi.org/10.1109/TKDE.2021.3049250.

S. Zhang and J. Li, “KNN Classification With One-Step Computation,” IEEE Trans. Knowl. Data Eng., vol. 35, no. 3, pp. 2711–2723, 2023, https://doi.org/10.1109/TKDE.2021.3119140.

H. Lee, H. Choi, K. Sohn, and D. Min, “KNN Local Attention for Image Restoration,” in 2022 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pp. 2129–2139, 2022, https://doi.org/10.1109/CVPR52688.2022.00218.

S. Goyal, “Handling Class-Imbalance with KNN (Neighbourhood) Under-Sampling for Software Defect Prediction,” Artif. Intell. Rev., vol. 55, no. 3, pp. 2023–2064, 2022, https://doi.org/10.1007/s10462-021-10044-w.

K. Kim, “Normalized class coherence change-based kNN for classification of imbalanced data,” Pattern Recognit., vol. 120, p. 108126, 2021, https://doi.org/https://doi.org/10.1016/j.patcog.2021.108126.

Sukamto, Hadiyanto, and Kurnianingsih, “KNN Optimization Using Grid Search Algorithm for Preeclampsia Imbalance Class,” E3S Web Conf., vol. 448, p. 2057, 2023, https://doi.org/10.1051/e3sconf/202344802057.

Z. Lei, L. Zhu, Y. Fang, X. Li, and B. Liu, “Anomaly detection of bridge health monitoring data based on KNN algorithm,” J. Intell. & Fuzzy Syst., vol. 39, no. 4, pp. 5243–5252, 2020, https://doi.org/10.3233/JIFS-189009.

B. S. Yaswanth, “Smart Safety and Security Solution for Women using kNN Algorithm and IoT,” no. i, pp. 87–92, 2020, https://doi.org/10.1109/MPCIT51588.2020.9350431.

A. Ali, M. A. T. Alrubei, L. F. M. Hassan, M. A. M. Al-Ja’afari, and S. H. Abdulwahed, “Diabetes Diagnosis Based On Knn,” IIUM Eng. J., vol. 21, no. 1, pp. 175–181, 2020, https://doi.org/10.31436/iiumej.v21i1.1206.

A. Juna et al., “Water Quality Prediction Using KNN Imputer and Multilayer Perceptron,” Water, vol. 14, no. 17, 2022, https://doi.org/10.3390/w14172592.

W. Zhuang and Y. Cao, “Short-Term Traffic Flow Prediction Based on a K-Nearest Neighbor and Bidirectional Long Short-Term Memory Model,” Appl. Sci., vol. 13, no. 4, 2023, https://doi.org/10.3390/app13042681.

J. Jang, “Travel time prediction using machine learning algorithms: focusing on k-NN, LSTM, and Transformer,” The Open Transportation Journal, vol. 18, no. 1, 2024, https://doi.org/10.2174/0126671212356139241101070347.

A. F. Aritenang, S. R. Ginting, and A. D. Sakti, “Metropolitan spatial structure based on commuting pattern: a comparison between Jakarta and Surabaya metropolitans,” International Journal of Urban Sciences, vol. 29, no. 2, pp. 503-521, 2025, https://doi.org/10.1080/12265934.2024.2358101.

G. N. A. Pranoto, A. Jatayu, M. R. I. Robbik, R. Hamdika, and N. Nurjannah, “Sensitivity of Variables Affecting Urban Heat Island (UHI) Intensity to Different Levels of Transit Oriented Development (TOD) and Non TOD-Adjacent Areas in Jakarta City,” In IOP Conference Series: Earth and Environmental Science, vol. 1498, no. 1, p. 012009, 2025, https://doi.org/10.1088/1755-1315/1498/1/012009.

R. A. Nugraha and R. Christiawan, “Airport Development in Indonesia: Legal and Policy Considerations,” In Aerodrome Governance in Asia: Legal and Managerial Perspectives, pp. 139-157, 2025, https://doi.org/10.1007/978-981-96-7568-5_8.

Y. K. Thakre and P. Y. Pawade, “Traffic Congestion at Urban Road-Review,” In IOP Conference Series: Earth and Environmental Science, vol. 1326, no. 1, p. 012094, 2024, https://doi.org/10.1088/1755-1315/1326/1/012094.

N. T. Tuan and N. P. Dong, “Improving performance and reducing emissions from a gasoline and liquefied petroleum gas bi-fuel system based on a motorcycle engine fuel injection system,” Energy for Sustainable Development, vol. 67, pp. 93-101, 2022, https://doi.org/10.1016/j.esd.2022.01.010.

R. Lopes et al., “Passive Safety Solutions on Coach according ECE R29: Experimental and Numerical analyses,” Procedia Struct. Integr., vol. 42, pp. 1159–1168, 2022, https://doi.org/10.1016/j.prostr.2022.12.148.

Y. Liu, Y. G. Liao, and M. C. Lai, “Effects of battery pack capacity on fuel economy of hybrid electric vehicles,” In 2021 IEEE Transportation Electrification Conference & Expo (ITEC), pp. 771-775, 2021, https://doi.org/10.1109/ITEC51675.2021.9490040.

R. A. Azdy and F. Darnis, “Use of Haversine Formula in Finding Distance Between Temporary Shelter and Waste End Processing Sites,” J. Phys. Conf. Ser., vol. 1500, no. 1, p. 12104, 2020, https://doi.org/10.1088/1742-6596/1500/1/012104.

E. Maria, E. Budiman, Haviluddin, and M. Taruk, “Measure distance locating nearest public facilities using Haversine and Euclidean Methods,” J. Phys. Conf. Ser., vol. 1450, no. 1, p. 12080, 2020, https://doi.org/10.1088/1742-6596/1450/1/012080.

D. Ikasari, Widiastuti, and R. Andika, “Determine the Shortest Path Problem Using Haversine Algorithm, A Case Study of SMA Zoning in Depok,” in 2021 3rd International Congress on Human-Computer Interaction, Optimization and Robotic Applications (HORA), 2021, pp. 1–6. https://doi.org/10.1109/HORA52670.2021.9461185.

S. A. Ige, M. S. Khan, and B. R. Biju, “Enhancing EV Charging Capabilities Using Haversine and Convex Optimization for ITS,” in 2023 IEEE Virtual Conference on Communications (VCC), 2023, pp. 165–170. https://doi.org/10.1109/VCC60689.2023.10475040.

A. Andreou, C. X. Mavromoustakis, J. M. Batalla, E. K. Markakis, G. Mastorakis, and S. Mumtaz, “UAV Trajectory Optimisation in Smart Cities Using Modified A* Algorithm Combined With Haversine and Vincenty Formulas,” IEEE Trans. Veh. Technol., vol. 72, no. 8, pp. 9757–9769, 2023, https://doi.org/10.1109/TVT.2023.3254604.

B. Işik, “Area Optimized FPGA Implementation of Slant Range Calculation Using Haversine Formula,” in 2021 29th Signal Processing and Communications Applications Conference (SIU), 2021, pp. 1–4. https://doi.org/10.1109/SIU53274.2021.9478008.

Z. Bian, C. M. Vong, P. K. Wong, and S. Wang, “Fuzzy KNN Method With Adaptive Nearest Neighbors,” IEEE Trans. Cybern., vol. 52, no. 6, pp. 5380–5393, 2022, https://doi.org/10.1109/TCYB.2020.3031610.

N. Marchang and R. Tripathi, “KNN-ST: Exploiting Spatio-Temporal Correlation for Missing Data Inference in Environmental Crowd Sensing,” IEEE Sens. J., vol. 21, no. 3, pp. 3429–3436, 2021, https://doi.org/10.1109/JSEN.2020.3024976.

A. Pérez-Navarro, R. Montoliu, E. Sansano-Sansano, M. Martínez-Garcia, R. Femenía, and J. Torres-Sospedra, “Accuracy of a Single Position Estimate for kNN-Based Fingerprinting Indoor Positioning Applying Error Propagation Theory,” IEEE Sens. J., vol. 23, no. 16, pp. 18765–18775, 2023, https://doi.org/10.1109/JSEN.2023.3287856.

C. Lin and N. D. Doyog, “Applying a Four-Way Factorial Experimental Model to Diagnose Optimum kNN Parameters for Precise Aboveground Biomass Mapping,” IEEE J. Sel. Top. Appl. Earth Obs. Remote Sens., vol. 18, pp. 479–495, 2025, https://doi.org/10.1109/JSTARS.2024.3486737.

I. G. S. M. Diyasa, D. A. Prasetya, M. Idhom, A. P. Sari, and A. M. Kassim, “Implementation of Haversine Algorithm and Geolocation for travel recommendations on Smart Applications for Backpackers in Bali,” in 2022 International Conference on Informatics, Multimedia, Cyber and Information System (ICIMCIS), pp. 504–508, 2022, https://doi.org/10.1109/ICIMCIS56303.2022.10017760.

Y. Li, S. Guo, G. Ma, Z. Li, J. Yang, and Z. Chen, “Dynamic Estimation of Load-Side Equivalent Inertia by Using Clustering Method,” CPSS Trans. Power Electron. Appl., vol. 10, no. 1, pp. 1–9, 2025, https://doi.org/10.24295/CPSSTPEA.2025.00001.

Y. Chen, Z. Shen, Z. Xu, L. Jin, and W. Chen, “Parameter Shift Prediction of Planar Transformer Based on Bi-LSTM Algorithm,” CPSS Trans. Power Electron. Appl., vol. 8, no. 1, pp. 13–22, 2023, https://doi.org/10.24295/CPSSTPEA.2023.00002.

M. Slawski, E. Ben-David, and P. Li, “Two-stage approach to multivariate linear regression with sparsely mismatched data,” J. Mach. Learn. Res., vol. 21, no. 204, pp. 1-42. 2020, https://www.jmlr.org/papers/v21/19-645.html.

Y. Quan, C. Liu, Z. Yuan, and Y. Zhou, “An Intelligent Multiscale Spatiotemporal Fusion Network Model for TCM,” IEEE Sens. J., vol. 23, no. 7, pp. 6628–6637, 2023, https://doi.org/10.1109/JSEN.2023.3244587.

S. Mishra, P. K. Mallick, H. K. Tripathy, L. Jena, and G.-S. Chae, “Stacked KNN with hard voting predictive approach to assist hiring process in IT organizations,” Int. J. Electr. Eng. & Educ., vol. 0, no. 0, p. 0020720921989015, https://doi.org/10.1177/0020720921989015.

E. Sitompul, R. M. Putra, H. Tarigan, A. Silitonga, and I. Bukhori, “Implementation of Digital Feedback Control with Change Rate Limiter in Regulating Water Flow Rate Using Arduino,” Bul. Ilm. Sarj. Tek. Elektro, vol. 6, no. 1, pp. 72–82, 2024, https://doi.org/10.12928/biste.v6i1.10234.

H. D. Trung, “Estimation of Crowd Density Using Image Processing Techniques with Background Pixel Model and Visual Geometry Group,” Bul. Ilm. Sarj. Tek. Elektro, vol. 6, no. 2, pp. 142–154, 2024, https://doi.org/10.12928/biste.v6i2.10785.

Downloads

Published

2026-04-10

How to Cite

[1]
F. Baskoro, “K-Nearest Neighbors for Smart Solution Transportation: Prediction Distance Travel and Optimization of Fuel Usage and Charging Recommendations for ICE Vehicles Based in Surabaya”, Buletin Ilmiah Sarjana Teknik Elektro, vol. 8, no. 2, pp. 421–434, Apr. 2026.

Issue

Section

Article