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.7+. Adds examples/visualize.rs that wires it all up: NSGA-II on Schaffer N.1, observer closure recording per-generation hypervolume, two SVGs written to disk.
47 lines
1.4 KiB
Markdown
47 lines
1.4 KiB
Markdown
# heuropt-plot
|
|
|
|
[](https://crates.io/crates/heuropt-plot)
|
|
[](https://docs.rs/heuropt-plot)
|
|
[](../LICENSE)
|
|
|
|
Lightweight SVG plotting helpers for [`heuropt`](https://crates.io/crates/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
|
|
|
|
```rust
|
|
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](../LICENSE) at the repo root.
|