Thanks! Fair enough. Maybe another option is building an array of DiffEqObjectives, and then making a new DiffEqObjective instance that sums them in parallel. I made a (serial) implementation of this that works (below). I need to figure out a good way of parallelising it now. Which might be obvious/impossible, I’m not that familiar with parallel processing but I’ll have a go.
function sum_losses(lArray::Array{T,1}, p0) where T<:DiffEqObjective
dummy_g = deepcopy(p0)
function cost1(p)
return reduce(+, [loss(p) for loss in lArray])
end
function cost2(p,g)
fill!(g,0)
c = 0
for el in lArray
c += el(p,dummy_g)
g .+= dummy_g
end
return c
end
return DiffEqObjective(cost1,cost2)
end