Skip to content

Commit 2530cad

Browse files
Automatic build\nPublished by build of: SciML/SciMLBenchmarks.jl@3faddf0
1 parent 55b98b4 commit 2530cad

12 files changed

Lines changed: 1695 additions & 1270 deletions

markdown/ParameterEstimation/FitzHughNagumoParameterEstimation.md

Lines changed: 544 additions & 417 deletions
Large diffs are not rendered by default.

markdown/ParameterEstimation/LorenzParameterEstimation.md

Lines changed: 531 additions & 396 deletions
Large diffs are not rendered by default.

markdown/ParameterEstimation/LotkaVolterraParameterEstimation.md

Lines changed: 547 additions & 431 deletions
Large diffs are not rendered by default.
-3.64 KB
Loading
11.2 KB
Loading
-10.5 KB
Loading
-136 KB
Loading
-7.29 KB
Loading
-35.4 KB
Loading

script/ParameterEstimation/FitzHughNagumoParameterEstimation.jl

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
using ParameterizedFunctions, OrdinaryDiffEq, DiffEqParamEstim, Optimization
33
using OptimizationBBO, OptimizationNLopt, ForwardDiff, Plots, BenchmarkTools
4+
using ModelingToolkit: t_nounits as t, D_nounits as D
45
gr(fmt=:png)
56

67

@@ -10,10 +11,24 @@ loc_init = [0.5,0.5,0.5,0.5]
1011
glo_init = [2.5,2.5,2.5,2.5]
1112

1213

13-
fitz = @ode_def FitzhughNagumo begin
14-
dv = v - v^3/3 -w + l
15-
dw = τinv*(v + a - b*w)
16-
end a b τinv l
14+
@mtkmodel FitzHughNagumo begin
15+
@parameters begin
16+
a = 0.7 # Parameter for excitability
17+
b = 0.8 # Recovery rate parameter
18+
τinv = 0.08 # Inverse of the time constant
19+
l = 0.5 # External stimulus
20+
end
21+
@variables begin
22+
v(t) = 1.0 # Membrane potential with initial condition
23+
w(t) = 1.0 # Recovery variable with initial condition
24+
end
25+
@equations begin
26+
D(v) ~ v - v^3 / 3 - w + l
27+
D(w) ~ τinv * (v + a - b * w)
28+
end
29+
end
30+
31+
@mtkbuild fitz = FitzHughNagumo()
1732

1833

1934
p = [0.7,0.8,0.08,0.5] # Parameters used to construct the dataset
@@ -27,7 +42,7 @@ prob_short = ODEProblem(fitz, r0, tspan2,p)
2742
dt = 30.0/3000
2843
tf = 30.0
2944
tinterval = 0:dt:tf
30-
t = collect(tinterval)
45+
time_points = collect(tinterval)
3146

3247

3348
h = 0.01
@@ -41,7 +56,7 @@ t_short = collect(tinterval_short)
4156
#Generate Data
4257
data_sol_short = solve(prob_short,Vern9(),saveat=t_short,reltol=1e-9,abstol=1e-9)
4358
data_short = convert(Array, data_sol_short) # This operation produces column major dataset obs as columns, equations as rows
44-
data_sol = solve(prob,Vern9(),saveat=t,reltol=1e-9,abstol=1e-9)
59+
data_sol = solve(prob,Vern9(),saveat=time_points,reltol=1e-9,abstol=1e-9)
4560
data = convert(Array, data_sol)
4661

4762

@@ -125,7 +140,7 @@ opt = Opt(:LD_MMA, 4)
125140
@btime res1 = solve(optprob, opt, maxiters = 10000, xtol_rel = 1e-12)
126141

127142

128-
obj = build_loss_objective(prob,Vern9(),L2Loss(t,data),Optimization.AutoForwardDiff(),tstops=t,reltol=1e-9,abstol=1e-9)
143+
obj = build_loss_objective(prob,Vern9(),L2Loss(time_points,data),Optimization.AutoForwardDiff(),tstops=time_points,reltol=1e-9,abstol=1e-9)
129144
optprob = OptimizationProblem(obj, glo_init, lb = first.(glo_bounds), ub = last.(glo_bounds))
130145
@btime res1 = solve(optprob, BBO_adaptive_de_rand_1_bin(), maxiters = 4e3)
131146

0 commit comments

Comments
 (0)