Skip to main content

hydroflow-opt

License Build codecov pre-commit.ci PyPI Python

hydroflow-opt is a Linux/Python 3.11–3.13 orchestration package for simulation-based optimization. It uses pygmo's island model and runs individual case evaluations in isolated subprocesses.

Cases are supplied by installed plugins. The package includes a deterministic quadratic case for laptop development and tests. A real case, such as hydroflow-opt-hydrofoil, depends on hydroflow-opt rather than the reverse.

Installation

Install with uv or pip on a supported Linux system:

uv sync --extra tests
# or
python -m pip install --editable '.[tests]'

pygmo is a required dependency. A simulation case may have additional runtime prerequisites, but those must not be imported by hydroflow-opt itself.

Run explicit candidates

hydroflow-opt check examples/quadratic.toml
hydroflow-opt run examples/quadratic.toml
hydroflow-opt inspect examples/runs/quadratic
[run]
directory = "runs/quadratic"
scratch_directory = "runs/quadratic/scratch"

[case]
name = "quadratic"

[resources]
available_cpus = 1
concurrent_evaluations = 1
mpi_ranks = 1
threads_per_rank = 1

[[candidate]]
id = "baseline"
[candidate.parameters]
x = 1.0
y = 2.0

Each candidate gets its own request, result, stdout, stderr, and scratch directory under the run directory. The resource invariant is:

concurrent_evaluations × mpi_ranks × threads_per_rank ≤ available_cpus

hydroflow-opt refuses a configuration that violates it. A case may use the allocated MPI rank count internally, but it must never choose global concurrency or use an oversubscription flag.

Optimize with islands

Add an [optimization] table and use optimize:

[optimization]
islands = 4
population_size = 8
generations = 10
differential_weight = 0.8
crossover_rate = 0.9
topology = "fully_connected"
seed = 12345 # optional; generated and recorded when omitted
hydroflow-opt optimize path/to/config.toml

Optimization runs write an atomic JSON checkpoint after initialization and after every generation. Resume an interrupted run using its stored effective configuration:

hydroflow-opt resume path/to/run-directory

Software and platform versions are recorded in manifest.json. Compatible version changes produce warnings when resuming rather than blocking the run; hydroflow-opt treats deterministic replay as best-effort.

The initial implementation supports pygmo differential evolution and a fully-connected archipelago. Islands use pygmo multiprocessing and therefore cannot exceed resources.concurrent_evaluations; this preserves the CPU budget even when each evaluation launches MPI ranks. The case plugin supplies parameter names, bounds, and decoding; optimization settings are per run.

Write a case plugin

Publish an entry point in the hydroflow_opt.cases group. Its plugin object exposes a parameter_space(options) method and a worker_command(request, result) method. The command receives JSON paths and must write one structured result. The worker protocol lets a future Slurm backend launch exactly the same case worker with scheduler-owned resources.

Release files for hydroflow-opt 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hydroflow-opt 0.1.0
File Size Uploaded
hydroflow_opt-0.1.0.tar.gz 23.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for hydroflow-opt 0.1.0
File Interpreter ABI Platform
hydroflow_opt-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 41.5 kB

Release files / hydroflow_opt-0.1.0.tar.gz

Download URL hydroflow_opt-0.1.0.tar.gz
Size 23.1 kB
Tags Source
SHA-256 checksum
How to use checksums
e03db500b7f2af2f35065f03af631424ab0b82c5930be7641c8fe27eda1eba81
BLAKE2b-256 checksum
How to use checksums
4875373f4239b3be501f3ee3fa0c5f725673f108af69485f4a1c7e80eea2902b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.31 {"installer":{"name":"uv","version":"0.11.31","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / hydroflow_opt-0.1.0-py3-none-any.whl

Download URL hydroflow_opt-0.1.0-py3-none-any.whl
Size 18.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cca6f60071641995da3c3b08daeadce8ad3f56443fa017b654f47512a5e0783a
BLAKE2b-256 checksum
How to use checksums
208425a1a91493288ad8c94ba882b476d942b3efad0a9b8a6ff2b0d429354c22
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.31 {"installer":{"name":"uv","version":"0.11.31","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page