diff --git a/jagua-rs/src/entities/placing_option.rs b/jagua-rs/src/entities/placing_option.rs index 0d10deb..b19f863 100644 --- a/jagua-rs/src/entities/placing_option.rs +++ b/jagua-rs/src/entities/placing_option.rs @@ -6,7 +6,7 @@ use crate::geometry::d_transformation::DTransformation; /// Encapsulates all required information to place an `Item` in a `Problem` pub struct PlacingOption { /// Which layout to place the item in - pub layout_index: LayoutIndex, + pub layout_idx: LayoutIndex, /// The id of the item to be placed pub item_id: usize, /// The decomposition of the transformation @@ -14,9 +14,9 @@ pub struct PlacingOption { } impl PlacingOption { - pub fn from_placed_item(layout_index: LayoutIndex, placed_item: &PlacedItem) -> Self { + pub fn from_placed_item(layout_idx: LayoutIndex, placed_item: &PlacedItem) -> Self { PlacingOption { - layout_index, + layout_idx, item_id: placed_item.item_id, d_transf: placed_item.d_transf, } diff --git a/jagua-rs/src/entities/problems/bin_packing.rs b/jagua-rs/src/entities/problems/bin_packing.rs index 311b989..c97b96f 100644 --- a/jagua-rs/src/entities/problems/bin_packing.rs +++ b/jagua-rs/src/entities/problems/bin_packing.rs @@ -113,7 +113,7 @@ impl BPProblem { impl ProblemGeneric for BPProblem { fn place_item(&mut self, p_opt: PlacingOption) -> (LayoutIndex, PItemKey) { - let layout_index = match &p_opt.layout_index { + let layout_index = match &p_opt.layout_idx { LayoutIndex::Real(i) => LayoutIndex::Real(*i), LayoutIndex::Template(i) => { //Layout is empty, clone it and add it to `layouts` diff --git a/jagua-rs/src/entities/problems/strip_packing.rs b/jagua-rs/src/entities/problems/strip_packing.rs index b407f24..b50db48 100644 --- a/jagua-rs/src/entities/problems/strip_packing.rs +++ b/jagua-rs/src/entities/problems/strip_packing.rs @@ -122,7 +122,7 @@ impl SPProblem { let cde = self.layout.cde(); if !cde.poly_collides(&transformed_shape, entities_to_ignore.as_ref()) { let insert_opt = PlacingOption { - layout_index: STRIP_LAYOUT_IDX, + layout_idx: STRIP_LAYOUT_IDX, item_id, d_transf, }; @@ -167,7 +167,7 @@ impl SPProblem { impl ProblemGeneric for SPProblem { fn place_item(&mut self, p_opt: PlacingOption) -> (LayoutIndex, PItemKey) { assert_eq!( - p_opt.layout_index, STRIP_LAYOUT_IDX, + p_opt.layout_idx, STRIP_LAYOUT_IDX, "Strip packing problems only have a single layout" ); let item_id = p_opt.item_id; diff --git a/jagua-rs/src/io/parser.rs b/jagua-rs/src/io/parser.rs index db78010..c508c26 100644 --- a/jagua-rs/src/io/parser.rs +++ b/jagua-rs/src/io/parser.rs @@ -316,7 +316,7 @@ pub fn build_strip_packing_solution( let d_transf = transform.decompose(); let placing_opt = PlacingOption { - layout_index: STRIP_LAYOUT_IDX, + layout_idx: STRIP_LAYOUT_IDX, item_id: item.id, d_transf, }; @@ -362,11 +362,11 @@ pub fn build_bin_packing_solution(instance: &BPInstance, json_layouts: &[JsonLay let d_transf = transform.decompose(); let initial_insert_opt = PlacingOption { - layout_index: LayoutIndex::Template(template_index), + layout_idx: LayoutIndex::Template(template_index), item_id: first_item.id, d_transf, }; - let (layout_index, _) = problem.place_item(initial_insert_opt); + let (layout_idx, _) = problem.place_item(initial_insert_opt); problem.flush_changes(); //Insert the rest of the items @@ -385,7 +385,7 @@ pub fn build_bin_packing_solution(instance: &BPInstance, json_layouts: &[JsonLay let d_transf = transform.decompose(); let insert_opt = PlacingOption { - layout_index, + layout_idx, item_id: item.id, d_transf, }; diff --git a/lbf/benches/hpg_bench.rs b/lbf/benches/hpg_bench.rs index a1d149b..3e633b4 100644 --- a/lbf/benches/hpg_bench.rs +++ b/lbf/benches/hpg_bench.rs @@ -45,7 +45,7 @@ fn hpg_query_bench(c: &mut Criterion) { .placed_items() .values() .map(|pi| PlacingOption { - layout_index: LayoutIndex::Real(0), + layout_idx: LayoutIndex::Real(0), item_id: pi.item_id, d_transf: pi.d_transf, }) @@ -133,7 +133,7 @@ fn hpg_update_bench(c: &mut Criterion) { .placed_items() .values() .map(|pi| PlacingOption { - layout_index: LayoutIndex::Real(0), + layout_idx: LayoutIndex::Real(0), item_id: pi.item_id, d_transf: pi.d_transf, }) @@ -195,7 +195,7 @@ fn hpg_update_bench(c: &mut Criterion) { if !layout.cde().poly_collides(&buffer_shape, &[]) { let d_transf = transf.decompose(); valid_placements.push(PlacingOption { - layout_index: LayoutIndex::Real(0), + layout_idx: LayoutIndex::Real(0), item_id: SELECTED_ITEM_ID, d_transf, }); diff --git a/lbf/benches/quadtree_bench.rs b/lbf/benches/quadtree_bench.rs index a9d050b..6985d10 100644 --- a/lbf/benches/quadtree_bench.rs +++ b/lbf/benches/quadtree_bench.rs @@ -54,27 +54,27 @@ fn quadtree_update_bench(c: &mut Criterion) { ); let (mut problem, _) = util::create_blf_problem(instance.clone(), config, 0); - let layout_index = LayoutIndex::Real(0); + let layout_idx = LayoutIndex::Real(0); let mut rng = SmallRng::seed_from_u64(0); group.bench_function(BenchmarkId::from_parameter(depth), |b| { b.iter(|| { // Remove an item from the layout let (pik, pi) = problem - .get_layout(&layout_index) + .get_layout(&layout_idx) .placed_items() .iter() .choose(&mut rng) .expect("No items in layout"); let p_opt = PlacingOption { - layout_index, + layout_idx, item_id: pi.item_id, d_transf: pi.d_transf, }; //println!("Removing item with id: {}\n", pi_uid.item_id); - problem.remove_item(layout_index, pik, true); + problem.remove_item(layout_idx, pik, true); problem.flush_changes(); @@ -178,24 +178,24 @@ fn quadtree_query_update_1000_1(c: &mut Criterion) { let mut sample_cycler = samples.chunks(N_SAMPLES_PER_ITER).cycle(); - let layout_index = LayoutIndex::Real(0); + let layout_idx = LayoutIndex::Real(0); group.bench_function(BenchmarkId::from_parameter(depth), |b| { b.iter(|| { let (pik, pi) = problem - .get_layout(layout_index) + .get_layout(layout_idx) .placed_items() .iter() .choose(&mut rng) .expect("No items in layout"); let p_opt = PlacingOption { - layout_index, + layout_idx, item_id: pi.item_id, d_transf: pi.d_transf, }; - problem.remove_item(layout_index, pik, true); + problem.remove_item(layout_idx, pik, true); problem.flush_changes(); let item_id = p_opt.item_id; diff --git a/lbf/benches/util.rs b/lbf/benches/util.rs index daa418a..0906fa6 100644 --- a/lbf/benches/util.rs +++ b/lbf/benches/util.rs @@ -67,7 +67,7 @@ pub fn create_blf_problem( .map(|k| { let pi = &problem.layout.placed_items()[*k]; PlacingOption { - layout_index: STRIP_LAYOUT_IDX, + layout_idx: STRIP_LAYOUT_IDX, item_id: pi.item_id, d_transf: pi.d_transf, } diff --git a/lbf/src/lbf_optimizer.rs b/lbf/src/lbf_optimizer.rs index ae2c4e0..e56f652 100644 --- a/lbf/src/lbf_optimizer.rs +++ b/lbf/src/lbf_optimizer.rs @@ -165,13 +165,13 @@ pub fn find_lbf_placement( pub fn sample_layout( problem: &Problem, - layout_index: LayoutIndex, + layout_idx: LayoutIndex, item: &Item, config: &LBFConfig, rng: &mut impl Rng, sample_counter: &mut usize, ) -> Option { - let layout: &Layout = problem.get_layout(&layout_index); + let layout: &Layout = problem.get_layout(&layout_idx); let cde = layout.cde(); let irrel_hazards = match item.hazard_filter.as_ref() { None => vec![], @@ -213,7 +213,7 @@ pub fn sample_layout( if worth_testing && !cde.poly_collides(&buffer, &irrel_hazards) { //sample is valid and improves on the current best let p_opt = PlacingOption { - layout_index, + layout_idx, item_id: item.id, d_transf: transform.decompose(), }; @@ -254,7 +254,7 @@ pub fn sample_layout( if worth_testing && !cde.poly_collides(&buffer, &irrel_hazards) { //sample is valid and improves on the current best let p_opt = PlacingOption { - layout_index, + layout_idx, item_id: item.id, d_transf, };