Struct net_ensembles::spacial::SpacialEnsemble
source · [−]pub struct SpacialEnsemble<T, R> { /* private fields */ }
Expand description
Implements a special Ensemble
- You can generate a dot file which includes special information.
- NOTE You should use neato for that to work
- see module for literature
Implementations
sourceimpl<T, R> SpacialEnsemble<T, R>where
T: Node,
R: Rng,
impl<T, R> SpacialEnsemble<T, R>where
T: Node,
R: Rng,
sourcepub fn new(n: usize, rng: R, f: f64, alpha: f64) -> Self
pub fn new(n: usize, rng: R, f: f64, alpha: f64) -> Self
Generate a new Spacial ensemble with
n
nodesrng
as random number generatorf
- see paperalpha
- see paper
The specific model I implemented is described in
Timo Dewenter and Alexander K. Hartmann, “Large-deviation properties of resilience of power grids” New J. Phys. 17 (2015), DOI: 10.1088/1367-2630/17/1/015005
sourcepub fn distance(&self, i: usize, j: usize) -> Option<f64>
pub fn distance(&self, i: usize, j: usize) -> Option<f64>
Euclidean distance between two vertices
- Calculates the distance between the vertices
corresponding to the indices
i
andj
None
if any of the indices is out of bounds
sourcepub fn edge_probability(&self, i: usize, j: usize) -> Option<f64>
pub fn edge_probability(&self, i: usize, j: usize) -> Option<f64>
Calculates probability
- calculates the probability for an edge between the
vertices corresponding to the indices
i
andj
Of cause you can check if there is currently an edge, but this probability is the probability used when determining, if there should be an edge
Trait Implementations
sourceimpl<T, R> AsRef<GenericGraph<T, SpacialNodeContainer<T>>> for SpacialEnsemble<T, R>
impl<T, R> AsRef<GenericGraph<T, SpacialNodeContainer<T>>> for SpacialEnsemble<T, R>
sourcefn as_ref(&self) -> &SpacialGraph<T>
fn as_ref(&self) -> &SpacialGraph<T>
Converts this type into a shared reference of the (usually inferred) input type.
sourceimpl<T: Clone, R: Clone> Clone for SpacialEnsemble<T, R>
impl<T: Clone, R: Clone> Clone for SpacialEnsemble<T, R>
sourcefn clone(&self) -> SpacialEnsemble<T, R>
fn clone(&self) -> SpacialEnsemble<T, R>
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<T: Debug, R: Debug> Debug for SpacialEnsemble<T, R>
impl<T: Debug, R: Debug> Debug for SpacialEnsemble<T, R>
sourceimpl<'de, T, R> Deserialize<'de> for SpacialEnsemble<T, R>where
T: Deserialize<'de>,
R: Deserialize<'de>,
impl<'de, T, R> Deserialize<'de> for SpacialEnsemble<T, R>where
T: Deserialize<'de>,
R: 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<T, R> Dot for SpacialEnsemble<T, R>where
T: Node,
impl<T, R> Dot for SpacialEnsemble<T, R>where
T: Node,
You should use neato if you want the correct spacial placement of nodes
sourcefn dot_from_indices<F, W, S1, S2>(
&self,
writer: W,
dot_options: S1,
f: F
) -> Result<(), Error>where
S1: AsRef<str>,
S2: AsRef<str>,
W: Write,
F: FnMut(usize) -> S2,
fn dot_from_indices<F, W, S1, S2>(
&self,
writer: W,
dot_options: S1,
f: F
) -> Result<(), Error>where
S1: AsRef<str>,
S2: AsRef<str>,
W: Write,
F: FnMut(usize) -> S2,
f
to create labels depending on the indexdot_options
use dot_options!
macro and take a look at module dot_constants
sourcefn dot_string_from_indices<F, S1, S2>(&self, dot_options: S1, f: F) -> Stringwhere
S1: AsRef<str>,
S2: AsRef<str>,
F: FnMut(usize) -> S2,
fn dot_string_from_indices<F, S1, S2>(&self, dot_options: S1, f: F) -> Stringwhere
S1: AsRef<str>,
S2: AsRef<str>,
F: FnMut(usize) -> S2,
self.dot_from_indices
but returns String insteadsourcefn dot_with_indices<S, W>(&self, writer: W, dot_options: S) -> Result<(), Error>where
S: AsRef<str>,
W: Write,
fn dot_with_indices<S, W>(&self, writer: W, dot_options: S) -> Result<(), Error>where
S: AsRef<str>,
W: Write,
sourcefn dot_string_with_indices<S>(&self, dot_options: S) -> Stringwhere
S: AsRef<str>,
fn dot_string_with_indices<S>(&self, dot_options: S) -> Stringwhere
S: AsRef<str>,
self.dot_with_indices
but returns String insteadsourcefn dot<S, W>(&self, writer: W, dot_options: S) -> Result<(), Error>where
S: AsRef<str>,
W: Write,
fn dot<S, W>(&self, writer: W, dot_options: S) -> Result<(), Error>where
S: AsRef<str>,
W: Write,
sourcefn dot_string<S>(&self, dot_options: S) -> Stringwhere
S: AsRef<str>,
fn dot_string<S>(&self, dot_options: S) -> Stringwhere
S: AsRef<str>,
self.dot()
, but returns a String insteadsourceimpl<T, R> MarkovChain<SpacialStep, SpacialStep> for SpacialEnsemble<T, R>where
T: Node,
R: Rng,
impl<T, R> MarkovChain<SpacialStep, SpacialStep> for SpacialEnsemble<T, R>where
T: Node,
R: Rng,
sourcefn undo_step_quiet(&mut self, step: &SpacialStep)
fn undo_step_quiet(&mut self, step: &SpacialStep)
- panics if
step
is error, or cannot be undone The latter means, you are undoing the steps in the wrong order
sourcefn m_step(&mut self) -> SpacialStep
fn m_step(&mut self) -> SpacialStep
Markov step Read more
sourcefn m_steps_quiet(&mut self, count: usize)
fn m_steps_quiet(&mut self, count: usize)
Markov steps without return Read more
sourcefn undo_step(&mut self, step: &SpacialStep) -> SpacialStep
fn undo_step(&mut self, step: &SpacialStep) -> SpacialStep
undo_steps
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<T, R> Serialize for SpacialEnsemble<T, R>where
T: Serialize,
R: Serialize,
impl<T, R> Serialize for SpacialEnsemble<T, R>where
T: Serialize,
R: Serialize,
sourceimpl<T, R> SimpleSample for SpacialEnsemble<T, R>where
T: Node + SerdeStateConform,
R: Rng,
impl<T, R> SimpleSample for SpacialEnsemble<T, R>where
T: Node + SerdeStateConform,
R: Rng,
sourcefn randomize(&mut self)
fn randomize(&mut self)
Randomizes the edges according to Er probabilities
- this is used by
ErEnsembleC::new
to create the initial topology - you can use this for sampling the ensemble
- runs in
O(vertices * vertices)
Auto Trait Implementations
impl<T, R> RefUnwindSafe for SpacialEnsemble<T, R>where
R: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, R> Send for SpacialEnsemble<T, R>where
R: Send,
T: Send,
impl<T, R> Sync for SpacialEnsemble<T, R>where
R: Sync,
T: Sync,
impl<T, R> Unpin for SpacialEnsemble<T, R>where
R: Unpin,
T: Unpin,
impl<T, R> UnwindSafe for SpacialEnsemble<T, R>where
R: UnwindSafe,
T: UnwindSafe,
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