Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
vyudu committed Oct 17, 2024
1 parent a3b1c1d commit d314e61
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
7 changes: 5 additions & 2 deletions src/aggregators/ccnrm.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ function CCNRMJumpAggregation(nj::Int, njt::T, et::T, crs::Vector{T}, sr::T,
add_self_dependencies!(dg)
end

ptt = PriorityTimeTable(zeros(T, length(crs)), 0.0, 1.0) # We will re-initialize this in initialize!()
binwidthconst = haskey(kwargs, :binwidthconst) ? kwargs[:binwidthconst] : 16
numbinsconst = haskey(kwargs, :numbinsconst) ? kwargs[:numbinsconst] : 20
ptt = PriorityTimeTable(zeros(T, length(crs)), zero(T), one(T),
binwidthconst = binwidthconst, numbinsconst = numbinsconst) # We will re-initialize this in initialize!()

affecttype = F2 <: Tuple ? F2 : Any
CCNRMJumpAggregation{T, S, F1, affecttype, RNG, typeof(dg), typeof(ptt)}(
Expand Down Expand Up @@ -116,7 +119,7 @@ function update_dependent_rates!(p::CCNRMJumpAggregation, u, params, t)
# Calculate new jump times for dependent jumps
if rx != p.next_jump && oldrate > zero(oldrate)
if cur_rates[rx] > zero(eltype(cur_rates))
update!(ptt, rx, oldtime, t + oldrate / cur_rates[rx] * (times[rx] - t))
update!(ptt, rx, oldtime, t + oldrate / cur_rates[rx] * (oldtime - t))
else
update!(ptt, rx, oldtime, floatmax(typeof(t)))
end
Expand Down
10 changes: 6 additions & 4 deletions src/aggregators/prioritytable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ end
### Routines for CCNRM ###
##########################

mutable struct TimeGrouper{T <: Number}
struct TimeGrouper{T <: Number}
mintime::T
binwidth::T
end
Expand All @@ -347,9 +347,11 @@ end
# Construct the time table with the default optimal bin width and number of bins.
# DEFAULT NUMBINS: 20 * √length(times)
# DEFAULT BINWIDTH: 16 / sum(propensities)
function PriorityTimeTable(times::AbstractVector, mintime, timestep)
numbins = floor(Int64, 20 * sqrt(length(times)))
maxtime = mintime + numbins * timestep
function PriorityTimeTable(
times::AbstractVector, mintime, timestep; binwidthconst = 16, numbinsconst = 20)
binwidth = binwidthconst * timestep
numbins = floor(Int64, numbinsconst * sqrt(length(times)))
maxtime = mintime + numbins * binwidth

pidtype = typeof(numbins)
ptype = eltype(times)
Expand Down

0 comments on commit d314e61

Please sign in to comment.