heuropt
A practical Rust toolkit for implementing heuristic single-objective, multi-objective, and many-objective optimization algorithms.
heuropt is not a research framework full of abstract machinery — it is a
small set of concrete types, a handful of simple traits, and a few reference
algorithms. The goal: an entry-level Rust engineer can define a problem, run a
built-in optimizer, or implement a new optimizer without learning any
framework concepts.
Installation
[]
= "0.1"
# Optional features:
# - "serde": derive Serialize/Deserialize on the core data types.
# - "parallel": evaluate populations across rayon's thread pool.
# Seeded runs stay bit-identical to serial mode.
# heuropt = { version = "0.1", features = ["serde", "parallel"] }
Define a problem
use *;
;
Run NSGA-II
use *;
# ;
#
let initializer = new;
let variation = GaussianMutation ;
let config = Nsga2Config ;
let mut optimizer = new;
let result = optimizer.run;
println!;
See examples/toy_nsga2.rs for the full version.
Implement a custom optimizer
A new optimizer is just an implementation of Optimizer<P>:
use *;
A complete worked example is in examples/custom_optimizer.rs.
Current algorithms
RandomSearch— sample-evaluate-keep baseline.Paes— a small (1+1) Pareto Archived Evolution Strategy.Nsga2— the canonical Pareto-based evolutionary algorithm.DifferentialEvolution— DE/rand/1/bin for single-objective real-valued problems.
Plus reusable utilities: pareto_compare, pareto_front, best_candidate,
non_dominated_sort, crowding_distance, ParetoArchive, and the metrics
spacing and hypervolume_2d.
Design philosophy
- Concrete data, small trait surface.
Problem,Optimizer,Initializer,Variationare the only traits a user interacts with day-to-day. Everything else is plain structs. - No type hell. No trait objects in the core path, no GATs, no HRTBs in
user-facing APIs, no generic-RNG plumbing —
Rngis a single concrete type alias. - Readable algorithms. Built-ins are written for clarity, not maximum
abstraction reuse.
RandomSearchis the recommended file to read before writing your own optimizer. - One crate first. No premature splitting into
-core/-algorithms/-operators. Split later if the crate grows. - Panic on programmer error. Invalid configuration panics with a clear
message in v1; the API may grow
Result-returning variants later if the base API proves useful.
See docs/heuropt_tech_design_spec.md for the full design rationale.
License
MIT — see LICENSE.
Changelog
See CHANGELOG.md.