pykappa.mixture

Manages collections of agents.

class pykappa.mixture.Mixture(patterns=None, track_components=False)[source]

A collection of agents and their connections.

Optionally tracks connected components.

Parameters:
  • patterns (Iterable[Pattern] | None)

  • track_components (bool)

classmethod from_kappa(patterns)[source]

Create a mixture from Kappa pattern strings and counts.

Parameters:

patterns (dict[str, int]) – Dictionary mapping pattern strings to copy counts.

Return type:

Self

property agents: IndexedSetView[Agent]

The agents in the mixture.

property kappa_str: str

The mixture in Kappa format with %init declarations.

property kappa_str_with_agent_ids: str

1` per component.

Type:

Kappa representation with IDs and one `%init

property component_tracking: bool

Whether connected components are being tracked.

property components: IndexedSetView[Component]
embeddings(component)[source]

Get embeddings of a tracked component (not accounting for symmetries).

Raises:

KeyError – If component is not being tracked.

Parameters:

component (Component)

Return type:

IndexedSetView[Embedding]

embeddings_in_component(match_pattern, mixture_component)[source]

Get embeddings of a pattern within a specific component.

Parameters:
Return type:

IndexedSetView[Embedding]