Skip to content

EnsembleSplitThreads runs N trajectories on each process #495

@mfairley

Description

@mfairley

As per this discourse thread, https://discourse.julialang.org/t/combining-pmap-with-ensembleproblem/38383/3 EnsembleSplitThreads runs N trajectories on each process instead of N trajectories in total.

Here's a small example:

# start with more than 1 process e.g. julia -p 2
using Distributed
@everywhere using DifferentialEquations
println("There are $(nprocs()) processes")
prob = ODEProblem((u,p,t)->1.01u,0.5,(0.0,1.0))

@everywhere function prob_func(prob,i,repeat)
    println("Running trajectory $i")
    ODEProblem(prob.f,rand()*prob.u0,prob.tspan)
end

ensemble_prob = EnsembleProblem(prob, prob_func=prob_func)
sim = solve(ensemble_prob,Tsit5(),EnsembleSplitThreads(),trajectories=2)

Output:

julia -p 2 test/trajacetories_example.jl
There are 3 processes
      From worker 2:	Running trajectory 1
      From worker 3:	Running trajectory 3
      From worker 3:	Running trajectory 4
      From worker 2:	Running trajectory 2
      From worker 2:	Running trajectory 5
      From worker 2:	Running trajectory 6

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions