Skip to main content

Crate heuropt_plot

Crate heuropt_plot 

Source
Expand description

Lightweight SVG plotting helpers for heuropt results.

Two core primitives:

  • pareto_front_svg — render a 2-objective Pareto front as an SVG scatter plot with axes and labels.
  • convergence_svg — render a per-generation “best-fitness so far” trace as an SVG line plot.

Hand-rolled SVG output (no plotters / tiny-skia dep) so the crate stays a tiny optional dependency. 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");
assert!(svg.starts_with("<svg"));
assert!(svg.contains("</svg>"));

Functions§

convergence_svg
Render a per-generation “best fitness so far” trace as an SVG line plot. bests[i] is the best fitness after generation i.
pareto_front_svg
Render a 2-objective Pareto front as an SVG scatter plot.