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.
Metadata
Release files for monarchopt 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| monarchopt-0.1.4.tar.gz | 11.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| monarchopt-0.1.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.0 kB
Release files / monarchopt-0.1.4.tar.gz
| Download URL | monarchopt-0.1.4.tar.gz |
|---|---|
| Size | 11.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cb2622397e39060a3600a761df0f000031a710af2374f187547c83dc56d49e42
|
|
BLAKE2b-256 checksum How to use checksums |
055b239936b971f5c9a793b4f11f1970f76e0817cd7f8e0b3309fac4bbd41ec9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.12
|
Release files / monarchopt-0.1.4-py3-none-any.whl
| Download URL | monarchopt-0.1.4-py3-none-any.whl |
|---|---|
| Size | 9.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
01079c214d692877f801d1190e225e0cfa0bff7ca3a5d275bd26d7fbe79b5f62
|
|
BLAKE2b-256 checksum How to use checksums |
a865513a7e4e58cd2dd916fb848bf9a070d6d7ea912dad0ccd014a87fe0e64c9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.12
|