Skip to content

Commit 74c932c

Browse files
update diffeqparamestim
1 parent 47ea61c commit 74c932c

File tree

3 files changed

+17
-16
lines changed

3 files changed

+17
-16
lines changed

src/cost_functions.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ function (f::L2Loss)(sol::DiffEqBase.DESolution)
3939
colloc_grad = f.colloc_grad
4040
dudt = f.dudt
4141

42-
if sol_tmp isa DiffEqBase.AbstractEnsembleSolution
43-
failure = any((s.retcode != :Success for s in sol_tmp)) && any((s.retcode != :Terminated for s in sol_tmp))
42+
if sol isa DiffEqBase.AbstractEnsembleSolution
43+
failure = any((s.retcode != :Success for s in sol)) && any((s.retcode != :Terminated for s in sol))
4444
else
45-
failure = sol_tmp.retcode != :Success && sol_tmp != :Terminated
45+
failure = sol.retcode != :Success && sol != :Terminated
4646
end
4747
failure && return Inf
4848

test/lorenz_test.jl

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
using DifferentialEquations, RecursiveArrayTools
2-
using NLopt
1+
using DifferentialEquations, RecursiveArrayTools, ParameterizedFunctions
2+
using NLopt, DiffEqParamEstim, BlackBoxOptim, Optim
33
Xiang2015Bounds = Tuple{Float64, Float64}[(9, 11), (20, 30), (2, 3)]
44

5-
g1 = @ode_def_nohes LorenzExample begin
5+
g1 = @ode_def LorenzExample begin
66
dx = σ*(y-x)
77
dy = x*-z) - y
88
dz = x*y - β*z
9-
end σ=>10.0 ρ=>28.0 β=>2.6666
9+
end σ ρ β
1010

1111
r0 = [0.1;0.0;0.0]
1212
tspan = (0.0,4.0)
13-
prob = ODEProblem(g1,r0,tspan)
13+
p = [10.0,28.0,2.66666]
14+
prob = ODEProblem(g1,r0,tspan,p)
1415
tspan2 = (0.0,3.0)
15-
prob_short = ODEProblem(g1,r0,tspan2)
16+
prob_short = ODEProblem(g1,r0,tspan2,p)
1617

1718
dt = 0.001
1819
tf = 4.0

test/lorenz_true_test.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66
# used. This means that the option which is set to get the correct timepoints
77
# is saveat, not tstops!
88

9-
using DifferentialEquations, RecursiveArrayTools
10-
using NLopt
11-
using BlackBoxOptim
9+
using DifferentialEquations, RecursiveArrayTools, ParameterizedFunctions
10+
using NLopt, DiffEqParamEstim, BlackBoxOptim, Optim
1211

1312
Xiang2015Bounds = Tuple{Float64, Float64}[(9, 11), (20, 30), (2, 3)] # for local optimizations
1413
xlow_bounds = [9.0,20.0,2.0]
@@ -17,17 +16,18 @@ LooserBounds = Tuple{Float64, Float64}[(0, 22), (0, 60), (0, 6)] # for global op
1716
GloIniPar = [0.0, 0.5, 0.1] # for global optimizations
1817
LocIniPar = [9.0, 20.0, 2.0] # for local optimization
1918

20-
g1 = @ode_def_nohes LorenzExample begin
19+
g1 = @ode_def LorenzExample begin
2120
dx = σ*(y-x)
2221
dy = x*-z) - y
2322
dz = x*y - β*z
24-
end σ=>10.0 ρ=>28.0 β=>2.6666
23+
end σ ρ β
2524

2625
r0 = [0.1;0.0;0.0]
2726
tspan = (0.0,30.0)
28-
prob = ODEProblem(g1,r0,tspan)
27+
p = [10.0,28.0,2.66666]
28+
prob = ODEProblem(g1,r0,tspan,p)
2929
tspan2 = (0.0,3.0)
30-
prob_short = ODEProblem(g1,r0,tspan2)
30+
prob_short = ODEProblem(g1,r0,tspan2,p)
3131

3232
dt = 30.0/3000
3333
tf = 30.0

0 commit comments

Comments
 (0)