Abstract
This paper concerns using the code2vec vector embeddings of the source code to improve automatic source code generation in Grammatical Evolution. Focusing on a particular programming language, such as Java in the research presented, and being able to represent each Java function in the form of a continuous vector in a linear space by the code2vec model, GE gains some additional knowledge on similarities between constructed functions in the linear space instead of semantic similarities, which are harder to process. We propose a few improvements to the regular GE algorithm, including a code2vec-based initialization of the evolutionary algorithm and a code2vec-based crossover operator. Computational experiments confirm the efficiency of the approach proposed on a few typical benchmarks.
Keywords
This is a preview of subscription content, log in via an institution.
Buying options
Tax calculation will be finalised at checkout
Purchases are for personal use only
Learn about institutional subscriptionsReferences
Affenzeller, M., Wagner, S., Winkler, S., Beham, A.: Genetic Algorithms and Genetic Programming: Modern Concepts and Practical Applications. Chapman and Hall/CRC (2009)
Alon, U., Brody, S., Levy, O., Yahav, E.: Code2seq: generating sequences from structured representations of code. arXiv preprint arXiv:1808.01400 (2018)
Alon, U., Zilberstein, M., Levy, O., Yahav, E.: Code2vec: learning distributed representations of code. Proc. ACM Program. Lang. 3(POPL) (2019)
Burbidge, R., Walker, J.H., Wilson, M.S.: Grammatical evolution of a robot controller. In: 2009 IEEE/RSJ International Conference on Intelligent Robots and Systems, pp. 357–362. IEEE (2009)
Byrne, J., Cardiff, P., Brabazon, A., et al.: Evolving parametric aircraft models for design exploration and optimisation. Neurocomputing 142, 39–47 (2014)
Compton, R., Frank, E., Patros, P., Koay, A.: Embedding Java classes with code2vec: improvements from variable obfuscation. In: Proceedings of the 17th International Conference on Mining Software Repositories, pp. 243–253 (2020)
Fagan, D., Fenton, M., O’Neill, M.: Exploring position independent initialisation in grammatical evolution. In: 2016 IEEE Congress on Evolutionary Computation (CEC), pp. 5060–5067. IEEE (2016)
Forstenlechner, S., Nicolau, M., Fagan, D., O’Neill, M.: Introducing semantic-clustering selection in grammatical evolution. In: Proceedings of the Companion Publication of the 2015 Annual Conference on Genetic and Evolutionary Computation, pp. 1277–1284 (2015)
Matsui, K.: New selection method to improve the population diversity in genetic algorithms. In: IEEE SMC 1999 Conference Proceedings. 1999 IEEE International Conference on Systems, Man, and Cybernetics (Cat. No. 99CH37028), vol. 1, pp. 625–630. IEEE (1999)
Mikolov, T., Sutskever, I., Chen, K., Corrado, G.S., Dean, J.: Distributed representations of words and phrases and their compositionality. In: Advances in Neural Information Processing Systems, vol. 26 (2013)
O’Neill, M., Ryan, C.: Grammatical evolution. IEEE Trans. Evol. Comput. 5(4), 349–358 (2001)
Pedregosa, F., et al.: Scikit-learn: machine learning in Python. J. Mach. Learn. Res. 12, 2825–2830 (2011)
Ryan, C., Azad, R.M.A.: Sensible initialisation in grammatical evolution. In: GECCO, pp. 142–145. AAAI (2003)
Ryan, C., Collins, J.J., Neill, M.O.: Grammatical evolution: evolving programs for an arbitrary language. In: Banzhaf, W., Poli, R., Schoenauer, M., Fogarty, T.C. (eds.) EuroGP 1998. LNCS, vol. 1391, pp. 83–96. Springer, Heidelberg (1998). https://doi.org/10.1007/BFb0055930
Shaker, N., Nicolau, M., Yannakakis, G.N., Togelius, J., O’neill, M.: Evolving levels for Super Mario Bros using grammatical evolution. In: 2012 IEEE Conference on Computational Intelligence and Games (CIG), pp. 304–311. IEEE (2012)
Acknowledgment
This work was supported by the Polish National Science Centre (NCN) under grant OPUS-18 no. 2019/35/B/ST6/04379.
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2023 The Author(s), under exclusive license to Springer Nature Switzerland AG
About this paper
Cite this paper
Kowalczykiewicz, M., Lipiński, P. (2023). Grammatical Evolution with Code2vec. In: Pappa, G., Giacobini, M., Vasicek, Z. (eds) Genetic Programming. EuroGP 2023. Lecture Notes in Computer Science, vol 13986. Springer, Cham. https://doi.org/10.1007/978-3-031-29573-7_14
Download citation
DOI: https://doi.org/10.1007/978-3-031-29573-7_14
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-031-29572-0
Online ISBN: 978-3-031-29573-7
eBook Packages: Computer ScienceComputer Science (R0)