Skip to main content

Library for Optmisation Algorithm Research

Project description

loares

Library for Optimisation Algorithm Research

PyPI

loares provides modular, composable optimisation algorithms built on top of pymoo. It includes the BxR (Best-x-worst Recombination) family of algorithms, an experiment runner with multiprocessing support, and automated post-processing with performance metrics and statistical analysis.

Installation

pip install loares

Usage

Running Experiments

import numpy as np
from pymoo.problems.multi import ZDT1
from pymoo.algorithms.moo.nsga2 import NSGA2

from loares.algorithms.bxr.moo import MO_BMR, MO_BWR
from loares.experiments.pymoo_runner import ExperimentRunner, AlgoFactory

problem = ZDT1()
seeds = np.arange(1, 6)

algorithms = [
    AlgoFactory(MO_BMR, pop_size=100),
    AlgoFactory(MO_BWR, pop_size=100),
    AlgoFactory(NSGA2, pop_size=100),  # stock pymoo algorithms work too
]

for factory in algorithms:
    runner = ExperimentRunner(problem, factory, max_evals=25000, test_name="zdt1-test")
    runner.multi_run(seeds, threads=4)

Post-Processing

from loares.experiments.pymoo_process import PostProcess

pp = PostProcess(
    test_dir="zdt1-test/raw_data",
    algo_grps={"BXR": ["MO-BMR", "MO-BWR"], "common": ["NSGA2"]},
    true_front=ZDT1().pareto_front(500),
    gen_rf=False,
    plot_convergence=True,
    plot_pareto=True,
)
pp.run(threads=4)

Post-processing generates:

  • Per-seed final metrics (GD, IGD, HV, Spacing)
  • Mean convergence histories as Parquet files
  • Convergence plots per algorithm group
  • Pareto front plots (2D, 3D, or parallel coordinates)
  • Net summary CSV across all algorithms

Statistical Analysis

from pathlib import Path
from loares.experiments.analysis.stats import run as run_stats

stats_dir = run_stats(Path("zdt1-test/analysis-2026-01-01-12-00-00/100"), alpha=0.05)
# Produces Friedman test results and post-hoc comparisons

Architecture

loares algorithms are built from composable pymoo operators:

  • Recombination: BxR operators (BMR, BWR, BMWR)
  • Pool Selection: Best-worst selection from sorted population
  • Mutation: Random reinitialisation
  • Mods: Local search, opposition-based learning, edge boosting
  • Survival: pymoo's RankAndCrowding (MOO) or FitnessSurvival (SOO)
  • Sub-populations: Adaptive splitting via HV-based policy

Custom algorithm assembly:

from loares.core.composable import ModularAlgorithm, RecombinationVariant
from loares.core.recombination import BMR
from loares.core.pool_selection import BestWorstSelection
from loares.core.mutation import RandomReinit
from loares.core.mods import LocalSearchMod

algo = ModularAlgorithm(
    name="Custom-BMR",
    pop_size=100,
    infill=RecombinationVariant(
        pool_selection=BestWorstSelection(),
        recombination=BMR(),
        mutation=RandomReinit(prob=0.5),
    ),
    mods=[LocalSearchMod()],
)

Output Format

Experiment results are stored as HDF5 files with one file per seed:

test_name/raw_data/{algorithm}/{psize}-{max_evals}/
    seed_001.h5
    seed_002.h5
    ...
    Info.json

Each HDF5 file contains:

  • metadata/ -- problem info, algorithm info, seed
  • function_evals/{n_eval}/ -- X (decision variables), F (objectives), G (constraints) at each snapshot
  • final_dict_json -- final population as JSON attribute

Requirements

Python >= 3.11

License

See 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

loares-1.0.1.tar.gz (127.1 kB view details)

Uploaded Source

Built Distribution

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

loares-1.0.1-py3-none-any.whl (41.1 kB view details)

Uploaded Python 3

File details

Details for the file loares-1.0.1.tar.gz.

File metadata

  • Download URL: loares-1.0.1.tar.gz
  • Upload date:
  • Size: 127.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for loares-1.0.1.tar.gz
Algorithm Hash digest
SHA256 70a7f2df2d590b63af3cec7792cfec7b0ea0454c20f4b3529da9fc3e66b66de4
MD5 1446438b7cd11d33db9e45590bbeb387
BLAKE2b-256 0304d51d216917d2a1f790179ac9a1031f07196fc9165aca05dff5a0349f4d9e

See more details on using hashes here.

Provenance

The following attestation bundles were made for loares-1.0.1.tar.gz:

Publisher: python-publish.yml on hari729/loares

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file loares-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: loares-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 41.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for loares-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5e5c6763ba513773007d3dae4fc91f20e020c878625c5d85dc69b39bff1cb6a3
MD5 e9eb56bd3350556ff43a6405e5eabb1c
BLAKE2b-256 76ce767a1c7aad67f1b99d1810984615aadbd4e3d7d419a998967f64fff2321f

See more details on using hashes here.

Provenance

The following attestation bundles were made for loares-1.0.1-py3-none-any.whl:

Publisher: python-publish.yml on hari729/loares

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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