Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature stochastic equations #134

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
7cf332f
Featuring stochastic equations.
Thomalpas Aug 25, 2022
4f2e11a
Add missing dependencies for Stochasticity.
iago-lito Sep 13, 2022
0f709f8
Autoformat test-stochasticity.jl.
iago-lito Sep 13, 2022
efb043a
Run stochasticity tests along with other tests.
iago-lito Sep 13, 2022
b642e3d
🔧 fixing docstest
Thomalpas Sep 14, 2022
31914b6
🔧 Update test after function name changes
Thomalpas Sep 14, 2022
f7e8ba1
🐛 Multiplex now returns empty AddStochasticity, not error
Thomalpas Sep 14, 2022
05bf49b
🔧 Adding stochastic simulate test
Thomalpas Sep 15, 2022
b7561da
🚀 Streamlining AddStochasticity
Thomalpas Sep 20, 2022
b5a5441
🔧 Covariance matrix now tests positive SEMI-definite
Thomalpas Sep 23, 2022
fd42416
🐛 Typo
Thomalpas Sep 23, 2022
87146e5
🐛 Fix stochasticity when added to consumers
Thomalpas Oct 6, 2022
872bc39
Bye bye extra space 🪐☄️👽🛰
Thomalpas Oct 7, 2022
6af1000
Autoformatter pass.
iago-lito Oct 7, 2022
ff783b8
🐛 Make the ExtinctionCallback callback ignore the parameter equations
Thomalpas Dec 16, 2022
045ee59
re-implement linear stressor on growth rate
Thomalpas May 22, 2023
7e299b6
Adding weighting to stressor ✨
Thomalpas Aug 4, 2023
142da39
Fix the Stressor display 🐛
Thomalpas Aug 14, 2023
51a00ea
adding allee effects for my next chapter
Thomalpas Feb 15, 2024
8b405c7
making allee effect deterministic too
Thomalpas Feb 27, 2024
d3a8042
export predators function
Thomalpas Mar 11, 2024
d57165e
modify stressor object
Thomalpas Jul 11, 2024
86cc7cf
implement the changes to stressor
Thomalpas Jul 11, 2024
ab7b776
modify tidy_output
Thomalpas Jul 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ authors = ["Eva Delmas <[email protected]>"]
version = "0.1.0"

[deps]
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Decimals = "abce61dc-4473-55a0-ba07-351d65e31d42"
DiffEqBase = "2b5f629d-d688-5b77-993f-72d75c75574e"
DiffEqCallbacks = "459566f4-90b8-5000-8ac3-15dfb0a30def"
DifferentialEquations = "0c46a032-eb83-5123-abaf-570d42b7fbaa"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
EcologicalNetworks = "f03a62fe-f8ab-5b77-a061-bb599b765229"
FiniteDiff = "6a86dc24-6348-571c-b903-95158fe2bd41"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Mangal = "b8b640a6-63d9-51e6-b784-5033db27bef2"
OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
15 changes: 14 additions & 1 deletion src/BEFWM2.jl
Original file line number Diff line number Diff line change
@@ -1,30 +1,38 @@
module BEFWM2

# Dependencies
import DifferentialEquations.CorrelatedWienerProcess
import DifferentialEquations.Rodas4
import DifferentialEquations.SSRootfind
import DifferentialEquations.Tsit5
using DataFrames
using DiffEqBase
using DiffEqCallbacks
using EcologicalNetworks
using FiniteDiff
using LinearAlgebra
using Mangal
using OrderedCollections
using SparseArrays
using Statistics
using Decimals

using StatsBase

# Include scripts
include(joinpath(".", "macros.jl"))
include(joinpath(".", "inputs/foodwebs.jl"))
include(joinpath(".", "inputs/nontrophic_interactions.jl"))
include(joinpath(".", "inputs/functional_response.jl"))
include(joinpath(".", "inputs/biological_rates.jl"))
include(joinpath(".", "inputs/stochasticity.jl"))
include(joinpath(".", "inputs/stressor.jl"))
include(joinpath(".", "inputs/allee_effect.jl"))
include(joinpath(".", "inputs/environment.jl"))
include(joinpath(".", "inputs/producer_competition.jl"))
include(joinpath(".", "model/model_parameters.jl"))
include(joinpath(".", "model/productivity.jl"))
include(joinpath(".", "model/consumption.jl"))
include(joinpath(".", "model/covariance_matrix.jl"))
include(joinpath(".", "model/metabolic_loss.jl"))
include(joinpath(".", "model/dbdt.jl"))
include(joinpath(".", "model/generate_dbdt.jl"))
Expand All @@ -47,6 +55,8 @@ export A_competition_full
export A_facilitation_full
export A_interference_full
export A_refuge_full
export AddStochasticity
export AlleeEffect
export allometric_rate
export AllometricParams
export attack_rate
Expand Down Expand Up @@ -99,6 +109,7 @@ export potential_competition_links
export potential_facilitation_links
export potential_interference_links
export potential_refuge_links
export predators
export predators_of
export preys_of
export producer_growth
Expand All @@ -108,6 +119,8 @@ export richness
export simulate
export species_persistence
export species_richness
export Stressor
export tidy_output
export total_biomass
export trophic_levels

Expand Down
62 changes: 62 additions & 0 deletions src/inputs/allee_effect.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#=
AlleeEffect
=#

#### Type definiton ####
mutable struct AlleeEffect
addallee::Bool
target::Symbol
μ::Real
β::Real
exponent::Real
end
#### end ####

#### Type display ####
"""
One line [`AlleeEffect`](@ref) display.
"""
function Base.show(io::IO, allee_effect::AlleeEffect)
if allee_effect.addallee == true
print(io, "AlleeEffect(addallee, target, μ, β, exponent)")
else
print(io, "Allee effects not added")
end
end

"""
Multiline [`AlleeEffect`](@ref) display.
"""
function Base.show(io::IO, ::MIME"text/plain", allee_effect::AlleeEffect)
if allee_effect.addallee == true
addallee = allee_effect.addallee
target = allee_effect.target
mu = allee_effect.μ
beta = allee_effect.β
exponent = allee_effect.exponent

println(io, "AlleeEffect:")
println(io, " addallee: $addallee")
println(io, " target: $target")
println(io, " μ: $mu")
println(io, " β: $beta")
println(io, " exponent: $exponent")

else
println(io, "AlleeEffect:")
print(io, " Allee effects not added")
end
end
#### end ####

"""
Literally all I need here is a switch and some values:
"""

function AlleeEffect(fw::EcologicalNetwork; addallee::Bool = false, target = :x, μ::Real = 0, β::Real = 0, exponent::Real = 0)

target ∈ [:x, :e] ||
throw(ArgumentError("Invalid 'target': should be :x or :e."))
AlleeEffect(addallee, target, μ, β, exponent)

end
2 changes: 1 addition & 1 deletion src/inputs/biological_rates.jl
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ BioRates:
"""
function BioRates(
network::EcologicalNetwork;
d::Union{Vector{<:Real},<:Real} = allometric_rate(network, DefaultMortalityParams()),
d::Union{Vector{<:Real},<:Real} = zeros(richness(network)),
r::Union{Vector{<:Real},<:Real} = allometric_rate(network, DefaultGrowthParams()),
x::Union{Vector{<:Real},<:Real} = allometric_rate(network, DefaultMetabolismParams()),
y::Union{Vector{<:Real},<:Real} = allometric_rate(
Expand Down
Loading