Hi,
I am trying to find the best environment for doing Agent Based modelling.
I could program myself (e.g., C, Phyton, …), use the statistical environment R, or dedicated programs like NetLogo or CompuCell3D. Each has it’s cons and pro’s.
What about Mathematica? Is it suitable for doing ABM? (I noticed some of the demo’s). Is it fast? Is it flexible? Any other thoughts?
I am aiming to simulated different types of immune cells (about 15000 in total), The simulation would comprise about 21 days in resolution of 1 hour. The cells can interact. And the will have to respond to a chemokine gradient, which I want to calculated with a pdf (diffusion equation). I assume that ODE/PDE/ABM can easily be integrated within mathematica (one reason for wanting to try M).
I understand that low-level languages are faster (and probably even more flexible) but if I can use pre-existing function from mathematica then this may save time.
Slow or fast depends on your code. Single function in Mathematica is basically C code. Things gets slow when you compose many top level functions. But it is still can be fast if it is well architected. Also I expect simple interactions to be simple functions - so you could Compile. Also see
I would not use Mathematica, Python, or any other interpreted language for this (especially not R which is probably the slowest of the bunch). Except maybe for prototyping.
Mathematica is very flexible, but not fast, especially for this type of code, which often requires procedural programming. People have done agent-based models in Mathematica. You will find a few posts on this website. But once you’re done with a prototype and know how your simulation needs to work, you might easily get very frustrated with the performance.
I would write the simulation in a low-level language such as C++, C or Java, then control it form Mathematica. Expect orders of magnitude higher performance when programmed carefully. If you go this route and decide to integrate the simulation into Mathematica, take a look at LibraryLink for C/C++ and J/Link for Java. If you go with LibraryLink, also take a look at my package LTemplate. I hope eventually I’ll have time to post some examples about how to easily integrate simulation code into Mathematica.
NetLogo may be worth trying even if it is a high level language. I am not very familiar with its performance characteristics, but it does have some significant advantages:
it is specifically made for agent based modelling, so it should be quick to set up a prototype
as I remember it can solve some sorts of simple PDEs, e.g. diffusion