Skip to content

Commit f813b0d

Browse files
committed
added docstring and added pso in main rst file
1 parent ca9e5fc commit f813b0d

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

PathPlanning/ParticleSwarmOptimization/particle_swarm_optimization.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,24 @@ def signal_handler(sig, frame):
2727
print("\nExiting...")
2828
plt.close("all")
2929
sys.exit(0)
30+
3031
signal.signal(signal.SIGINT, signal_handler)
32+
3133
class Particle:
34+
"""Represents a single particle in the PSO swarm.
35+
Each particle maintains its current position, velocity, and personal best
36+
position discovered during the search. Particles explore the search space
37+
by updating their velocity based on personal experience (cognitive component)
38+
and swarm knowledge (social component).
39+
Attributes:
40+
search_bounds: List of tuples [(x_min, x_max), (y_min, y_max)] defining search space
41+
max_velocity: Maximum velocity allowed in each dimension (5% of search space range)
42+
position: Current 2D position [x, y] in search space
43+
velocity: Current velocity vector [vx, vy]
44+
pbest_position: Personal best position found so far
45+
pbest_value: Fitness value at personal best position
46+
path: List of all positions visited by this particle
47+
"""
3248
def __init__(self, search_bounds, spawn_bounds):
3349
self.search_bounds = search_bounds
3450
self.max_velocity = np.array([(b[1] - b[0]) * 0.05 for b in search_bounds])

docs/modules/5_path_planning/path_planning_main.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Path planning is the ability of a robot to search feasible and efficient path to
1919
visibility_road_map_planner/visibility_road_map_planner
2020
vrm_planner/vrm_planner
2121
rrt/rrt
22+
particleSwarmOptimization/particleSwarmOptimization
2223
cubic_spline/cubic_spline
2324
bspline_path/bspline_path
2425
catmull_rom_spline/catmull_rom_spline

0 commit comments

Comments
 (0)