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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hydroflow_opt-0.1.0.tar.gz (23.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hydroflow_opt-0.1.0-py3-none-any.whl (18.4 kB view details)

Uploaded Python 3

File details

Details for the file hydroflow_opt-0.1.0.tar.gz.

File metadata

  • Download URL: hydroflow_opt-0.1.0.tar.gz
  • Upload date:
  • Size: 23.1 kB
  • Tags: Source
  • Uploaded using 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}

File hashes

Hashes for hydroflow_opt-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e03db500b7f2af2f35065f03af631424ab0b82c5930be7641c8fe27eda1eba81
MD5 f4a0bdfc4500907070475fdfe4373a1f
BLAKE2b-256 4875373f4239b3be501f3ee3fa0c5f725673f108af69485f4a1c7e80eea2902b

See more details on using hashes here.

File details

Details for the file hydroflow_opt-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: hydroflow_opt-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 18.4 kB
  • Tags: Python 3
  • Uploaded using 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}

File hashes

Hashes for hydroflow_opt-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cca6f60071641995da3c3b08daeadce8ad3f56443fa017b654f47512a5e0783a
MD5 b913b0bbeaf5e392d6b1dde4f275b4cb
BLAKE2b-256 208425a1a91493288ad8c94ba882b476d942b3efad0a9b8a6ff2b0d429354c22

See more details on using hashes here.

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