ptnet_core/timed.rs
1/*!
2This module provides an extension to include timed transitions.
3
4To study performance and dependability issues of systems it is necessary to include a timing concept into the model.
5There are several possibilities to do this for a Petri net; however, the most common way is to associate a *firing
6delay* with each transition. This delay specifies the time that the transition has to be *enabled*, before it can
7actually fire. If the delay is a random distribution function, the resulting net class is called a *stochastic Petri
8net*. Different types of transitions can be distinguished depending on their associated delay, for instance *immediate
9transitions* (no delay), *exponential transitions* (delay is an exponential distribution), and *deterministic
10transitions* (delay is fixed).
11
12*/
13
14use crate::net::Transition;
15use crate::sim::{Duration, IMMEDIATE};
16
17// ------------------------------------------------------------------------------------------------
18// Public Types
19// ------------------------------------------------------------------------------------------------
20
21///
22/// This trait extends a basic transition with a duration value (in steps). When this transition
23/// fires the duration is retrieved and while any source tokens are immediately consumed, tokens
24/// are not transferred to the targets until the duration expires.
25///
26pub trait TimedTransition: Transition {
27 ///
28 /// Return the duration this transition takes to complete firing.
29 ///
30 fn duration(&self) -> Duration;
31}
32
33///
34/// This trait is an explicit version of the standard notion of an un-timed transition. It will
35/// always return a duration of zero.
36///
37pub trait ImmediateTransition: TimedTransition {
38 fn duration(&self) -> Duration {
39 IMMEDIATE
40 }
41}
42
43///
44/// The duration for this transition is calculated as a random value between the lower and upper
45/// bounds (inclusive).
46///
47pub trait RandomBoundedTransition: TimedTransition {
48 fn lower_bound(&self) -> Option<Duration>;
49 fn upper_bound(&self) -> Option<Duration>;
50}