@getriebe/petri
Inspect and fire Petri nets with explicit token bindings.
Source revision 49560371f6cd34d30383df5619df46969c594ae4.
export interface Arc { readonly place: PlaceId; readonly weight?: number;}FiringResult
Section titled “FiringResult”export type FiringResult = { readonly status: "fired"; readonly marking: Marking; readonly consumed: readonly PlaceTokens[]; readonly produced: readonly PlaceTokens[];} | { readonly status: "rejected"; readonly reason: "unknown-transition" | "disabled" | "invalid-binding" | "capacity";};Marking
Section titled “Marking”declare class Marking { constructor(owner: PetriNet, snapshot: MarkingSnapshot); get size(): number; get nextTokenId(): TokenId; tokens(place: PlaceId): readonly TokenId[]; count(place: PlaceId): number; snapshot(): MarkingSnapshot;}MarkingSnapshot
Section titled “MarkingSnapshot”export interface MarkingSnapshot { readonly nextTokenId: TokenId; readonly places: readonly PlaceTokens[];}maxLiveTokens
Section titled “maxLiveTokens”export declare const maxLiveTokens = 100000;NetDefinition
Section titled “NetDefinition”export interface NetDefinition { readonly places: readonly PlaceId[]; readonly transitions: readonly TransitionDefinition[];}PetriNet
Section titled “PetriNet”export declare class PetriNet { constructor(definition: NetDefinition); initialMarking(counts?: readonly PlaceCount[]): Marking; restoreMarking(snapshot: unknown): Marking; isEnabled(marking: Marking, id: TransitionId): boolean; enabledTransitions(marking: Marking): readonly TransitionId[]; fire(marking: Marking, id: TransitionId, binding?: readonly PlaceTokens[]): FiringResult; clearPlaces(marking: Marking, places: ReadonlySet<PlaceId>): Marking;}PlaceCount
Section titled “PlaceCount”export interface PlaceCount { readonly place: PlaceId; readonly count: number;}PlaceId
Section titled “PlaceId”export type PlaceId = string;PlaceTokens
Section titled “PlaceTokens”export interface PlaceTokens { readonly place: PlaceId; readonly tokens: readonly TokenId[];}TokenId
Section titled “TokenId”export type TokenId = number;TransitionDefinition
Section titled “TransitionDefinition”export interface TransitionDefinition { readonly id: TransitionId; readonly inputs: readonly Arc[]; readonly outputs: readonly Arc[];}TransitionId
Section titled “TransitionId”export type TransitionId = string;