遗传算法求sinx最大值

import random import math import numpy as np import matplotlib.pyplot as pltpopulation_size = 400 # 种群数量 generations = 2000 # 迭代次数 chrom_length = 8 # 染色体长度 pc = 0.8 # 交配概率 pm = 0.01 # 变异概率 genetic_population = [] # 种群的基因编码(二进制) population = [] # 种群对应的十进制数值,并标准化范围到[0, 10] fitness = [] # 适应度