Skip to content

Commit

Permalink
fix: index properly into multi-type propensities (#1072)
Browse files Browse the repository at this point in the history
* fix: index properly into multi-type propensities

* Fix the fix

* Update Project.toml

---------

Co-authored-by: Adriano Meligrana <[email protected]>
  • Loading branch information
jesseylin and Tortar authored Sep 2, 2024
1 parent 65ee60e commit 932d75f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 3 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Agents"
uuid = "46ada45e-f475-11e8-01d0-f70cc89e6671"
authors = ["George Datseris", "Tim DuBois", "Aayush Sabharwal", "Ali Vahdati", "Adriano Meligrana"]
version = "6.1.4"
version = "6.1.5"

[deps]
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
Expand All @@ -10,8 +10,8 @@ DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
DynamicSumTypes = "5fcdbb90-de43-509e-b9a6-c4d43f29cf26"
Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
DynamicSumTypes = "5fcdbb90-de43-509e-b9a6-c4d43f29cf26"
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
LazyArtifacts = "4af54fe1-eca0-43a8-85a7-787d91b784e3"
Expand Down Expand Up @@ -47,8 +47,8 @@ DataFrames = "0.21, 0.22, 1"
DataStructures = "0.18"
Distributed = "1"
Distributions = "0.25"
DynamicSumTypes = "3"
Downloads = "1"
DynamicSumTypes = "3"
GraphMakie = "0.5"
Graphs = "1.4"
JLD2 = "0.4"
Expand Down
6 changes: 4 additions & 2 deletions src/core/model_event_queue.jl
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,11 @@ function add_event!(agent, model) # TODO: Study type stability of this function
propensities_type[i] = p
end
# Then, select an event based on propensities
event_idx = events_type[sample_propensity(abmrng(model), propensities_type)] # The time to the event is generated from the selected event
# The time to the event is generated from the selected event
prop_idx = sample_propensity(abmrng(model), propensities_type)
event_idx = events_type[prop_idx]
selected_event = events[event_idx]
selected_prop = propensities_type[event_idx]
selected_prop = propensities_type[prop_idx]
t = selected_event.timing(agent, model, selected_prop)
# we then propagate to the direct function
add_event!(agent, event_idx, t, model)
Expand Down

0 comments on commit 932d75f

Please sign in to comment.