资源简介
自适应多目标粒子群优化器
The Adaptive Multi-Objective Particle Swarm Optimizer (AMOPSO).
代码片段和文件信息
//mopso con epsilon dominance y clusters
#include
#include
#include
#include
#include
#include “efile.h“
using namespace std;
MOPSO::~MOPSO(){
}
MOPSO::MOPSO(int _dims int _objsint _partsint _nclustersint _gmaxdouble *_lbdouble *_ub ){
srand(time(0));
ndimensions=_dims;
nobjectives=_objs;
nparticles=_parts;
nclusters=_nclusters;
gmax=_gmax;
gen=0;
lb.resize(ndimensions);
ub.resize(ndimensions);
particles.resize(nparticles);
for(int _j(0);_j lb[_j]=_lb[_j];
ub[_j]=_ub[_j];
}
archive.init(ndimensions nobjectives nclusters100);
}
void MOPSO::initialize(){
C1=2.0;
C2=2.0;
W=0.4;
for(int _i(0);_i for(int _j(0);_j particles[_i].vel[_j]=0;
particles[_i].x[_j]=rnd(lb[_j]ub[_j]);
particles[_i].xpbest[_j]=particles[_i].x[_j];
}
function(_i);
for(int _j(0);_jjectives;_j++){
particles[_i].fxpbest[_j]=particles[_i].fx[_j];
}
archive.add(particles[_i]-1);
}
}
void MOPSO::execute(){
initialize();
for(gen=0;gen archive.updatematrix=true;
archive.hierarchicalClustering();
flight();
}
archive.output();
}
void MOPSO::flight(){
for(int _i(0);_i int _whichcluster=(int)_i/(nparticles/nclusters);
int _gbestselected;
_gbestselected=archive.selectClusteredRandomSolution(_whichcluster);
for(int _k(0);_k<5;_k++){
for(int _j(0);_j particles[_i].vel[_j]=W*particles[_i].vel[_j]+C1*rnd(01)*(archive.solutions[_gbestselected].x[_j]-particles[_i].x[_j])+C2*rnd(01)*(particles[_i].xpbest[_j]-particles[_i].x[_j]);
particles[_i].x[_j]+=particles[_i].vel[_j];
if(particles[_i].x[_j]
particles[_i].x[_j]=lb[_j];
if(particles[_i].x[_j]>ub[_j])
particles[_i].x[_j]=ub[_j];
}
function(_i);
int _tmp=archive.domine1(particles[_i].fxparticles[_i].fxpbest);
if(_tmp==11||_tmp==1){
copy(particles[_i].fxpbestparticles[_i].fx);
copy(particles[_i].xpbestparticles[_i].x);
archive.add(particles[_i](int)_i/(nparticles/nclusters));
}
}
}
}
void MOPSO::perturbation(int _whichparticle){
int _dimension=0;
double _lb_ub_rango;
double _gt=(double)gen/gmax;
double _pM=pow(_gt1.7)-2.0*_gt+1.0;
int _flag(0);
if((rnd(0.01.0)>_pM)&&_flag<=ndimensions){
_dimension= (int) rnd(0ndimensions);
_rango=(ub[_dimension]-lb[_dimension])*_pM/2.0;//totGen
if(particles[_whichparticle].x[_dimension]-_rango
_lb=lb[_dimension];
else
_lb=particles[_whichparticle].x[_dimension]-_rango;
if(particles[_whichparticle].x[_dimension]+_rango>ub[_dimension])
_ub=ub[_dimension];
else
_ub=particles[_whichparticle].x[_dimension]+_rango;
particles[_whichparticle].x[_dimension]=rnd(_lb_ub);
_flag++;
}
}
void MOPSO::function(int _w){
/*
double sum1=0.0
- 上一篇:servlet获取表单数据详解十分全
- 下一篇:计算器图形化界面Qt版
评论
共有 条评论