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
407 stars 57 forks source link

Improved documentation #225

Open GlenHenshaw opened 3 years ago

GlenHenshaw commented 3 years ago

In the older version there was a discrete example that showed how to derive and solve the DiscreteProblem identified from data -- one called DMD() on the result of solve. This no longer works in the new version, and the documentation does not provide a barebones example of how to use DifferentialEquations.jl to solve the approximate discrete system. I'm a newbie and the learning curve for this seems steeper than it should be.

AlCap23 commented 3 years ago

I am sorry if I lost information in the progress. The change to v0.6.0 is breaking, so the interface changed highly and until v1.0 should not be considered stable. DMD is described in this chapter.

The results for generators can be simulated like the SINDy results, the DiscreteSystem is not yet implemented. However, all results and AbstractBasis ( also Koopman) structs are callable. So you can just use something along the lines of

result = solve(datadrivenprob, DMD())
ps = parameters(result)
prob = DiscreteProblem(result, u0, tspan, ps)
sol = solve(prob, FunctionMap())

I will add this later :+1:

ChrisRackauckas commented 3 years ago

A is not documented in sparse_regression!

GlenHenshaw commented 3 years ago

The above doesn't work:

julia> prob = DiscreteProblem(res, u0, tspan, ps)
ERROR: MethodError: no method matching DiscreteProblem(::DataDrivenSolution{Koopman{LinearAlgebra.Eigen{ComplexF64, ComplexF64, Matrix{ComplexF64}, Vector{ComplexF64}}, Matrix{Float64}, Matrix{Float64}, Matrix{Float64}}, Vector{Float64}, NamedTuple{(:Problem, :Basis), Tuple{DataDrivenProblem{Float64}, Basis}}, DMDSVD{Float64}, Matrix{Float64}, NamedTuple{(:Error, :AICC, :Errors, :AICCs), Tuple{Float64, Float64, Vector{Float64}, Vector{Float64}}}}, ::Vector{Int64}, ::Tuple{Float64, Float64}, ::Vector{Float64})
Closest candidates are:
  DiscreteProblem(::SciMLBase.AbstractDiscreteFunction, ::Any, ::Tuple, ::Any; kwargs...) at /Users/glenhenshaw/.julia/packages/SciMLBase/grNUR/src/problems/discrete_problems.jl:54
  DiscreteProblem(::Union{Function, Type}, ::Any, ::Tuple, ::Any; kwargs...) at /Users/glenhenshaw/.julia/packages/SciMLBase/grNUR/src/problems/discrete_problems.jl:58
  DiscreteProblem(::JumpSystem, ::Any, ::Union{Nothing, Tuple}, ::Any; kwargs...) at /Users/glenhenshaw/.julia/packages/ModelingToolkit/C24vs/src/systems/jumps/jumpsystem.jl:208
  ...
Stacktrace:
 [1] top-level scope
   @ REPL[16]:1

What does work is this:

system = result(res)
prob = DiscreteProblem((u, p, t)->system(u, ps, t), u0, tspan)
AlCap23 commented 3 years ago

A is not documented in sparse_regression!

Via #233