Simple bruteforce framework for 3D bin packing problem.
- Provides two types: Cartons to be packed, and Pallet which accepts cartons using a greedy, layer based algorithm.
- Implementation can be handled by the user. Alternatively a helper function is provided in prelude which should cover typical use cases.
Quick and dirty appoximations fast enough for real world application.
cargo add palletize// Example, pack two items where the weights don't matter.
let mut things_to_pack = vec![
Carton::new(cm(40.0), cm(30.0), cm(20.0), None),
Carton::new(cm(25.0), cm(25.0), cm(25.0), None),
];
let dim_of_bin = Dims {
length: cm(100.0),
width: cm(100.0),
height: cm(100.0),
};
let shipment: Vec<Pallet> = packit(&mut items, dims, None);// Example, catching an overweight pallet.
let mut pallet = Pallet::from_dims(Dims {
length: cm(100.0), width: cm(100.0), height: cm(100.0),
});
pallet.max_weight = Some(kg(20.0));
let heavy_box = Carton::new(cm(40.0), cm(30.0), cm(20.0), Some(kg(15.0)));
assert!(pallet.add(heavy_box).is_ok());
let another_box = Carton::new(cm(30.0), cm(30.0), cm(30.0), Some(kg(10.0)));
let result = pallet.add(another_box);
assert!(matches!(result, Err(Mispack::Overweight)));