Enum net_ensembles::sw::SwChangeState
source · [−]pub enum SwChangeState {
InvalidAdjecency,
BlockedByExistingEdge,
Nothing,
Rewire(usize, usize, usize),
Reset(usize, usize, usize),
GError(GraphErrors),
}
Expand description
Returned by markov steps
- information about the performed step and possible errors
Variants
InvalidAdjecency
ERROR adjecency list invalid?
BlockedByExistingEdge
Can not add edge twice
Nothing
Nothing happend
Rewire(usize, usize, usize)
old edge: (Rewire.0, Rewire.1), new edge (Rewire.0, Rewire.2)
Reset(usize, usize, usize)
old edge: (Reset.0, Reset.1), new edge (Reset.0, Reset.2)
GError(GraphErrors)
A GraphError occurred
Implementations
sourceimpl SwChangeState
impl SwChangeState
sourcepub fn is_nothing(&self) -> bool
pub fn is_nothing(&self) -> bool
checks if self is Nothing
variant
sourcepub fn is_nothing_or_blocked(&self) -> bool
pub fn is_nothing_or_blocked(&self) -> bool
checks if self is Nothing
or BlockedByExistingEdge
sourcepub fn not_nothing_or_blocked(&self) -> bool
pub fn not_nothing_or_blocked(&self) -> bool
result is equal to !self.is_nothing_or_blocked()
sourcepub fn is_valid(&self) -> bool
pub fn is_valid(&self) -> bool
valid states:
SwChangeState::Rewire(..)
SwChangeState::Reset(..)
SwChangeState::Nothing
SwChangeState::BlockedByExistingEdge
invalid states:
SwChangeState::InvalidAdjecency
SwChangeState::GError(..)
Trait Implementations
sourceimpl Clone for SwChangeState
impl Clone for SwChangeState
sourcefn clone(&self) -> SwChangeState
fn clone(&self) -> SwChangeState
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 moresourceimpl Debug for SwChangeState
impl Debug for SwChangeState
sourceimpl<'de> Deserialize<'de> for SwChangeState
impl<'de> Deserialize<'de> for SwChangeState
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<T, R> MarkovChain<SwChangeState, SwChangeState> for SwEnsemble<T, R>where
T: Node + SerdeStateConform,
R: Rng,
impl<T, R> MarkovChain<SwChangeState, SwChangeState> for SwEnsemble<T, R>where
T: Node + SerdeStateConform,
R: Rng,
sourcefn m_step(&mut self) -> SwChangeState
fn m_step(&mut self) -> SwChangeState
Markov step
- use this to perform a markov step
- keep in mind, that it is not unlikely for a step to do
Nothing
as it works by drawing an edge and then reseting it withr_prob
, else the edge is rewired - result
SwChangeState
can be used to undo the step withself.undo_step(result)
- result should never be
InvalidAdjecency
orGError
if used on a valid graph
sourcefn undo_step(&mut self, step: &SwChangeState) -> SwChangeState
fn undo_step(&mut self, step: &SwChangeState) -> SwChangeState
Undo a markov step
- rewires edge to old state
- Note: cannot undo
InvalidAdjecency
orGError
, will just returnInvalidAdjecency
orGError
respectively - returns result of rewire
Important:
Restored graph is the same as before the random step except the order of nodes in the adjacency list might be shuffled!
sourcefn undo_step_quiet(&mut self, step: &SwChangeState)
fn undo_step_quiet(&mut self, step: &SwChangeState)
Undo a Monte Carlo step
- rewires edge to old state
- panics if you try to undo
InvalidAdjecency
orGError
- panics if rewire result (
SwChangeState
) is invalid (i.e.!result.is_valid()
)
Important:
Restored graph is the same as before the random step except the order of nodes in the adjacency list might be shuffled!
sourcefn m_steps_quiet(&mut self, count: usize)
fn m_steps_quiet(&mut self, count: usize)
Markov steps without return Read more
sourcefn m_step_acc<Acc, AccFn>(&mut self, acc: &mut Acc, acc_fn: AccFn) -> Swhere
AccFn: FnMut(&Self, &S, &mut Acc),
fn m_step_acc<Acc, AccFn>(&mut self, acc: &mut Acc, acc_fn: AccFn) -> Swhere
AccFn: FnMut(&Self, &S, &mut Acc),
Accumulating markov step Read more
sourcefn m_steps_acc<Acc, AccFn>(
&mut self,
count: usize,
steps: &mut Vec<S, Global>,
acc: &mut Acc,
acc_fn: AccFn
)where
AccFn: FnMut(&Self, &S, &mut Acc),
fn m_steps_acc<Acc, AccFn>(
&mut self,
count: usize,
steps: &mut Vec<S, Global>,
acc: &mut Acc,
acc_fn: AccFn
)where
AccFn: FnMut(&Self, &S, &mut Acc),
Accumulating markov steps Read more
sourcefn m_steps_acc_quiet<Acc, AccFn>(
&mut self,
count: usize,
acc: &mut Acc,
acc_fn: AccFn
)where
AccFn: FnMut(&Self, &S, &mut Acc),
fn m_steps_acc_quiet<Acc, AccFn>(
&mut self,
count: usize,
acc: &mut Acc,
acc_fn: AccFn
)where
AccFn: FnMut(&Self, &S, &mut Acc),
Accumulating markov steps Read more
sourcefn undo_steps_quiet(&mut self, steps: &[S])
fn undo_steps_quiet(&mut self, steps: &[S])
Undo markov steps Read more
sourcefn steps_accepted(&mut self, _steps: &[S])
fn steps_accepted(&mut self, _steps: &[S])
Function called whenever the steps are accepted. Read more
sourcefn steps_rejected(&mut self, _steps: &[S])
fn steps_rejected(&mut self, _steps: &[S])
Function called whenever the steps are rejected. Read more
sourceimpl Serialize for SwChangeState
impl Serialize for SwChangeState
impl Copy for SwChangeState
Auto Trait Implementations
impl RefUnwindSafe for SwChangeState
impl Send for SwChangeState
impl Sync for SwChangeState
impl Unpin for SwChangeState
impl UnwindSafe for SwChangeState
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
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
impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
fn cast_trunc(self) -> T
fn cast_trunc(self) -> T
Cast to integer, truncating Read more
fn cast_nearest(self) -> T
fn cast_nearest(self) -> T
Cast to the nearest integer Read more
fn cast_floor(self) -> T
fn cast_floor(self) -> T
Cast the floor to an integer Read more
fn try_cast_trunc(self) -> Result<T, Error>
fn try_cast_trunc(self) -> Result<T, Error>
Try converting to integer with truncation Read more
fn try_cast_nearest(self) -> Result<T, Error>
fn try_cast_nearest(self) -> Result<T, Error>
Try converting to the nearest integer Read more
fn try_cast_floor(self) -> Result<T, Error>
fn try_cast_floor(self) -> Result<T, Error>
Try converting the floor to an integer Read more
fn try_cast_ceil(self) -> Result<T, Error>
fn try_cast_ceil(self) -> Result<T, Error>
Try convert the ceiling to an integer Read more