Skip to content

Latest commit

 

History

History
83 lines (68 loc) · 4.44 KB

File metadata and controls

83 lines (68 loc) · 4.44 KB

Generators

Generators are functions that create Multihistory objects. They take rules for a computational system and additional parameters specifying how to perform the evaluation.

In SetReplace, we split the states of computational systems into components which we call tokens. Rewrites (which we call events) replace some of these tokens with others. SetReplace can evaluate multiple branches of nondeterministic systems simultaneously. That is done by applying different events to the same tokens and keeping events and tokens instead of states in Multihistory objects. We can reconstruct the states from that information afterward.

There are parameters that control how this evaluation is done. Some of them control which events to select. Other parameters might control how to deduplicate identical tokens, etc. Different generators correspond to different settings of parameters. Additional parameters can be specified with a syntax similar to options.

Note that if the system does not terminate, it is necessary to specify some parameters, such as MaxEvents or MaxGeneration.

For example, GenerateSingleHistory corresponds to MaxDestroyerEvents -> 1 and thus does not produce nondeterministic branching:

In[] := #["ExpressionsEventsGraph", VertexLabels -> Placed[Automatic, After]] & @
  SetReplaceTypeConvert[WolframModelEvolutionObject] @
    GenerateSingleHistory[MultisetSubstitutionSystem[{a_, b_} /; a < b :> {a + b}]] @ {1, 2, 3, 4}

Out[] = Graph[... {1, 2} -> {3 (* gen 1 *)}, {3 (* init *), 4} -> {7}, {3 (* gen 1 *), 7} -> {10} ...]

We can also use a more general GenerateMultihistory and specify MaxDestroyerEvents manually.

In[] := #["ExpressionsEventsGraph", VertexLabels -> Placed[Automatic, After]] & @
  SetReplaceTypeConvert[WolframModelEvolutionObject] @
    GenerateMultihistory[
      MultisetSubstitutionSystem[{a_, b_} /; a < b :> {a + b}], MaxDestroyerEvents -> 2] @ {1, 2, 3, 4}

Out[] = Graph[...
{1, 2} -> {3 (* gen 1 *)},
{1, 3 (* init *)} -> {4 (* gen 1 *)},
{2, 3 (* init *)} -> {5},
{3 (* gen 1 *), 4 (* init *)} -> {7},
{4 (* init *), 5} -> {9}
...]

The same generators support multiple systems. In addition to MultisetSubstitutionSystem, other examples include HypergraphSubstitutionSystem, StringSubstitutionSystem, etc. Many of these systems have shared parameters.

All generators take the form

Generator[System[rules], parameters...] @ init

parameters can be specified either as a Sequence of Rules, a List of Rules or an Association. Keys supported in such Rules depend on the system and can be looked up with SetReplaceSystemParameters.