SciML / DataDrivenDiffEq.jl

Data driven modeling and automated discovery of dynamical systems for the SciML Scientific Machine Learning organization
https://docs.sciml.ai/DataDrivenDiffEq/stable/
MIT License
404 stars 57 forks source link

Question reg combing several "experiments" #339

Closed zahachtah closed 2 years ago

zahachtah commented 2 years ago

I am looking at the example "Implicit Nonlinear Dynamics: Michaelis Menten" where data from two "experiments" are combined into one dataseries which is fed into the ContinuousDataDrivenProblem.

How does the jump between the end of experiment 1 and start of experiment 2 affect the ability to find the right solution, how is this jump handled? I ask because for some applications I would have in mind, I might have hundreds of experiments but with very short time series. Can one tell the solver about the "jumps" between experiments if they all get appended into one long dataseries? Or is there a better way to handle this? Or does it not matter?

Second question is probably revealing my lack of understanding of implicit methods... :

the example in the documentation (Michaelis Menten) is defined as

function michaelis_menten(u, p, t) [0.6 - 1.5u[1]/(0.3+u[1])] end

but the solution parameters spits out:

[-1.0 5.0 1.7 5.6]

Why are the parameters so different?

AlCap23 commented 2 years ago

I have been working on this literally today and will open up a PR introducing DataDrivenDataSets 😅 .

Yes it matters and is disturbing 👍

AlCap23 commented 2 years ago

Since my quick answer is not that well explaining:

The problem with the data of multiple experiments is, as you rightfully pointed out, in the discontinuities. For the identification algorithms, this does not lead to misbehaviour, since every datapoint still behaves well ( at least for a continuous or direct problem). What I mean by this is that every target is a function of the current time point ( so dx(t_m) = f(x(t_m)) ... ). However, for the collocation this introduces error due to the jumps in the state trajectory. This is taken care of in the Dataset now.

The implicit method searches for equations of the form g(dx, x) = f(dx, x). Hence, it can also find alphag(dx, x) = alphaf(dx, x) for any scaling alpha. Using the example from the docs, if I do

p ./ 5.0 .* 1.5
1×4 Matrix{Float64}:
 -0.3  1.5  0.51  1.68

which is pretty close and a little off due to the relatively scarce data and the rounding of the output.

zahachtah commented 2 years ago

Hey, that is amazing, thanks for the update! Does the many-experiment just work now or do I need to tell the solver where the jumps are? What is the PR btw, would be interested to see how it's implemented!

And thanks for the explanation of the implicit method, I understand better now!