⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dmain.cpp

📁 多目标优化进化算法目前公认效果收敛性最好的算法NSGA2c++源码,具有一般性
💻 CPP
字号:
///////////////////////////////////////////////////////////////////
/*****************************************************************
Copyright: Artificial Life and Adaptive Robotics Laboratory - ALAR
School of ITEE, UNSW@ADFA, Australia, 2005
*******************************************************************/
///////////////////////////////////////////////////////////////////#include "operators_NSGA2.h"int main(int argc, char* argv[]){	
	double dev=0;		int i,select=1;	int N = 100;  // populations	int GEN = 200;  // generation	int SEED = 1050;	 	double pc=0.15,pm=0.06;	int objID=1;		int NObjs=2;            // number of objectives		int NGenes=30;            // number of genes in the chromosome	int *GSize; // length of each gene	double *Ub; // upper bounds of gene-variables	double *Lb; // lower bounds of gene-variables			// threshold and number of non-dominated solutions or archive fixed size		int alpha=20;						if (argc != 8)
	{
		cout << endl << endl;
		cout << "There should be 7 parameters                 " << endl;
		cout << "-----------------------------                 " << endl;
		cout << "01- population_size                           " << endl;
		cout << "02- number_of_genes                           " << endl;
		cout << "03- number_of_generations                     " << endl;
		cout << "04- Number_of_objectives                      " << endl;
		cout << "05- Objective_number                          " << endl;
		cout << "06- start SEED  " << endl;
		cout << "07- end SEED  " << endl;
		
		exit(1);
	}		// Pass the parameters		N      = atoi(argv[1]);	NGenes = atoi(argv[2]);	GEN    = atoi(argv[3]);	NObjs  = atoi(argv[4]);	objID  = atoi(argv[5]);	int ss = atoi(argv[6]);
	int es = atoi(argv[7]);			//	if (objID==5) NGenes=11;    	if (objID==6) NGenes=10;    	if (objID==4) NGenes=10;    	if (objID>=7) NGenes=5;    		GSize = new int[NGenes];    // length of each gene		Ub=new double[NGenes];   // upper bounds of gene-variables	Lb=new double[NGenes];		
	// For Dynammic testing: only problems: 7,8,9,10,11,12
	for (i=0;i<NGenes;i++)
	{		if (objID==5)		{			if (i==0)				GSize[i]=30;			else				GSize[i]=5;		} else			GSize[i]=30;
				if (objID==4)		{			if (i==0)			{Ub[i]=1; Lb[i]=0;}			else			{Ub[i]=5; Lb[i]=-5;}		}		else if ((objID>=7)&&(objID<=12))		{			Ub[i]=100; Lb[i]=0;		}		else		{			Ub[i]=1; Lb[i]=0;		}	}			operators_NSGA2 opNSGA2(pc,pm,objID);
	int j;
	
	for (SEED=ss;SEED<=es;SEED=SEED+10)
	{
		for (i=50;i<=100;i=i+5)
		{
			for (j=0;j<=20;j++)
			{
				pc    = (double)i/100.0;
				pm    = (double)j/100.0;
				opNSGA2.init(pc,pm,objID);
				opNSGA2.Evolve(N,GEN,SEED,NGenes,NObjs,GSize,Ub,Lb); 
			}
		}
	}
	return 0; }

⌨️ 快捷键说明

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