feat(async): AsyncProblem trait + run_async on RandomSearch and DifferentialEvolution

Adds the headline async/await capability for IO-bound evaluations
(HTTP services, RPC clients, spawned subprocesses) — the
differentiator vs pymoo / hyperopt / MOEA Framework.

No public-API breaks for synchronous users. The new surface is
gated behind a new `async` feature flag.

- core::async_problem::AsyncProblem trait (async fn evaluate_async).
- algorithms::parallel_eval_async::evaluate_batch_async helper using
  futures::stream::FuturesOrdered with concurrency-bounded chunks;
  preserves input order so seeded determinism holds when evaluations
  are themselves deterministic.
- run_async on RandomSearch and DifferentialEvolution.
- examples/async_eval.rs: simulated 20 ms remote service. concurrency=1
  → 4.2 s, concurrency=4 → 2.1 s (2× speedup).

Bumps Cargo.toml to 0.8.0; CHANGELOG entry covers the above plus a
note that 0.6.0/0.7.0 on crates.io are yanked experimentals and 0.8
picks up cleanly from 0.5.
This commit is contained in:
2026-05-06 07:55:56 -06:00
parent fa3f2e8fb0
commit 6368ca5f3d
10 changed files with 396 additions and 2 deletions
+8 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "heuropt"
version = "0.5.0"
version = "0.8.0"
edition = "2024"
rust-version = "1.85"
authors = ["Stephen Waits <steve@waits.net>"]
@@ -17,8 +17,10 @@ categories = ["algorithms", "science", "mathematics", "simulation"]
default = []
serde = ["dep:serde"]
parallel = ["dep:rayon"]
async = ["dep:futures"]
[dependencies]
futures = { version = "0.3", optional = true, default-features = false, features = ["std", "async-await"] }
rand = "0.9"
rand_distr = "0.5"
rayon = { version = "1", optional = true }
@@ -27,11 +29,16 @@ serde = { version = "1", features = ["derive"], optional = true }
[dev-dependencies]
gungraun = "0.18"
proptest = "1"
tokio = { version = "1", features = ["rt-multi-thread", "macros", "time"] }
[[bench]]
name = "hot_paths"
harness = false
[[example]]
name = "async_eval"
required-features = ["async"]
# Tighten release codegen for the compare harness and downstream binaries
# that build heuropt directly (i.e. when this crate is the workspace root).
# When heuropt is used as a dependency the consumer's profile wins.