torchebm.integrators.euler_maruyama ¶
Euler-Maruyama and Backward (implicit) Euler-Maruyama integrators.
BackwardEulerMaruyamaIntegrator ¶
Bases: BaseSDERungeKuttaIntegrator
Backward (implicit) Euler-Maruyama integrator for Itô SDEs and ODEs.
The SDE form is:
When diffusion is omitted, this reduces to the backward Euler method for ODEs.
Update rule (implicit in the drift, explicit in the diffusion):
The implicit equation is solved by fixed-point (Picard) iteration, seeded with an explicit Euler predictor. Iteration stops when the max-abs change falls below atol or after max_iter iterations. Picard converges only when step_size times the drift Lipschitz constant is below 1; for stiffer regimes choose a smaller step_size.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
device | Optional[device] | Device for computations. | None |
dtype | Optional[dtype] | Data type for computations. | None |
max_iter | Maximum fixed-point iterations per step. | required | |
atol | float | Absolute tolerance for the fixed-point solve and adaptive stepping. | 1e-06 |
rtol | float | Relative tolerance for adaptive stepping. | 0.001 |
max_steps | int | Maximum number of steps before raising | 10000 |
safety | float | Safety factor for step-size adjustment (< 1). | 0.9 |
min_factor | float | Minimum step-size shrink factor. | 0.2 |
max_factor | float | Maximum step-size growth factor. | 10.0 |
max_step_size | float | Maximum absolute step size during adaptive integration. | float('inf') |
norm | Optional[Callable[[Tensor], Tensor]] | Callable | None |
Example
Source code in torchebm/integrators/euler_maruyama.py
EulerMaruyamaIntegrator ¶
Bases: BaseSDERungeKuttaIntegrator
Euler-Maruyama integrator for Itô SDEs and ODEs.
The SDE form is:
When diffusion is omitted, this reduces to the Euler method for ODEs.
Update rule:
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
device | Optional[device] | Device for computations. | None |
dtype | Optional[dtype] | Data type for computations. | None |
atol | float | Absolute tolerance for adaptive stepping. | 1e-06 |
rtol | float | Relative tolerance for adaptive stepping. | 0.001 |
max_steps | int | Maximum number of steps before raising | 10000 |
safety | float | Safety factor for step-size adjustment (< 1). | 0.9 |
min_factor | float | Minimum step-size shrink factor. | 0.2 |
max_factor | float | Maximum step-size growth factor. | 10.0 |
max_step_size | float | Maximum absolute step size during adaptive integration. | float('inf') |
norm | Optional[Callable[[Tensor], Tensor]] | Callable | None |