Skip to main content

The HMS (Hierarchic Memetic Strategy) is a composite global optimization strategy consisting of a multi-population evolutionary strategy and some auxiliary methods. The HMS makes use of a tree with a fixed maximal height and variable internal node degree. Each component population is governed by a particular evolutionary engine. This package provides a simple python implementation with examples of using different population engines.

Project description

pyhms

GitHub Test Badge codecov Documentation Status

pyhms is a Python implementation of Hierarchic Memetic Strategy (HMS).

The Hierarchic Memetic Strategy is a stochastic global optimizer designed to tackle highly multimodal problems. It is a composite global optimization strategy consisting of a multi-population evolutionary strategy and some auxiliary methods. The HMS makes use of a dynamically-evolving data structure that provides an organization among the component populations. It is a tree with a fixed maximal height and variable internal node degree. Each component population is governed by a particular optimization engine. This package provides a simple python implementation.

Installation

Installation can be done using pypi:

pip install pyhms

It's also possible to install the current main branch:

pip install git+https://github.com/agh-a2s/pyhms.git@main

Quick Start

from pyhms import minimize
import numpy as np

fun = lambda x: sum(x**2)
bounds = np.array([(-20, 20), (-20, 20)])
solution = minimize(
    fun=fun,
    bounds=bounds,
    maxfun=10000,
    log_level="debug",
    seed=42
)

pyhms provides an interface similar to scipy.optimize.minimize. This is the simplest way to run HMS with default parameters.

import numpy as np
from pyhms import (
    EALevelConfig,
    hms,
    get_NBC_sprout,
    DontStop,
    MetaepochLimit,
    SEA,
    Problem,
)

square_bounds = np.array([(-20, 20), (-20, 20)])
square_problem = Problem(lambda x: sum(x**2), maximize=False, bounds=square_bounds)

config = [
    EALevelConfig(
        ea_class=SEA,
        generations=2,
        problem=square_problem,
        pop_size=20,
        mutation_std=1.0,
        lsc=DontStop(),
    ),
    EALevelConfig(
        ea_class=SEA,
        generations=4,
        problem=square_problem,
        pop_size=10,
        mutation_std=0.25,
        sample_std_dev=1.0,
        lsc=DontStop(),
    ),
]
global_stop_condition = MetaepochLimit(limit=10)
sprout_condition = get_NBC_sprout(level_limit=4)
hms_tree = hms(config, global_stop_condition, sprout_condition)
print(hms_tree.summary())

Relevant literature

  • J. Sawicki, M. Łoś, M. Smołka, R. Schaefer. Understanding measure-driven algorithms solving irreversibly ill-conditioned problems. Natural Computing 21:289-315, 2022. doi: 10.1007/s11047-020-09836-w
  • J. Sawicki, M. Łoś, M. Smołka, J. Alvarez-Aramberri. Using Covariance Matrix Adaptation Evolutionary Strategy to boost the search accuracy in hierarchic memetic computations. Journal of computational science, 34, 48-54, 2019. doi: 10.1016/j.jocs.2019.04.005

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

pyhms-0.1.0.tar.gz (28.7 kB view details)

Uploaded Source

Built Distribution

pyhms-0.1.0-py3-none-any.whl (40.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyhms-0.1.0.tar.gz
  • Upload date:
  • Size: 28.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.10.7 Darwin/22.1.0

File hashes

Hashes for pyhms-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3a3999273747f2b0ed4baa9ef8969dba0f2d850658d0b58cfc369a1332b63540
MD5 9304b0ef52eddb65cc93900d295a2f1f
BLAKE2b-256 c851459b9d61aa98df617d4789e4b96928799a119742b4c83e85486532818919

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyhms-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 40.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.10.7 Darwin/22.1.0

File hashes

Hashes for pyhms-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b541787b5b672f6ee846c53cf587fad278155de6f39a359e67b16bb45673f486
MD5 2540e21d809db04020a7ab9741c46706
BLAKE2b-256 c98da29e977119bc417f2c2e2f1ce0f571e2fad5e623e06428a0a7dc5b5f7280

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page