Git Product home page Git Product logo

catemplates's Issues

Implement a template ADT

Should look like this:

Template
{
template : {x8,x7,x6}
ExpansionFunction : Partial[ExpandTemplate[k,r]]
k : 2
r : 1
N : 3
}

RuleTemplateVars returns the symbols in lex order

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}�����

RestrictedTemplateIntersection[t1,t1] results in {} instead of t1

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|>

ColorBlindTemplate[4] produces error.

Probably because it uses ImprisonmentExpressions internally for k>4, and ModularTemplateIntersection is not prepared to treat these kinds of expressions.

When mixing modular and non-modular templates, ModularTemplateIntersection depends on the order of it's arguments

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.

$RecursionLimit set to Infinity should be default in the package.

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.

Bug when handling asymmetric radii

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

ModularTemplateIntersection produces wrong results on equivalent templates

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?

Create a version of TemplateIntersection that works with templates generated with Mod[].

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).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.