pub struct SPProblem { /* private fields */ }Expand description
Modifiable counterpart of SPInstance: items can be placed and removed, strip can be extended or fitted.
Implementations§
Source§impl SPProblem
impl SPProblem
Sourcepub fn new(instance: SPInstance) -> Result<Self>
pub fn new(instance: SPInstance) -> Result<Self>
Creates a problem, returning an error if its strip cannot form a container.
Sourcepub fn change_strip_width(&mut self, new_width: f32) -> Result<()>
pub fn change_strip_width(&mut self, new_width: f32) -> Result<()>
Modifies the width of the strip in the back, keeping the front fixed. Returns an error without changing the problem if the new container is invalid.
Sourcepub fn fit_strip(&mut self) -> Result<()>
pub fn fit_strip(&mut self) -> Result<()>
Shrinks the strip to the minimum width that fits all items. Returns an error if no items are placed.
Sourcepub fn place_item(&mut self, placement: SPPlacement) -> PItemKey
pub fn place_item(&mut self, placement: SPPlacement) -> PItemKey
Places an item according to the given SPPlacement in the problem.
Panics if the item’s demand is exhausted.
Sourcepub fn remove_item(&mut self, pkey: PItemKey) -> SPPlacement
pub fn remove_item(&mut self, pkey: PItemKey) -> SPPlacement
Removes a placed item from the strip. Returns the placement of the item.
Sourcepub fn save(&self) -> SPSolution
pub fn save(&self) -> SPSolution
Creates a snapshot of the current state of the problem as a SPSolution.
Sourcepub fn restore(&mut self, solution: &SPSolution)
pub fn restore(&mut self, solution: &SPSolution)
Restores the state of the problem to the given SPSolution.
pub fn instance(&self) -> &SPInstance
pub fn strip(&self) -> &Strip
pub fn layout(&self) -> &Layout
pub fn item_demand_qtys(&self) -> &[usize]
pub fn density(&self) -> f32
pub fn strip_width(&self) -> f32
pub fn n_placed_items(&self) -> usize
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SPProblem
impl RefUnwindSafe for SPProblem
impl Send for SPProblem
impl Sync for SPProblem
impl Unpin for SPProblem
impl UnsafeUnpin for SPProblem
impl UnwindSafe for SPProblem
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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