jagua_rs/probs/bpp/io/
export.rs

1use crate::io::export::export_layout_snapshot;
2use crate::probs::bpp::entities::{BPInstance, BPSolution};
3use crate::probs::bpp::io::ext_repr::ExtBPSolution;
4use std::time::Instant;
5
6/// Exports a solution out of the library
7pub fn export(instance: &BPInstance, solution: &BPSolution, epoch: Instant) -> ExtBPSolution {
8    ExtBPSolution {
9        cost: solution.cost(instance),
10        layouts: solution
11            .layout_snapshots
12            .values()
13            .map(|sl| export_layout_snapshot(sl, instance))
14            .collect(),
15        run_time_sec: solution.time_stamp.duration_since(epoch).as_secs(),
16        density: solution.density(instance),
17    }
18}