pso_km.txt

来自「毕设题目」· 文本 代码 · 共 44 行

TXT
44
字号

#include <iostream> 
#include <fstream> 
#include <stdlib.h>
#include <time.h>
#include <stdio.h>
#include <afx.h>
#include <string.h>
#include <math.h>

using namespace std; 
#define square(x) ((x)*(x))
#define DIMEN_MAX  20
#define POP_MAX	   40			// 粒子群群体规模
#define coe	       1            //粒子适应度系数

#define LOOP_MAX	10000		//循环最大次数
#define WU			0.9			//权重系数
#define WB			0.4			//权重系数
#define C1			2.0			//调节参数
#define C2			2.0			//调节参数
#define	RANGE		1000.0
#define START		-500.0

#define V_MAX	   1000         //速度最大值
#define FRAND()	   (double(rand())/RAND_MAX) //随机的位于0到1之间的数

//二维结构体
struct point2d
{
    public: double x,y;
	int cluster[POP_MAX];       //所属类号
};


point2d * centroid;    //存放中心点
point2d * set;         //存放样本点
//int *nb;               //纪录类的个数

//粒子结构体
struct particle
{
	point2d position[DIMEN_MAX];		//位置,二维的
	point2d velocity[DIMEN_MAX];		//速度,二维的			

⌨️ 快捷键说明

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