pub struct DiscreteEncoding {
pub depth: usize,
pub layer_templates: Vec<usize>,
pub gate_choices: Vec<Vec<usize>>,
pub entanglement_choices: Vec<usize>,
}Expand description
Discrete architecture encoding as a sequence of choices.
Fields§
§depth: usizeNumber of layers (depth choice)
layer_templates: Vec<usize>Template choice for each layer
gate_choices: Vec<Vec<usize>>Gate choices for customizable positions
entanglement_choices: Vec<usize>Entanglement pattern choices per layer
Implementations§
Source§impl DiscreteEncoding
impl DiscreteEncoding
Sourcepub fn new(
depth: usize,
layer_templates: Vec<usize>,
gate_choices: Vec<Vec<usize>>,
entanglement_choices: Vec<usize>,
) -> Self
pub fn new( depth: usize, layer_templates: Vec<usize>, gate_choices: Vec<Vec<usize>>, entanglement_choices: Vec<usize>, ) -> Self
Creates a new discrete encoding.
Sourcepub fn random<R: Rng>(space: &SearchSpace, rng: &mut R) -> Self
pub fn random<R: Rng>(space: &SearchSpace, rng: &mut R) -> Self
Creates a random encoding for the given search space.
Sourcepub fn validate(&self, space: &SearchSpace) -> Result<()>
pub fn validate(&self, space: &SearchSpace) -> Result<()>
Validates the encoding against a search space.
Sourcepub fn to_flat_vector(&self, space: &SearchSpace) -> Vec<usize>
pub fn to_flat_vector(&self, space: &SearchSpace) -> Vec<usize>
Converts to a flat vector representation.
Sourcepub fn from_flat_vector(flat: &[usize], space: &SearchSpace) -> Result<Self>
pub fn from_flat_vector(flat: &[usize], space: &SearchSpace) -> Result<Self>
Creates an encoding from a flat vector.
Sourcepub fn expected_flat_size(space: &SearchSpace) -> usize
pub fn expected_flat_size(space: &SearchSpace) -> usize
Returns the expected size of a flat vector for this search space.
Trait Implementations§
Source§impl Clone for DiscreteEncoding
impl Clone for DiscreteEncoding
Source§fn clone(&self) -> DiscreteEncoding
fn clone(&self) -> DiscreteEncoding
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for DiscreteEncoding
impl Debug for DiscreteEncoding
Source§impl<'de> Deserialize<'de> for DiscreteEncoding
impl<'de> Deserialize<'de> for DiscreteEncoding
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for DiscreteEncoding
impl PartialEq for DiscreteEncoding
Source§impl Serialize for DiscreteEncoding
impl Serialize for DiscreteEncoding
impl StructuralPartialEq for DiscreteEncoding
Auto Trait Implementations§
impl Freeze for DiscreteEncoding
impl RefUnwindSafe for DiscreteEncoding
impl Send for DiscreteEncoding
impl Sync for DiscreteEncoding
impl Unpin for DiscreteEncoding
impl UnwindSafe for DiscreteEncoding
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