Skip to content

Commit 52b421e

Browse files
Merge pull request #265 from avik-pal/ap/fixes
Proper handling of complex numbers and failures
2 parents 1e4c3c0 + c489b23 commit 52b421e

33 files changed

+831
-847
lines changed

.github/workflows/CI.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ on:
1010
- master
1111
paths-ignore:
1212
- 'docs/**'
13+
concurrency:
14+
# Skip intermediate builds: always.
15+
# Cancel intermediate builds: only if it is a pull request build.
16+
group: ${{ github.workflow }}-${{ github.ref }}
17+
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
1318
jobs:
1419
test:
1520
runs-on: ubuntu-latest

.github/workflows/Downstream.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ on:
44
branches: [master]
55
tags: [v*]
66
pull_request:
7-
7+
concurrency:
8+
# Skip intermediate builds: always.
9+
# Cancel intermediate builds: only if it is a pull request build.
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
812
jobs:
913
test:
1014
name: ${{ matrix.package.repo }}/${{ matrix.package.group }}/${{ matrix.julia-version }}

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ ADTypes = "0.2"
4040
ArrayInterface = "6.0.24, 7"
4141
BandedMatrices = "1"
4242
ConcreteStructs = "0.2"
43-
DiffEqBase = "6.130"
43+
DiffEqBase = "6.136"
4444
EnumX = "1"
4545
Enzyme = "0.11"
4646
FastBroadcast = "0.1.9, 0.2"
@@ -56,7 +56,7 @@ RecursiveArrayTools = "2"
5656
Reexport = "0.2, 1"
5757
SciMLBase = "2.4"
5858
SimpleNonlinearSolve = "0.1.23"
59-
SparseDiffTools = "2.6"
59+
SparseDiffTools = "2.9"
6060
StaticArraysCore = "1.4"
6161
UnPack = "1.0"
6262
Zygote = "0.6"

docs/Project.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
AlgebraicMultigrid = "2169fc97-5a83-5252-b627-83903c6c433c"
33
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
44
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
5+
DiffEqBase = "2b5f629d-d688-5b77-993f-72d75c75574e"
56
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
67
IncompleteLU = "40713840-3770-5561-ab4c-a76e7d0d7895"
78
LinearSolve = "7ed4a6bd-45f5-4d41-b270-4a48e9bafcae"
89
ModelingToolkit = "961ee093-0014-501f-94e3-6117800e7a78"
910
NonlinearSolve = "8913a72c-1f9b-4ce2-8d82-65094dcecaec"
1011
NonlinearSolveMINPACK = "c100e077-885d-495a-a2ea-599e143bf69d"
12+
SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
1113
SciMLNLSolve = "e9a6253c-8580-4d32-9898-8661bb511710"
1214
SimpleNonlinearSolve = "727e6d20-b764-4bd8-a329-72de5adea6c7"
1315
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
@@ -19,12 +21,14 @@ Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7"
1921
AlgebraicMultigrid = "0.5, 0.6"
2022
ArrayInterface = "6, 7"
2123
BenchmarkTools = "1"
24+
DiffEqBase = "6.136"
2225
Documenter = "1"
2326
IncompleteLU = "0.2"
2427
LinearSolve = "2"
2528
ModelingToolkit = "8"
2629
NonlinearSolve = "1, 2"
2730
NonlinearSolveMINPACK = "0.1"
31+
SciMLBase = "2.4"
2832
SciMLNLSolve = "0.1"
2933
SimpleNonlinearSolve = "0.1.5"
3034
StaticArrays = "1"

docs/make.jl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using Documenter, NonlinearSolve, SimpleNonlinearSolve, Sundials, SciMLNLSolve,
2-
NonlinearSolveMINPACK, SteadyStateDiffEq
2+
NonlinearSolveMINPACK, SteadyStateDiffEq, SciMLBase, DiffEqBase
33

44
cp("./docs/Manifest.toml", "./docs/src/assets/Manifest.toml", force = true)
55
cp("./docs/Project.toml", "./docs/src/assets/Project.toml", force = true)
@@ -8,9 +8,8 @@ include("pages.jl")
88

99
makedocs(sitename = "NonlinearSolve.jl",
1010
authors = "Chris Rackauckas",
11-
modules = [NonlinearSolve, NonlinearSolve.SciMLBase, NonlinearSolve.DiffEqBase,
12-
SimpleNonlinearSolve, Sundials, SciMLNLSolve, NonlinearSolveMINPACK,
13-
SteadyStateDiffEq],
11+
modules = [NonlinearSolve, SciMLBase, DiffEqBase, SimpleNonlinearSolve, Sundials,
12+
SciMLNLSolve, NonlinearSolveMINPACK, SteadyStateDiffEq],
1413
clean = true, doctest = false, linkcheck = true,
1514
linkcheck_ignore = ["https://twitter.com/ChrisRackauckas/status/1544743542094020615"],
1615
warnonly = [:missing_docs, :cross_references],

docs/pages.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ pages = ["index.md",
66
"Handling Large Ill-Conditioned and Sparse Systems" => "tutorials/large_systems.md",
77
"Symbolic System Definition and Acceleration via ModelingToolkit" => "tutorials/modelingtoolkit.md",
88
"tutorials/small_compile.md",
9-
"tutorials/termination_conditions.md",
109
"tutorials/iterator_interface.md"],
1110
"Basics" => Any["basics/NonlinearProblem.md",
1211
"basics/NonlinearFunctions.md",

docs/src/basics/TerminationCondition.md

Lines changed: 68 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,75 @@
11
# [Termination Conditions](@id termination_condition)
22

33
Provides a API to specify termination conditions for [`NonlinearProblem`](@ref) and
4-
[`SteadyStateProblem`](@ref). For details on the various termination modes, i.e.,
5-
NLSolveTerminationMode, see the documentation for [`NLSolveTerminationCondition`](@ref).
4+
[`SteadyStateProblem`](@ref). For details on the various termination modes:
65

7-
## Termination Condition API
6+
## Termination Conditions
7+
8+
The termination condition is constructed as:
9+
10+
```julia
11+
cache = init(du, u, AbsNormTerminationMode(); abstol = 1e-9, reltol = 1e-9)
12+
```
13+
14+
If `abstol` and `reltol` are not supplied, then we choose a default based on the element
15+
types of `du` and `u`.
16+
17+
We can query the `cache` using `DiffEqBase.get_termination_mode`, `DiffEqBase.get_abstol`
18+
and `DiffEqBase.get_reltol`.
19+
20+
To test for termination simply call the `cache`:
21+
22+
```julia
23+
terminated = cache(du, u, uprev)
24+
```
25+
26+
!!! note
27+
28+
The default for NonlinearSolve.jl is `AbsSafeBestTerminationMode`!
29+
30+
### Absolute Tolerance
31+
32+
```@docs
33+
AbsTerminationMode
34+
AbsNormTerminationMode
35+
AbsSafeTerminationMode
36+
AbsSafeBestTerminationMode
37+
```
38+
39+
### Relative Tolerance
40+
41+
```@docs
42+
RelTerminationMode
43+
RelNormTerminationMode
44+
RelSafeTerminationMode
45+
RelSafeBestTerminationMode
46+
```
47+
48+
### Both Absolute and Relative Tolerance
49+
50+
```@docs
51+
NormTerminationMode
52+
SteadyStateDiffEqTerminationMode
53+
SimpleNonlinearSolveTerminationMode
54+
```
55+
56+
### Return Codes
57+
58+
```@docs
59+
DiffEqBase.NonlinearSafeTerminationReturnCode
60+
DiffEqBase.NonlinearSafeTerminationReturnCode.Success
61+
DiffEqBase.NonlinearSafeTerminationReturnCode.Default
62+
DiffEqBase.NonlinearSafeTerminationReturnCode.Failure
63+
DiffEqBase.NonlinearSafeTerminationReturnCode.PatienceTermination
64+
DiffEqBase.NonlinearSafeTerminationReturnCode.ProtectiveTermination
65+
```
66+
67+
## [Deprecated] Termination Condition API
68+
69+
!!! warning
70+
71+
This is deprecated. Currently only parts of `SimpleNonlinearSolve` uses this API. That
72+
will also be phased out soon!
873

974
```@docs
1075
NLSolveTerminationCondition

docs/src/tutorials/termination_conditions.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

ext/NonlinearSolveFastLevenbergMarquardtExt.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ end
3232
(f::InplaceFunction{false})(fx, x, p) = (fx .= f.f(x, p))
3333

3434
function SciMLBase.__init(prob::NonlinearLeastSquaresProblem,
35-
alg::FastLevenbergMarquardtJL, args...; abstol = 1e-8, reltol = 1e-8,
36-
verbose = false, maxiters = 1000, kwargs...)
35+
alg::FastLevenbergMarquardtJL, args...; abstol = 1e-8, reltol = 1e-8,
36+
verbose = false, maxiters = 1000, kwargs...)
3737
iip = SciMLBase.isinplace(prob)
3838

3939
@assert prob.f.jac!==nothing "FastLevenbergMarquardt requires a Jacobian!"

ext/NonlinearSolveLeastSquaresOptimExt.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ end
3333
(f::FunctionWrapper{false})(du, u) = (du .= f.f(u, f.p))
3434

3535
function SciMLBase.__init(prob::NonlinearLeastSquaresProblem, alg::LeastSquaresOptimJL,
36-
args...; abstol = 1e-8, reltol = 1e-8, verbose = false, maxiters = 1000, kwargs...)
36+
args...; abstol = 1e-8, reltol = 1e-8, verbose = false, maxiters = 1000, kwargs...)
3737
iip = SciMLBase.isinplace(prob)
3838

3939
f! = FunctionWrapper{iip}(prob.f, prob.p)

0 commit comments

Comments
 (0)