pm4py.analysis.generate_marking#

pm4py.analysis.generate_marking(net: PetriNet, place_or_dct_places: str | Place | Dict[str, int] | Dict[Place, int]) Marking[source]#

Generates a marking for a given Petri net based on specified places and token counts.

Parameters:
  • net (PetriNet) – The Petri net for which to generate the marking.

  • place_or_dct_places – Specifies the places and their token counts for the marking. It can be: - A single PetriNet.Place object, which will have one token. - A string representing the name of a place, which will have one token. - A dictionary mapping PetriNet.Place objects to their respective number of tokens. - A dictionary mapping place names (strings) to their respective number of tokens.

Returns:

The generated Marking object.

Return type:

Marking

import pm4py

net, im, fm = pm4py.read_pnml('model.pnml')
marking = pm4py.generate_marking(net, {'source': 2})