#include <stdio.h>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#define POPSIZE 500 //种群大小
#define chromlength 8 //染色体长度
int popsize ; //种群
大小
int maxgeneration; //最大世代数
double pc =
0.0; //交叉率
double pm =
0.0; //变异率
struct individual //定义染色
体个体结构体
{
int chrom[chromlength]; //定义染色体二
进制表达形式,edit by ppme 将 char 转为 int
double value; //染色
体的值
double fitness; //染色体
的适应值
};
int generation; //当前执
行的世代数
int best_index; //最好的
染色体索引序号
int worst_index; //最差的
染色体索引序号
struct individual bestindividual; //最佳染色体个体
struct individual worstindividual; //最差染色体个体
struct individual currentbest; //当前最好的染色体个体
currentbest
struct individual population[POPSIZE];//种群数组
//函数声明
评论1