-
-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Labels
bugSomething isn't workingSomething isn't working
Description
MWE. To remake, we get an error when supplying both u0 and p. Separately, it works fine. Think it is a SII problem, just using normal parameter vectors things work fine. Not sure if this is fundamenetally a ModelingToolkitNeuralNets problem. I was trying to reproduce in normal MTK and things works fine initially, but might be some finer point relating to vecotr parameters or something. @AayushSabharwal probably worth having a look at.
using ModelingToolkit
using ModelingToolkit: t_nounits as t, D_nounits as D
@variables X(t) Y(t)
@parameters v=1.0 K=1.0 n=1.0 d=1.0 # Sets unused default values for all parameters (but vaguely useful as potential optimization initial conditions).
using Lux
nn_arch = Lux.Chain(
Lux.Dense(1 => 3, Lux.softplus, use_bias = false),
Lux.Dense(3 => 3, Lux.softplus, use_bias = false),
Lux.Dense(3 => 1, Lux.softplus, use_bias = false)
)
using ModelingToolkitNeuralNets
sym_nn,
θ = SymbolicNeuralNetwork(; nn_p_name = :θ, chain = nn_arch, n_input = 1, n_output = 1)
sym_nn_func(x) = sym_nn([x], θ)[1]
eqs_ude = [D(X) ~ sym_nn_func(Y) - d*X
D(Y) ~ X - d*Y]
@mtkcompile xy_model_ude = System(eqs_ude, t)
u0 = [X => 2.0, Y => 0.1]
ps_true = [v => 1.1, K => 2.0, n => 3.0, d => 0.5]
oprob_base = ODEProblem(xy_model_ude, u0, (0.0, 1.0))
using SymbolicIndexingInterface: setp_oop
set_ps = setp_oop(oprob_base, [d; θ])
p = set_ps(oprob_base, [1.0; oprob_base.ps[:θ]])
using OrdinaryDiffEqDefault
@time remake(oprob_base; p) # Fine
@time remake(oprob_base; u0 = [X => 2.0, Y => 0.1]) # Fine
@time remake(oprob_base; p, u0 = [X => 2.0, Y => 0.1]) # ERROR: BoundsError: attempt to access 1-element Vector{M
@time remake(oprob_base; p = [d => 1.0], u0 = [X => 2.0, Y => 0.1]) # FineI should note that I also have a problem with a really heavy perofrmance hit when updating u0 in remake here as well, but I have not been able to get a good MWE yet. But if anyone might recognise something like that, it would be useful to know.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working