iga.h

来自「一个函数寻优的免疫遗传算法」· C头文件 代码 · 共 60 行

H
60
字号
// IGA.h: interface for the CIGA class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_IGA_H__498BCC7D_2836_405A_8783_3B9E1D9198DD__INCLUDED_)
#define AFX_IGA_H__498BCC7D_2836_405A_8783_3B9E1D9198DD__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "AntiCell.h"

#if !defined(AFX_ALLDEF_)
#define AFX_ALLDEF_

const int LOOPNUM=1000;	//迭代次数
const int SUM=100;		//总细胞数
const int MSUM=10;		//记忆细胞数
const int NEWSUM=20;	//随机产生新细胞的数量
const int LB=20;		//-Lower Bound保守的下界值
const double PC=0.9;	//交叉概率
const double PM=0.4;	//变异概率
const double delt=0.01;	//适当小值
const double beita=0.2;	//浓度调节比
const double TL=-2;	//浓度调节比
const double TH=2;	//浓度调节比

#endif
class CIGA  
{
public:
	void Genetic();
	double DoIGA(CAntiCell *ac);
	double AverageRandom(double min,double max);
	void fun(CAntiCell *ac);
	CAntiCell AntiBase[SUM];
	CAntiCell NB[NEWSUM];	//NewAntiBase
	CAntiCell MB[MSUM];		//MemoryBase
	CIGA();
	virtual ~CIGA();
private:
	void CalMemoryC();
	void InitMemory();
	void Mutation(CAntiCell *ac1,CAntiCell *ac2);
	void CrossOver(int i1,int i2,CAntiCell *c1,CAntiCell* c2);
	void SelectAnti(double psum,int&i1,int&i2);
	void AddMemory();
	void Updatesp();
	double GetMemoryFit();
	void CalAntiC();
	void ResortMB();
	void UpdateMemory();
	void ResortAntiBase();
	void AddNew();
	void GenerateNew();

};

#endif // !defined(AFX_IGA_H__498BCC7D_2836_405A_8783_3B9E1D9198DD__INCLUDED_)

⌨️ 快捷键说明

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