Skip to content

Commit

Permalink
new @agent syntax and ABM subtyping
Browse files Browse the repository at this point in the history
  • Loading branch information
mastrof committed Oct 14, 2023
1 parent 4527041 commit 17a66d7
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/chemotaxis/brown-berg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Default parameters:
- `receptor_binding_constant = 100` μM
- `memory = 1` s
"""
@agent BrownBerg{D} ContinuousAgent{D,Float64} where D AbstractMicrobe{D} begin
@agent struct BrownBerg{D}(ContinuousAgent{D,Float64}) <: AbstractMicrobe{D}
speed::Float64
motility::AbstractMotility = RunTumble()
turn_rate::Float64 = 1 / 0.67
Expand Down
2 changes: 1 addition & 1 deletion src/chemotaxis/brumley.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Default parameters:
- `chemotactic_precision = 6.0` → 'Π'
- `radius = 0.5` μm → 'a'
"""
@agent Brumley{D} ContinuousAgent{D,Float64} where D AbstractMicrobe{D} begin
@agent struct Brumley{D}(ContinuousAgent{D,Float64}) <: AbstractMicrobe{D}
speed::Float64
motility::AbstractMotility = RunReverseFlick(speed_forward = [46.5])
turn_rate::Float64 = 1 / 0.45
Expand Down
2 changes: 1 addition & 1 deletion src/chemotaxis/celani.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Default parameters:
- `memory = 1` s
- `radius = 0.5` μm
"""
@agent Celani{D} ContinuousAgent{D,Float64} where {D} AbstractMicrobe{D} begin
@agent struct Celani{D}(ContinuousAgent{D,Float64}) <: AbstractMicrobe{D}
speed::Float64
motility::AbstractMotility = RunTumble(speed = [30.0])
turn_rate::Float64 = 1 / 0.67
Expand Down
2 changes: 1 addition & 1 deletion src/chemotaxis/xie.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Default parameters:
- `chemotactic_precision = 0.0`
- `radius = 0.5` μm
"""
@agent Xie{D} ContinuousAgent{D,Float64} where D AbstractMicrobe{D} begin
@agent struct Xie{D}(ContinuousAgent{D,Float64}) <: AbstractMicrobe{D}
speed::Float64
motility::AbstractMotility = RunReverseFlick(speed_forward = [46.5])
turn_rate_forward::Float64 = 2.3
Expand Down
2 changes: 1 addition & 1 deletion src/microbes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Default parameters:
- `vel::SVector{D,Float64}` unit velocity vector
- `speed::Float64` magnitude of the velocity vector
"""
@agent Microbe{D} ContinuousAgent{D,Float64} where D AbstractMicrobe{D} begin
@agent struct Microbe{D}(ContinuousAgent{D,Float64}) <: AbstractMicrobe{D}
speed::Float64
motility::AbstractMotility = RunTumble()
turn_rate::Float64 = 1.0
Expand Down
4 changes: 2 additions & 2 deletions src/model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -171,15 +171,15 @@ in which case the simulations stops when `n` returns true.
- `showprogress = false`
See `Agents.run!` and `Agents.step!` for detailed information.
"""
function Agents.run!(model::AgentBasedModel{S,A}, n = 1;
function Agents.run!(model::AgentBasedModel{S}, n = 1;
when = true,
when_model = when,
adata = nothing,
mdata = nothing,
obtainer = identity,
agents_first = true,
showprogress = false
) where {S<:ContinuousSpace,A<:AbstractMicrobe}
) where {S<:ContinuousSpace}
run!(model, microbe_step!, model.update!, n;
when, when_model,
adata, mdata,
Expand Down
2 changes: 1 addition & 1 deletion src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export random_velocity, random_speed, ChainedFunction, →, distance, distanceve
Generate a random velocity vector with unit norm respecting the
dimensionality of `model`.
"""
function random_velocity(model::AgentBasedModel{S,A}) where {S,D,A<:AbstractMicrobe{D}}
function random_velocity(model::AgentBasedModel{ContinuousSpace{D}}) where D
random_velocity(abmrng(model), D)
end
function random_velocity(rng::AbstractRNG, D::Int)
Expand Down

0 comments on commit 17a66d7

Please sign in to comment.