How to plot the population/particle in Particle Swarm Optimization iteratively?
Mostra commenti meno recenti
I did some programming about PSO. I want to show the movement of my particles/swarms every iteration. It will show like animation because every particle will move based on the result of every iteration. Anyone can help me with the coding or has any idea about this?
Risposte (1)
khadija portu
il 19 Mag 2019
1 voto
hello, did u plot it if yes can you help me
3 Commenti
Mouktar Bello
il 11 Mag 2020
I see your questions are dated. So I'll answer for other people.
You need to store all the values (the X-positions) of your particles at each iteration, and then you just make a loop to display each iteration.
For example if you have this form Swarm(n).Particles(i).X to designate the X position of the i-th particle at the n-th iteration, you can use this code:
for n= 1: max_Iteration
clf;
for j=1:noP
plot(Swarm(n).Particles(j).X(1),Swarm(n).Particles(j).X(2),'k.', 'MarkerSize', 30)
hold on
grid on
end
pause(1); %Pause a little bit before plotting the next iteration
end
Where noP: is number of particles
And here you go!
Bhaskar Tripathi
il 17 Ago 2020
Thank you ! That's helpful
Michela Trapani
il 5 Ago 2021
Hi! How did u save all the values (the X-positions) of your particles at each iteration?
Categorie
Scopri di più su Particle Swarm in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!