Adds heuropt-plot, a tiny SVG-only plotter that takes heuropt results and emits scatter plots (pareto_front_svg) and line plots (convergence_svg). No heavy 'plotters' or 'tiny-skia' dep — hand- rolled SVG so the crate adds <100 KB to a build. Workspace setup: root Cargo.toml gains [workspace] with members = ['.', 'heuropt-plot']. heuropt-plot has its own version (0.1.0) and publishes independently against heuropt 0.8+. Adds examples/visualize.rs that wires it up: NSGA-II on Schaffer N.1, plain run() (no observer plumbing), final-front SVG written to disk.
1.4 KiB
1.4 KiB
heuropt-plot
Lightweight SVG plotting helpers for heuropt
results.
Hand-rolled SVG output (no plotters, no tiny-skia, no
heavyweight dependency) so adding heuropt-plot to your project
costs ~20 KB of compiled code.
What's in the box
pareto_front_svg— render a 2-objective Pareto front as an SVG scatter plot with axes and labels.convergence_svg— render a "best fitness so far" trace as an SVG line plot.
Output is a String of valid SVG. Write it to a file, embed it in
HTML, or pipe it to a browser.
Example
use heuropt::prelude::*;
use heuropt_plot::pareto_front_svg;
let space = ObjectiveSpace::new(vec![
Objective::minimize("f1"),
Objective::minimize("f2"),
]);
let front = vec![
Candidate::new((), Evaluation::new(vec![0.0, 1.0])),
Candidate::new((), Evaluation::new(vec![0.5, 0.5])),
Candidate::new((), Evaluation::new(vec![1.0, 0.0])),
];
let svg = pareto_front_svg(&front, &space, 600, 400, "Sample front");
std::fs::write("front.svg", svg).unwrap();
License
MIT — see LICENSE at the repo root.