jagua_rs/probs/bpp/util/
assertions.rs1use crate::entities::Item;
2use crate::probs::bpp::entities::{BPProblem, BPSolution, Bin};
3use crate::util::assertions::layouts_match;
4
5pub fn problem_matches_solution(bpp: &BPProblem, sol: &BPSolution) -> bool {
6 let BPSolution {
7 layout_snapshots,
8 time_stamp: _,
9 } = sol;
10
11 for (lkey, l) in &bpp.layouts {
12 let ls = &layout_snapshots[lkey];
13 if !layouts_match(l, ls) {
14 return false;
15 }
16 }
17
18 true
19}
20
21pub fn instance_item_bin_ids_correct(items: &[(Item, usize)], bins: &[Bin]) -> bool {
22 items.iter().enumerate().all(|(i, (item, _))| item.id == i)
23 && bins.iter().enumerate().all(|(i, bin)| bin.id == i)
24}