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

📄 particle.cpp

📁 标准的粒子群优化算法,visual c++.net环境下编写的代码,有助于学习和理解粒子群算法
💻 CPP
字号:
#include "StdAfx.h"
#include ".\particle.h"

CParticle::CParticle(void)
{
	Pos = 0; 
	Vel = 0; 
	PosBest = 0; 
	Dim = 0;
}

CParticle::CParticle( int iDim )
{
	Dim = iDim;
	Pos = new double[Dim];
	Vel = new double[Dim];
	PosBest = new double[Dim];
}

CParticle::~CParticle(void)
{
	if(Dim)
	{
		delete []Pos;
		delete []Vel;
		delete PosBest;
	}
}

void CParticle::SetDim( int Dimension )
{
	if( Pos )
		delete []Pos;
	if( Vel )
		delete []Vel;
	if( PosBest )
		delete []PosBest;
	Dim = Dimension;
	Pos = new double[Dimension];
	Vel = new double[Dimension];
	PosBest = new double[Dimension];
}

⌨️ 快捷键说明

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