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.0.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.0-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: monarchopt-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 c7991e6be2353ba271ed918ee05f0a785c9a0c42e0f607742160101acf7a4e7a
MD5 eae77e098a3a541df4096660180ade18
BLAKE2b-256 6758bf57aa8cc157d7bc266c056e3bbdbd9fca61058554420dd5b99275a0c44a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: monarchopt-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.3 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fdeafbe1f81096191df9e21d2c87ca49e58e0beb3ae4482b20df7a3ba40ef747
MD5 f4c4e4533fd3dfabaef83693781fe818
BLAKE2b-256 4fbee1c85c00c5773d8f85c337c42336e17ca21063c5bed778368dfb2ba7baed

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