I have a question about AnyLogic’s use of computer hardware. The agent-based AnyLogic 6.2 models I am currently
running bring my current computer (which uses a single core processor) to a standstill. I’m now in the market for a
new computer. Many available hardware setups have 2 or 4 or even 8 processor cores, and processor speed varies quite a
bit. How does AnyLogic 6.2 make use of multiple processor cores? If the decision is between more processor cores or
faster processor speed, which would you recommend?
I know that reducing the number of "individuals" in the model would make things run faster, but I must keep
(and in the future, greatly increase) the number of individuals in the model. The computing will only become more
intensive.
Khoi Nguyen — 17.01.08
Hi Warren!
I'm testing Anylogic 6, too. It seems that Anylogic 6 uses only one core on my dual core laptop. I still can work on
another application during running model with full speed.
Regards,
Khoi
Andrei — 20.01.08
AnyLogic model is a single-process multi-thread application (e.g. animation drawing is one thread, event execution is
another, etc.). It may potentially benefit (speed-up) from hardware that allows different threads to be executed on
different processors, but not really a lot: the threads are pretty much synchronized.
In general it is a very rare case when you can distribute a SINGLE simulation run over multiple processors (or
computers) and increase the execution speed: average simulation model requires a lot of time synchronization, and the
resulting overhead eats up the potential acceleration. "Heavy" architectures like HLA are used more to make
different components of a large model interoperable than to increase the execution speed. As a bottom line, any
simulation model (regardless the underlying tool/engine) requires thorough analysis and fair amount of coding before it
can be efficiently parallelized or distributed.
But there is another way you can easily utilize multiple processors or computers and speed up the simulation greatly: in
experiments where multiple simulation runs are needed (parameter variation, monte carlo, optimization, etc.) different
runs can be placed on different processors and (being completely independent) execute concurrently.
Andrei — 20.01.08
Forgot to say: when you run those experiments as they are generated by AnyLogic, this is still a sequential execution.
You need to execute different runs in different PROCESSES (different JVMs?). Or different THREADS are OK?
Khoi Nguyen — 22.01.08
Andrei,
This means Opquest in AnyLogic cannot run experiments in parallel? Can I run different processes in parallel with one
AnyLgic 6 license? With Anylogic 5.5 I can start more than one instance and can run multiple processes in parallel.
Roberto Nibali — 24.01.08
What Andrei mentions is very important. The overhead of synchronising data between processor threads is quite large with
todays cheap multi-core processor integration. Really the only way (except dissecting your problem into tiny bits that
do not need synchronisation or data exchange) to make use of multi-core or multi-processor nodes is to start multiple
instances of your simulation with varying parameters. Under Linux you can use process to processor binding, so that you
can guarantee an instance per processor. Due to the (mostly synchonised) threaded nature of Anylogic (at least from my
experience working with 5.x versions) depending on your JVM and how you tune and invoke it, you can make use of your
multi-cores.
Roberto Nibali — 24.01.08
Ah, I forgot. As far as I know the Anylogic license is not processor-bound, so you can fire up as many instances as you
want with your license. On top of that you can always create a ready to use application out of Anylogic that runs on any
computer even without license, the license is more used to create models using the Anylogic framework.
Victor Gleim — 30.01.08
Roberto, there is another very important thing mentioned in the License Agreement. According to standard agreement, it
is not allowed to create standalone applications, only applets, and use it in any commercial projects. Please read the
License Agreement more carefully.
Warren — 19.02.08
Khoi, Andrei, Roberto, and (for the details on the license agreement) Victor:
Thank you all for your comments. They were helpful in putting together a computer that (at least so far) is very happy
running the AnyLogic models. I ended up going with an Intel Core 2 Quad running at 3.00 GHz. I am also running with 4
gigs of 800MHz ECC RAM and a couple of speedy (albeit non RAIDed) hard drives. Compared to the single core 2.0GHz
machine I was running before, the new machine happily runs through the simulations that my old machine "white
screened" me with just a month ago. From what I've read on all of your comments, it is likely the case that the
processor speed has a lot more to do with this than the multiple processors, but I went with the multiple processors in
an effort to "future proof" my machine.
If others are interested, I will watch the cores at work on the Task Manager while running the models to see what is
going on (or, at least, what the OS says is going on) and post what I see.
I think that many others would find it useful if XJTek would include details on the multiple-core matter in their
machine specs page. Likewise, it might be interesting for several of us to run, say, one or two of the sample models
that XJTek sends with the AL distributions and use them as a benchmark (of sorts) to see what kind of machines are
happiest running AL. (Is there already something like this in the discussion threads that I cannot find?)
With regards to the commands for forcing the program to use multiple processors, I wish I could say that I was at that
level of programming. Unfortunately, I'm only about one year into the AnyLogic/Java world, and I haven't embarked on a
focused program of study. I am interested in learning. I'd ask more questions about this here, but I think that such a
move would be more appropriate for a new thread.
Again, thank you all for your comments.
Roberto Nibali — 16.03.08
My sincere apologies for the false information regarding the license agreement and thank you Victor for the correction.
dingo — 15.04.09
Hi,
running simulations in the same JVM in separate threads works just fine, Quad processor PC can run about 3x faster,
say 60 seconds one run in single thread. 4 simulations in paralel about 80 seconds each, so when you need real big
amount experiments, multicore really works.
but,
1) i had to code mini framework for threading, including simulation task pool
2) i made custom result output to db , which in my case (MS ACCESS) has to be synchronized for multiple threads, normal
RDBMS would save you some effort, and keep in mind it is faster to prepare all results as a batch and output all at
once. which i am not sure anylogic can do. if you do inserts one by one, it can be that output takes much longer than
simulation itself
Now, i wonder, can I rely on anylogic being able to detect the fact that simulation is running in backgroup -> no
visible GUI -> save processing time by skiping all presenation actions (charts,animation etc). or it is better to
disable all unnecessary presentation code/components ? testing both options is possible, but to be sure..
Pavel — 16.07.09
Hi dingo,
The model can be run in the fastest mode if you replace "run()" method by "runFast()". It can be
done from the "Custom" experiment (available only in AnyLogic Professional). The presentation window will not
be created, you will get only the output results.