mverardo / catemplates Goto Github PK
View Code? Open in Web Editor NEWA Mathematica package that enables CellularAutomata researchers (and enthusiasts) to use the Template framework.
License: MIT License
A Mathematica package that enables CellularAutomata researchers (and enthusiasts) to use the Template framework.
License: MIT License
IN >> ExpandTemplateModK[ModNStateConservingTemplate[3], 3]
Results in invalid rules, as ModNStateConservingTemplate is generating a Mod 3 template with k=2.
There should be an expansion function that performs a mod N in the end, and removes invalid rule tables, as does the default ExpandTemplate.
Should look like this:
Template
{
template : {x8,x7,x6}
ExpansionFunction : Partial[ExpandTemplate[k,r]]
k : 2
r : 1
N : 3
}
To reproduce:
In > RuleTemplateVars[BaseTemplate[2, 2]]����
Out> {x0, x1, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x2, x20, x21, x22, x23, x24, x25, x26, x27, x28, x29, x3, x30, x31, x4, x5, x6, x7, x8, x9}�����
We desperately need documentation on this project!
In >> ModularTemplateIntersection[TotalisticTemplate[], OuterTotalisticTemplate[], 2]
Out >> {x7, x5, x5, x2, x5, x2, x2, x0}
New names should be:
ModKMapper,
IdentityMapper,
FilterVariableAssignments, and
FilterKOutOfRange.
To reproduce:
ColorBlindTemplate[3]
Given a template, it is expected that this operation create a set of templates that if expanded generates all rules that the original template don't represent
Currently, it works only with binary templates.
In := t1 = BuildTemplate[3, 1.0, {2, x1 \[Element] {0, 2}, 0}, RestrictedExpansion];
In := t2 = BuildTemplate[3, 1.0, {2, x1, 0}, RestrictedExpansion];
In := TemplateIntersection[t1, t2]
Out = <|"k" -> 3, "r" -> 1., "rawList" -> {}, "expansionFunction" -> RestrictedExpansion|>
Out should be
<|"k" -> 3, "r" -> 1., "rawList" -> {2, x1 \[Element] {0, 2}, 0}, "expansionFunction" -> RestrictedExpansion|>
@zorandir is taking a look at this.
Create a operation that generates the replacements in a template that generate invalid rules.
Probably because it uses ImprisonmentExpressions internally for k>4, and ModularTemplateIntersection is not prepared to treat these kinds of expressions.
Given the templates:
t1 = ColorBlindTemplate[3, 2];
t2 = TotalisticTemplate[3, 2];
If ModularTemplateIntersection is used as follows:
In >> ModularTemplateIntersection[t2, t1, 3]
Out >> {2, 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 0}
The output is a valid k-ary rule table.
If the order of the arguments are reversed, the output is:
{2, 0, -2, 0, 1, 2, -2, 2, 0, 0, 1, 2, 1, 2, 0, 2, 0, 1, -2, 2, 0, 2, 0, -2, 0, -2, 2, 0, 1, 2, 1, 2, 0, 2, 0, 1, 1, 2, 0, 2, 0, 1, 0, 1, 2, 2, 0, 1, 0, 1, 2, 1, 2, 0, -2, 2, 0, 2, 0, -2, 0, -2, 2, 2, 0, -2, 0, -2, 2, -2, 2, 0, 0, -2, 2, -2, 2, 0, 2, 0, -2, -3, 1, -1, 1, -1, -3, -1, -3, 1, 1, -1, -3, -1, -3, 1, -3, 1, -1, -1, -3, 1, -3, 1, -1, 1, -1, -3, 1, -1, -3, -1, -3, 1, -3, 1, -1, -1, -3, 1, -3, 1, 5, 1, 5, 3, 3, 1, 5, 1, 5, 3, 5, 3, 1, 5, 3, 1, 3, 1, 5, 1, 5, 3, 3, 1, 5, 1, 5, 3, 5, 3, 1, 1, 5, 3, 5, 3, 1, 3, 1, 5, 4, 2, 0, 2, 0, 4, 0, 4, 2, 2, 0, 4, 0, 4, 2, 4, 2, 0, 0, 4, 2, 4, 2, 0, 2, 0, 4, 2, 0, 1, 0, 1, 2, 1, 2, 0, 0, 1, 2, 1, 2, 0, 2, 0, 1, 1, 2, 0, 2, 0, 1, 0, 1, 2, 0, 4, 2, 4, 2, 0, 2, 0, 4, 1, 2, 0, 2, 0, 1, 0, 1, 2, 2, 0, 4, 0, 1, 2, 4, 2, 0}
Wich, clearly, is not a valid rule table.
So, @zorandir , where do you think it should be moved to?
The example in the READ.ME,
With[{k = 2, r = 5.0},
TemplateIntersection[ColorBlindTemplate[k, r], TotalisticTemplate[k, r]]];
doesn't work, unless $RecursionLimit set to a big value. As a matter of uniformity, maybe it should be set to Infinity as default. By the way, until this is done, READ.ME should be altered with an example that would work.
Below, two cases to make the bug evident, both for k=3. Possibly, the bug occurs only for k>2, but this should be checked.
In[6]:= Intersection[
ExpandTemplate[With[{k = 3, r = 0.5}, ColorBlindTemplate[k, r]]],
ExpandTemplate[With[{k = 3, r = 0.5}, TotalisticTemplate[k, r]]]]
Out[6]= {{2, 0, 1, 0, 1, 2, 1, 2, 0}}
ExpandTemplate[
With[{k = 3, r = 0.5},
TemplateIntersection[
ColorBlindTemplate[k, r],
TotalisticTemplate[k, r]]]] // Length
Out[5]= 0
In[10]:= Intersection[
ExpandTemplate[With[{k = 3, r = 1.5}, ColorBlindTemplate[k, r]]],
ExpandTemplate[With[{k = 3, r = 1.5}, TotalisticTemplate[k, r]]]]
Out[10]= {{2, 1, 0, 1, 0, 2, 0, 2, 1, 1, 0, 2, 0, 2, 1, 2, 1, 0, 0, 2,
1, 2, 1, 0, 1, 0, 2, 1, 0, 2, 0, 2, 1, 2, 1, 0, 0, 2, 1, 2, 1, 0,
1, 0, 2, 2, 1, 0, 1, 0, 2, 0, 2, 1, 0, 2, 1, 2, 1, 0, 1, 0, 2, 2, 1,
0, 1, 0, 2, 0, 2, 1, 1, 0, 2, 0, 2, 1, 2, 1, 0}}
In[11]:= ExpandTemplate[
With[{k = 3, r = 1.5},
TemplateIntersection[ColorBlindTemplate[k, r],
TotalisticTemplate[k, r]]]] // Length
Out[11]= 0
Currently, the function is defined in a way that is hard to read.
It would be better if it used private functions or constans to increase it's readability.
The following templates are equivalent when expanded mod 3:
In >> t1 = {2 + x1, x0};
In >> t2 = {x1, x0};
Problem is that their intersection is empty:
In >> ModularTemplateIntersection[t1, t2, 3]
Out >> {}
Changing one of the template's variables to yi corrects this problem, tough:
In >> ty2 = Symbol[StringReplace[SymbolName[#], "x" -> "y"]] & /@ t2;
In >> ModularTemplateIntersection[t1, ty2, 3]
Out >> {2 + x1, x0}
Maybe ModularTemplateIntersection should translate one of it's arguments to ys?
this version of the TemplateIntersection function should use the modulus -> k option, and translate the C[i] constants into template variables.
Currently, the problem with this approach is that the C[i] constants can't be called x_i, as this would create a semantic conflict between these variables and the ones from templates generated without mod.
It's still not clear if all new intersections should be named with different variables, or if the C[i] should get a new name with a new template (possibly resulting from intersections).
Currently, the function is defined in a way that is hard to read. It would be better if it used private functions or constans to increase it's readability.
Here's an example, with 32 variables in the template (Mathematica crashes in my machine with 16GB):
ExpandTemplate[With[{k = 2, r = 2.5}, ColorBlindTemplate[k, r]]]
In a case like this, the user should be warned and given the possibility of an iterative expansion, that would yield the results little by little on the Mathematica notebook, or directly into file.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.