Developing MultiwaySystem
Developing MultiwaySystem
Old Code
Old Code
In[]:=
SREvolveCN0[rewrite_,{ic_,eventls_,ind_}]:=With[{diff=#2-#1&@@(StringLength/@rewrite),rhslen=StringLength[rewrite[[2]]],positions=StringPosition[ic,rewrite[[1]]]},With[{difflist=MapIndexed[{ind+#2[[1]],#+(#2[[1]]-1)diff}&,positions]},{Flatten[MapIndexed[Thread[#(#2[[1]]+ind)]&,Take[eventls,#]&/@positions]],StringReplace[ic,rewrite],Fold[Join[Take[#,#2[[2,1]]-1],Table[#2[[1]],{rhslen}],Drop[#,#2[[2,2]]]]&,eventls,difflist],ind+Length[difflist]}]]
SREvolveCN1[rule_,{ic_,eventls_,ind_}]:=Fold[Join[Drop[#,-3],SREvolveCN0[#2,Take[#,-3]]]&,{ic,eventls,ind},rule]
In[]:=
SREvolveCN2[rule_,{ic_,eventls_,ind_}]:=FoldList[SREvolveCN0[#2,Rest[#]]&,{{},ic,eventls,ind},rule]
In[]:=
SREvolveCN[rule_List,init_,t_]:=Rest[Drop[#,-3]&/@NestList[SREvolveCN1[rule,Take[#,-3]]&,{{},init,Array[(1)&,StringLength[init]],1},t]]
In[]:=
SREvolveCN[rule_Rule,init_,t_]:=SREvolveCN[{rule},init,t]
In[]:=
SREvolveCN[{"A""AA","B""AB"},"ABA",3]
Out[]=
{{{12,13},{14}},{{25,26,47,38,39},{410}},{{511,512,613,614,715,716,1017,818,819,920,921},{1022}}}
In[]:=
SREvolveCN[{"A""AA"},"A",5]
»
{A,{1},1}
»
{AA,{2,2},2}
»
{AAAA,{3,3,4,4},4}
»
{AAAAAAAA,{5,5,6,6,7,7,8,8},8}
»
{AAAAAAAAAAAAAAAA,{9,9,10,10,11,11,12,12,13,13,14,14,15,15,16,16},16}
Out[]=
New Code
New Code
At every step, results are given as {“A”->id1,”B”->id2,...} where the idi are the creator events for those characters.
In[]:=
{(#{0})&/@Characters["ABAAA"]}
Out[]=
{{A{0},B{0},A{0},A{0},A{0}}}
In the end, for each element in each result we need the list of creator events, and the list of destroyer events.
At each step, we store the list of current states, as well as
Every edge in the evolution graph is an event...
In[]:=
Graph[MultiwaySystem[{"A""AA","B""AB"},{"ABA"},3,"EvolutionGraph"],VertexLabelsAutomatic]
Out[]=
In[]:=
MultiwaySystem[{"A""AA","B""AB"},{"ABA"},2,"TracedStatesList"]
Out[]=
At every step, we can say that every character
In[]:=
NewID[]
Out[]=
NewID[]
In[]:=
MultiwaySystemIDed[rules:{(_String_String)..},state:{_String...},n_Integer]:=Map[Association,Module[{id=1,idrules},NewID[]:=(id++);idrules=IDedRules[rules];NestList[Flatten[ReplaceList[#,idrules]&/@#,1]&,IDedState/@state,n]],{2}]
In[]:=
IDedState[string_String]:=NewID[]#&/@Characters[string]
In[]:=
IDedRules[rules:{(_String_String)..}]:=IDedRules0/@rules
In[]:=
IDedRules0[lhs_Stringrhs_String]:=Flatten[{{x___},_#&/@Characters[lhs],{y___}}]Join[{x},NewID[]#&/@Characters[rhs],{y}]
In[]:=
MultiwaySystemIDed[{"A""AA"},{"AB"},3]
Out[]=
{charID,creationID,deletionID}
This graph with every edge having an intermediate (“event”) node, and with the intermediate node connected by “Causal” tagged edges to other event nodes:
This picture with an overlay graph of causal connections
Out[]=
In[]:=
LayeredGraphPlot[MultiwaySystem[{"A""AA","B""AB"},{"ABA"},3,"EvolutionGraph"],VertexLabelsAutomatic]
Out[]=
MultiwaySystem[{"A""AA","B""AB"},{"ABA"},3,"EvolutionGraph"]
Lock the result coordinates, and let the intermediate nodes hang out.....