Skip to main content

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):

  1. Clone the GitHub repository:
git clone https://github.com/gazioglue/monarchopt.git
cd monarchopt
  1. Run UFLP solver:
python examples/solve_uflp.py examples/data/uflp/test_instances/cap71.txt
  1. 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

monarchopt-0.1.4.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

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

monarchopt-0.1.4-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file monarchopt-0.1.4.tar.gz.

File metadata

  • Download URL: monarchopt-0.1.4.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for monarchopt-0.1.4.tar.gz
Algorithm Hash digest
SHA256 cb2622397e39060a3600a761df0f000031a710af2374f187547c83dc56d49e42
MD5 d63c5dd06fc869e892f3663f6b4e3bf4
BLAKE2b-256 055b239936b971f5c9a793b4f11f1970f76e0817cd7f8e0b3309fac4bbd41ec9

See more details on using hashes here.

File details

Details for the file monarchopt-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: monarchopt-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for monarchopt-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 01079c214d692877f801d1190e225e0cfa0bff7ca3a5d275bd26d7fbe79b5f62
MD5 3f539e29f4d389068f3f04c225c8823e
BLAKE2b-256 a865513a7e4e58cd2dd916fb848bf9a070d6d7ea912dad0ccd014a87fe0e64c9

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