#bin #algorithm #packing #bin-packing #pack #fit #offline

pack_it_up

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

3 releases (1 stable)

1.0.0 Mar 7, 2023
0.1.1 Jan 9, 2023
0.1.0 Jan 7, 2023

#1216 in Algorithms

Download history 124/week @ 2024-03-13 153/week @ 2024-03-20 108/week @ 2024-03-27 133/week @ 2024-04-03 149/week @ 2024-04-10 62/week @ 2024-04-17 85/week @ 2024-04-24 77/week @ 2024-05-01 90/week @ 2024-05-08 88/week @ 2024-05-15 111/week @ 2024-05-22 123/week @ 2024-05-29 135/week @ 2024-06-05 124/week @ 2024-06-12 83/week @ 2024-06-19 19/week @ 2024-06-26

389 downloads per month

MIT license

11KB
174 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

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