Giter Site home page Giter Site logo

mkg33 / datadrivendiffeq.jl Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sciml/datadrivendiffeq.jl

0.0 0.0 0.0 3.71 MB

A simple package for data driven modeling of dynamical systems

Home Page: https://datadriven.sciml.ai/dev/

License: MIT License

Julia 100.00%

datadrivendiffeq.jl's Introduction

DataDrivenDiffEq.jl

Build Status Build status Coverage Status codecov.io

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 = Operation[x; y; z]
polys = Operation[]
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, maxiter = 100, opt = opt, 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

datadrivendiffeq.jl's People

Contributors

alcap23 avatar asinghvi17 avatar chrisrackauckas avatar gabrevaya avatar github-actions[bot] avatar juliatagbot avatar kanav99 avatar mkg33 avatar shashi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.