#bin #algorithm #packing #bin-packing #pack #size #fit

pack_it_up

pack_it_up is a simple Rust library that implements various bin packing algorithms

4 releases (2 stable)

new 1.1.0 Feb 14, 2025
1.0.0 Mar 7, 2023
0.1.1 Jan 9, 2023
0.1.0 Jan 7, 2023

#394 in Algorithms

Download history 61/week @ 2024-10-28 64/week @ 2024-11-04 72/week @ 2024-11-11 92/week @ 2024-11-18 142/week @ 2024-11-25 48/week @ 2024-12-02 73/week @ 2024-12-09 98/week @ 2024-12-16 1/week @ 2024-12-23 34/week @ 2024-12-30 99/week @ 2025-01-06 164/week @ 2025-01-13 166/week @ 2025-01-20 173/week @ 2025-01-27 102/week @ 2025-02-03 273/week @ 2025-02-10

721 downloads per month

MIT license

30KB
556 lines

pack_it_up

Crates.io docs.rs

pack_it_up is a simple Rust library that implements various bin packing algorithms

Current implemented algorithms

  • First-fit
  • First-fit-decreasing
  • Next-fit

Basic example

use pack_it_up::offline::first_fit_decreasing::first_fit_decreasing;

struct MyItem {
    some_content: i32,
    size: usize,
}

impl Pack for MyItem {
    fn size(&self) -> usize {
        self.size
    }
}

fn main() {
    let my_items = vec![
        MyItem { some_content: 1, size: 1, },
        MyItem { some_content: 2, size: 2, },
        MyItem { some_content: 3, size: 19, },
        MyItem { some_content: 4, size: 17, },
        MyItem { some_content: 5, size: 1, }, 
    ];
    
    let mut bins = first_fit_decreasing(20, my_items);
}

The above will result in 2 full bins, one with sizes 19 and 1, and the other with sizes 17, 2 and 1.

Planned features

  • Remaining algorithms
  • Performance optimizations
  • Simple derive for Pack if your struct already has a field called size

No runtime deps