Abstract
Making evolutionary algorithms greener implies tackling implementation issues from different angles. Practitioners need to focus on those that can be more easily leveraged, such as the choice of the language that is going to be used; high-level (interpreted), mid-level (based on multi-platform virtual machines), and low-level (native) languages will need power in different ways, and choosing one or the other will have an impact on energy consumption. We will be looking at the implementation of key evolutionary algorithm functions, in three languages at three different levels: the high-level JavaScript, the mid-level Kotlin, which runs on the Java Virtual Machine, and the low-level Zig. Looking beyond the obvious, as the lower the level, the less energy consumption should be expected, we will try to have a more holistic view of the implementation of the algorithms in order to extract best practices regarding its green implementation.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Similar content being viewed by others
Data Availability Statement
The source of this paper as well as the data and whole writing history is available from https://github.com/JJ/energy-ga-icsoft-2023 under a GPL license.
Notes
- 1.
Described in https://www.un.org/millenniumgoals/bkgd.shtml, for instance.
- 2.
Please note that there are no languages that are considered low-level and interpreted, although there are minimalist interpreted languages like Lua [9].
- 3.
Which, for the purposes of this paper, is considered mid-level, since it compiles to bytecode.
- 4.
Please note that at the time of writing this, many other versions have been published; we have used this one to be able to compare with previous papers. These same papers show that its performance and energy consumption have important improvements, so in case of close calls, we would recommend retaking measurements at the time of running your experiments.
- 5.
We are not saying here that it is not an energy-consuming operation, even more so here where we are generating all chromosomes we are using in a single loop; however, while the initial population is generated only once in an EA, every other operation used here is going to be repeated every generation; thus, in terms of either time of energy consumption, the proportion employed by chromosome generation will be one vs. number of generations needed to find the solution.
- 6.
zig will greatly vary the amount of energy needed depending on relatively irrelevant choices such as using constant or mutable pointers; in a previous experiment run, included in the repository, that used mutable pointers, energy consumption was almost 10% higher.
References
Abdelhafez, A., Alba, E., Luque, G.: A component-based study of energy consumption for sequential and parallel genetic algorithms. J. Supercomput. 75(10), 6194–6219 (2019). https://doi.org/10.1007/s11227-019-02843-4
Connolly Bree, D., Ó Cinnéide, M.: Energy efficiency of the visitor pattern: contrasting Java and C++ implementations. Empirical Softw. Eng. 28(6), 145 (2023)
Corne, D., Lones, M.A.: Evolutionary Algorithms, pp. 1–22. Springer, Cham (2018). https://doi.org/10.1007/978-3-319-07153-4_27-1
Díaz-Álvarez, J., Castillo, P.A., Fernandez de Vega, F., Chávez, F., Alvarado, J.: Population size influence on the energy consumption of genetic programming. Meas. Control 55(1-2), 102–115 (2022)
Fortin, F.A., De Rainville, F.M., Gardner, M.A.G., Parizeau, M., Gagné, C.: DEAP: evolutionary algorithms made easy. J. Mach. Learn. Res. 13(1), 2171–2175 (2012)
Garg, K., Jindal, C., Kumar, S., Juneja, S.: Analyzing and rating greenness of nature-inspired algorithms. In: 6th International Conference on Innovative Computing and Communication (ICICC 2023) (2023)
Hidalgo, I., et al.: Sustainable artificial intelligence systems: an energy efficiency approach (2023)
Holló-Szabó, Á., Albert, I., Botzheim, J.: Statistical racing crossover based genetic algorithm for vehicle routing problem. In: 2021 IEEE 21st International Symposium on Computational Intelligence and Informatics (CINTI), pp. 000267–000272. IEEE (2021)
Ierusalimschy, R., de Figueiredo, L.H., Celes, W.: The evolution of Lua. In: Proceedings of the Third ACM SIGPLAN Conference on History of Programming Languages, p. 2-1 (2007)
Köhler, S., et al.: Pinpoint the Joules: unifying runtime-support for energy measurements on heterogeneous systems. In: 2020 IEEE/ACM International Workshop on Runtime and Operating Systems for Supercomputers (ROSS), pp. 31–40 (2020). https://doi.org/10.1109/ROSS51935.2020.00009
Lannelongue, L., et al.: Greener principles for environmentally sustainable computational science. Nat. Comput. Sci. 3(6), 514–521 (2023)
Lima, L.G., Soares-Neto, F., Lieuthier, P., Castor, F., Melfe, G., Fernandes, J.P.: Haskell in green land: analyzing the energy behavior of a purely functional language. In: 2016 IEEE 23rd International Conference on Software Analysis, Evolution, and Reengineering (SANER), vol. 1, pp. 517–528. IEEE (2016)
Merelo-Guervós, J.J., et al.: Ranking the performance of compiled and interpreted languages in genetic algorithms. In: Proceedings of the International Conference on Evolutionary Computation Theory and Applications, Porto, Portugal, vol. 11, pp. 164–170 (2016)
Merelo-Guervós, J.-J., et al.: Ranking programming languages for evolutionary algorithm operations. In: Squillero, G., Sim, K. (eds.) EvoApplications 2017. LNCS, vol. 10199, pp. 689–704. Springer, Cham (2017). https://doi.org/10.1007/978-3-319-55849-3_44
Merelo-Guervós, J.J., García-Valdez, M., Castillo, P.A.: An analysis of energy consumption of JavaScript interpreters with evolutionary algorithm workloads. In: Fill, H., Mayo, F.J.D., van Sinderen, M., Maciaszek, L.A. (eds.) Proceedings of the 18th International Conference on Software Technologies, ICSOFT 2023, Rome, Italy, 10–12 July 2023, pp. 175–184. SCITEPRESS (2023). https://doi.org/10.5220/0012128100003538
Merelo, J.J., Romero, G., Arenas, M.G., Castillo, P.A., Mora, A.M., Laredo, J.L.J.: Implementation matters: programming best practices for evolutionary algorithms. In: Cabestany, J., Rojas, I., Joya, G. (eds.) IWANN 2011. LNCS, vol. 6692, pp. 333–340. Springer, Heidelberg (2011). https://doi.org/10.1007/978-3-642-21498-1_42
Pereira, R., et al.: Ranking programming languages by energy efficiency. Sci. Comput. Program. 205, 102609 (2021)
Pinto, G., Castor, F.: Energy efficiency: a new concern for application software developers. Commun. ACM 60(12), 68–75 (2017)
Theis, T.N., Wong, H.S.P.: The end of Moore’s Law: a new beginning for information technology. Comput. Sci. Eng. 19(2), 41–50 (2017)
de Vega, F.F., et al.: A cross-platform assessment of energy consumption in evolutionary algorithms. In: Handl, J., Hart, E., Lewis, P.R., López-Ibáñez, M., Ochoa, G., Paechter, B. (eds.) PPSN 2016. LNCS, vol. 9921, pp. 548–557. Springer, Cham (2016). https://doi.org/10.1007/978-3-319-45823-6_51
Watson, R.A., Hornby, G.S., Pollack, J.B.: Modeling building-block interdependency. In: Eiben, A.E., Bäck, T., Schoenauer, M., Schwefel, H.-P. (eds.) PPSN 1998. LNCS, vol. 1498, pp. 97–106. Springer, Heidelberg (1998). https://doi.org/10.1007/BFb0056853
Acknowledgements
This work is supported by the Ministerio español de Economía y Competitividad (Spanish Ministry of Competitivity and Economy) under project PID2020-115570GB-C22 (DemocratAI::UGR).
We are also very grateful to the zig community, withouts which programming these operations in that language would have been impossible.
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2025 The Author(s), under exclusive license to Springer Nature Switzerland AG
About this paper
Cite this paper
Merelo-Guervós, J.J., García-Valdez, M. (2025). How Evolutionary Algorithms Consume Energy Depending on the Language and Its Level. In: Festa, P., Ferone, D., Pastore, T., Pisacane, O. (eds) Learning and Intelligent Optimization. LION 2024. Lecture Notes in Computer Science, vol 14990. Springer, Cham. https://doi.org/10.1007/978-3-031-75623-8_20
Download citation
DOI: https://doi.org/10.1007/978-3-031-75623-8_20
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-031-75622-1
Online ISBN: 978-3-031-75623-8
eBook Packages: Computer ScienceComputer Science (R0)