pub struct PermutationSolution {
pub sequence: Vec<usize>,
pub rotations: Vec<usize>,
pub rotation_counts: Arc<[usize]>,
pub mirrors: Vec<bool>,
/* private fields */
}Expand description
Permutation-based solution for SA.
Fields§
§sequence: Vec<usize>The permutation (indices).
rotations: Vec<usize>Rotation/orientation index per item (by item, not by sequence position — a reorder moves items, not their rotations).
rotation_counts: Arc<[usize]>How many rotation/orientation options each item has: rotations[i]
is always below rotation_counts[i].
mirrors: Vec<bool>Mirror flag per item (allow_flip support, 2D nesting only — see
NeighborhoodOperator::MirrorFlip).
Implementations§
Source§impl PermutationSolution
impl PermutationSolution
Sourcepub fn new(rotation_counts: impl Into<Arc<[usize]>>) -> Self
pub fn new(rotation_counts: impl Into<Arc<[usize]>>) -> Self
The identity order, every item at its first rotation; one item per
entry of rotation_counts (each item’s number of options).
Sourcepub fn random<R: Rng>(
rotation_counts: impl Into<Arc<[usize]>>,
rng: &mut R,
) -> Self
pub fn random<R: Rng>( rotation_counts: impl Into<Arc<[usize]>>, rng: &mut R, ) -> Self
A random order, each item at a rotation drawn uniformly from its own options.
Sourcepub fn apply_swap<R: Rng>(&self, rng: &mut R) -> Self
pub fn apply_swap<R: Rng>(&self, rng: &mut R) -> Self
Applies swap operator: swaps two elements in sequence.
Sourcepub fn apply_relocate<R: Rng>(&self, rng: &mut R) -> Self
pub fn apply_relocate<R: Rng>(&self, rng: &mut R) -> Self
Applies relocate operator: moves an element to a new position.
Sourcepub fn apply_inversion<R: Rng>(&self, rng: &mut R) -> Self
pub fn apply_inversion<R: Rng>(&self, rng: &mut R) -> Self
Applies inversion operator: reverses a segment.
Sourcepub fn apply_rotation<R: Rng>(&self, rng: &mut R) -> Self
pub fn apply_rotation<R: Rng>(&self, rng: &mut R) -> Self
Applies rotation operator: moves one item that has more than one option to another of its options, drawn uniformly. An item with one option is never chosen, so the move always changes the solution.
Sourcepub fn apply_mirror_flip<R: Rng>(&self, rng: &mut R) -> Self
pub fn apply_mirror_flip<R: Rng>(&self, rng: &mut R) -> Self
Applies mirror-flip operator: flips one element’s mirror bit
(allow_flip support). Same shape as apply_rotation — unconditional
on the gene, the consuming problem masks it against its own
per-item mirror-eligibility (e.g. Geometry2D::allow_flip()).
Sourcepub fn apply_chain<R: Rng>(&self, rng: &mut R) -> Self
pub fn apply_chain<R: Rng>(&self, rng: &mut R) -> Self
Applies chain operator: 3-opt style move.
Trait Implementations§
Source§impl Clone for PermutationSolution
impl Clone for PermutationSolution
Source§impl Debug for PermutationSolution
impl Debug for PermutationSolution
Source§impl SaSolution for PermutationSolution
impl SaSolution for PermutationSolution
Auto Trait Implementations§
impl Freeze for PermutationSolution
impl RefUnwindSafe for PermutationSolution
impl Send for PermutationSolution
impl Sync for PermutationSolution
impl Unpin for PermutationSolution
impl UnsafeUnpin for PermutationSolution
impl UnwindSafe for PermutationSolution
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.