Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There should be the possibility of an iterative way for expanding templates that demand a lot of memory #66

Open
PPBO opened this issue Feb 27, 2017 · 3 comments

Comments

@PPBO
Copy link
Collaborator

PPBO commented Feb 27, 2017

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.

@mverardo
Copy link
Owner

ExpandTemplate has an overload that accepts which of the ith expansions should be made.
For instance:

With[{k = 2, t = ColorBlindTemplate[2, 1.0]},
 ExpandTemplate[t, #] & /@ 
  Range[0, k^Length[TemplateCoreVars[t]] - 1]]

is equivalent to:

With[{k = 2, t = ColorBlindTemplate[2, 1.0]},
 ExpandTemplate[t]]

This means the user can partition the range any way he wants and perform any kind of side effect (dump into a file, for instance) as needed for each partition.

What we could do to make this easier is expose a function that gives you the upper bound of the expansion range so the user won't have to calculate it.

@mverardo
Copy link
Owner

Note that the user can also use a more imperative approach if he wants:

With[{k = 2, t = ColorBlindTemplate[2, 1.0]},
 For[i = 0, i < k^Length[TemplateCoreVars[t]], i++,
  e = ExpandTemplate[t, i];
  DumpToFile[e];]]

@PPBO
Copy link
Collaborator Author

PPBO commented Feb 28, 2017

This is certainly a good workaround, and we might be happy to stick to it for the moment.

But what I really had in mind is an iterative alternative, tha might allow the user to compute all expansions wanted, provided they would be willing to wait. This is what the IthTuple function in CAMaT allows; have a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants