Comments (4)
Hi Pablo, can you provide a minimal example of what you're trying to solve so that we can have a more specific context?
from neurodiffeq.
If I understand correctly, you are trying to solve ODEs w.r.t. u(t)
involving a time-dependent coefficient (say θ(t)
), where both the solution u(t)
and the coefficient θ(t)
are unknown. This is essentially the same as solving ODEs w.r.t. two unknown functions (u(t), θ(t))
. If this is the case, the Lotka-Volterra equation in the README is a good example.
(If you don't want to enforce any initial condition for θ
, you can put a neurodiffeq.conditions.NoCondition()
instance as a placeholder.
from neurodiffeq.
Hi Shuheng-liu,
Thanks for the quick response. I can provide the systems of ODE that I am trying to solve.
I have a dataset with u and s over time and I was wondering if I could use this package to find the other variables through time. Thanks a lot! any insights would be very valuable.
from neurodiffeq.
Hi Pablo,
Assuming your data is free of noise, you can recover u(t) and s(t) by interpolating discrete data points (ti, ui) and (ti, si).
You can also recover the derivatives du/dt and ds/dt if your interpolant is differentiable (say Lagrangian polynomial).
This way, the problem is essentially solving an ODE system w.r.t. three unkonwn functions alpha(t), beta(t), and gamma(t).
from neurodiffeq import diff
from neurodiffeq.solvers import Solver1D
from neurodiffeq.conditions import NoCondition
import matplotlib.pyplot as plt
u_interp = lambda t: ... # some interpolant function (note: t is a torch.Tensor)
s_interp = lambda t: ... # some interpolant function
def eq(alpha, beta, gamma, t):
u, s = u_interp(t), s_interp(t)
dudt, dsdt = diff(u, t), diff(s, t)
return [
alpha - beta * u - dudt,
beta * u - gamma * s - dsdt,
]
conditions = [
NoCondition(), # no constraint for alpha
NoCondition(), # no constraint for beta
NoCondition(), # no constraint for gamma
]
T_MIN, T_MAX = 0, 1
solver = Solver1D(
eq,
conditions,
t_min=T_MIN,
t_max=T_MAX,
n_batches_valid=1, # [Optional] to speed up computation
)
solver.fit(max_epochs=10)
solution = solver.get_solution(best=True, copy=True)
t = np.linspace(T_MIN, T_MAX, 100)
alpha, beta, gamma = solution(t, to_numpy=True)
plt.plot(t, alpha, label='alpha')
plt.plot(t, beta, label='beta')
plt.plot(t, gamma, label='gamma')
plt.legend()
If you have constraints for alpha, beta, or gamma, you can change the corresponding entry in conditions
to neurodiffeq.conditions.IVP(..., ...)
or neurodiffeq.conditions.DirichletBVP(..., ...)
. See documentation for details.
from neurodiffeq.
Related Issues (20)
- Is there a way to access the train/valid loss history for Solver1D, like for solve? HOT 2
- Using Special type activation function HOT 9
- Finding value of weights HOT 2
- Saving subclass of solvers HOT 1
- TqdmKeyError: "Unknown argument(s): {'colour': 'blue'}" HOT 3
- Publish `neurodiffeq` on `conda-forge`?
- Neumann boundary conditions
- Nonzero Dirichlet boundary conditions HOT 8
- Add tests for solver_utils
- BundleSolver setup too restrictive HOT 1
- Problems :return inspect.signature(optimizer.step).parameters.get('closure').default == inspect._empty AttributeError: 'NoneType' object has no attribute 'default' HOT 2
- Parametric system of ODEs HOT 1
- Bundle Solution for PDEs
- Improve Docs
- Solving system of PDEs/ODEs HOT 1
- Missing eq_param_index when loading BundleSolution HOT 4
- Could we implement the differential equations in symbolic format? HOT 3
- Access to the differential equations of the system.
- Adding the option to use a learning rate schedule during training.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from neurodiffeq.