Base Solver¶
Abstract base classes for ODE and SDE solvers.
base_solver
¶
Base Solver Abstract Class
Defines the interface for all ODE/SDE solvers in FlowPDE.
BaseSolver
¶
Bases: ABC
Abstract base class for ODE solvers.
This defines the common interface for numerical integration methods used to solve differential equations in normalizing flows.
Solvers can be: - Fixed-step (e.g., Euler, RK4) - Adaptive step-size (e.g., Dopri5, Dopri8) - Stochastic (SDE solvers) (Future work)
Source code in flowpde/core/base_solver.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | |
is_adaptive
abstractmethod
property
¶
Whether this is an adaptive step-size solver.
supports_adjoint
property
¶
Whether this solver supports adjoint method for backprop.
__init__(rtol=1e-05, atol=1e-07, method_options=None, **kwargs)
¶
Initialize solver.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rtol
|
float
|
Relative tolerance for adaptive solvers |
1e-05
|
atol
|
float
|
Absolute tolerance for adaptive solvers |
1e-07
|
method_options
|
Optional[Dict[str, Any]]
|
Additional solver-specific options |
None
|
**kwargs
|
Any
|
Additional parameters |
{}
|
Source code in flowpde/core/base_solver.py
solve(func, y0, t_span, **kwargs)
abstractmethod
¶
Solve the differential equation \(dy/dt = f(t, y)\).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
func
|
Callable[[Tensor, Tensor], Tensor]
|
Function computing \(dy/dt\) given \((t, y)\) Signature: func(t: Tensor, y: Tensor) -> Tensor |
required |
y0
|
Tensor
|
Initial state (batch_size, dim) |
required |
t_span
|
Tuple[float, float]
|
Time interval \((t_{ ext{start}}, t_{ ext{end}})\) |
required |
**kwargs
|
Any
|
Additional solving parameters |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
Union[Tensor, Tuple[Tensor, Dict[str, Any]]]
|
\(y_{ ext{final}}\): Final state at \(t_{ ext{end}}\) (batch_size, dim) |
|
info |
optional
|
Dictionary with solving statistics |
Source code in flowpde/core/base_solver.py
solve_trajectory(func, y0, t_eval, **kwargs)
¶
Solve and return trajectory at specified time points.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
func
|
Callable[[Tensor, Tensor], Tensor]
|
Function computing \(dy/dt\) |
required |
y0
|
Tensor
|
Initial state (batch_size, dim) |
required |
t_eval
|
Tensor
|
Time points for evaluation (n_steps,) |
required |
**kwargs
|
Any
|
Additional parameters |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
trajectory |
Union[Tensor, Tuple[Tensor, Dict[str, Any]]]
|
States at each time point (n_steps, batch_size, dim) |
info |
optional
|
Dictionary with solving statistics |
Source code in flowpde/core/base_solver.py
get_solver_info()
abstractmethod
¶
Get information about the solver configuration.
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dictionary with solver properties |
ODESolver
¶
Bases: BaseSolver
Base class specifically for ODE solvers.
Ordinary Differential Equation solvers for deterministic flows.
Source code in flowpde/core/base_solver.py
__init__(method, rtol=1e-05, atol=1e-07, **kwargs)
¶
Initialize ODE solver.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
method
|
str
|
Integration method name |
required |
rtol
|
float
|
Relative tolerance |
1e-05
|
atol
|
float
|
Absolute tolerance |
1e-07
|
**kwargs
|
Any
|
Additional parameters |
{}
|
Source code in flowpde/core/base_solver.py
get_solver_info()
¶
Get ODE solver information.