-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy patheventDeduplication.wlt
More file actions
125 lines (116 loc) · 5.73 KB
/
Copy patheventDeduplication.wlt
File metadata and controls
125 lines (116 loc) · 5.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<|
"eventDeduplication" -> <|
"init" -> (
Attributes[Global`testUnevaluated] = {HoldAll};
Global`testUnevaluated[args___] := SetReplace`PackageScope`testUnevaluated[VerificationTest, args];
),
"tests" -> {
(* No deduplication is the default *)
VerificationTest[
Options[WolframModel, "EventDeduplication"],
{"EventDeduplication" -> None}
],
(* Deduplication requires Method -> "LowLevel" *)
testUnevaluated[
WolframModel[{1 -> 2, 1 -> 3}, {1}, "EventDeduplication" -> "SameInputSetIsomorphicOutputs", Method -> #1],
#2
] & @@@ {{Automatic, WolframModel::symbNotImplemented}, {"Symbolic", WolframModel::symbOrdering}},
(* Non-symmetric case *)
VerificationTest[
WolframModel[{{1, 2}, {1, 3}} -> {{2, 3}},
{{1, 2}, {1, 3}},
1,
"EventSelectionFunction" -> "MultiwaySpacelike",
"EventDeduplication" -> "SameInputSetIsomorphicOutputs"],
WolframModel[{{1, 2}, {1, 3}} -> {{2, 3}}, {{1, 2}, {1, 3}}, 1, "EventSelectionFunction" -> "MultiwaySpacelike"]
],
(* Symmetric case *)
VerificationTest[
WolframModel[{{1, 2}, {1, 3}} -> {{2, 3}, {3, 2}},
{{1, 2}, {1, 3}},
1,
"EventSelectionFunction" -> "MultiwaySpacelike",
"EventDeduplication" -> "SameInputSetIsomorphicOutputs"]["EventsList"],
{{1, {1, 2} -> {3, 4}}}
],
(* System that becomes non-overlapping *)
VerificationTest[
WolframModel[{{1, 2}, {2, 1}} -> {{1, 3}, {3, 1}, {3, 2}, {2, 3}},
{{1, 2}, {2, 1}},
3,
"EventSelectionFunction" -> "MultiwaySpacelike",
"EventDeduplication" -> #1]["EventsCount"],
#2
] & @@@ {{None, 42}, {"SameInputSetIsomorphicOutputs", 7}},
VerificationTest[
WolframModel[{{1, 2}, {2, 1}} -> {{1, 3}, {3, 1}, {3, 2}, {2, 3}},
{{1, 2}, {2, 1}},
3,
"EventSelectionFunction" -> "MultiwaySpacelike",
"EventDeduplication" -> "SameInputSetIsomorphicOutputs"]["FinalState"],
{{1, 6}, {6, 1}, {6, 4}, {4, 6}, {4, 7}, {7, 4}, {7, 3}, {3, 7}, {3, 8}, {8, 3}, {8, 5}, {5, 8}, {5, 9}, {9, 5},
{9, 2}, {2, 9}}
],
(* Neat examples *)
VerificationTest[
WolframModel[{{x, y}, {x, z}} -> {{x, y}, {x, w}, {y, w}, {z, w}},
{{0, 0}, {0, 0}},
3,
"EventSelectionFunction" -> "MultiwaySpacelike",
"EventDeduplication" -> None]["EventsCount"] >
WolframModel[{{x, y}, {x, z}} -> {{x, y}, {x, w}, {y, w}, {z, w}},
{{0, 0}, {0, 0}},
3,
"EventSelectionFunction" -> "MultiwaySpacelike",
"EventDeduplication" -> "SameInputSetIsomorphicOutputs"]["EventsCount"]
],
(* Tests for correct isomorphism *)
VerificationTest[
WolframModel[#1,
#2,
#3,
"EventSelectionFunction" -> "MultiwaySpacelike",
"EventDeduplication" -> "SameInputSetIsomorphicOutputs"]["EventsCount"],
#4
] & @@@ {
(* Symmetric case *)
{{{1, 2}, {1, 3}} -> {{2, 3}, {3, 2}}, {{1, 2}, {1, 3}}, 1, 1},
(* Nontrivial isomorphism *)
{{{1, 2}, {1, 3}} -> {{2, 4}, {4, 5}, {5, 3}, {3, 6}, {6, 2}}, {{1, 2}, {1, 3}}, 1, 2},
{{{1, 2}, {1, 3}} -> {{2, 4}, {4, 3}, {3, 5}, {5, 2}}, {{1, 2}, {1, 3}}, 1, 1},
(* Different size subgraph-isomorphic outputs *)
{{{{1}} -> {{1, 2}}, {{1}} -> {{1, 2}, {1, 2}}}, {{1}}, 1, 2},
{{{{1}} -> {{1, 2}, {1, 2}}, {{1}} -> {{1, 2}}}, {{1}}, 1, 2},
(* Empty output *)
{{{1}, {1}} -> {}, {{1}, {1}}, 1, 1},
{{{1}, {1}} -> {}, {{1}, {1}, {1}}, 1, 3},
{{{{1}, {1}} -> {}, {{1}, {1}} -> {}}, {{1}, {1}, {1}}, 1, 3},
{{{{1}, {1}} -> {}, {{1}, {1}, {1}} -> {}}, {{1}, {1}, {1}}, 1, 4},
(* Neat examples *)
{{{1}, {1}} -> {{1}, {1}}, {{1}, {1}, {1}}, 2, 12},
{{{0, 1}, {0, 6}} -> {{1, 4}, {2, 3}, {2, 4}, {3, 4}, {3, 5}, {4, 5}, {6, 4}}, {{0, 1}, {0, 6}}, 1, 1},
{{{0, 1}, {0, 6}} -> {{1, 4}, {2, 3}, {2, 4}, {3, 4}, {3, 5}, {4, 5}, {4, 6}}, {{0, 1}, {0, 6}}, 1, 2},
(* Pattern rules *)
{<|"PatternRules" -> {{0, a_}, {0, b_}} :> Module[{c, d}, {{a, c}, {b, d}}]|>, {{0, 1}, {0, 2}}, 1, 1},
{<|"PatternRules" -> {{0, a_}, {0, b_}} :> {{a, 1}, {b, 2}}|>, {{0, 1}, {0, 2}}, 1, 2},
{<|"PatternRules" -> {{0, a_}, {0, b_}} :> {{a, 3}, {b, 4}}|>, {{0, 1}, {0, 2}}, 1, 2},
{<|"PatternRules" -> {{0, a_}, {0, b_}} :> Module[{c, d}, {{a, 1}, {b, 2}}]|>, {{0, 1}, {0, 2}}, 1, 2}
},
(* Correct weights in random evolution *)
VerificationTest[
Count[Table[First[WolframModel[{{{1}, {1}, {1}, {1}} -> {}, {{1}} -> {}},
{{1}, {1}, {1}, {1}},
<|"MaxEvents" -> 1|>,
"EventOrderingFunction" -> {}]["AllEventsRuleIndices"]], 1000], 2] < 200
],
VerificationTest[
Count[Table[First[WolframModel[{{{1}, {1}, {1}, {1}} -> {}, {{1}} -> {}},
{{1}, {1}, {1}, {1}},
<|"MaxEvents" -> 1|>,
"EventOrderingFunction" -> {},
"EventDeduplication" -> "SameInputSetIsomorphicOutputs"][
"AllEventsRuleIndices"]], 1000], 1] < 300
]
}
|>
|>