Subjects optimization

Particle Swarm Optimization

Step-by-step solutions with LaTeX - clean, fast, and student-friendly.

Search Solutions

Particle Swarm Optimization


1. **Problem Statement:** We want to maximize the function $$f(x_1,x_2) = x_1^2 - x_1 x_2 + x_2^2 + 2x_1 + 4x_2 + 3$$ subject to $$-5 \leq x_1, x_2 \leq 5$$ using Particle Swarm Optimization (PSO). 2. **Basic Algorithm of Particle Swarm Optimization:** - Initialize a swarm of particles with random positions and velocities within the search space. - Each particle remembers its best position found so far (personal best). - The swarm also remembers the best position found by any particle (global best). - Update each particle's velocity and position using: $$v_i(t+1) = w v_i(t) + c_1 r_1 (pbest_i - x_i(t)) + c_2 r_2 (gbest - x_i(t))$$ $$x_i(t+1) = x_i(t) + v_i(t+1)$$ where $w$ is inertia weight, $c_1, c_2$ are acceleration coefficients, and $r_1, r_2$ are random numbers in $[0,1]$. - Repeat updates until convergence or max iterations. 3. **Important Rules:** - Keep particles within bounds by clamping positions. - Evaluate the function at each particle's position. - Update personal and global bests accordingly. 4. **Applying PSO to the given function:** - Define the function: $$f(x_1,x_2) = x_1^2 - x_1 x_2 + x_2^2 + 2x_1 + 4x_2 + 3$$ - Initialize particles randomly in $$[-5,5]$$ for both $x_1$ and $x_2$. - Use typical PSO parameters, e.g., $w=0.7$, $c_1=1.5$, $c_2=1.5$. - Iterate updates and track best solution. 5. **Analytical check for maximum:** - Find critical points by setting gradients to zero: $$\frac{\partial f}{\partial x_1} = 2x_1 - x_2 + 2 = 0$$ $$\frac{\partial f}{\partial x_2} = -x_1 + 2x_2 + 4 = 0$$ - Solve the system: From first: $$x_2 = 2x_1 + 2$$ Substitute into second: $$-x_1 + 2(2x_1 + 2) + 4 = 0 \Rightarrow -x_1 + 4x_1 + 4 + 4 = 0$$ $$3x_1 + 8 = 0 \Rightarrow x_1 = -\frac{8}{3} \approx -2.6667$$ Then: $$x_2 = 2(-\frac{8}{3}) + 2 = -\frac{16}{3} + 2 = -\frac{10}{3} \approx -3.3333$$ - Check if within bounds: yes, both in $$[-5,5]$$. 6. **Evaluate function at critical point:** $$f(-\frac{8}{3}, -\frac{10}{3}) = \left(-\frac{8}{3}\right)^2 - \left(-\frac{8}{3}\right)\left(-\frac{10}{3}\right) + \left(-\frac{10}{3}\right)^2 + 2\left(-\frac{8}{3}\right) + 4\left(-\frac{10}{3}\right) + 3$$ $$= \frac{64}{9} - \frac{80}{9} + \frac{100}{9} - \frac{16}{3} - \frac{40}{3} + 3$$ $$= \frac{64 - 80 + 100}{9} - \frac{16 + 40}{3} + 3 = \frac{84}{9} - \frac{56}{3} + 3$$ $$= 9.3333 - 18.6667 + 3 = -6.3334$$ 7. **Interpretation:** - The critical point is a minimum (since the quadratic form is positive definite). - The function is unbounded above in the domain, so maximum occurs at boundary. 8. **Check boundaries:** - Evaluate $f$ at corners: - At $(5,5)$: $$25 - 25 + 25 + 10 + 20 + 3 = 58$$ - At $(5,-5)$: $$25 + 25 + 25 + 10 - 20 + 3 = 68$$ - At $(-5,5)$: $$25 + 25 + 25 - 10 + 20 + 3 = 88$$ - At $(-5,-5)$: $$25 - (-5)(-5) + 25 - 10 - 20 + 3 = 48$$ 9. **Maximum value:** - The maximum is at $(-5,5)$ with value $$88$$. **Final answer:** The maximum of $$f(x_1,x_2)$$ in $$[-5,5]^2$$ is $$88$$ at $$x_1 = -5, x_2 = 5$$. This matches what PSO would find by exploring the domain and converging to the boundary maximum.