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

Basic Usage

from monarchopt import MSO
import numpy as np

def fitness(solution):
    """Example fitness function: maximize sum of elements."""
    return np.sum(solution)

MSO.run(
    obj_func=fitness,
    dim=20,
    pop_size=50,
    max_iter=100,
    obj_type='max'
)

Solving DUF Benchmark Functions

The package includes standalone scripts for solving DUF (Decomposable Unitation-based Functions) problems:

# Basic usage
python solve_dufs.py duf1

# With custom parameters
python solve_dufs.py duf2 --dim 200 --pop-size 2000 --seed 42

Solving UFLP Problems

For solving Uncapacitated Facility Location Problems:

# Basic usage
python solve_uflp.py cap71.txt

# With custom parameters
python solve_uflp.py cap71.txt --pop-size 2000 --max-iter 1000 --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.1.tar.gz (10.6 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.1-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: monarchopt-0.1.1.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

Hashes for monarchopt-0.1.1.tar.gz
Algorithm Hash digest
SHA256 0dc3436bf51ae878f99204b811468a95017f2d36bccf1924f06834b500e9d99b
MD5 08546912bf02b997de0f73596dd562ba
BLAKE2b-256 42d464c7cfc2d055d75a061adbaa4c0f4c8e8c41cc18bbb31855834a35f4f73f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: monarchopt-0.1.1-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

Hashes for monarchopt-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 433f6ef6e37094dc759ad4e2718c6410451029c28c9654234366a7453b5d2c2a
MD5 de6498f64ae81dabe626117d7472aa66
BLAKE2b-256 c7f285054c49f0e463ff5f0e807d50b1cbc9ff0a0a8ce07f7debc882886697e0

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