第13章 基于PSO的寻优计算

You might also like

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 20

MATLAB

13
PSO

MATLAB

13.1
PSO

PSO

PSO

MATLAB

13.1
Frank Heppner

PSO

MATLAB

13.1
PSO
Step1 m

1 m;
xmax , xmax
2 i s
vmax , vmax

3 yi ixi s

Step2
4 i

xis

vis

Step3 pis

Step4 pgs

Step5
Step6 Step2

MATLAB

13.3
PSO 13-1

MATLAB

13.3.1
f x x sin x x / cos x

fmincon

Starting at 0

40

40

Starting at 3

40

20

20

30

20

-20

-20

-20

40

5
x
Starting at 6

10

0
40

5
x
Starting at 8

10

0
40

20

20

20

-20

-20

-20

5
x
Starting at 10

10

10
0
-10
-20
-30
-40

5
x

10

5
x

10

Solution using globalSearch.

40

20

x sin(x) + x cos(2 x)

Starting at 1

x sin(x) + x/cos(x)

x sin(x) + x cos(2 x)

% fmincon
% fmincon(FUN,X,A,B,Aeq,Beq,LB,UB,NONLCON,options,varargin)
x(i) = fmincon(f,x0(i),[],[],[],[],lb,ub,[],...
optimset('Algorithm','SQP','Disp','none'));

5
x

10

5
x

10

MATLAB

13.3.2

Griewank

Rastrigin

MATLAB

13.3.2

Schaffer

Ackley

13.3.2

Rosenbrock

MATLAB

MATLAB

13.3.3

MATLAB

13.3.3
%
V(j,:) = V(j,:) + c1*rand*(gbest(j,:) - pop(j,:)) + c2*rand*(zbest pop(j,:));
V(j,find(V(j,:)>Vmax))=Vmax;
V(j,find(V(j,:)<Vmin))=Vmin;
%
pop(j,:)=pop(j,:)+0.5*V(j,:);
pop(j,find(pop(j,:)>popmax))=popmax;
pop(j,find(pop(j,:)<popmin))=popmin;
%
if rand>0.8
k=ceil(2*rand);
pop(j,k)=rand;
end
%
fitness(j)=fun(pop(j,:));

MATLAB

13.3.3
%
if fitness(j) < fitnessgbest(j)
gbest(j,:) = pop(j,:);
fitnessgbest(j) = fitness(j);
end
%
if fitness(j) < fitnesszbest
zbest = pop(j,:);
fitnesszbest = fitness(j);
end

function y = fun(x)
y=-20*exp(-0.2*sqrt((x(1)^2+x(2)^2)/2))-exp((cos(2*pi*x(1))
+cos(2*pi*x(2)))/2)+20+2.71289; %Ackley

MATLAB

13.3.3
200

1.8
1.6
1.4
1.2

1
0.8
0.6
0.4
0.2
0
-0.2

20

40

60

80

100
120

140

160

180

200

MATLAB

13.3.4

5 x1 4 x2 6 x3

x1 x 2 x 3 20

3x1 2x 2 4x 3 42

3x1 2x 2 30
0 x1, 0 x 2, 0 x 3

function y = fun2(x)
y=-5*x(1)-4*x(2)-6*x(3);
end

MATLAB

13.3.4
200

-30
-35
-40
-45

-50
-55
-60
-65
-70
-75
-80

20

40

60

80

100
120

140

160

180

200

MATLAB

13.3.5 APSO

f x a1 x12 x2 a2 x3 x4 x2 14
k 3000 x2 84000

3000 2

x1 x2
2

2 x2
x22 x1 x3

1
2

1
2

x22 3 x1 x3
2 2 x1 x2

2 13600

x x1 x3
k

2
2

504000
30000
2
x4 x3

MATLAB

13.3.5 APSO

f x a1 x12 x2 a2 x3 x4 x2 14

0.25 x4 x33 2.1952


6.1423 10

x32 x46
1 0.0282 x3 6000
36

0.125 x1 x4

a1 1 x12 a2 x3 x4 x2 14 5.0
a1 1.10471

0.1 x1 2.0

0.1 x2 10.0

a2 0.04811

0.1 x3 10.0

0.1 x4 2.0

MATLAB

13.3.5 APSO

Lb=[0.1 0.1 0.1 0.1];


Ub=[2.0 10.0 10.0 2.0];
%
para=[25 150 0.95];

%
%
%[ gama ]

% APSO
[gbest,fmin]=pso_mincon(@cost,@constraint,Lb,Ub,para);
%
Bestsolution=gbest

fmin

%%
function f=cost(x)
f=1.10471*x(1)^2*x(2)+0.04811*x(3)*x(4)*(14.0+x(2));

MATLAB

13.3.5 APSO
%
function [g,geq]=constraint(x)
%
Q=6000*(14+x(2)/2);
D=sqrt(x(2)^2/4+(x(1)+x(3))^2/4);
J=2*(x(1)*x(2)*sqrt(2)*(x(2)^2/12+(x(1)+x(3))^2/4));
alpha=6000/(sqrt(2)*x(1)*x(2));
%
beta=Q*D/J;
%
tau=sqrt(alpha^2+2*alpha*beta*x(2)/(2*D)+beta^2);
%
sigma=504000/(x(4)*x(3)^2);
%
delta=65856000/(30*10^6*x(4)*x(3)^3);
%
F=4.013*(30*10^6)/196*sqrt(x(3)^2*x(4)^6/36)*(1-x(3)*sqrt(30/48)/28);
g(1)=tau-13600;
g(2)=sigma-30000; g(3)=x(1)-x(4);
g(4)=0.10471*x(1)^2+0.04811*x(3)*x(4)*(14+x(2))-5.0;
g(5)=0.125-x(1); g(6)=delta-0.25; g(7)=6000-F;
% geq=[]
geq=[];

MATLAB

13.3.5 APSO

13

15

x 10

10

50

100

150

You might also like