Struct relearn::spaces::OptionSpace
source · [−]pub struct OptionSpace<S> {
pub inner: S,
}
Expand description
A space whose elements are either None
or Some(inner_elem)
.
The feature vectors are
[1, 0, ..., 0]
forNone
[0, inner_feature_vector(x)]
forSome(x)
.
Fields
inner: S
Implementations
sourceimpl<S> OptionSpace<S>
impl<S> OptionSpace<S>
Trait Implementations
sourceimpl<S: Clone> Clone for OptionSpace<S>
impl<S: Clone> Clone for OptionSpace<S>
sourcefn clone(&self) -> OptionSpace<S>
fn clone(&self) -> OptionSpace<S>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<S: Debug> Debug for OptionSpace<S>
impl<S: Debug> Debug for OptionSpace<S>
sourceimpl<S: Default> Default for OptionSpace<S>
impl<S: Default> Default for OptionSpace<S>
sourcefn default() -> OptionSpace<S>
fn default() -> OptionSpace<S>
Returns the “default value” for a type. Read more
sourceimpl<'de, S> Deserialize<'de> for OptionSpace<S> where
S: Deserialize<'de>,
impl<'de, S> Deserialize<'de> for OptionSpace<S> where
S: Deserialize<'de>,
sourcefn 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
sourceimpl<S: Display> Display for OptionSpace<S>
impl<S: Display> Display for OptionSpace<S>
sourceimpl<S> Distribution<<OptionSpace<S> as Space>::Element> for OptionSpace<S> where
S: Space + Distribution<S::Element>,
impl<S> Distribution<<OptionSpace<S> as Space>::Element> for OptionSpace<S> where
S: Space + Distribution<S::Element>,
sourcefn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> <Self as Space>::Element
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> <Self as Space>::Element
Generate a random value of T
, using rng
as the source of randomness.
sourcefn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T> where
R: Rng,
fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T> where
R: Rng,
Create an iterator that generates random values of T
, using rng
as
the source of randomness. Read more
sourceimpl<S: FeatureSpace> FeatureSpace for OptionSpace<S>
impl<S: FeatureSpace> FeatureSpace for OptionSpace<S>
Features are [0.0, features(x)..]
for Some(x)
and [1.0, 0.0, ..., 0.0]
for None
.
sourcefn num_features(&self) -> usize
fn num_features(&self) -> usize
Length of the encoded feature vectors.
sourcefn features_out<'a, F: Float>(
&self,
element: &Self::Element,
out: &'a mut [F],
zeroed: bool
) -> &'a mut [F]ⓘNotable traits for &[u8]impl Read for &[u8]impl Write for &mut [u8]
fn features_out<'a, F: Float>(
&self,
element: &Self::Element,
out: &'a mut [F],
zeroed: bool
) -> &'a mut [F]ⓘNotable traits for &[u8]impl Read for &[u8]impl Write for &mut [u8]
Encode the feature vector of an element into a mutable slice. Read more
sourcefn features<T>(&self, element: &Self::Element) -> T where
T: BuildFromArray1D,
<T::Array as NumArray1D>::Elem: Float,
fn features<T>(&self, element: &Self::Element) -> T where
T: BuildFromArray1D,
<T::Array as NumArray1D>::Elem: Float,
Encode the feature vector of an element into an array.
sourcefn batch_features_out<'a, I, A>(
&self,
elements: I,
out: &mut ArrayBase<A, Ix2>,
zeroed: bool
) where
I: IntoIterator<Item = &'a Self::Element>,
Self::Element: 'a,
A: DataMut,
A::Elem: Float,
fn batch_features_out<'a, I, A>(
&self,
elements: I,
out: &mut ArrayBase<A, Ix2>,
zeroed: bool
) where
I: IntoIterator<Item = &'a Self::Element>,
Self::Element: 'a,
A: DataMut,
A::Elem: Float,
Encode the feature vectors of multiple elements into rows of a two-dimensional array. Read more
sourcefn batch_features<'a, I, T>(&self, elements: I) -> T where
I: IntoIterator<Item = &'a Self::Element>,
I::IntoIter: ExactSizeIterator,
Self::Element: 'a,
T: BuildFromArray2D,
<T::Array as NumArray2D>::Elem: Float,
fn batch_features<'a, I, T>(&self, elements: I) -> T where
I: IntoIterator<Item = &'a Self::Element>,
I::IntoIter: ExactSizeIterator,
Self::Element: 'a,
T: BuildFromArray2D,
<T::Array as NumArray2D>::Elem: Float,
Encode the feature vectors of multiple elements as rows of a two-dimensional array.
sourceimpl<S: FiniteSpace> FiniteSpace for OptionSpace<S>
impl<S: FiniteSpace> FiniteSpace for OptionSpace<S>
sourceimpl<S: Hash> Hash for OptionSpace<S>
impl<S: Hash> Hash for OptionSpace<S>
sourceimpl<S: LogElementSpace> LogElementSpace for OptionSpace<S>
impl<S: LogElementSpace> LogElementSpace for OptionSpace<S>
sourcefn log_element<L: StatsLogger + ?Sized>(
&self,
name: &'static str,
element: &Self::Element,
logger: &mut L
) -> Result<(), LogError>
fn log_element<L: StatsLogger + ?Sized>(
&self,
name: &'static str,
element: &Self::Element,
logger: &mut L
) -> Result<(), LogError>
Log an element of the space
sourceimpl<S: Space> NonEmptySpace for OptionSpace<S>
impl<S: Space> NonEmptySpace for OptionSpace<S>
sourcefn some_element(&self) -> Self::Element
fn some_element(&self) -> Self::Element
An arbitrary deterministic element from the space.
sourceimpl<S: Ord> Ord for OptionSpace<S>
impl<S: Ord> Ord for OptionSpace<S>
sourcefn cmp(&self, other: &OptionSpace<S>) -> Ordering
fn cmp(&self, other: &OptionSpace<S>) -> Ordering
1.21.0 · sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl<S: PartialEq> PartialEq<OptionSpace<S>> for OptionSpace<S>
impl<S: PartialEq> PartialEq<OptionSpace<S>> for OptionSpace<S>
sourcefn eq(&self, other: &OptionSpace<S>) -> bool
fn eq(&self, other: &OptionSpace<S>) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &OptionSpace<S>) -> bool
fn ne(&self, other: &OptionSpace<S>) -> bool
This method tests for !=
.
sourceimpl<S: PartialOrd> PartialOrd<OptionSpace<S>> for OptionSpace<S>
impl<S: PartialOrd> PartialOrd<OptionSpace<S>> for OptionSpace<S>
sourcefn partial_cmp(&self, other: &OptionSpace<S>) -> Option<Ordering>
fn partial_cmp(&self, other: &OptionSpace<S>) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl<S> Serialize for OptionSpace<S> where
S: Serialize,
impl<S> Serialize for OptionSpace<S> where
S: Serialize,
sourceimpl<S: Space> Space for OptionSpace<S>
impl<S: Space> Space for OptionSpace<S>
sourceimpl<S: SubsetOrd> SubsetOrd for OptionSpace<S>
impl<S: SubsetOrd> SubsetOrd for OptionSpace<S>
sourcefn subset_cmp(&self, other: &Self) -> Option<Ordering>
fn subset_cmp(&self, other: &Self) -> Option<Ordering>
Compare using the subset relationship. This is a partial order.
sourcefn strict_subset_of(&self, other: &Self) -> bool
fn strict_subset_of(&self, other: &Self) -> bool
Check if this is a strict subset of other
.
sourcefn subset_of(&self, other: &Self) -> bool
fn subset_of(&self, other: &Self) -> bool
Check if this is a subset (strict or equal) of other
.
sourcefn strict_superset_of(&self, other: &Self) -> bool
fn strict_superset_of(&self, other: &Self) -> bool
Check if this is a strict superset of other
.
sourcefn superset_of(&self, other: &Self) -> bool
fn superset_of(&self, other: &Self) -> bool
Check if this is a superset (strict or equal) of other
.
impl<S: Copy> Copy for OptionSpace<S>
impl<S: Eq> Eq for OptionSpace<S>
impl<S> StructuralEq for OptionSpace<S>
impl<S> StructuralPartialEq for OptionSpace<S>
Auto Trait Implementations
impl<S> RefUnwindSafe for OptionSpace<S> where
S: RefUnwindSafe,
impl<S> Send for OptionSpace<S> where
S: Send,
impl<S> Sync for OptionSpace<S> where
S: Sync,
impl<S> Unpin for OptionSpace<S> where
S: Unpin,
impl<S> UnwindSafe for OptionSpace<S> where
S: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.