Crates.io | ptnet-elementary |
lib.rs | ptnet-elementary |
version | 0.1.2 |
source | src |
created_at | 2023-12-13 17:10:06.66479 |
updated_at | 2023-12-16 18:18:23.440271 |
description | Implementation of ptnet-core for Elementary nets (EN). |
homepage | |
repository | https://github.com/johnstonskj/rust-ptnets |
max_upload_size | |
id | 1068215 |
size | 41,746 |
This crate provides an implementation of the
ptnet-core
traits for Elementary net (EN) systems.
use ptnet_core::{
fmt::{print_net, NetMatrixFormatter},
net::Net,
sim::{Marking, Simulation},
trace::{MatrixTracer, TraceableSimulation},
};
use ptnet_elementary::{
Dot, ElementaryNet, ElementaryNetBuilder, ElementarySimulation, GraphvizNetFormatter,
SimpleArc, SimpleMarking, SimplePlace, SimpleTransition,
};
let mut net = ElementaryNet::default();
let p0 = net.add_place();
let p1 = net.add_place();
let p2 = net.add_place();
let t0 = net.add_transition();
let t1 = net.add_transition();
net.add_arc(p0, t0);
net.add_arc(t0, p1);
net.add_arc(p1, t1);
net.add_arc(t1, p2);
println!("-----");
let mut f = NetMatrixFormatter::default();
print_net(&net, &mut f).unwrap();
println!("-----");
let mut f = GraphvizNetFormatter::default();
print_net(&net, &mut f).unwrap();
println!("-----");
let mut im = SimpleMarking::from(&net);
im.mark(p0, Dot::from(true));
let tracer: MatrixTracer<
SimplePlace,
SimpleTransition,
SimpleArc,
ElementaryNet,
Dot,
SimpleMarking,
ElementarySimulation,
> = MatrixTracer::default();
let mut sim = ElementarySimulation::new(net.into(), im.clone());
sim.add_tracer(tracer.into());
while !sim.is_complete().unwrap_or_default() {
sim.step().unwrap();
}
Version 0.1.2
v0.1.2
and adjust to changes in core traits.NetFormatter
and MarkedNetFormatter
interfaces.ElementarySimulation
.Version 0.1.1
Version 0.1.0