pub enum PackStrategy {
NextFit,
FirstFit,
BestFit,
WorstFit,
FirstFitDecreasing,
BestFitDecreasing,
FirstFitShuffle,
ModifiedFirstFitDecreasing,
OptimizedBestFitDecreasing,
ParallelOptimizedBestFitDecreasing,
Harmonic,
}Expand description
Packing algorithm strategy.
Used to select which algorithm the Packer dispatches to.
Variants§
NextFit
Next Fit: O(n), single open bin. Worst ratio (2.0) but fastest and lowest memory.
FirstFit
First Fit: O(n log B), leftmost bin with space. Online baseline with 1.7 approx ratio.
BestFit
Best Fit: O(n log B), tightest fitting bin. Slightly better than FF in practice.
WorstFit
Worst Fit: O(n log B), loosest fitting bin. Spreads items evenly across bins.
FirstFitDecreasing
First Fit Decreasing: sort desc + FF. 11/9 ≈ 1.22 ratio. Best general-purpose offline algorithm.
BestFitDecreasing
Best Fit Decreasing: sort desc + BF. Same ratio as FFD.
FirstFitShuffle
First Fit Shuffle: shuffle with seed + FF. Preserves training randomness (used by NeMo).
ModifiedFirstFitDecreasing
Modified First Fit Decreasing: 5-phase with size classes (>1/2, >1/3, etc.). Tighter worst-case bound than FFD: 71/60 ≈ 1.183.
OptimizedBestFitDecreasing
Optimized Best-Fit Decreasing: counting sort + capacity segment tree. O(N log L) where L = max_length. Primary target to beat baseline.
ParallelOptimizedBestFitDecreasing
Parallel Optimized Best-Fit Decreasing: splits input across threads, repacks partial bins. Uses Rayon for data-parallel packing.
Harmonic
Harmonic-k: classifies items by size into k classes. Near-optimal asymptotic ratio.
Implementations§
Source§impl PackStrategy
impl PackStrategy
Sourcepub fn short_name(&self) -> Option<&'static str>
pub fn short_name(&self) -> Option<&'static str>
Short-form alias for API usage.
Returns None for strategies that don’t have a common abbreviation.
Sourcepub fn from_short_name(name: &str) -> Option<Self>
pub fn from_short_name(name: &str) -> Option<Self>
Look up a strategy by its short name (case-insensitive).
Trait Implementations§
Source§impl Clone for PackStrategy
impl Clone for PackStrategy
Source§fn clone(&self) -> PackStrategy
fn clone(&self) -> PackStrategy
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PackStrategy
impl Debug for PackStrategy
Source§impl Default for PackStrategy
impl Default for PackStrategy
Source§fn default() -> PackStrategy
fn default() -> PackStrategy
Source§impl PartialEq for PackStrategy
impl PartialEq for PackStrategy
impl Copy for PackStrategy
impl Eq for PackStrategy
impl StructuralPartialEq for PackStrategy
Auto Trait Implementations§
impl Freeze for PackStrategy
impl RefUnwindSafe for PackStrategy
impl Send for PackStrategy
impl Sync for PackStrategy
impl Unpin for PackStrategy
impl UnsafeUnpin for PackStrategy
impl UnwindSafe for PackStrategy
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more