Find the maximum of the function f = −2x5 +4.2x4 +2x3 - x
2 +20x − 5 in the range −8 ≤ x ≤
10 using the Particle Swarm Optimization method. Use 4 particles with the initial
positions x1 = −2, x2 = 0, x3 = 1, and x4 = 3. Solve the numerical using MATLAB coding
for 2 iterations.
x1=66.2
x2=-5
x3=18.2
x4=7.27
td=10^-2;
a=0;
for i= 1:10
a=0+i;
if( (abs(x1-x1)<td && abs(x2-x2)<td) && (abs(x3-x3)<td)&& abs(x4-x4)<td)
x1=(-23+x2-x3+2*x4)/4;
x2=(-21-2*x1+x3-3*x4)/6;
x3=(-11+x1+2*x2-x4)/5;
x4=(22+x1-2*x2+3*x3)/6;
end
k=(4*x1-x2+x3-2*x4);
l=(2*x1+6*x2-x3+3*x4);
m=(-x1-2*x2+5*x3+x4);
n=(-x1+2*x2-3*x3+6*x4);
end
rslt=[k l m n ; x1 x2 x3 x4]
Comments
Leave a comment