问题描述:
目标函数:o=sum(D_(x).^2),其中,x={0,1}; D_(x)={10,20,30,40}; 使用BPSO优化
文件目录:
BPSO.m
ObjectiveFunction.m
BPSO.m
clear all
close all
clc
% Define the details of the binary optimization problem
nVar = 20 ;
ub =ones(1,nVar);
lb = zeros(1,nVar);
fobj = @ObjectiveFunction;
% Define the PSO's paramters
noP = 100;
maxIter = 1000;
wMax = 0.9;
wMin = 0.2;
c1 = 2;
c2 = 2;
vMax = (ub - lb) .* 0.2;
vMin = -vMax;
% Initialize the particles
for k = 1 : noP
Swarm.Particles(k).X = round ( (ub-lb) .* rand(1,nVar) + lb );
Swarm.Particles(k).V = zeros(1, nVar);
Swarm.Particles(k).PBEST.X = zeros(1,nVar);
Swarm.Particles(k).PBEST