Skip to content

Add C++/Python ACO, PSO, GSA, fuzzy, and hybrid optimization - #22

Merged
Rahuldrabit merged 5 commits into
mainfrom
feature/metaheuristics-suite
Sep 4, 2026
Merged

Add C++/Python ACO, PSO, GSA, fuzzy, and hybrid optimization#22
Rahuldrabit merged 5 commits into
mainfrom
feature/metaheuristics-suite

Conversation

@Rahuldrabit

@Rahuldrabit Rahuldrabit commented Sep 3, 2026

Copy link
Copy Markdown
Owner

Summary

  • add a shared C++17 IContinuousOptimizer interface, common result/configuration types, seeded populations, and a heterogeneous solution-transfer pipeline
  • add seven PSO families: global-best, ring local-best, constriction, bare-bones, fully informed, quantum-behaved, and binary
  • add graph ACO with Ant System, Elitist AS, Rank-Based AS, Ant Colony System, and MAX-MIN AS, plus continuous ACOR
  • add continuous Gravitational Search Algorithm (GSA)
  • add standalone fuzzy C-means and a reusable zero-order Sugeno controller
  • expose the complete suite through both C++ and Python
  • add C++/Python examples, benchmarks, documentation, CTest registration, and cross-platform CI

Python API

Python now exposes:

  • SearchConfig, ProgressState, ControlSignal, and OptimizationResult
  • all PSO and graph ACO variants
  • ContinuousAntColonyOptimizer (ACOR) and GravitationalSearchOptimizer
  • FuzzyCMeans and fully configurable FuzzyAdaptiveController
  • GeneticAlgorithmAdapter and MetaheuristicPipeline
  • subclass hooks for custom Python AdaptiveController and ContinuousOptimizer implementations

The bindings release the main GIL during optimization and safely reacquire it for Python fitness/controller callbacks. Smart-holder lifetime management keeps Python-defined controllers and optimizers valid while the C++ pipeline owns them.

User-controlled composition

  • the library never selects an algorithm, creates a hybrid, reorders stages, or enables adaptation automatically
  • callers choose each optimizer and its exact position by calling MetaheuristicPipeline.add(...)
  • all algorithm parameters and budgets are supplied through public configuration structs; defaults are convenience values, not an automatic tuning policy
  • adaptive controllers are opt-in, and FuzzyControllerConfig exposes membership thresholds, improvement scale, and every Sugeno consequent
  • valid caller-provided control multipliers are forwarded unchanged; invalid/non-finite values are rejected explicitly

Existing GA improvements

  • evaluate each mutated offspring exactly once
  • avoid constructing bound vectors for every mutation
  • support seed solutions for cross-algorithm transfer
  • preserve the global best even when elitism is disabled
  • report exact evaluation and iteration counts
  • validate configurations, seeds, and non-finite fitness values

For the default GA shape (N=50, about 3 elites, crossover rate 0.8), removing pre-mutation crossover evaluations reduces expected offspring objective calls from about 86.4 to 47 per generation (about 45.6%). The exact reduction depends on crossover rate and elite count.

Validation

  • Release build and CTest: 10/10 suites passed, including Python bindings
  • AddressSanitizer + UndefinedBehaviorSanitizer: 10/10 suites passed
  • Python coverage: all 7 PSO variants, all 5 graph ACO variants, ACOR, GSA, FCM, fuzzy control, multithreaded callbacks, hybrid order, and Python extension hooks passed
  • standalone Python GA → PSO → ACOR example passed
  • wheel build, isolated installation, import, and optimization smoke test passed
  • strict -Wall -Wextra -Wpedantic -Wshadow -Wconversion -Wsign-conversion compile for modified headers/examples passed
  • Linux, macOS, and Windows Debug/Release CI is configured

Scope note

“Every ACO/PSO type” is not a finite set in the literature. This PR implements the major distinct families listed above and provides extension interfaces for additional C++ or Python optimizers without changing the user-defined pipeline.

@Rahuldrabit Rahuldrabit changed the title Add interoperable ACO, PSO, GSA, and fuzzy optimization suite Add C++/Python ACO, PSO, GSA, fuzzy, and hybrid optimization Sep 4, 2026
@Rahuldrabit
Rahuldrabit merged commit f8f7749 into main Sep 4, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant