UniversalDifferentialEquation<T>
Models & Types · AiDotNet.PhysicsInformed.ScientificML
Implements Universal Differential Equations (UDEs) - ODEs with neural network components.
Inheritance: NeuralNetworkBase<T> → UniversalDifferentialEquation<T>
How It Works
For Beginners: Universal Differential Equations combine known physics with machine learning.
Traditional ODEs: dx/dt = f(x, t, θ) where f is a known function with parameters θ Example: dx/dt = -kx (exponential decay, k is known)
Pure Neural ODEs: dx/dt = NN(x, t, θ) where NN is a neural network
- Very flexible, can learn any dynamics
- But ignores known physics
- May violate physical laws
Universal Differential Equations (UDEs): dx/dt = f_known(x, t) + NN(x, t, θ)
- Combines known physics (f_known) with learned corrections (NN)
- Best of both worlds!
Key Idea: Use neural networks to model UNKNOWN parts of the physics while keeping KNOWN parts as explicit equations.
Example - Epidemic Model: Known: dS/dt = -βSI, dI/dt = βSI - γI (basic SIR model) Unknown: How β (infection rate) varies with temperature, policy, etc. UDE: dS/dt = -β(T, P)SI where β(T, P) = NN(temperature, policy)
Applications:
- Climate modeling (known physics + unknown feedback loops)
- Epidemiology (known disease spread + unknown interventions)
- Chemistry (known reactions + unknown catalysis effects)
- Biology (known population dynamics + unknown environmental factors)
- Engineering (known mechanics + unknown friction/damping)
Example
var ude = new UniversalDifferentialEquation<float>();
Constructors
| Constructor | Summary |
|---|---|
UniversalDifferentialEquation() |
|
UniversalDifferentialEquation(NeuralNetworkArchitecture<T> architecture, int stateDim, Func<T[], T, T[]> knownDynamics, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> optimizer, UniversalDifferentialEquationsOptions options) |
Initializes a new instance of the UniversalDifferentialEquation with the specified architecture. |
Properties
| Property | Summary |
|---|---|
bool SupportsTraining { get; } |
Serializes UDE-specific data. |
Methods
| Method | Summary |
|---|---|
ModelMetadata<T> GetModelMetadata() |
Gets metadata about the UDE model. |
T[] ComputeDerivative(T[] state, T time) |
Computes dx/dt = f_known(x, t) + NN(x, t). |
Tensor<T> Forward(Tensor<T> input) |
Performs a forward pass through the network. |
Tensor<T> Simulate(T[] initialState, T tStart, T tEnd, int numSteps, OdeIntegrationMethod method) |
Simulates the UDE forward in time. |