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

📄 main.cpp

📁 该压缩包有文档和代码
💻 CPP
字号:
////////////////////////////////////////////////////////////////////////
//  Class Name: Ant Colony System for Function Optimization           //
//  Version:    0.1                                                   //
//  Author:     Chen Ye (Sichuan University)                          //
//  E-mail:     arrowcy@163.com, chenye84@gmail.com                   //
//  Blog:       http://www.mscenter.edu.cn/blog/chenye                //
//  Date:       2006-07-01                                            //
////////////////////////////////////////////////////////////////////////
#include "CACS4Fun.h"
#include <iostream.h>
#include <stdlib.h>
#include <time.h>
//#include <CACS4Fun.h>

void main()
{
	srand(time(NULL));
	//srand(0);
	CAcs4Fun acs;
	acs.alpha=0.2;
	acs.num_ants=20;
	acs.num_iters=500;
	acs.num_layers=60;	//layers_per_dimension=60/10=6
	acs.dimension=10;
	acs.p0=0.8;
	acs.rho=0.2;
	acs.tau0=0.01;
	acs.allocate_vars();
	acs.start();
	cout<<acs.gbfit<<endl;//当迭代终结时,最终的到的全局适应度即为最终最小适应度
	for (int i=0; i<acs.dimension; i++)
		cout<<"X["<<i<<"]="<<acs.gbx[i]<<endl;//这里只是给出了最优变量值
}

⌨️ 快捷键说明

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