A Python implementation of Monarch Swarm Optimization algorithm
Project description
MonarchOpt: Monarch Butterfly Swarm Optimization
A Python implementation of the Monarch Swarm Optimization algorithm, designed for solving binary optimization problems. The algorithm is inspired by the migration behavior of monarch butterflies and uses a novel approach combining swarm intelligence with gradient-based optimization.
Features
- Binary optimization for various problem types
- 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 monarchopt
Quick Start
from monarchopt import MSO
import numpy as np
def simple_fitness(solution):
"""Example fitness function: maximize sum of elements."""
return np.sum(solution)
MSO.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/monarchopt.git
cd monarchopt
- 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 to change.
License
This project is licensed under the MIT License - see the LICENSE file for details.
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
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 monarchopt-0.1.3.tar.gz.
File metadata
- Download URL: monarchopt-0.1.3.tar.gz
- Upload date:
- Size: 10.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eede658e1fc6f6b1ed14f01b446d39dccabf9c09afcb17a37e2e7d3e08df1d4c
|
|
| MD5 |
1676f72ba2bc81633c9d11ae0db2fbd0
|
|
| BLAKE2b-256 |
32651b6038070fe2dabe3e6f48ada756877d85e0b748c443183288f5b3bd94db
|
File details
Details for the file monarchopt-0.1.3-py3-none-any.whl.
File metadata
- Download URL: monarchopt-0.1.3-py3-none-any.whl
- Upload date:
- Size: 9.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
46a399a160bc3e8c4c2d6d0833190ed95730b3138cc5d57575ca9f9d8484c0d6
|
|
| MD5 |
c5ca09c61b6ac7a37218131b581674c7
|
|
| BLAKE2b-256 |
98fc8cdeb18b9d8f58efe64bebd2bb56c07091791fb69bb05266ca332ff5095b
|