Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Peter Jentsch
CovidAlertABM
Commits
99904e52
Commit
99904e52
authored
Jun 26, 2021
by
Peter Jentsch
Browse files
minor optimization in household graph generation
parent
c995d9f4
Changes
1
Show whitespace changes
Inline
Side-by-side
CovidAlertVaccinationModel/src/ABM/agents.jl
View file @
99904e52
...
...
@@ -33,8 +33,6 @@ Also returns a vector of AgentDemographic representing each agent, defined by th
total_household_pop
=
sum
(
sum
.
(
households_composition
))
population_list
=
Vector
{
AgentDemographic
}(
undef
,
total_household_pop
)
wg
=
WeightedGraph
(
total_household_pop
,
sampler_matrix
)
# test_graph_1 = SimpleGraph(total_household_pop)
# test_graph_2 = SimpleGraph(total_household_pop)
vertex_pointer
=
1
for
household
in
households_composition
num_vertices
=
sum
(
household
)
...
...
@@ -43,22 +41,14 @@ Also returns a vector of AgentDemographic representing each agent, defined by th
@inbounds
population_list
[
vertex_pointer
+
household_pointer
:
vertex_pointer
+
household_pointer
+
size
-
1
]
.=
AgentDemographic
(
k
)
household_pointer
+=
size
end
for
v
in
vertex_pointer
:
(
vertex_pointer
+
num_vertices
-
1
),
w
in
vertex_pointer
:
(
vertex_pointer
+
num_vertices
-
1
)
for
v
in
vertex_pointer
:
(
vertex_pointer
+
num_vertices
-
1
),
w
in
vertex_pointer
:
v
if
v
!=
w
weight
::
UInt8
=
rand
(
Random
.
default_rng
(
Threads
.
threadid
()),
sampler_matrix
[
Int
(
population_list
[
v
]),
Int
(
population_list
[
w
])])
add_edge!
(
wg
,
v
,
w
,
weight
)
# add_edge!(test_graph_1,v,w)
end
end
# for v in vertex_pointer:(vertex_pointer + num_vertices - 1), w in vertex_pointer:(vertex_pointer + num_vertices - 1)
# if v != w
# weight::UInt8 = rand(Random.default_rng(Threads.threadid()),sampler_matrix[Int(population_list[v]),Int(population_list[w])])
# add_edge!(test_graph_2,v,w)
# end
# end
vertex_pointer
+=
num_vertices
end
# display((test_graph.ne,ne(wg)))
return
wg
,
population_list
end
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment