A numerical metamorphic relationship generation method based on metaheuristic optimi-zation algorithm is proposed to address the problem of difficult to obtain metamorphic relationships and high testing costs caused by errors in metamorphic testing.By analyzing the mathematical char-acteristics of numerical metamorphic relationships and combining equations and inequality relation-ships,an input and output parameter matrix is formed.Through the combination of two metaheu-ristic optimization algorithms,namely the particle swarm optimization and the simulated annealing,appropriate cost functions are set,and the constructed parameter matrix is used as the search parti-cle to search and generate metamorphic relationships of various equations and inequalities.Experi-ment results show that compared to using only one search algorithm,the proposed method can skip local optima without changing the type of solution,and can save the time costs and improve the effi-ciency of metamorphic relationship generation.