Skip to content
Merged
2 changes: 1 addition & 1 deletion src/aggregators/ccnrm.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function CCNRMJumpAggregation(nj::Int, njt::T, et::T, crs::Vector{T}, sr::T,
rng, dg, ptt)
end

+############################# Required Functions ##############################
############################# Required Functions ##############################
# creating the JumpAggregation structure (function wrapper-based constant jumps)
function aggregate(aggregator::CCNRM, u, p, t, end_time, constant_jumps,
ma_jumps, save_positions, rng; kwargs...)
Expand Down
7 changes: 4 additions & 3 deletions src/aggregators/prioritytable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -350,13 +350,14 @@ end
function PriorityTimeTable(
times::AbstractVector, mintime, timestep; binwidthconst = 16, numbinsconst = 20)
binwidth = binwidthconst * timestep
numbins = floor(Int64, numbinsconst * sqrt(length(times)))
# Use native Int so F matches Tuple{Int,Int} / Int kwargs on 32-bit.
numbins = floor(Int, numbinsconst * sqrt(length(times)))
maxtime = mintime + numbins * binwidth

pidtype = typeof(numbins)
ptype = eltype(times)
groups = Vector{PriorityGroup{ptype, Vector{pidtype}}}()
pidtogroup = Vector{Tuple{Int, Int}}(undef, length(times))
pidtogroup = Vector{Tuple{pidtype, pidtype}}(undef, length(times))

ttgdata = TimeGrouper{ptype}(mintime, binwidth)
# Create the groups, [t_min, t_min + τ), [t_min + τ, t_min + 2τ)...
Expand All @@ -366,7 +367,7 @@ function PriorityTimeTable(

ptt = PriorityTimeTable(
groups, pidtogroup, times, ttgdata, zero(pidtype),
zero(pidtype), maxtime, binwidthconst, numbinsconst)
zero(pidtype), maxtime, pidtype(binwidthconst), pidtype(numbinsconst))
# Insert priority ids into the groups
for (pid, time) in enumerate(times)
if time > maxtime
Expand Down
3 changes: 2 additions & 1 deletion src/solve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ end
# jump aggregator's RNG. We cannot assume the JumpProblem's stored RNG is any particular
# type, so we pass the seed through `hash` (to decorrelate from the input) and then through
# a Xoshiro draw (to ensure strong mixing regardless of the target RNG's seeding quality).
const _JUMP_SEED_SALT = 0x4a756d7050726f63 # "JumPProc" in ASCII
# Truncate salt to native UInt so hash(::UInt64, ::UInt) matches on 32-bit Julia.
const _JUMP_SEED_SALT = 0x4a756d7050726f63 % UInt # "JumPProc" in ASCII
_derive_jump_seed(seed) = rand(Random.Xoshiro(hash(seed, _JUMP_SEED_SALT)), UInt64)

function resetted_jump_problem(_jump_prob, seed)
Expand Down
4 changes: 2 additions & 2 deletions test/extended_jump_array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ bc_mismatch = ExtendedJumpArray(rand(rng, 8), rand(rng, 4))
bc_dtype_1 = ExtendedJumpArray(rand(rng, 10), rand(rng, 1:10, 2))
bc_dtype_2 = ExtendedJumpArray(rand(rng, 10), rand(rng, 1:10, 2))
result = bc_dtype_1 + bc_dtype_2 * 2
@test eltype(result.jump_u) == Int64
@test eltype(result.jump_u) == Int
out_result = ExtendedJumpArray(zeros(10), zeros(2))
out_result .= bc_dtype_1 .+ bc_dtype_2 .* 2
@test eltype(result.jump_u) == Int64
@test eltype(result.jump_u) == Int
@test out_result ≈ result

# Test that fast broadcasting also gives the correct results
Expand Down
Loading