Genetic algorithm for structural adaptation of sorting algorithms
Abstract
Constructivism was applied to form the sorting algorithm code. The meta-algorithm of program code generation is presented. Parts of existing sorting algorithms and auxiliary utilities are used for generation. A genetic algorithm was used to select the algorithm with the maximum time efficiency under the given conditions of use. The use of a standard genetic algorithm faces a problem associated with a different number of elementary sorting operations, which leads to the use of chromosomes of diff erent lengths. To solve the problem, a representation of the chromosome in the form of a binary tree is proposed. Each node has start genes, end genes, and two child nodes. To form an algorithm that is guaranteed to sort the array, all end nodes (leaves) include the final sorting gene at the end of the start genes sequence. This gene is decoded by calling the existing sorting algorithm, which is guaranteed to perform sorting. Crossover and mutation operations are performed on chromosomes in the form of a binary tree. Crossover is performed using the exchange of tree branches. Mechanisms of coding and decoding of the sorting algorithm from chromosome have been implemented. Decoding and formation of a suitable sorting algorithm is performed using linearization: formation of a textual representation using a depth-first tree traversal algorithm. The fitness function is defined as the average time of sorting randomly generated arrays for sorting (identical arrays for all chromosomes) in some stable environment, considering certain features of these arrays. It is possible to use other fitness functions related to the number of calculations, comparisons, or permutations. The developed software should be used for adaptation of sorting algorithms to stable input data streams and environments.
Prombles in programming 2024; 2-3: 11-18
Keywords
Full Text:
PDF (Українська)References
A.Yu. Berko, O.M. Veres, V.V. Pasichnik, Database and knowledge systems. Book 2, Magnolia-2006, 2013.
O. Mendelevitch, C. Stella, D. Eadline, Practical Data Science with Hadoop and Spark, Addison-Wesley, 2016.
D. Knuth, The Art Of Computer Programming, vol. 3: Sorting And Searching, Addison-Wesley, 1973.
Timsort. https://svn.python.org/projects/python/trunk/Objects/listsort.txt.
D.R. Musser, Introspective Sorting and Selection Algorithms, in: Software: Practice and Experience, 1997, 27 (8), pp.983–993. doi: 10.5555/261387.261395.
V.I. Shinkarenko, A.Yu. Doroshenko, O.A. Yatsenko, V.V. Raznosilin, K.K. Galanin, Bicomponent sorting algorithms, in: Problems of programming, 2022, № 3-4, pp. 32-41. doi: 10.15407/pp2022.03-04.032.
J.H. Holland, Adaptation in Natural and Artificial Systems, The MIT Press, 1992.
V.I. Shinkarenko, O.V. Makarov, Study of the effectiveness of some deterministic preprocessing methods of data sorting, in: Problems of programming, 2023, № 4, pp. 3-14. doi: 10.15407/pp2023.04.003.
R. Tarjan, Depth-First Search and Linear Graph Algorithms, in: SIAM Journal on Computing, 1972, № 1(2). doi: 10.1137/0201010
Refbacks
- There are currently no refbacks.