Hi All,
I want to use “DiffEqFlux.sciml_train” to get parameters after using “ModelingToolkit.structural_simplify”. I’m able to get a reasonable result but have a weird warning:
Warning: Warning: Unrecognized keyword arguments found. Future versions will error.
│ The only allowed keyword arguments to `solve` are:
│ (:dense, :saveat, :save_idxs, :tstops, :d_discontinuities, :save_everystep, :save_on, :save_start, :save_end, :initialize_save, :adaptive, :abstol, :reltol, :dt, :dtmax, :dtmin, :force_dtmin, :internalnorm, :controller, :gamma, :beta1, :beta2, :qmax, :qmin, :qsteady_min, :qsteady_max, :qoldinit, :failfactor, :calck, :alias_u0, :maxiters, :callback, :isoutofdomain, :unstable_check, :verbose, :merge_callbacks, :progress, :progress_steps, :progress_name, :progress_message, :timeseries_errors, :dense_errors, :calculate_errors, :initializealg, :alg, :save_noise, :delta, :seed, :alg_hints, :kwargshandle, :trajectories, :batch_size, :sensealg, :advance_to_tstop, :stop_at_next_tstop, :default_set, :second_time)
│ See https://diffeq.sciml.ai/stable/basics/common_solver_opts/ for more details.
│
│ Set kwargshandle=KeywordArgError for an error message and more details.
│ Set kwargshandle=KeywordArgSilent to ignore this message.
└ @ DiffEqBase C:\Users\mzhen\.julia\packages\DiffEqBase\U3LtB\src\solve.jl:213
The code:
using ModelingToolkit, DifferentialEquations, DiffEqFlux, Plots
using DataFrames, Plots, CSV, Statistics, Zygote
df_obs = DataFrame(CSV.File("data/res5.csv"))
t_save = df_obs.time
obs = Array(df_obs[!, [2:8;]])
tspan = (t_save[1], last(t_save))
@parameters param_c1 param_c2 param_c3 param_c4 param_c5 param_l1 param_l2
@variables t x[1:7](t) z[1:5](t)
D = Differential(t)
u0 = [x[1] => 0.0,
x[2] => 0.0,
x[3] => 0.0,
x[4] => 0.0,
x[5] => 0.0,
x[6] => 0.0,
x[7] => 0.0,
z[1] => 0.82,
z[2] => 0.179,
z[3] => 0.315,
z[4] => 0.0336,
z[5] => 0.0336]
eqs = [
D(x[1]) ~ z[1] / param_c1,
D(x[2]) ~ z[2] / param_c2,
D(x[3]) ~ z[3] / param_c3,
D(x[4]) ~ z[4] / param_c4,
D(x[5]) ~ z[5] / param_c5,
D(x[6]) ~ x[2] / param_l1,
D(x[7]) ~ x[4] / param_l2,
0 ~ z[3] + z[4] + x[7] - z[2] - x[6],
0 ~ x[1] - x[3] - x[2],
0 ~ x[3] - x[5] - x[4],
0 ~ z[1] + z[2] + x[6] - 1.0 + x[1],
0 ~ z[4] + x[7] - z[5] - x[5]
]
@named sys = ODESystem(eqs)
sys_low = dae_index_lowering(sys)
simpsys = structural_simplify(sys_low)
params = [param_c1 => 1.0, param_c2 => 1.0, param_c3 => 1.0,
param_c4 => 1.0, param_c5 => 1.0, param_l1 => 1.0, param_l2 => 1.0]
p_init = [x.second for x in params]
prob = ODAEProblem(simpsys, u0, tspan, params, jac=true)
loss = function(p)
pred_sol = solve(prob, Tsit5(), p=p, saveat=t_save)
pred = Array(pred_sol')
mse = mean((pred - obs).^2)
return mse
end
callback = function (p, l)
println(l, " ", p)
return false
end
result = DiffEqFlux.sciml_train(loss, p_init, ADAM(0.1), cb = callback, maxiters = 100)
Any idea how to fix it?
Thanks!