计算机工程与应用 ›› 2022, Vol. 58 ›› Issue (23): 83-93.DOI: 10.3778/j.issn.1002-8331.2204-0228

• 理论与研发 • 上一篇    下一篇

改进黑猩猩优化算法的测试数据生成研究

高大唤,梁宏涛,杜军威,于旭,胡强   

  1. 青岛科技大学 信息科学技术学院,山东 青岛 266100
  • 出版日期:2022-12-01 发布日期:2022-12-01

Research on Test Data Generation for Improved Chimpanzee Optimization Algorithm

GAO Dahuan, LIANG Hongtao, DU Junwei, YU Xu, HU Qiang   

  1. Institute of Information Science and Technology, Qingdao University of Science and Technology, Qingdao, Shandong 266100, China
  • Online:2022-12-01 Published:2022-12-01

摘要: 自动生成测试数据的关键在于能否生成覆盖率高、纠错能力强的数据。针对目前测试数据生成效率低及黑猩猩优化算法仍存在易陷入局部最优、收敛精度低等问题,提出一种正余弦扰动策略黑猩猩优化算法(chimp optimization algorithm for sine-cosine perturbation strategy,SC-ChOA)。使用拉丁超立方策略初始化种群,增强种群的多样化;引入非线性衰减收敛因子来平衡算法的全局和局部勘探能力;在位置更新时添加正余弦扰动因子,避免群体陷入局部范围搜索而导致的算法停滞现象。使用测试函数与标准黑猩猩优化算法及常用的遗传算法进行对比实验,验证算法的有效性;将改进算法应用到测试数据生成领域,通过在桩中插入分支函数来建立适应度函数,以促进测试数据的优化。为验证改进算法在测试数据生成方面的有效性,使用多个基准程序进行算法对比实验,结果表明SC-ChOA在测试数据生成的覆盖率、平均迭代次数和运行时间上均有明显优势。

关键词: 黑猩猩优化算法, LHS序列, 正余弦扰动因子, 软件测试, 测试数据生成

Abstract: The key of automatically generating test data is whether it can generate data with high coverage and strong error-correcting ability. In order to solve the problems of low test data generation efficiency and low convergence precision of chimp optimization algorithm, a chimp optimization algorithm based on sine-cosine perturbation strategy(SC-ChOA) is proposed. Firstly, the Latin hypercube strategy is used to initialize the population and enhance the diversity of the population. Secondly, the nonlinear decay convergence factor is introduced to balance the global and local exploration ability of the algorithm, to avoid the algorithm stagnation caused by the local range search of the group. In addition, the test function is compared with standard chimp optimization algorithm and common genetic algorithm to verify the effectiveness of the algorithm. Finally, the improved algorithm is applied to test data generation, in order to optimize the test data, a branch function is inserted into the pile to establish the fitness function. In order to verify the effectiveness of the improved algorithm in test data generation, several benchmark programs are used to compare the algorithms, the results show that SC-ChOA has obvious advantages in the coverage, average iteration times and running time of test data generation.

Key words: chimp optimization algorithm, LHS sequence, sine-cosine perturbation factor, software testing, test data generation