All Projects → SciML → Datadrivendiffeq.jl

SciML / Datadrivendiffeq.jl

Licence: mit
Data driven modeling and automated discovery of dynamical systems for the SciML Scientific Machine Learning organization

Programming Languages

julia
2034 projects

DataDrivenDiffEq.jl

Build Status Coverage Status codecov.io DOI

DataDrivenDiffEq.jl is a package in the SciML ecosystem for data-driven differential equation structural estimation and identification. These tools include automatically discovering equations from data and using this to simulate perturbed dynamics.

For information on using the package, see the stable documentation. Use the in-development documentation for the version of the documentation which contains the un-released features.

Quick Demonstration

## Generate some data by solving a differential equation
########################################################

using DataDrivenDiffEq
using ModelingToolkit
using OrdinaryDiffEq

using LinearAlgebra
using Plots
gr()

# Create a test problem
function lorenz(u,p,t)
    x, y, z = u
     = 10.0*(y - x)
     = x*(28.0-z) - y
     = x*y - (8/3)*z
    return [, , ]
end

u0 = [-8.0; 7.0; 27.0]
p = [10.0; -10.0; 28.0; -1.0; -1.0; 1.0; -8/3]
tspan = (0.0,100.0)
dt = 0.001
problem = ODEProblem(lorenz,u0,tspan)
solution = solve(problem, Tsit5(), saveat = dt, atol = 1e-7, rtol = 1e-8)

X = Array(solution)
DX = similar(X)
for (i, xi) in enumerate(eachcol(X))
    DX[:,i] = lorenz(xi, [], 0.0)
end

## Now automatically discover the system that generated the data
################################################################

@variables x y z
u = [x; y; z]
polys = Any[]
for i  0:4
    for j  0:i
        for k  0:j
            push!(polys, u[1]^i*u[2]^j*u[3]^k)
            push!(polys, u[2]^i*u[3]^j*u[1]^k)
            push!(polys, u[3]^i*u[1]^j*u[2]^k)
        end
    end
end

basis = Basis(polys, u)

opt = STRRidge(0.1)
Ψ = SINDy(X, DX, basis, opt, maxiter = 100, normalize = true)
print_equations(Ψ)
get_error(Ψ)
3-dimensional basis in ["x", "y", "z"]
dx = p₁ * x + p₂ * y
dy = p₃ * x + p₄ * y + z * x * p₅
dz = p₆ * z + x * y * p₇

# Error
3-element Array{Float64,1}:
 6.7202639134663155e-12
 3.505423292198665e-11
 1.2876598297504605e-11
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].