Skip to main content
added 574 characters in body
Source Link
C. E.
  • 71.2k
  • 6
  • 141
  • 269

###Method #4 New as of the 26th of August 2014 (i.e. not a part of the original post.) This method should be faster than the others.

forest = RandomChoice[{1, 1, 0}, {1000, 1000}];
forest = ReplacePart[forest, RandomChoice[Position[forest, 1]] -> 10];

res = FixedPoint[
   Composition[
    Unitize[First@#] + 9 UnitStep[Last@# - 110] &,
    {#, ListConvolve[{{0, 1, 0}, {1, 100, 1}, {0, 1, 0}}, #, {2, 2}, 0]} &
    ],
   forest
   ];
ArrayPlot[res, ColorRules -> {0 -> Brown, 1 -> Green, 10 -> Orange}]

###Conclusions I hope that in these three different examples you can find something that might help you simulate your model. As for efficiency, a lot of the time is spent visualizing. The computation is much faster, and I tried to measure it, although I am unsure of my results because they seem very unlikely. I would be grateful if someone would confirm them. Remember that these times also seem faster than you anticipate because it takes time for the frontend to display the result, even in list form. For 200x200 pixel grid the methods take this much time:

###Conclusions I hope that in these three different examples you can find something that might help you simulate your model. As for efficiency, a lot of the time is spent visualizing. The computation is much faster, and I tried to measure it, although I am unsure of my results because they seem very unlikely. I would be grateful if someone would confirm them. Remember that these times also seem faster than you anticipate because it takes time for the frontend to display the result, even in list form. For 200x200 pixel grid the methods take this much time:

###Method #4 New as of the 26th of August 2014 (i.e. not a part of the original post.) This method should be faster than the others.

forest = RandomChoice[{1, 1, 0}, {1000, 1000}];
forest = ReplacePart[forest, RandomChoice[Position[forest, 1]] -> 10];

res = FixedPoint[
   Composition[
    Unitize[First@#] + 9 UnitStep[Last@# - 110] &,
    {#, ListConvolve[{{0, 1, 0}, {1, 100, 1}, {0, 1, 0}}, #, {2, 2}, 0]} &
    ],
   forest
   ];
ArrayPlot[res, ColorRules -> {0 -> Brown, 1 -> Green, 10 -> Orange}]

###Conclusions I hope that in these three different examples you can find something that might help you simulate your model. As for efficiency, a lot of the time is spent visualizing. The computation is much faster, and I tried to measure it, although I am unsure of my results because they seem very unlikely. I would be grateful if someone would confirm them. Remember that these times also seem faster than you anticipate because it takes time for the frontend to display the result, even in list form. For 200x200 pixel grid the methods take this much time:

deleted 466 characters in body
Source Link
C. E.
  • 71.2k
  • 6
  • 141
  • 269

###Background A while back someone told me aboutThis is a homeworksample problem he was working on. Since I hadn't been in that class I hadn't heard about cellular automatons... So when I was bored and wanted to try the homework problem I ended up implementing everything from scratch. A few weeks later I stumbled upon CellularAutomaton in Vitaliy Kaurov's post here. I hope that my solutions can help you somehow.

###The problem The homework problem isbe helpful; a fire that can spread in four directions (the Von Neumann neighborhood). Only trees can catch fire though. A typical fire looks like this:

Any of the methods below can generate it. There appears to be a namedname collision between method 1 and 2, so you may need to restart the kernel before you can try the next.

If you have any questions please know that all I have ever done regarding CA is in this post, but if Iyou can ask, and I will try to help you.

###Background A while back someone told me about a homework problem he was working on. Since I hadn't been in that class I hadn't heard about cellular automatons... So when I was bored and wanted to try the homework problem I ended up implementing everything from scratch. A few weeks later I stumbled upon CellularAutomaton in Vitaliy Kaurov's post here. I hope that my solutions can help you somehow.

###The problem The homework problem is a fire that can spread in four directions (the Von Neumann neighborhood). Only trees can catch fire though. A typical fire looks like this:

Any of the methods below can generate it. There appears to be a named collision between method 1 and 2, so you may need to restart the kernel before you can try the next.

If you have any questions please know that all I have ever done regarding CA is in this post, but if I can I will try to help you.

This is a sample problem that I hope can be helpful; a fire that can spread in four directions (the Von Neumann neighborhood). Only trees can catch fire though. A typical fire looks like this:

Any of the methods below can generate it. There appears to be a name collision between method 1 and 2, so you may need to restart the kernel before you can try the next.

If you have any questions you can ask, and I will try to help you.

added 17 characters in body
Source Link
C. E.
  • 71.2k
  • 6
  • 141
  • 269

The conclusion is that it appears one can do simulations faster by writing one's own code for it. However CellularAutomaton is fastoffers concise syntax and is somewhat easy to use. If you can think of a way to formulate your rules in the format required by CellularAutomaton, therefore, you could start with that and see if speed is a problem or not. In the other methods you are free to write program your rules however you want.

If you have any questions please know that all I have ever done regarding CA is in this post. But, but if I can I will try to help you.

The conclusion is that it appears one can do simulations faster by writing one's own code for it. However CellularAutomaton is fast and somewhat easy to use. If you can think of a way to formulate your rules in the format required by CellularAutomaton, therefore, you could start with that and see if speed is a problem or not. In the other methods you are free to write program your rules however you want.

If you have any questions please know that all I have ever done regarding CA is in this post. But if I can I will try to help you.

The conclusion is that it appears one can do simulations faster by writing one's own code for it. However CellularAutomaton offers concise syntax and is somewhat easy to use. If you can think of a way to formulate your rules in the format required by CellularAutomaton, therefore, you could start with that and see if speed is a problem or not. In the other methods you are free to write program your rules however you want.

If you have any questions please know that all I have ever done regarding CA is in this post, but if I can I will try to help you.

added 28 characters in body
Source Link
C. E.
  • 71.2k
  • 6
  • 141
  • 269
Loading
Source Link
C. E.
  • 71.2k
  • 6
  • 141
  • 269
Loading