Skip to content

Commit

Permalink
MultiwayQ property (#503)
Browse files Browse the repository at this point in the history
## Changes
* Adds a new `WolframModelEvolutionObject` property, `"MultiwayQ"`, which checks if any expressions were destroyed by multiple events.

## Examples
* Check that a particular system does not branch:
```wl
In[] := WolframModel[{{1, 2}} -> {{1, 3}, {3, 2}}, {{1, 1}}, 2, 
  "EventSelectionFunction" -> "MultiwaySpacelike"]["MultiwayQ"]
Out[] = False
```
  • Loading branch information
maxitg authored Nov 2, 2020
1 parent 64ef6e8 commit 8986200
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 0 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
###### [Symbols and Functions](/README.md#symbols-and-functions) > [WolframModel and WolframModelEvolutionObject](../WolframModelAndWolframModelEvolutionObject.md) > [Properties](../WolframModelAndWolframModelEvolutionObject.md#properties) >

# MultiwayQ

**`"MultiwayQ"`** checks if a given evolution contains multiway branching, i.e., there is an expression used in multiple events.

```wl
In[] := EchoFunction[#["ExpressionsEventsGraph"] &][
WolframModel[{{1, 2}, {2, 3}} -> {{1, 2}, {2, 3}, {3, 4}},
{{1, 2}, {2, 3}, {3, 4}},
1,
"EventSelectionFunction" -> "MultiwaySpacelike"]]["MultiwayQ"]
```

<img src="/Documentation/Images/MultiwayExpressionsEventsGraphEchoed.png" width="451">

```wl
Out[] = True
```

Note that even if [`"EventSelectionFunction"`](/Documentation/WolframModelAndWolframModelEvolutionObject/Options/EventSelectionFunction.md) is set to allow multiway branching, the system might still be singleway if no overlapping matches occurred:


```wl
In[] := EchoFunction[#["ExpressionsEventsGraph"] &][WolframModel[
{{1, 2}} -> {{1, 3}, {3, 2}}, {{1, 1}}, 2, "EventSelectionFunction" -> "MultiwaySpacelike"]]["MultiwayQ"]
```

<img src="/Documentation/Images/SinglewayExpressionsEventsGraphEchoed.png" width="415">

```wl
Out[] = False
```
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ Currently, it's equivalent to `<|"MaxEvents" -> 5000, "MaxVertices" -> 200|>`, s
- [Creator and Destroyer Events](Properties/CreatorAndDestroyerEvents.md)
- [Causal Graphs](Properties/CausalGraphs.md)
- [Expression Separations](Properties/ExpressionSeparations.md)
- [MultiwayQ](Properties/MultiwayQ.md)
- [Rule Indices for Events](Properties/RuleIndicesForEvents.md)
- [Edge and Event Generations](Properties/EdgeAndEventGenerations.md)
- [Termination Reason](Properties/TerminationReason.md)
Expand Down
8 changes: 8 additions & 0 deletions Kernel/WolframModelEvolutionObject.m
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
"EdgeDestroyerEventIndices" -> {0, 0},
"EdgeGenerationsList" -> {0, 0},
"ExpressionsSeparation" -> {2, 2},
"MultiwayQ" -> {0, 0},
"Properties" -> {0, 0}|>,
Association[# -> {0, 0} & /@ Keys[$accessorProperties]]];

Expand Down Expand Up @@ -920,6 +921,13 @@ connecting them if the same event is a creator and a destroyer for the same expr
If[Length[boundaryExpressions] =!= 0, "Branchlike", "Spacelike"]
]

propertyEvaluate[True, includeBoundaryEventsPattern][
obj : WolframModelEvolutionObject[_ ? evolutionDataQ],
caller_,
"MultiwayQ"] := ModuleScope[
Max[Length /@ propertyEvaluate[True, None][obj, caller, "EdgeDestroyerEventsIndices"]] > 1
]

(* Public properties call *)

$masterOptions = {
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ We have a [Discord server](https://discord.setreplace.org). If you would like to
- [Creator and Destroyer Events](Documentation/SymbolsAndFunctions/WolframModelAndWolframModelEvolutionObject/Properties/CreatorAndDestroyerEvents.md)
- [Causal Graphs](Documentation/SymbolsAndFunctions/WolframModelAndWolframModelEvolutionObject/Properties/CausalGraphs.md)
- [Expression Separations](Documentation/SymbolsAndFunctions/WolframModelAndWolframModelEvolutionObject/Properties/ExpressionSeparations.md)
- [MultiwayQ](Documentation/SymbolsAndFunctions/WolframModelAndWolframModelEvolutionObject/Properties/MultiwayQ.md)
- [Rule Indices for Events](Documentation/SymbolsAndFunctions/WolframModelAndWolframModelEvolutionObject/Properties/RuleIndicesForEvents.md)
- [Edge and Event Generations](Documentation/SymbolsAndFunctions/WolframModelAndWolframModelEvolutionObject/Properties/EdgeAndEventGenerations.md)
- [Termination Reason](Documentation/SymbolsAndFunctions/WolframModelAndWolframModelEvolutionObject/Properties/TerminationReason.md)
Expand Down
21 changes: 21 additions & 0 deletions Tests/WolframModelEvolutionObject.wlt
Original file line number Diff line number Diff line change
Expand Up @@ -1945,6 +1945,27 @@
Infinity,
"EventSelectionFunction" -> None]["ExpressionsSeparation", -2, -1],
"Spacelike"
],

(* MultiwayQ *)

VerificationTest[
WolframModel[{{1}} -> {{1}}, {{1}}, 0]["MultiwayQ"],
False
],

VerificationTest[
WolframModel[{{1, 2}, {2, 3}} -> {{1, 2}, {2, 3}, {3, 4}}, {{1, 2}, {2, 3}, {3, 4}}, 1]["MultiwayQ"],
False
],

VerificationTest[
WolframModel[{{1, 2}, {2, 3}} -> {{1, 2}, {2, 3}, {3, 4}},
{{1, 2}, {2, 3}, {3, 4}},
1,
"EventSelectionFunction" -> "MultiwaySpacelike"][
"MultiwayQ"],
True
]
}]
}]
Expand Down

0 comments on commit 8986200

Please sign in to comment.