Skip to main content

Builder

Struct Builder 

Source
pub struct Builder { /* private fields */ }
Expand description

Fluent builder for Petri net construction.

Implementations§

Source§

impl Builder

Source

pub fn new() -> Self

Creates a new Builder.

Source

pub fn place(self, label: &str, initial: f64) -> Self

Adds a place with the given label and initial token count.

Source

pub fn place_with_capacity( self, label: &str, initial: f64, capacity: f64, ) -> Self

Adds a place with initial tokens and capacity limit.

Source

pub fn transition(self, label: &str) -> Self

Adds a transition with the given label.

Source

pub fn transition_with_role(self, label: &str, role: &str) -> Self

Adds a transition with a specific role.

Source

pub fn arc(self, source: &str, target: &str, weight: f64) -> Self

Adds an arc from source to target with the given weight.

Source

pub fn inhibitor_arc(self, source: &str, target: &str, weight: f64) -> Self

Adds an inhibitor arc from source to target.

Source

pub fn flow( self, from_place: &str, transition: &str, to_place: &str, weight: f64, ) -> Self

Adds bidirectional arcs for a flow pattern: place -> transition -> place.

Source

pub fn chain(self, initial_tokens: f64, elements: &[&str]) -> Self

Creates a sequential chain of places connected by transitions.

Elements must be odd length: place, trans, place, trans, place… The first place gets initial_tokens, all others get 0.

Source

pub fn sir(self, susceptible: f64, infected: f64, recovered: f64) -> Self

Creates a standard SIR epidemic model.

Source

pub fn done(self) -> PetriNet

Returns the completed Petri net.

Source

pub fn with_rates(self, default_rate: f64) -> (PetriNet, HashMap<String, f64>)

Returns the net and a rates map initialized to the given default rate.

Source

pub fn with_custom_rates( self, rates: HashMap<String, f64>, ) -> (PetriNet, HashMap<String, f64>)

Returns the net and allows setting custom rates.

Trait Implementations§

Source§

impl Default for Builder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.