Welcome to Francis Academic Press

Academic Journal of Computing & Information Science, 2022, 5(2); doi: 10.25236/AJCIS.2022.050212.

Research on Magic Square Construction Based on Genetic Algorithm


Xintian Cui, Xiangqi Cheng, Guoxuan Bu

Corresponding Author:
Xintian Cui

Mechanical Engineering, Dalian Jiaotong University, Dalian, China


The construction of magic squares is a complex permutation and combination problem. It is very difficult to construct the magic square with the continuous minimum natural number, and its solution has the nature of diversity and increases exponentially with the increase of order. In this paper, the magic square is constructed by selecting specific real numbers in different situations. Firstly, the magic square model is realized by using genetic algorithm, and the population is selected, crossed and mutated, and the optimal solution is selected, so that the semi-magic square whose sum of rows and columns is magic sum can be generated. Then, the parent gene of diagonal magic population is generated again by row exchange and column exchange, and the data of diagonal magic population is improved. Then, the selection, crossover and diagonal local adjustment are carried out in turn, and finally, the N-order high-quality magic square in the interval of [1, N2] natural number is obtained.


Magic Square; Genetic Algorithm; Random Search

Cite This Paper

Xintian Cui, Xiangqi Cheng, Guoxuan Bu. Research on Magic Square Construction Based on Genetic Algorithm. Academic Journal of Computing & Information Science (2022), Vol. 5, Issue 2: 77-80. https://doi.org/10.25236/AJCIS.2022.050212.


[1] Guo Ping, Liu Xingxiang. Definition and algebraic properties of sum magic matrix [J]. Journal of Yan'an University (Natural Science Edition), 2017, 36(01): 21-27.

[2] Zhang Shide, Li Cheng, Johnny. Several necessary and sufficient conditions of magic square [J]. Practice and cognition of mathematics, 2016, 46(04): 198-214.

[3] Wang Fei, Yao Huasheng. A method of magic square construction [J]. Journal of Huangshan University, 2009, 11(03): 28-32.

[4] Lu Zhenhong. Research on intelligent calculation method of magic square problem [D]. National University of Defense Technology, 2005.