1 unstable release

0.1.0 Aug 4, 2021

#1029 in Math

MIT/Apache

165KB
3.5K SLoC

PNETS TPN_

PNETS reduce is a library which reduce Petri nets according while keeping some properties on the network


This crate provides an api for creating reductions on Petri nets and integrating some of the reductions described in the paper Counting Petri net markings from reduction equations.

This crate provides an api for creating reductions on Petri nets and integrating some of the reductions described in the publication STTT.

This crate provides two modules:

The modifications module gathers the different modifications that can be made to a network while preserving certain properties.

The reducers module provides three features: Reduce, PlaceReduce and TransitionReduce which allow all reduction algorithms to have a common interface.

There are also generic reduction algorithms that make it easier to handle chaining and looping of reductions: IdentityReducer, LoopReducer, SmartReducer and ChainReducer.

This version of the library also provides reductions that apply to standard Petri nets within the reductions::standard module.

Usage

use pnets::standard::Net;
use pnets_shrunk::reducers::standard::SimpleChainReducer;

fn main() {
    // Load a standard Petri net from stdin
    let mut net = Net::from(pnets_tina::Parser::new(BufReader::new(io::stdin())).parse()?);
    
    // Application of the reduction
    let mut modifications = vec![];
    SimpleChainReducer::reduce(&mut net, &mut modifications);

    // Auto naming is needed to allow fill name for auto-created places
    net.auto_name();
    
    // Display modifications
    println!("{:?}", modifications);
    // Display new network on stdout
    ExporterBuilder::new(file)
        .build()
        .export(net)?;
}

Dependencies

~700KB
~11K SLoC