-
-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Made JumpStepWrapper backwards compatible with PIDController and some…
… nits
- Loading branch information
1 parent
345e23a
commit c3c4dcf
Showing
7 changed files
with
203 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
from .adaptive import ( | ||
from .adaptive_base import ( | ||
AbstractAdaptiveStepSizeController as AbstractAdaptiveStepSizeController, | ||
PIDController as PIDController, | ||
) | ||
from .base import AbstractStepSizeController as AbstractStepSizeController | ||
from .constant import ConstantStepSize as ConstantStepSize, StepTo as StepTo | ||
from .jump_step_wrapper import JumpStepWrapper as JumpStepWrapper | ||
from .pid import ( | ||
PIDController as PIDController, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from collections.abc import Callable | ||
from typing import Optional, TypeVar | ||
|
||
from equinox import AbstractVar | ||
from jaxtyping import PyTree | ||
|
||
from .._custom_types import RealScalarLike | ||
from .base import AbstractStepSizeController | ||
|
||
|
||
_ControllerState = TypeVar("_ControllerState") | ||
_Dt0 = TypeVar("_Dt0", None, RealScalarLike, Optional[RealScalarLike]) | ||
|
||
|
||
class AbstractAdaptiveStepSizeController( | ||
AbstractStepSizeController[_ControllerState, _Dt0] | ||
): | ||
"""Indicates an adaptive step size controller. | ||
Accepts tolerances `rtol` and `atol`. When used in conjunction with an implicit | ||
solver ([`diffrax.AbstractImplicitSolver`][]), then these tolerances will | ||
automatically be used as the tolerances for the nonlinear solver passed to the | ||
implicit solver, if they are not specified manually. | ||
""" | ||
|
||
rtol: AbstractVar[RealScalarLike] | ||
atol: AbstractVar[RealScalarLike] | ||
norm: AbstractVar[Callable[[PyTree], RealScalarLike]] | ||
|
||
def __check_init__(self): | ||
if self.rtol is None or self.atol is None: | ||
raise ValueError( | ||
"The default values for `rtol` and `atol` were removed in Diffrax " | ||
"version 0.1.0. (As the choice of tolerance is nearly always " | ||
"something that you, as an end user, should make an explicit choice " | ||
"about.)\n" | ||
"If you want to match the previous defaults then specify " | ||
"`rtol=1e-3`, `atol=1e-6`. For example:\n" | ||
"```\n" | ||
"diffrax.PIDController(rtol=1e-3, atol=1e-6)\n" | ||
"```\n" | ||
) |
Oops, something went wrong.