Planned Basic Usage

Once implemented, the PSO algorithm will follow a similar API to HP-MOCD:

  import networkx as nx
from pymocd import PSO  # Coming soon

G = nx.karate_club_graph()

# PSO instantiation (planned)
alg = PSO(
    graph=G,
    debug_level=1,
    swarm_size=100,
    max_iter=100,
    inertia=0.7,
    cognitive=1.5,
    social=1.5
)

solution = alg.run()
print(solution)
  

Planned Parameters

ParameterTypeDescription
graphnetworkx.GraphYour unweighted, undirected graph
debug_levelu8Verbosity of logging (0-3)
swarm_sizeusizeNumber of particles in the swarm
max_iterusizeMaximum number of iterations
inertiaf64Inertia weight (controls exploration vs exploitation)
cognitivef64Cognitive coefficient (particle’s own experience weight)
socialf64Social coefficient (swarm’s collective knowledge weight)

Status: 🚧 Under Development

For a working algorithm, see HP-MOCD Basic Usage.

Last updated 20 Nov 2025, 09:16 -0300 . history