main.cpp
来自「标准pso算法」· C++ 代码 · 共 28 行
CPP
28 行
// pso.cpp : Defines the entry point for the console application.
#include <iostream.h>
#include <cmath>
#include "pso.h"
#include "pso.cpp"
//申明相关数据
const int PNum = 20; //微粒个数
const int PDim = 20; //微粒维数
const int MAX_NUM = 2000; //最大迭代次数
int main(void)
{
double bestfit;
PSO pso(PNum, PDim);
pso.SetC1(1.494);
pso.SetC2(1.494);
pso.SetW(0.729);
pso.SetXmax(5.12);
pso.SetVmax(5.12);
cout<<"\nRun Now:\n";
bestfit = (pso.Run(MAX_NUM)).BestFit;
cout<<"\nThe Result is:\t"<<bestfit<<"\n";
return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?