chromosome.h

来自「基本遗传算法在求一个函数表达式的最大值应用!」· C头文件 代码 · 共 37 行

H
37
字号
//对染色体的结构定义
#ifndef CHROMOSOME_H
#define CHROMOSOME_H
//my codes
#include "Gene.h"
#include "parameter.h"
#include <iostream>
#include <string>
extern MyParameter myparameter;

class Chromosome{
 private:
    int    Length;
    double Fitness;	
	void   set_length(int len);
protected:
	//
public: 
	Gene   *myGenes;        // the genes

	Chromosome(int all = myparameter.lchrom);
	Chromosome(const Chromosome & c);
	~Chromosome();

	void   set_fitness(double fit);
	double get_fitness();


	int    get_length();
	std::string genes_to_string();

	void   copyGene(Gene * gen,int offset ,int index );
	void   evaluate();
	void   tocross(Chromosome & c ,int index);
	void   mutate(double pmut = myparameter.pmutate );
};
#endif ///:~CHROMOSOME_H

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?