排课系统的开发是基于遗传算法的这里有遗传算法框架,可运行的!!就是不懂得排课系统的分析需求!如何改造适应度函数,求高手指点……
#include
#include
#include
#include
#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];//种群数组
//函数声明
void generateinitialpopulation(); //ok-初始化当代种群
void generatenextpopulation(); //??产生下一代种群
void evaluatepopulation(); //评价种群
void calculateobjectfitness(); //计算种群适应度
//long decodechromosome(char *,int,int);//染色体解码
double decodechromosome(int,int); //染色体解码
void findbestandworstindividual(); //寻找最好的和最坏的染色体个体
void performevolution(); //进行演变进化
void selectoperator(); //选择操作
void crossoveroperator(); //交换操作
void mutationoperator(); //变异操作
void input(); //输入接口
void outputtextreport(); //输出文字报告
void main() //主函数
{