A Python implementation of Gradient-guided Swarm Optimization algorithm
Project description
GSO: Gradient-guided Swarm Optimization
A Python implementation of the Gradient-guided Swarm Optimization algorithm, designed for solving binary optimization problems. The algorithm uses a mathematically grounded approach combining gradient-based directional guidance with neighborhood learning mechanisms.
Features
- Binary optimization for various problem types
- Gradient-guided search for effective exploration
- Neighborhood-based learning for local exploitation
- Built-in command line interface
- Automatic result saving and history tracking
- Early stopping with known optimum
- Automatic progress reporting
- Built-in timeout mechanism
- Reproducible results with seed setting
Installation
pip install gso
Quick Start
from gso import GSO
import numpy as np
def simple_fitness(solution):
"""Example fitness function: maximize sum of elements."""
return np.sum(solution)
GSO.run(
obj_func=simple_fitness,
dim=100,
pop_size=1000,
max_iter=800,
obj_type='max',
neighbour_count=3,
gradient_strength=0.8,
base_learning_rate=0.1
)
Test Examples and Data
To run the test examples (UFLP and DUF problems):
- Clone the GitHub repository:
git clone https://github.com/gazioglue/gso.git
cd gso
- Run UFLP solver:
python examples/solve_uflp.py examples/data/uflp/test_instances/cap71.txt
- Run DUF solver:
python examples/solve_dufs.py duf1
Available Command Line Options
For UFLP:
python solve_uflp.py cap71.txt --pop-size 2000 --max-iter 1000 --seed 42
For DUF:
python solve_dufs.py duf2 --dim 200 --pop-size 2000 --seed 42
Documentation
For more detailed usage instructions and examples, see USAGE.md.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like change.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gradient_swarm_optimization-0.1.1.tar.gz.
File metadata
- Download URL: gradient_swarm_optimization-0.1.1.tar.gz
- Upload date:
- Size: 10.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
51ee4babf671ad01ec39478e2f95ab859d4b1af6d3397664c4500bacd125e004
|
|
| MD5 |
48ad32c080c630164482abe81e14969e
|
|
| BLAKE2b-256 |
a68f05030bad9d0500d0a5f2f543b983113a7c8030b2c7206cda54cacac31f12
|
File details
Details for the file gradient_swarm_optimization-0.1.1-py3-none-any.whl.
File metadata
- Download URL: gradient_swarm_optimization-0.1.1-py3-none-any.whl
- Upload date:
- Size: 9.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7deb43e026a28c622ebda888e1182242c540d30ac3084ed68ff32dda15772106
|
|
| MD5 |
0d7a2efffe6db0a72117fbcef970812c
|
|
| BLAKE2b-256 |
05296a7314d4dd9681033bde4580a36c40bd2a3aebe00306388f099bc2c18a03
|