#include "Params.h"

//先初始化
unsigned long	CParams::lNumData;			//数据总数
unsigned int	CParams::iNumEpoch;			//进化代数
unsigned int	CParams::iPopSize;			//种群数量
unsigned int	CParams::iChromoLength;		//基因长度
unsigned int	CParams::iNumElite;			//精英数
unsigned int	CParams::iNumCopiesElite;	//精英选择数
double	CParams::dCrossoverRate;		//杂交率
double	CParams::dMutationRate;			//突变率
double	CParams::dMaxPerturbation;		//每个权重的最大变化率概率

//从文件中返回值
bool CParams::LoadInParameters(string szFileName)
{
	ifstream grab(szFileName.c_str());

	//检查文件存在否
	if (!grab)
		return false;

	//从文件中读入
	string ParamDescription;

	grab >> ParamDescription;
	grab >> lNumData;
	//cout << lNumData << endl;

	grab >> ParamDescription;
	grab >> iNumEpoch;
	//cout << iNumEpoch << endl;

	grab >> ParamDescription;
	grab >> iPopSize;
	//cout << iPopSize << endl;

	grab >> ParamDescription;
	grab >> iChromoLength;
	//cout << iChromoLength << endl;

	grab >> ParamDescription;
	grab >> iNumElite;
	//cout << iNumElite << endl;

	grab >> ParamDescription;
	grab >> iNumCopiesElite;
	//cout << iNumCopiesElite << endl;

	grab >> ParamDescription;
	grab >> dCrossoverRate;
	//cout << dCrossoverRate << endl;

	grab >> ParamDescription;
	grab >> dMutationRate;
	//cout << dMutationRate << endl;

	grab >> ParamDescription;
	grab >> dMaxPerturbation;
	//cout << dMaxPerturbation << endl;

	return true;
}







