using Pkg
Pkg.activate(".")
Activating project at `~/Desktop/MyProjects/Julia_Tutorial_on_AI4MathBiology`
More details can be seen in
Getting Started with Differential Equations in Julia · DifferentialEquations.jl
using Pkg
Pkg.activate(".")
Activating project at `~/Desktop/MyProjects/Julia_Tutorial_on_AI4MathBiology`
Actually, you can also use Cursor - The AI-first Code Editor (VSCode with ChatGPT embedded.)
using DifferentialEquations
function sir!(du,u,p,t)
= u
S,I,R = p
β,γ 1] = -β*S*I
du[2] = β*S*I-γ*I
du[3] = γ*I
du[end
= [0.1,0.05]
parms = [0.99,0.01,0.0]
initialvalue = (0.0,200.0)
tspan = ODEProblem(sir!,initialvalue,tspan,parms)
sir_prob = solve(sir_prob,saveat = 0.1); sir_sol
In Julia, we use Plots.jl
or Makie.jl
or TidierPlots.jl
(similar to ggplot2
)
using Plots
plot(sir_sol)
Solving the following differential equations with neural networks embedded \[ \left\{ \begin{aligned} & \frac{\mathrm{d}S}{\mathrm{dt}} = - \mathrm{NN}(I) S , \\ & \frac{\mathrm{d}I}{\mathrm{dt}} = \mathrm{NN}(I) S- \gamma I, \end{aligned} \right. \]
using DifferentialEquations
using Flux
using Plots
= Flux.Chain(Flux.Dense(1, 64, tanh), Flux.Dense(64, 1))
ann_node = Flux.destructure(ann_node) # destructure
para, re function SIR_nn(du,u,p,t)
= u
S, I 1] = - S*re(p)([I])[1]
du[2] = S*re(p)([I])[1] - 0.1*I
du[end
= Float32.([0.99,0.01])
initialvalue = (0.0f0,200.0f0)
tspan = ODEProblem(SIR_nn, initialvalue, tspan, para)
prob_nn =solve(prob_nn)
sol_nnplot(sol_nn)