Skip to content

Commit

Permalink
State dependent rates (#35)
Browse files Browse the repository at this point in the history
* rate functions can be a function of the current state and time

* version bump

* Added backwards compatibility with old method of just time dependent rate function

* Made tagbot run more frequently

* bump documentation julia version

* Fix typo in github actions

* Added install of compose to hopefully get the latest version

* grasping at straws now...
  • Loading branch information
mehalter authored Sep 1, 2020
1 parent ffffd1f commit 9117123
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/TagBot.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: TagBot
on:
schedule:
- cron: 0 0 * * *
- cron: 0 * * * *
jobs:
TagBot:
runs-on: ubuntu-latest
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ jobs:
- name: "Set up Julia"
uses: julia-actions/setup-julia@latest
with:
version: '1.4'
version: '1.5'
- name: "Install system dependencies"
run: |
sudo apt-get update
sudo apt-get install graphviz ttf-dejavu
- name: "Install Julia dependencies"
run: julia --project=docs -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate();'
run: julia --project=docs -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate(); Pkg.update();'
- name: "Build and deploy docs"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Petri"
uuid = "4259d249-1051-49fa-8328-3f8ab9391c33"
authors = ["Micah Halter <[email protected]>", "James Fairbanks <[email protected]>"]
version = "1.1.1"
version = "1.2"

[deps]
AutoHashEquals = "15f4f7f2-30c1-5605-9d31-71845cf9641f"
Expand Down
5 changes: 4 additions & 1 deletion examples/epidemiology.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ Graph(sir)

u0 = LVector(S=990.0, I=10.0, R=0.0)
tspan = (0.0,40.0)
β = LVector(inf=0.5/sum(u0), rec=0.25);
# add a dynamic transition rate for infection
# where the rate of infection decreases over time
# as is dependent on the current state of the system
β = LVector(inf=((u,t)->((3/sum(u))/(t+1))), rec=0.25);

# Petri.jl provides interfaces to StochasticDiffEq.jl, DiffEqJump.jl, and
# OrdinaryDiffEq.jl Here, we call the `JumpProblem` function that returns an
Expand Down
6 changes: 3 additions & 3 deletions src/solvers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import StochasticDiffEq: SDEProblem
import DiffEqJump: JumpProblem

funcindex!(list, key, f, vals...) = list[key] = f(list[key],vals...)
valueat(x::Number, t) = x
valueat(f::Function, t) = f(t)
valueat(x::Number, u, t) = x
valueat(f::Function, u, t) = try f(u,t) catch e f(t) end
transitionrate(S, T, k, rate, t) = exp(reduce((x,y)->x+log(S[y] <= 0 ? 0 : S[y]),
keys(first(T[k]));
init=log(valueat(rate[k],t))))
init=log(valueat(rate[k],S,t))))

""" vectorfield(m::Model)
Expand Down

2 comments on commit 9117123

@mehalter
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/20609

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.2.0 -m "<description of version>" 91171231dc3193d18fd4273474ca969b542f8ae0
git push origin v1.2.0

Please sign in to comment.