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

Uploaded Python 3

File details

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

File metadata

  • Download URL: loares-1.0.2.tar.gz
  • Upload date:
  • Size: 127.6 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.2.tar.gz
Algorithm Hash digest
SHA256 55be27bcf2acee4173f87b0a64680a4f7da024e3f279d3553820b0857683a332
MD5 9247a42bab81d42c91622ede3658ca14
BLAKE2b-256 698180c62171b24b0c2031edc45ee67963c915820167483afeca1b2e280dc63b

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: loares-1.0.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 34b8fc8416dc357b36e78816b92f33e2e7067ed86bd6ae9a336db4096943433c
MD5 bfed906814a9f764bfbdcc715b5fb1e7
BLAKE2b-256 70450705391f100c8085bdae44ebb302c049bcee6c05b87e6874258d3046da76

See more details on using hashes here.

Provenance

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