Skip to main content

Dynamic Hierarchical Cooperative Swarm Algorithm (DHCS)

Overview

The Dynamic Hierarchical Cooperative Swarm Algorithm (DHCS) is a novel optimization technique inspired by swarm intelligence. The algorithm involves agents that adapt their roles dynamically to balance exploration and exploitation in high-dimensional optimization landscapes. The agents cooperate by forming clusters, sharing solutions, and periodically synchronizing to avoid stagnation.

This approach is particularly effective for solving complex optimization problems such as the Ackley function.

Features

  • Dynamic Agent Roles: Agents take on different roles such as explorers, refiners, and leaders based on their performance.
  • Memory Sharing: Agents maintain and share high-quality solutions to improve convergence.
  • Dynamic Clustering: Agents form clusters based on proximity and fitness, with cluster leaders guiding others.
  • Synchronization: Periodic synchronization of agents’ positions and velocities to prevent divergence.

Algorithm Details

  1. Agent Behavior: Agents explore, exploit, and lead other agents to find optimal solutions.
  2. Memory and Role Adaptation: Agents store their best-found solutions and adapt their roles based on fitness improvement.
  3. Cluster Formation: Agents are grouped based on proximity and fitness, with the best agent becoming a leader.
  4. Synchronization: Agents are synchronized if no significant improvement occurs for a set number of iterations.

Requirements

To run this algorithm, the following Python packages are required:

  • numpy (for numerical operations)
  • matplotlib (for plotting the convergence history)
  • random (for generating random values)
  • time (for measuring execution time)

You can install the necessary dependencies using pip:

pip install numpy matplotlib

Usage

  1. Install via pip:
pip install dhcs_algorithm
  1. Usage(Example 1):
from dhcs_algorithm.dhcs import run_dhcs
import numpy as np

# Define an optimization function
def sphere_function(x):
    return np.sum(x**2)

# Run the optimization with default values
results = run_dhcs(sphere_function)
print("Best Fitness:", results["best_fitness"])
  1. Usage(Example 2):
from dhcs_algorithm.dhcs import run_dhcs
import numpy as np

# Define a custom function
def rosenbrock(x):
    return sum(100.0*(x[i+1] - x[i]**2.0)**2 + (1 - x[i])**2 for i in range(len(x) - 1))

# Run with custom parameters
results = run_dhcs(rosenbrock, num_agents=100, dim=30, max_iterations=200)

print("Best Fitness:", results["best_fitness"])
print("Time Taken:", results["time_taken"])

License Terms

MIT License

Copyright (c) [2025] [Krishna Bajpai]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Usage

Until permission is granted, this software should not be used, distributed, or modified.

Terms of Use:

  • The use of this algorithm is restricted to specific permissions granted by the owner.
  • Any usage outside of these permissions is prohibited.

For permission to use or modify this algorithm, please contact bajpaikrishna715@gmail.com.

Acknowledgements

This work is based on ideas from swarm intelligence and optimization techniques. Special thanks to the community for contributing to the development of optimization algorithms and mathematical models.

Contact

For any inquiries or further information, please contact the author at bajpaikrishna715@gmail.com.

Metadata

Release files for dhcs-algorithm 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dhcs-algorithm 1.0.0
File Size Uploaded
dhcs_algorithm-1.0.0.tar.gz 6.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dhcs-algorithm 1.0.0
File Interpreter ABI Platform
dhcs_algorithm-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 12.8 kB

Release files / dhcs_algorithm-1.0.0.tar.gz

Download URL dhcs_algorithm-1.0.0.tar.gz
Size 6.3 kB
Tags Source
SHA-256 checksum
How to use checksums
63af19710936c7ff28680cd008a0b6e8eabd76d4570469c233a30390c3e04d89
BLAKE2b-256 checksum
How to use checksums
093597063a4a2bf2a274258935ca49771c818b11cc144d5ffcc0488bff718601
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.1

Release files / dhcs_algorithm-1.0.0-py3-none-any.whl

Download URL dhcs_algorithm-1.0.0-py3-none-any.whl
Size 6.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
299c003cac6fd34a21de70e3cc351f86bb13f1fac6a6ce5dcf4a372b8e6334c0
BLAKE2b-256 checksum
How to use checksums
1a6585acb65808e195f7d01bc5d352547703668e4ba5556a59e1a6b83b92fca0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.1

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page