loares
Library for multi-objective optimisation algorithm research built on pymoo. loares provides BxR (best-x-worst recombination) algorithms plus a file-based experiment pipeline for running repeated trials, calculating quality indicators, and comparing algorithms statistically.
Installation
pip install loares
loares requires Python 3.11 or later.
Quick Start
The following multi-objective ZDT1 experiment follows examples/zdt1_comparison.py (reduced to fewer runs). It runs BxR variants and NSGA-II, then computes quality indicators and performs statistical analysis.
import inspect
from pathlib import Path
from pymoo.algorithms.moo.nsga2 import NSGA2
from pymoo.indicators.gd import GD
from pymoo.indicators.hv import HV
from pymoo.indicators.igd import IGD
from pymoo.indicators.spacing import SpacingIndicator
from pymoo.problems.multi import ZDT1
from loares.algorithms.moo.mobxr_cd import MO_BMR_CD, MO_BWR_CD, MO_BMWR_CD
from loares.indicator import indicator_multi_run
from loares.run import parallel_run
from loares.statistics import statistical_test
runs = 5
pop_size = 100
max_evals = 25_000
problem = ZDT1()
output_dir = Path(inspect.stack()[0].filename).resolve().parent / "output"
common = {
"algorithm_kwargs": {"pop_size": pop_size},
"problem_name": "ZDT1",
"problem": problem,
}
algorithms = [
{"algorithm_name": "MO-BMR", "algorithm": MO_BMR_CD},
{"algorithm_name": "MO-BWR", "algorithm": MO_BWR_CD},
{"algorithm_name": "MO-BMWR", "algorithm": MO_BMWR_CD},
{"algorithm_name": "NSGA-II", "algorithm": NSGA2},
]
algorithm_specs = [
{
"solver_kwargs": {
"seed": seed,
"termination": ("n_eval", max_evals),
"save_history": True,
},
**common,
**algorithm,
}
for seed in range(1, runs + 1)
for algorithm in algorithms
]
parallel_run(algorithm_specs, output_dir, n_jobs=5)
true_front = problem.pareto_front(500)
indicator_specs = [
{"indicator_name": "GD", "indicator": GD(true_front)},
{"indicator_name": "IGD", "indicator": IGD(true_front)},
{"indicator_name": "Spacing", "indicator": SpacingIndicator()},
{"indicator_name": "HV", "indicator": HV(ref_point=[1.1, 1.1])},
]
indicator_multi_run(indicator_specs, output_dir, n_jobs=5)
parallel_run skips specs whose result already exists. Pass overwrite=True to run every spec again.
Statistical Analysis
Use the generated metrics_manifest.csv to build a seed-by-algorithm comparison for each indicator. The example below analyses hypervolume; use GD, IGD, or Spacing to analyse a different metric.
stat_specs = [
{
"filter": {
"indicator_name": "HV",
"pop_size": pop_size,
"termination_metric": "n_eval",
"termination_value": max_evals,
"source": "opt",
},
"pivot": {"index": "seed", "columns": "algorithm_name", "values": "indicator_value"},
}
]
statistical_test(stat_specs, output_dir / "metrics_manifest.csv", output_dir)
Results are written under statistical-test/<problem>/<metric>-<value>/<pop_size>/, including Friedman results, average ranks, and Vargha-Delaney A12 matrices. The sub-folder is built from the filter values that are present, so specs that differ only by filter do not overwrite each other; pass a name key in a spec to choose the folder explicitly.
Each spec compares algorithms with a Friedman test (>= 3 algorithms) or a Wilcoxon signed-rank test (exactly 2), followed by a Conover-Holm post-hoc when the Friedman test is significant.
Indicator direction (minimise vs maximise)
The direction of each indicator is a property of the indicator, not the test. indicator_multi_run records it as a minimize column in metrics_manifest.csv:
- A built-in default covers
GD/GDPlus,IGD/IGDPlus,Spacing(minimise) andHV(maximise). - For any other indicator, add
"minimize": True/Falseto the indicator spec.
statistical_test reads the direction from the manifest (or from an optional "minimize" key in the stat spec) and normalises the A12 matrix so that a value > 0.5 always means the row algorithm is better.
Reading the heatmaps
Both the A12 and Conover-Holm heatmaps are annotated with the value in each cell and mark
statistically significant comparisons (p < alpha) with a * next to the value.
The A12 heatmap additionally encodes the direction of each comparison. A12 > 0.5 always
means the row algorithm is better, and this is shown in two ways: the cell is coloured red
(blue when the column algorithm is better, white for a tie at 0.5) and a marker is drawn to
the right of the value — ^ when the row wins, v when the column wins.
Convergence History and Plots
When runs are saved with save_history: True, you can compute per-evaluation indicator histories and plot mean convergence curves:
from loares.indicator import (
indicator_history_multi_run,
mean_history_multi_run,
plot_convergence,
)
indicator_history_multi_run(indicator_specs, output_dir, n_jobs=5)
mean_history_multi_run(output_dir / "history.parquet", output_dir)
plot_specs = [
{
"filter": {
"indicator_name": "HV",
"problem_name": "ZDT1",
"pop_size": pop_size,
"termination_metric": "n_eval",
"termination_value": max_evals,
"source": "opt",
},
"xlabel": "Function Evaluations",
"ylabel": "Hypervolume",
"algo_grps": {
"BMR": ["MO-BMR"],
"BWR": ["MO-BWR"],
"BMWR": ["MO-BMWR"],
"common": ["NSGA-II"],
},
}
]
plot_convergence(plot_specs, output_dir / "mean_history.parquet", output_dir)
indicator_history_multi_runevaluates each indicator at every recorded snapshot and writeshistory.parquet.mean_history_multi_runinterpolates each seed's curve onto a shared evaluation grid and averages across seeds, writingmean_history.parquet.plot_convergencereads the compiledmean_history.parquet(no recomputation) and writes a multi-pageconvergence.pdf. Each spec is either a plain filter (one page, one line per distinctgroup_byvalue) or a grouped spec withalgo_grps(one page per non-commongroup, plotted against thecommonalgorithms).
Algorithms
Preconfigured multi-objective BxR variants are available from loares.algorithms.moo.mobxr_cd:
MO_BMR_CD-- Best-Mean-Recombination with Rank-and-Crowding survivalMO_BWR_CD-- Best-Worst-Recombination with Rank-and-Crowding survivalMO_BMWR_CD-- Best-Mean-Worst-Recombination with Rank-and-Crowding survival
Any compatible pymoo algorithm, such as NSGA2, can be used in an algorithm spec.
Building blocks
The algorithms are assembled from reusable operators:
loares.base.bxr.BxR-- a pymooAlgorithmsubclass driven by a core operator, selection, survival and mutation.loares.operators.bxr-- theBMR,BWRandBMWRrecombination operators.loares.operators.mutation--RandomReinitandQOPPReinitmutations.loares.operators.selection.bxr_cd--CD_BW_selectionandCD_BW_archive_selection.loares.operators.survival--NDSFarthestPointSurvival(non-dominated sorting + farthest-point sampling).
Output
Each run creates a gzipped pickle result and a run manifest at:
{output_dir}/{problem_name}/{termination_metric}-{termination_value}/
{algorithm_name}/{pop_size}/seed_{seed:03d}/result.pkl.gz
The result file stores the full pymoo minimize result object including F, X, and optionally history. The pipeline produces these files at the output_dir root:
run_manifest.csv-- one row per run (spec info, result path, error if any).metrics_manifest.csv-- one row per run x indicator (final indicator value,sourceopt/archive,minimize).history.parquet-- per-evaluation indicator values (requiressave_history).mean_history.parquet-- one averaged curve per algorithm/indicator group.statistical-test/-- statistical comparison outputs.convergence.pdf-- convergence plots.
License
See LICENSE.
Metadata
Release files for loares 2.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| loares-2.3.0.tar.gz | 116.9 kB | With provenance | Details for loares-2.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| loares-2.3.0-py3-none-any.whl | Python 3 | none | any | Details for loares-2.3.0-py3-none-any.whl |
Total release size: 142.9 kB
Release files / loares-2.3.0.tar.gz
| Download URL | loares-2.3.0.tar.gz |
|---|---|
| Size | 116.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
be095a371a37db3862c107983f158f855a5c31f7f0d993303b93ebdba4dffcef
|
|
BLAKE2b-256 checksum How to use checksums |
004fefdc9d90f0466fc28518615644b1ad3d8af8d8e19af78b92978519183d2b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 29, 2026.
Transparency logRelease files / loares-2.3.0-py3-none-any.whl
| Download URL | loares-2.3.0-py3-none-any.whl |
|---|---|
| Size | 26.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
aeb9bc8d93cbf0e6446ceb98d4df48ab06bda73f23e51a75ad1ee84e76e01194
|
|
BLAKE2b-256 checksum How to use checksums |
ae6b9364a2667d15b3145baaa23bf02701729ab0ec6fc14c4f5494d44b696f04
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 29, 2026.
Transparency logSecurity for loares 2.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for loares-2.3.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 29, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.