config.h

来自「文化算法的实际应用」· C头文件 代码 · 共 84 行

H
84
字号
#ifndef CAEP_CONFIG_H
#define CAEP_CONFIG_H
#include <vector>
#include <iostream>
using namespace std;
namespace CAEP
{
	enum CellType
	{
		SemiFeasible	 = 1,
		Feasible		 = 2,
		Stranger         = 3,
		NotFeasible		 = 4,
	};


	class Configer
	{
	public:
		int VariableCount;
		int ConstraintCount;
		int EqConstraintCount;
		int TestTreeCount;
		int MaxDepth;
		int TreeDim;
		int TreeNodeCount;
		int PopulationSize;
		int TopCount;
		bool IsTrustIndividual;

		Configer()
		{
			//VariableCount = 13;
			//ConstraintCount = 9;
			//EqConstraintCount = 0;
			//TestTreeCount = 13;
			//MaxDepth = 5;
			//TreeDim = 3;
			//TreeNodeCount = 8;
			//PopulationSize = 20;
			//TopCount = 3;
			//IsTrustIndividual = true;
		}

		void ToString(ostream& o)
		{
			o<<"Variable Count:\t\t"<<VariableCount<<endl;
			o<<"Constraint Count:\t"<<ConstraintCount<<endl;
			o<<"EqConstraint Count:\t"<<EqConstraintCount<<endl;
			o<<"Test Tree Count:\t"<<EqConstraintCount<<endl;
			o<<"Max Depth:\t\t"<<MaxDepth<<endl;
			o<<"Tree Dim:\t\t"<<TreeDim<<endl;
			o<<"Tree Node Count:\t"<<TreeNodeCount<<endl;
			o<<"Population Size:\t"<<PopulationSize<<endl;
			o<<"Top Count:\t\t"<<TopCount<<endl;
		}
	};

	
	class Result
	{
	public:
		int mIndexMax;
		int mIndexMin;
		float mAverage;
		int mEvalutionCount;
		vector<float> mVariables;
		float mBestValue;
		int mCurrentGeneration;

		Result(Configer& cfg):mVariables(cfg.VariableCount)
		{
			mIndexMax = 0;
			mIndexMin = 0;
			mAverage = 0;
			mEvalutionCount = 0;
			mBestValue = 0;
			mCurrentGeneration = 0;
		}
	};
}

#endif

⌨️ 快捷键说明

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