pub struct SolveResult<S> {Show 16 fields
pub placements: Vec<Placement<S>>,
pub boundaries_used: usize,
pub utilization: f64,
pub unplaced: Vec<String>,
pub computation_time_ms: u64,
pub generations: Option<u32>,
pub iterations: Option<u64>,
pub best_fitness: Option<f64>,
pub fitness_history: Option<Vec<f64>>,
pub strategy: Option<String>,
pub stop_reason: StopReason,
pub strip_stats: Vec<StripStats>,
pub total_piece_area: f64,
pub total_material_used: f64,
pub total_requested: usize,
pub used_bounding_box: [f64; 2],
}Expand description
Result of a nesting or packing solve operation.
Fields§
§placements: Vec<Placement<S>>List of placements for all successfully placed geometry instances.
boundaries_used: usizeNumber of boundaries (bins) used.
utilization: f64Utilization ratio (0.0 - 1.0). Calculated as: total_geometry_measure / total_boundary_measure
unplaced: Vec<String>IDs of geometries that could not be placed.
computation_time_ms: u64Computation time in milliseconds.
generations: Option<u32>Number of generations (for GA-based solvers).
iterations: Option<u64>Number of iterations (for SA-based solvers).
best_fitness: Option<f64>Best fitness value achieved (for GA/SA-based solvers).
fitness_history: Option<Vec<f64>>Fitness history over generations (for analysis).
strategy: Option<String>Strategy used for solving.
stop_reason: StopReasonWhy the run stopped – at the time limit, at the target, on cancellation, or at its own end.
strip_stats: Vec<StripStats>Per-strip statistics for multi-strip packing. Contains used_length, piece_area, piece_count for each strip.
total_piece_area: f64Total area of all placed pieces.
total_material_used: f64Total material area consumed (sum of strip_width × used_length for each strip).
total_requested: usizeTotal number of geometry instances requested (Σ of every geometry’s
quantity). This is the instance-level denominator: the count of unplaced
instances is total_requested - placements.len(), since placements is
instance-level while unplaced is deduplicated to unique geometry IDs.
Set once at the top-level solve/solve_with_progress entry point.
used_bounding_box: [f64; 2]Axis-aligned bounding box [width, height] of the placed pieces’ actual
footprint (2D). Unlike utilization (piece area over the full boundary,
which shrinks arbitrarily as boundary height grows), the used bounding box
is boundary-padding independent — for an open-ended roll the larger axis is
the material length actually consumed. [0.0, 0.0] when nothing is placed.
Populated at the 2D validation/filter step; unused by 3D packing.
Implementations§
Source§impl<S> SolveResult<S>
impl<S> SolveResult<S>
Sourcepub fn new() -> SolveResult<S>
pub fn new() -> SolveResult<S>
Creates a new empty result.
Sourcepub fn all_placed(&self) -> bool
pub fn all_placed(&self) -> bool
Returns true if all geometries were placed.
Sourcepub fn placed_count(&self) -> usize
pub fn placed_count(&self) -> usize
Returns the number of placed geometry instances.
Sourcepub fn unplaced_count(&self) -> usize
pub fn unplaced_count(&self) -> usize
Returns the number of unplaced geometry types.
Sourcepub fn is_successful(&self) -> bool
pub fn is_successful(&self) -> bool
Returns true if the solve was successful (at least one placement).
Sourcepub fn with_strategy(self, strategy: impl Into<String>) -> SolveResult<S>
pub fn with_strategy(self, strategy: impl Into<String>) -> SolveResult<S>
Sets the strategy name.
Sourcepub fn with_generations(self, generations: u32) -> SolveResult<S>
pub fn with_generations(self, generations: u32) -> SolveResult<S>
Sets the generations count.
Sourcepub fn with_best_fitness(self, fitness: f64) -> SolveResult<S>
pub fn with_best_fitness(self, fitness: f64) -> SolveResult<S>
Sets the best fitness.
Sourcepub fn with_fitness_history(self, history: Vec<f64>) -> SolveResult<S>
pub fn with_fitness_history(self, history: Vec<f64>) -> SolveResult<S>
Sets the fitness history.
Sourcepub fn floored_at(
self,
baselines: impl IntoIterator<Item = SolveResult<S>>,
beats: impl Fn(&SolveResult<S>, &SolveResult<S>) -> bool,
) -> SolveResult<S>
pub fn floored_at( self, baselines: impl IntoIterator<Item = SolveResult<S>>, beats: impl Fn(&SolveResult<S>, &SolveResult<S>) -> bool, ) -> SolveResult<S>
The best of a search’s result (self) and baselines – layouts a
simple deterministic fill produced for the same request – where beats
says whether its first argument is strictly better than its second.
A search can stop, on a short budget, at a layout the simple fill would have beaten; flooring it here means a search never returns less. A tie keeps the search’s layout. When a baseline wins, its placements are returned with the search’s provenance – strategy, generations, iterations, fitness history, stop reason – because the search did run.
Sourcepub fn deduplicate_unplaced(&mut self)
pub fn deduplicate_unplaced(&mut self)
Removes duplicate entries from the unplaced list. This is useful when multiple instances of the same geometry failed to place.
Sourcepub fn record_unplaced<G>(&mut self, geometries: &[G])where
G: Geometry,
pub fn record_unplaced<G>(&mut self, geometries: &[G])where
G: Geometry,
Sets unplaced from the placements: each geometry with a copy the
placements do not contain, once, in request order.
The layout is the one fact; what it leaves short follows from it, so a strategy that stops early (time limit, cancellation) cannot report a list that disagrees with what it placed.
Sourcepub fn placement_stats(&self) -> PlacementStats
pub fn placement_stats(&self) -> PlacementStats
Computes placement statistics.
Sourcepub fn utilization_percent(&self) -> String
pub fn utilization_percent(&self) -> String
Returns utilization as a percentage string.
Sourcepub fn merge(&mut self, other: SolveResult<S>, boundary_offset: usize)
pub fn merge(&mut self, other: SolveResult<S>, boundary_offset: usize)
Merges placements from another result (for multi-bin scenarios).
Sourcepub fn with_strip_stats(self, stats: Vec<StripStats>) -> SolveResult<S>
pub fn with_strip_stats(self, stats: Vec<StripStats>) -> SolveResult<S>
Sets strip statistics.
Sourcepub fn calculate_utilization(&mut self)
pub fn calculate_utilization(&mut self)
Calculates and sets utilization from strip stats. This is the accurate utilization based on actual material consumed.
Source§impl SolveResult<f64>
impl SolveResult<f64>
Sourcepub fn to_boundary_local(&mut self, extent: f64)
pub fn to_boundary_local(&mut self, extent: f64)
Rewrites placement x-coordinates from the global multi-strip frame
(sheets laid side-by-side: x ≈ boundary_index * extent) into the
per-boundary local frame, so each placement’s x is relative to the
origin of its own sheet (boundary_index selects the sheet).
solve_multi_strip emits global strip coordinates (the strip-packing
representation its benchmark callers rely on). Binding/wire consumers that
render per-sheet panels want sheet-local coordinates instead; this is the
single shared transform they apply at the response boundary.
extent is the boundary’s x-axis extent (b_max[0] - b_min[0]), identical
to the strip_width used during solving. After this call every placement’s
x lies in [0, extent) (modulo spacing/margin) within its sheet.
Trait Implementations§
Source§impl<S> Clone for SolveResult<S>where
S: Clone,
impl<S> Clone for SolveResult<S>where
S: Clone,
Source§fn clone(&self) -> SolveResult<S>
fn clone(&self) -> SolveResult<S>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<S> Debug for SolveResult<S>where
S: Debug,
impl<S> Debug for SolveResult<S>where
S: Debug,
Source§impl<S> Default for SolveResult<S>
impl<S> Default for SolveResult<S>
Source§fn default() -> SolveResult<S>
fn default() -> SolveResult<S>
Auto Trait Implementations§
impl<S> Freeze for SolveResult<S>
impl<S> RefUnwindSafe for SolveResult<S>
impl<S> Send for SolveResult<S>
impl<S> Sync for SolveResult<S>
impl<S> Unpin for SolveResult<S>
impl<S> UnsafeUnpin for SolveResult<S>
impl<S> UnwindSafe for SolveResult<S>
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<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.