In[]:=
MultiwaySystem[{"A""AA","B""AB"},{First[#]}&,{"ABA"},3,"EvolutionEventsGraph"]
Out[]=
In[]:=
MultiwaySystem[{"A""AA","B""AB"},Take[#,UpTo[2]]&,{"ABA"},3,"EvolutionEventsGraph"]
Out[]=
In[]:=
MultiwaySystem[{"A""AA","B""AB"},Take[#,UpTo[3]]&,{"ABA"},3,"EvolutionEventsGraph"]
Out[]=
In[]:=
MultiwaySystem[{"BA""AB"},Take[#,UpTo[3]]&,StringTuples["AB",3],3,"EvolutionEventsGraph"]
Out[]=
In[]:=
MultiwaySystem[{"BA""AB"},Take[#,UpTo[3]]&,StringTuples["AB",3],3,"EvolutionCausalGraph"]
Out[]=
In[]:=
MultiwaySystem[{"BA""AB"},Take[#,UpTo[4]]&,StringTuples["AB",3],3,"EvolutionCausalGraph"]
Out[]=
Max’s generational algorithm
Max’s generational algorithm
In[]:=
MultiwaySystem[{"A""AA","B""AB"},Identity,{"ABA"},3,"AllEventsList"]
Out[]=
We could imagine a knapsacked algorithm, but Max’s algorithm is basically a greedy algorithm.
It sorts the events in some order, then applies successive events that do overlap previous ones....
Sort by decreasing suffix length:
In[]:=
ReverseSortBy[{{"A""AA","A",{"","ABA"}},{"A""AA","A",{"","BAA"}},{"A""AA","A",{"A","BA"}},{"A""AA","A",{"AAB",""}},{"A""AA","A",{"AB","A"}},{"A""AA","A",{"ABA",""}},{"B""AB","B",{"A","AA"}},{"B""AB","B",{"AA","A"}}},StringLength[#[[-1,-1]]]&]
Out[]=
{{AAA,A,{,BAA}},{AAA,A,{,ABA}},{BAB,B,{A,AA}},{AAA,A,{A,BA}},{BAB,B,{AA,A}},{AAA,A,{AB,A}},{AAA,A,{ABA,}},{AAA,A,{AAB,}}}
Pick out the maximal suffix first, then go through pruning back
GreedyMaximalSuffix[events_List]:=FirstCase[events,
In[]:=
getStringReplacementEvents[{"A""AA","B""AB"},{"ABBABBAAA"}]
Out[]=
Max’s version of his algorithm:
Max’s version of his algorithm:
In[]:=
singleGenerationEvents[allEvents_]:=Reap[NestWhile[Function[{events},(Sow[#];Complement[events,{#},SameTest(IntervalIntersection@@(Interval[StringLength[#[[3,1]]]+1+{0,StringLength[#[[1,1]]]-1}]&/@{##})=!=Interval[]&)])&@First@SortBy[events,{(-#&)@*StringLength@*Last@*Last,StringLength@*First@*Last,First}]],allEvents,#=!={}&]][[2,1]]
In[]:=
singleGenerationEvents[{{"A""AA","A",{"","BBABBAAA"}},{"A""AA","A",{"ABB","BBAAA"}},{"A""AA","A",{"ABBABB","AA"}},{"A""AA","A",{"ABBABBA","A"}},{"A""AA","A",{"ABBABBAA",""}},{"B""AB","B",{"A","BABBAAA"}},{"B""AB","B",{"AB","ABBAAA"}},{"B""AB","B",{"ABBA","BAAA"}},{"B""AB","B",{"ABBAB","AAA"}}}]
This should be tree-like wrt states:
In the “generational” approach, one can daisy-chain multiple events in going from one state to the next.......