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, pb=1.0),
    ),
    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.0.tar.gz (126.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.0-py3-none-any.whl (39.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: loares-1.0.0.tar.gz
  • Upload date:
  • Size: 126.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.0.tar.gz
Algorithm Hash digest
SHA256 d28b88574955723a2f5c7f4eaaf0f8f0293bba3dcb9bb58316b7d5868277b2bd
MD5 48149b375579e2df4a1510330221a049
BLAKE2b-256 e2337c6787d0c1b3d822c3d1235c32f060723d6c90c5d1cc0db82fcfa137d629

See more details on using hashes here.

Provenance

The following attestation bundles were made for loares-1.0.0.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.0-py3-none-any.whl.

File metadata

  • Download URL: loares-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 39.4 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 008df3e247ddc6cf433861cfe003597052980efee4d215b209ad9c1bb6b8dd1b
MD5 108bfb5e133bbd4f6d369360e8aba0bc
BLAKE2b-256 d886d75b0454ec68314b255b7897e2f78f69fb835c563ff319e9b65f719eec32

See more details on using hashes here.

Provenance

The following attestation bundles were made for loares-1.0.0-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