Abstract
The k-means algorithm is one of the most commonly used clustering algorithms in the field of artificial intelligence. However, as the amount of data increases, traditional electronic computers face challenges such as low computational efficiency and high energy consumption when executing the k-means algorithm. The ternary optical computer (TOC), as a novel optoelectronic hybrid computer, employs optical processing and electrical control to perform data computations. This type of computer features a large number of data bits, carry-free addition, and low power consumption, making it well-suited to address the issues encountered by electronic computers in implementing the k-means algorithm. Leveraging the characteristics of TOC, such as its abundant data bits and reconfigurable processor, this paper designs a parallel k-means algorithm based on TOC. Additionally, this paper also proposes an implementation method for a TOC-based subtractor. This subtractor eliminates the need to take the opposite of the subtrahend, thus making the TOC more convenient for implementing the k-means algorithm. Finally, experimental validation was conducted on the TOC experimental platform. The results demonstrate that the implementation of the subtractor is correct and that the parallel k-means algorithm on TOC is feasible. Through performance comparison, it is shown that the time complexity of the multiplication process in calculating the distance between sample points and cluster centers can be optimized from \(O\left( {{n^2}} \right)\) to \(O\left( n \right)\), and under sufficient data bit conditions, it can achieve a time complexity of \(O(\log _2 n)\), exhibiting higher computational efficiency.










Similar content being viewed by others
Data availability
The data used to support the finding of this study are included within the article.
References
Zhang H, Peng Q (2022) Pso and k-means-based semantic segmentation toward agricultural products. Future Generat Computer Syst 126:82–87. https://doi.org/10.1016/j.future.2021.06.059
Jiang W, Zhou K, Xiong C et al (2023) Kscb: A novel unsupervised method for text sentiment analysis. Appl Intell 53(1):301–311. https://doi.org/10.1007/s10489-022-03389-4
AL-Sharuee MT, Liu F, Pratama M (2021) Sentiment analysis: dynamic and temporal clustering of product reviews. Appl Intell 51:51–70. https://doi.org/10.1007/s10489-020-01668-6
Asad M, Jiang H, Yang J et al (2022) Multi-stream 3d latent feature clustering for abnormality detection in videos. Appl Intell. https://doi.org/10.1007/s10489-021-02356-9
Ismkhan H, Izadi M (2022) K-means-g*: accelerating k-means clustering algorithm utilizing primitive geometric concepts. Inform Sci 618:298–316. https://doi.org/10.1016/j.ins.2022.11.001
Jin Y, He H, Lü Y (2003) Ternary optical computer principle. Inform Sci 46:145–150. https://doi.org/10.1360/03yf9012
Wang H, Ouyang S, Shen Y, et al (2021) Ternary optical computer: an overview and recent developments. In: 2021 12th International Symposium on Parallel Architectures, Algorithms and Programming (PAAP). IEEE, 82–87, https://doi.org/10.1109/PAAP54281.2021.9720446
Li S, Wang Z, Wang S et al (2022) Theoretical basis and implementation mechanism of the programming platform for ternary optical computer. IEEE Access 10:5585–5594. https://doi.org/10.1109/ACCESS.2022.3142329
Yan J, Jin Y, Zuo K (2008) Decrease-radix design principle for carrying/borrowing free multi-valued and application in ternary optical computer. Sci China Ser F: Informa Sci 51(10):1415–1426. https://doi.org/10.1007/s11432-008-0140-z
Li M (2016) Design and realization of ternary logic optical computer lab system(in chinese). Computer Technol Develop 26(10):192–195
Song K, Li W, Zhang B et al (2022) Parallel design and implementation of jacobi iterative algorithm based on ternary optical computer. J Supercomput 78(13):14965–14990. https://doi.org/10.1007/s11227-022-04471-x
Zhehe W, Yunfu S (2021) Design and implementation of the walsh-hadamard transform on a ternary optical computer. Appl Optics 60(30):9254–9262. https://doi.org/10.1364/AO.435457
Wang Z, Shen Y, Li S et al (2023) A fine-grained fast parallel genetic algorithm based on a ternary optical computer for solving traveling salesman problem. J Supercomput 79(5):4760–4790. https://doi.org/10.1007/s11227-022-04813-9
Jiang JB, Zhang XF, Shen YF et al (2021) Design and implementation of sj-msd adder in ternary optical computer. Acta Eectonica Sinica 49(2):275–285. https://doi.org/10.12263/DZXB.20180572
Avizienis A (1961) Signed-digit numbe representations for fast parallel arithmetic. IRE Trans Electron Computers 3:389–400. https://doi.org/10.1109/TEC.1961.5219227
Shen Y, Zhang S, Wang Z et al (2021) Design and implementation of parallel radix-4 msd iterative division of ternary optical computer. Optics Commun 501:127360. https://doi.org/10.1016/j.optcom.2021.127360
Jin Y, Shen Y, Peng J et al (2010) Principles and construction of msd adder in ternary optical computer. Sci China Inform Sci 53:2159–2168. https://doi.org/10.1007/s11432-010-4091-9
Peng J, Shen R, Jin Y et al (2012) Design and implementation of modified signed-digit adder. IEEE Trans Computers 63(5):1134–1143. https://doi.org/10.1109/TC.2012.285
Peng J, Shen R, Ping X (2016) Design of a high-efficient msd adder. J Supercomput 72:1770–1784. https://doi.org/10.1007/s11227-015-1484-y
Song K, Yan L (2012) Design and implementation of the one-step msd adder of optical computer. Appl Optics 51(7):917–926. https://doi.org/10.1364/AO.51.000917
Xu Q, Wang X, Xu C (2017) Design and implementation of the modified signed digit multiplication routine on a ternary optical computer. Appl optics 56(16):4661–4669. https://doi.org/10.1364/AO.56.004661
Xu Q, Shen Y, Jin Y (2016) High-efficiency realization of srt division on ternary optical computers. In: High performance computing and applications. Springer International Publishing, Cham, 158– 169. https://doi.org/10.1007/978-3-319-32557-6_17
Nie F, Li Z, Wang R et al (2022) An effective and efficient algorithm for k-means clustering with new formulation. IEEE Trans Knowl Data Eng 35(4):3433–3443. https://doi.org/10.1109/TKDE.2022.3155450
Lloyd S (1982) Least squares quantization in pcm. IEEE Trans Inform Theory 28(2):129–137. https://doi.org/10.1109/TIT.1982.1056489
Peng D, Chen Z, Fu J, et al (2021) Fast k-means clustering based on the neighbor information. In: 2021 International Symposium on Electrical, Electronics and Information Engineering. Association for Computing Machinery, New York, USA, 551–555, https://doi.org/10.1145/3459104.3459194
Xia S, Peng D, Meng D et al (2020) Ball \(k\) k-means: fast adaptive clustering with no bounds. IEEE Trans Pattern Analy Mach Intell 44(1):87–99. https://doi.org/10.1109/TPAMI.2020.3008694
Kai S, Liping Y (2017) Control mechanism of double-rotator-structure ternary optical computer. Optics Commun 387:338–349. https://doi.org/10.1016/j.optcom.2016.12.004
Kai S, LiPing Y (2015) Reconfigurable ternary optical processor based on row operation unit. Optics Commun 350:6–12. https://doi.org/10.1016/j.optcom.2015.03.080
Acknowledgements
The authors would like to express their sincere gratefulness to the TOC team, School of Computer Engineering and Science, Shanghai University, for providing the optical platform and giving many inspired ideas to the paper.
Funding
This work was supported by the National Natural Science Foundation of China (NSFC) (62262022, 62362031), the Natural Science Foundation of Jiangxi Province (20232BAB202026, 20224BAB202021).
Author information
Authors and Affiliations
Contributions
Conceptualization: Kai Song, Haiming Zhang; Writing - original draft: Kai Song, Haiming Zhang; Validation: Huaqiong Ma; Project administration: Yongjun Sun, Liping Yan; Funding acquisition: Kai Song
Corresponding author
Ethics declarations
Conflict of interest
The authors declare that they have no known competing financial interests that could have appeared to influence the work reported in this paper.
Ethical approval
Not applicable
Consent to participate
Not applicable
Consent for publication
Not applicable
Additional information
Publisher's Note
Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
Rights and permissions
Springer Nature or its licensor (e.g. a society or other partner) holds exclusive rights to this article under a publishing agreement with the author(s) or other rightsholder(s); author self-archiving of the accepted manuscript version of this article is solely governed by the terms of such publishing agreement and applicable law.
About this article
Cite this article
Song, K., Zhang, H., Ma, H. et al. Design and implementation of parallel k-means algorithm based on ternary optical computer. J Supercomput 81, 536 (2025). https://doi.org/10.1007/s11227-025-07016-0
Accepted:
Published:
DOI: https://doi.org/10.1007/s11227-025-07016-0