Does SimJulia support parallel computation?

I have developed a traffic simulation package using SimJulia. When the network is larger, the simulation is not quick enough. Does anyone know whether SimJulia supports the parallel calculation? This is not mentioned in the documentation.
SimJulia

I checked the CPU usage on a 72-Core server, only 1 core is fully used. Is there any method to make SimJulia run in a multiple-core mode. I checked the source code of SimJulia, which depends on ResumableFunctions. I currently have no idea on how to use multiple core.
I need to simulate the movement of millions objects, and thus it is almost does not work using just one core. Can anyone help? Thanks!

looking at this example in particular:

@resumable function start_sim(env::Environment, repair_facility::Resource, spares::Store{Process})
    for i in 1:N
        proc = @process machine(env, repair_facility, spares)
        @yield interrupt(proc)
    end
    for i in 1:S
        proc = @process machine(env, repair_facility, spares)
        @yield put(spares, proc) 
    end
end

the amount of variables is defined by the user, so you can try using some parallel methods here. i recommend using the new multithreading capabilities of julia 1.3, adding Threads.@threads in any loops that your function may have, and starting the julia process in the server with more threads (72 in your case)

There is a long history of parallellizing discrete event simulations with mixed results. The problem is the synchronization of events at the end of parallel (sub) branches. In order to do this successfully you need to know in advance which events each sub - branch is dependent on, which most often (c. q. in general) is impossible. Most parallel attempts follow the “optimistic” simulation paradigm with rewinding capability. When this becomes too expensive (which it often does) “conservative” i.e. single thread simulation is than the fastest you can get.

Exactly. Here is a link reference summary of how the research on this topic developed since '70s that was presented during WinterSim in 2017.

The easiest way to speed up DSE in Julia is to switch from process-oriented implementation to event-oriented one (this still will be single threaded). Here is an example implementation I have made some time ago exactly because of this limitation https://github.com/bkamins/EventSimulation.jl (but it is essentially a thin wrapper around priority queue so you might as well write your own event scheduler from scratch which should be pretty easy in Julia).

4 Likes

Thank you so much! I am rewriting the simulation based on EventSimulation.jl to benchmark the simulation speed. I will share the results soon.

1 Like

Great! Feedback is welcome. Note that if “agent logic” is much more expensive than event scheduling cost there should not be a big difference. I would expect the biggest impact of this change if the action taken is very cheap.