Skip to main content

Dynamic Hierarchical Cooperative Swarm Optimization (DHCS)

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dhcs_algorithm-1.0.0.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dhcs_algorithm-1.0.0-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file dhcs_algorithm-1.0.0.tar.gz.

File metadata

  • Download URL: dhcs_algorithm-1.0.0.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for dhcs_algorithm-1.0.0.tar.gz
Algorithm Hash digest
SHA256 63af19710936c7ff28680cd008a0b6e8eabd76d4570469c233a30390c3e04d89
MD5 fef354dfc946bfd7375c30532378b47a
BLAKE2b-256 093597063a4a2bf2a274258935ca49771c818b11cc144d5ffcc0488bff718601

See more details on using hashes here.

File details

Details for the file dhcs_algorithm-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: dhcs_algorithm-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for dhcs_algorithm-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 299c003cac6fd34a21de70e3cc351f86bb13f1fac6a6ce5dcf4a372b8e6334c0
MD5 4534a249ef1649a31e658d17c00435e6
BLAKE2b-256 1a6585acb65808e195f7d01bc5d352547703668e4ba5556a59e1a6b83b92fca0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page