I was wondering what is most efficient and issue free way to create random positions for agents.
At the moment Im using this where sides = [1e3, 1e2, 5e2]
positions = [sides .* rand(SVector{3,Float64}) for _ in 1:number_of_particles]
which works but sometimes throw this error when I try to run model
julia> adf, mdf = run!(model, step_point; adata = [:vel, :pos], mdata = [:count], init = true, when = (model, t) -> true, showprogress = false)
ERROR: Tried to remove agent with ID 66 from the space, but that agent is not on the space
Stacktrace:
[1] error(s::LazyString)
@ Base ./error.jl:35
[2] remove_agent_from_space!
@ ~/.julia/packages/Agents/dTr7O/src/spaces/continuous.jl:143 [inlined]
[3] move_agent!(agent::CELL, pos::SVector{…}, model::StandardABM{…})
@ Agents ~/.julia/packages/Agents/dTr7O/src/spaces/continuous.jl:157
[4] walk!
@ ~/.julia/packages/Agents/dTr7O/src/spaces/walk.jl:64 [inlined]
[5] move_agent!
@ ~/.julia/packages/Agents/dTr7O/src/spaces/continuous.jl:187 [inlined]
[6] agent_step!(agent::CELL, model::StandardABM{…})
@ Main ~/PhD/Program_Julia/code/abm_vs_prob_test_eqidistance.jl:211
[7] step_ahead!(model::StandardABM{…}, agent_step!::typeof(agent_step!), model_step!::typeof(model_step!), n::Int64, t::Base.RefValue{…})
@ Agents ~/.julia/packages/Agents/dTr7O/src/simulations/step_standard.jl:17
[8] step!
@ ~/.julia/packages/Agents/dTr7O/src/simulations/step_standard.jl:5 [inlined]
[9] _run!(model::StandardABM{…}, df_agent::DataFrame, df_model::DataFrame, n::Float64, when::Function, when_model::Function, mdata::Vector{…}, adata::Vector{…}, obtainer::typeof(identity), dt::Int64, p::ProgressUnknown)
@ Agents ~/.julia/packages/Agents/dTr7O/src/simulations/collect.jl:166
[10] run!(model::StandardABM{…}, n::Float64; when::Function, when_model::Function, mdata::Vector{…}, adata::Vector{…}, obtainer::Function, showprogress::Bool, init::Bool, dt::Float64)
@ Agents ~/.julia/packages/Agents/dTr7O/src/simulations/collect.jl:148
[11] top-level scope
@ ~/PhD/Program_Julia/code/abm_vs_prob_test_eqidistance.jl:269
Some type information was truncated. Use `show(err)` to see complete types.
Although based on position output seems agent is in space.
julia> model[66].pos
3-element SVector{3, Float64} with indices SOneTo(3):
599.9812375700334
62.84457279233983
486.74628139637053