Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
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
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
11 deletions
+1
-11
CovidAlertVaccinationModel/src/ABM/agents.jl
CovidAlertVaccinationModel/src/ABM/agents.jl
+1
-11
No files found.
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
Markdown
is supported
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