@@ -49,10 +49,10 @@ function dudt_(u, p,t)
49
49
end
50
50
51
51
prob_nn = ODEProblem (dudt_,u0, tspan, p)
52
- s = concrete_solve (prob_nn, Tsit5 (), u0, p, saveat = solution. t)
52
+ s = solve (prob_nn, Tsit5 (), u0 = u0, p = p, saveat = solution. t)
53
53
54
54
function predict (θ)
55
- Array (concrete_solve (prob_nn, Vern7 (), u0, θ, saveat = solution. t,
55
+ Array (solve (prob_nn, Vern7 (), u0 = u0, p = θ, saveat = solution. t,
56
56
abstol= 1e-6 , reltol= 1e-6 ))
57
57
end
58
58
@@ -119,19 +119,10 @@ opt = SR3()
119
119
# Create the thresholds which should be used in the search process
120
120
λ = exp10 .(- 10 : 0.05 : - 0.5 )
121
121
# Target function to choose the results from; x = L0 of coefficients and L2-Error of the model
122
- function eval_target (x)
123
- y = similar (x)
124
- if iszero (x[1 ])
125
- y[1 ] = convert (eltype (x), Inf )
126
- end
127
- y[2 ] = x[2 ]
128
- return y
129
- end
130
-
131
- alg = GoalProgramming (x-> norm (x, 2 ), eval_target)
122
+ g (x) = x[1 ] < 1 ? Inf : norm (x, 2 )
132
123
@info " Start SINDy regression with unknown threshold"
133
124
# Test on uode derivative data
134
- Ψ = SINDy (X[:, 2 : end ], Y[:, 2 : end ], basis, λ, opt = opt , maxiter = 10000 , normalize = true , denoise = true , alg = alg ) # Succeed
125
+ Ψ = SINDy (X[:, 2 : end ], Y[:, 2 : end ], basis, λ, opt, g = g , maxiter = 10000 , normalize = true , denoise = true ) # Succeed
135
126
p̂ = parameters (Ψ)
136
127
@info " Build initial guess system"
137
128
# The parameters are a bit off, so we reiterate another SINDy term to get closer to the ground truth
@@ -142,7 +133,7 @@ unknown_eq = ODEFunction(unknown_sys)
142
133
b = Basis ((u, p, t)-> unknown_eq (u, ones (size (p̂)), t), u)
143
134
# Test on uode derivative data
144
135
@info " Refine the guess"
145
- Ψ = SINDy (X[:, 2 : end ], Y[:, 2 : end ],b, opt = SR3 (0.1 ), maxiter = 1000 ) # Succeed
136
+ Ψ = SINDy (X[:, 2 : end ], Y[:, 2 : end ],b, SR3 (0.1 ), maxiter = 1000 ) # Succeed
146
137
p̂ = parameters (Ψ)
147
138
148
139
@info " Checking equations"
162
153
unknown_sys = ODESystem (Ψ)
163
154
unknown_eq = ODEFunction (unknown_sys)
164
155
165
-
166
156
# Build a ODE for the estimated system
167
157
function approx (du, u, p, t)
168
158
# Add SINDy Term
0 commit comments