pnets::timed

Struct Net

Source
pub struct Net {
    pub name: String,
    pub transitions: IndexVec<TransitionId, Transition>,
    pub places: IndexVec<PlaceId, Place>,
    /* private fields */
}
Expand description

Timed Petri net, with produce, consume, condition and inhibitors arcs

This structure is indexed with PlaceId and TransitionId to allow easy access to places and transitions.

As this kind of network is a superset of standard Petri net, we can create one from standard Petri net without loosing any informations.

Fields§

§name: String

Name of this network

§transitions: IndexVec<TransitionId, Transition>

Transitions of the network

§places: IndexVec<PlaceId, Place>

Places of the network

Implementations§

Source§

impl Net

Source

pub fn create_place(&mut self) -> PlaceId

Create a place with automatic name

Source

pub fn create_transition(&mut self) -> TransitionId

Create a transition with an empty name

Source

pub fn get_name_by_index(&self, index: &NodeId) -> Option<String>

Get node name with its id

Source

pub fn get_index_by_name(&self, name: &str) -> Option<NodeId>

Get node id with its name

Source

pub fn rename_node(&mut self, id: NodeId, name: &str) -> Result<(), NetError>

Rename node

Source

pub fn add_arc(&mut self, arc: Kind) -> Result<(), Box<dyn Error>>

Add an arc in the network. This kind of network support only arc::Kind::Consume, arc::Kind::Produce, arc::Kind::Inhibitor and arc::Kind::Test arcs.

§Errors

Return NetError::UnsupportedArc when trying to add a kind of arc which is not supported

Source

pub fn delete_place(&mut self, place: PlaceId)

Disconnect a place in the network

The place is not really deleted to avoid memory relocation and extra information about this place such as name can be useful later.

Source

pub fn delete_transition(&mut self, transition: TransitionId)

Disconnect a transition in the network

The transition is not really deleted to avoid memory relocation and extra information about this transitions such as name can be useful later.

Source

pub fn add_priority(&mut self, tr_index: TransitionId, over: TransitionId)

Add a priority relation in the network

Source

pub fn update_priorities(&mut self) -> Result<(), Box<dyn Error>>

Update all priorities to make a transitive closure

§Errors

NetError::CyclicPriorities is returned if there is a cyclic priority in the network

Trait Implementations§

Source§

impl Debug for Net

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Net

Source§

fn default() -> Net

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

impl From<&Net> for Net

Source§

fn from(standard: &Net) -> Self

Converts to this type from the input type.
Source§

impl From<Net> for Net

Source§

fn from(timed: Net) -> Self

Converts to this type from the input type.
Source§

impl Index<PlaceId> for Net

Source§

type Output = Place

The returned type after indexing.
Source§

fn index(&self, index: PlaceId) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl Index<TransitionId> for Net

Source§

type Output = Transition

The returned type after indexing.
Source§

fn index(&self, index: TransitionId) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl IndexMut<PlaceId> for Net

Source§

fn index_mut(&mut self, index: PlaceId) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl IndexMut<TransitionId> for Net

Source§

fn index_mut(&mut self, index: TransitionId) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more

Auto Trait Implementations§

§

impl Freeze for Net

§

impl !RefUnwindSafe for Net

§

impl Send for Net

§

impl Sync for Net

§

impl !Unpin for Net

§

impl !UnwindSafe for Net

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.