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.3.tar.gz (127.7 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.3-py3-none-any.whl (41.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: loares-1.0.3.tar.gz
  • Upload date:
  • Size: 127.7 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.3.tar.gz
Algorithm Hash digest
SHA256 68d4cfca1716b53fb56b087d80220bcda7fa99d6c84e3178593aa38590aed759
MD5 81037673a249159df03611f3d0b35172
BLAKE2b-256 7f098ef7650d8ba9fb2a627b62bd539be682701dc496bcaa5eaeac4bc502893c

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: loares-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 41.6 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c36b6601b5a423b52e54f3f978a0e131c16601f6bff8782dcea41865ddd181e0
MD5 119db541123a0ddc16967939b54ea774
BLAKE2b-256 9113f4374d3a4f1bb5d309b68fcb1ff2c714b4aba8da53dda5fa673eedbf536c

See more details on using hashes here.

Provenance

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