Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
isaacsas opened this issue Feb 11, 2025 · 0 comments
Labels

Comments

@isaacsas
Copy link
Member

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.

@isaacsas isaacsas added the bug label Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant