pub struct Counter {
pub operation: Operation,
pub dist: Option<Dist>,
pub copy: bool,
}
Expand description
A specification of how one of a Machine
’s counters should be updated
when transitioning to a State
. Consists of an
Operation
to be applied to the counter with one of three values: by
default, the value 1, unless a distribution is provided or the copy flag is
set to true. If the copy flag is set to true, the counter will be updated
with the value of the other counter prior to transitioning to the state.
If a distribution is provided, the counter will be updated with a value
sampled from the distribution.
Fields§
§operation: Operation
The operation to apply to the counter upon a state transition. If the distribution is not set and copy is false, the counter will be updated by 1.
dist: Option<Dist>
If set, sample the value to update the counter with from a distribution.
copy: bool
If set, the counter will be updated by the other counter’s value prior
to transitioning to the state. Supersedes the dist
field.
Implementations§
Source§impl Counter
impl Counter
Sourcepub fn new(operation: Operation) -> Self
pub fn new(operation: Operation) -> Self
Create a new counter with an operation that modifies the counter with value 1.
Sourcepub fn new_dist(operation: Operation, dist: Dist) -> Self
pub fn new_dist(operation: Operation, dist: Dist) -> Self
Create a new counter with an operation and a distribution to sample the value from.
Sourcepub fn new_copy(operation: Operation) -> Self
pub fn new_copy(operation: Operation) -> Self
Create a new counter with an operation that copies the value of the other counter prior to transitioning to the state.
Sourcepub fn sample_value<R: RngCore>(&self, rng: &mut R) -> u64
pub fn sample_value<R: RngCore>(&self, rng: &mut R) -> u64
Sample a value to update the counter with.