Skip to content

Ensure non-default rngs are properly seeded with threading and repeated solve calls #476

@isaacsas

Description

@isaacsas

See the test added in #475, which fails for StableRngs for example.

One way this could be handled is to ensure we reseed in

function resetted_jump_problem(_jump_prob, seed)
jump_prob = deepcopy(_jump_prob)
if !isempty(jump_prob.jump_callback.discrete_callbacks)
rng = jump_prob.jump_callback.discrete_callbacks[1].condition.rng
if seed === nothing
Random.seed!(rng, rand(UInt64))
else
Random.seed!(rng, seed)
end
end
if !isempty(jump_prob.variable_jumps)
@assert jump_prob.prob.u0 isa ExtendedJumpArray
randexp!(_jump_prob.rng, jump_prob.prob.u0.jump_u)
jump_prob.prob.u0.jump_u .*= -1
end
jump_prob
end
function reset_jump_problem!(jump_prob, seed)
if seed !== nothing && !isempty(jump_prob.jump_callback.discrete_callbacks)
Random.seed!(jump_prob.jump_callback.discrete_callbacks[1].condition.rng, seed)
end
if !isempty(jump_prob.variable_jumps)
@assert jump_prob.prob.u0 isa ExtendedJumpArray
randexp!(jump_prob.rng, jump_prob.prob.u0.jump_u)
jump_prob.prob.u0.jump_u .*= -1
end
end

even if there are no discrete callbacks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions