Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: restore the history of SimpleNonlinearSolve #487

Merged
merged 500 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
500 commits
Select commit Hold shift + click to select a range
09180ce
readme fix
yash-rs Sep 15, 2023
908c8c5
Merge pull request #79 from yash2798/ys/readme
ChrisRackauckas Sep 15, 2023
8ea0f0e
CompatHelper: bump compat for SciMLBase to 2, (keep existing compat)
Sep 22, 2023
b9d95aa
Merge pull request #81 from SciML/compathelper/new_version/2023-09-22…
ChrisRackauckas Sep 22, 2023
a6e6c0d
Update Project.toml
ChrisRackauckas Sep 22, 2023
c6a6413
Fix error in README example
TomRottier Oct 16, 2023
4814334
Merge pull request #84 from TomRottier/patch-1
ChrisRackauckas Oct 16, 2023
65bcea0
Set ITP as the default method for interval problems
ChrisRackauckas Oct 17, 2023
f73842d
Merge pull request #85 from SciML/default
ChrisRackauckas Oct 17, 2023
e2f84c6
Update Project.toml
ChrisRackauckas Oct 17, 2023
1db1c98
Halley -> SimpleHalley
ChrisRackauckas Oct 17, 2023
6d975f4
fix naming
ChrisRackauckas Oct 17, 2023
ebb501f
fix page name
ChrisRackauckas Oct 17, 2023
7c92a08
Merge pull request #86 from SciML/simplehally
ChrisRackauckas Oct 17, 2023
d7d9c45
Update Project.toml
ChrisRackauckas Oct 17, 2023
0f94dda
Add matrix resizing and fix cases with u0 as a matrix
ChrisRackauckas Oct 20, 2023
580c439
don't restructure on number
ChrisRackauckas Oct 20, 2023
aa27e6a
Merge pull request #87 from SciML/matrix_resizing
ChrisRackauckas Oct 20, 2023
0e6aba3
Format .jl files
ChrisRackauckas Oct 21, 2023
6936ccc
Merge pull request #88 from SciML/auto-juliaformatter-pr
ChrisRackauckas Oct 21, 2023
cca90d0
Change typeof(x) <: y to x isa y
Nov 2, 2023
559778f
Merge pull request #93 from pepijndevos/new-branch
ChrisRackauckas Nov 2, 2023
ad12493
Add a dispatch to SimpleNewtonRaphson for NNLS and SimpleGaussNewton
ChrisRackauckas Oct 30, 2023
754b15e
Update runtests.jl
ChrisRackauckas Nov 3, 2023
f40bc46
Update test/least_squares.jl
ChrisRackauckas Nov 3, 2023
27af8bd
Update least_squares.jl
ChrisRackauckas Nov 3, 2023
dcae5f1
Merge pull request #91 from SciML/least_squares
ChrisRackauckas Nov 3, 2023
cdbc567
Update Project.toml
ChrisRackauckas Nov 3, 2023
2292fbe
fix badges in README.md
ranocha Nov 3, 2023
df18946
Merge pull request #94 from ranocha/patch-1
ChrisRackauckas Nov 3, 2023
c6ee541
Update Project.toml
ChrisRackauckas Nov 5, 2023
77c359f
Require v1.9 and drop backwards compat
ChrisRackauckas Nov 7, 2023
960ed93
Require SciMLBase with v2.7 for NonlinearLeastSquares
ChrisRackauckas Nov 7, 2023
7f16738
Update least_squares.jl
ChrisRackauckas Nov 7, 2023
2ad0b37
Merge pull request #97 from SciML/ChrisRackauckas-patch-1
ChrisRackauckas Nov 7, 2023
9387e5f
fixed gradient and GN Hessian approximation
FHoltorf Nov 18, 2023
5b9100a
make step accepteance less consersative for better performance
FHoltorf Nov 18, 2023
7c6b572
simple fraction with forward slash instead of backslash (for otherwis…
FHoltorf Nov 22, 2023
66a0732
run formatter
FHoltorf Nov 22, 2023
000f4db
Incorrect RetCode upon termination due to stalling of iterates or rep…
FHoltorf Nov 22, 2023
0cc84ab
compute Newton step as opposed to Gauss-Newton step when J is square …
FHoltorf Nov 22, 2023
8fba768
undo ReturnCode changes => treat in another issue
FHoltorf Nov 22, 2023
31b8a57
Merge pull request #99 from FHoltorf/TR
ChrisRackauckas Nov 23, 2023
19436d1
Start cleaning up simplenonlinearsolve
avik-pal Nov 21, 2023
0915379
Update Klement
avik-pal Nov 22, 2023
d3af9e1
CLeanup bisection
avik-pal Nov 22, 2023
71ed2fe
Make some progress on Falsi and SimpleDFSane
avik-pal Nov 22, 2023
408243e
Use a macro for compile time compatibility between inplace and oop ve…
avik-pal Nov 23, 2023
f229231
Fix brent
avik-pal Nov 23, 2023
190ca22
Fix the interval methods
avik-pal Nov 23, 2023
b50ece4
Move things around a bit
avik-pal Nov 24, 2023
62d99e0
Move out the @bb macro into a separate package
avik-pal Nov 24, 2023
12006d1
Reenable some more compilation
avik-pal Nov 24, 2023
1b1029e
bad rebase
avik-pal Nov 24, 2023
3c3e401
More robust and allocated version of TrustRegion
avik-pal Nov 24, 2023
82342fd
Fix Limited Memory Broyden
avik-pal Nov 24, 2023
0c2b365
Type stability fixes
avik-pal Nov 24, 2023
8f6d66d
Fix Halley's method
avik-pal Nov 25, 2023
83102b0
Add tests for the nonlinear solvers
avik-pal Nov 25, 2023
c1d3e8c
Fix the tests
avik-pal Nov 25, 2023
88e99f6
Bump version
avik-pal Nov 25, 2023
3111c28
Formatting fix
avik-pal Nov 25, 2023
f6c952f
Fix the tests
avik-pal Nov 27, 2023
ab95a66
Add AllocCheck.jl
avik-pal Nov 27, 2023
e908f14
Fix chunk size picking for StaticArrays
avik-pal Nov 27, 2023
23779df
Skip 1 broyden test
avik-pal Nov 28, 2023
32c20f1
Change the norm
avik-pal Nov 28, 2023
14b65b4
Merge pull request #100 from avik-pal/ap/cleanup
ChrisRackauckas Nov 28, 2023
cd2e8c9
Update Project.toml
ChrisRackauckas Nov 28, 2023
7f0cedd
Add compat entries and change default norm
avik-pal Nov 28, 2023
f557f02
revert the norm change
avik-pal Nov 28, 2023
6fe4ed6
No transpose
avik-pal Nov 28, 2023
3388160
Disambiguate conditionals with `Bool`
avik-pal Nov 28, 2023
d64875d
Don't support Batched TR for correctness reasons
avik-pal Nov 28, 2023
91304a7
Needs a safety copy
avik-pal Nov 30, 2023
a784753
Extra cache in DFSane
avik-pal Dec 1, 2023
6a7e3ce
Bug fixes
avik-pal Dec 4, 2023
54acf9f
Fix DFSane tests and Klement allocations
avik-pal Dec 4, 2023
b8afd8d
Typo
avik-pal Dec 4, 2023
4cfc0cc
Merge pull request #105 from avik-pal/ap/minor_fixes
ChrisRackauckas Dec 4, 2023
e196db7
Update Klement to exploit the diagonal structure
avik-pal Dec 6, 2023
a86117d
Fix links
avik-pal Dec 7, 2023
17d65e9
Merge pull request #107 from avik-pal/ap/fix_docs
ChrisRackauckas Dec 7, 2023
ca5d82f
Update Project.toml
ChrisRackauckas Dec 7, 2023
d859ef6
Merge pull request #106 from avik-pal/ap/klement
ChrisRackauckas Dec 7, 2023
171cf42
Update Project.toml
ChrisRackauckas Dec 7, 2023
beabc41
Fix non vec Limited Memory Broyden
avik-pal Dec 17, 2023
41ce280
Merge pull request #109 from avik-pal/ap/patch_nonvec
avik-pal Dec 17, 2023
d7deef5
Fix the 23 test problems
avik-pal Dec 25, 2023
27ebb96
Merge pull request #111 from avik-pal/ap/23tests
ChrisRackauckas Dec 25, 2023
703d6ca
Update Project.toml
ChrisRackauckas Dec 25, 2023
ff3c7be
Add Polyester ForwardDiff support
avik-pal Dec 25, 2023
31c596d
Add tests
avik-pal Dec 26, 2023
3f63d6c
Merge pull request #113 from avik-pal/ap/polyester_mode
ChrisRackauckas Dec 26, 2023
0f8ce36
Add downgrade CI
ErikQQY Dec 25, 2023
b35a140
Update .github/workflows/Downgrade.yml
ChrisRackauckas Dec 25, 2023
77cade8
Add ForwardDiff Inplace Overloads
avik-pal Dec 26, 2023
f66e913
Fix tests
avik-pal Dec 27, 2023
ef11f39
Merge pull request #114 from avik-pal/ap/inplace_duals
avik-pal Dec 27, 2023
5d4d766
Dispatch on solve directly and forward to __solve
avik-pal Jan 13, 2024
ec1d5b3
Non allocating version of LBroyden for StaticArrays
avik-pal Jan 13, 2024
ebfcffd
Allow allocations for the termination condition version
avik-pal Jan 13, 2024
8ef9686
AllocCheck for SimpleLimitedMemoryBroyden
avik-pal Jan 13, 2024
043336b
Make DFSane non-allocating as well
avik-pal Jan 13, 2024
91a995d
Add kernel launch tests
avik-pal Jan 13, 2024
6eb690e
Merge pull request #118 from SciML/ap/static_kernels
avik-pal Jan 13, 2024
686c1cb
Add Line Search to Broyden
avik-pal Jan 10, 2024
e822edd
Add Line Search to LBroyden
avik-pal Jan 10, 2024
ee1b66d
Update src/nlsolve/lbroyden.jl
Vaibhavdixit02 Jan 10, 2024
7648d58
temp diable termination condition
Vaibhavdixit02 Jan 12, 2024
20296e8
isfinite not comiling
Vaibhavdixit02 Jan 12, 2024
c222e64
use DiffEqBase definitions of norm etc
Vaibhavdixit02 Jan 12, 2024
705ac06
T(phi)
Vaibhavdixit02 Jan 12, 2024
5a92d0f
Typer assertions and simplify function eval all around
Vaibhavdixit02 Jan 12, 2024
f14726d
Bring back bb
Vaibhavdixit02 Jan 12, 2024
8a5526a
Broyden line search works inside kernels
avik-pal Jan 14, 2024
cf2551b
Add linesearch to the cuda tests
avik-pal Jan 14, 2024
1d5eeb8
Add linesearch to LBroyden
avik-pal Jan 14, 2024
223ca68
Remove the old flaky benchmarktools allocations tests
avik-pal Jan 14, 2024
545e335
DFSane non-allocating for scalars now
avik-pal Jan 14, 2024
2ff6536
Resolve tolerances differently for kernel launches
avik-pal Jan 14, 2024
a1ce1cf
Add alpha scaling
avik-pal Jan 14, 2024
ba289be
Resolve ambiguities
avik-pal Jan 14, 2024
4d35fc6
More of the 23 tests are working
avik-pal Jan 14, 2024
7e2fc08
Update src/linesearch.jl
avik-pal Jan 14, 2024
34289ef
Update src/linesearch.jl
avik-pal Jan 14, 2024
eae355d
Merge pull request #116 from SciML/ap/ls
Vaibhavdixit02 Jan 14, 2024
36c2c83
Clean up some of the docs
avik-pal Jan 15, 2024
51d5039
Merge pull request #119 from SciML/ap/doc_fixes
avik-pal Jan 15, 2024
6a02226
Bump actions/cache from 3 to 4
dependabot[bot] Jan 22, 2024
44e122b
Merge pull request #120 from SciML/dependabot/github_actions/actions/…
ChrisRackauckas Jan 23, 2024
f86134d
Patch Adjoint Sensitivity for Simple Nonlinear Solve Algorithms
avik-pal Feb 5, 2024
22c699b
Merge pull request #123 from avik-pal/ap/fix_adjoint
ChrisRackauckas Feb 6, 2024
9bdd485
Run tests in Parallel
avik-pal Feb 8, 2024
559c51b
Merge pull request #124 from SciML/ap/fast_testing
avik-pal Feb 8, 2024
6ac95bd
Add NLsolve update rule to SimpleTrustRegion
avik-pal Feb 8, 2024
419eca8
Merge branch 'main' into qqy/downgrade_ci
avik-pal Feb 8, 2024
1d81618
Update Project.toml
avik-pal Feb 8, 2024
03bab8e
Update Project.toml
avik-pal Feb 8, 2024
28a3c9b
Update Project.toml
avik-pal Feb 8, 2024
fe60a39
Update Project.toml
avik-pal Feb 8, 2024
cd4899d
Apply suggestions from code review
avik-pal Feb 8, 2024
0a86a9e
Merge pull request #125 from SciML/ap/tr_nlsolve_update
ChrisRackauckas Feb 9, 2024
07ec573
Use ReTestItems instead of XUnit
avik-pal Feb 9, 2024
5fd1cd7
Test on multiple os
avik-pal Feb 9, 2024
7591156
Retry for Broyden
avik-pal Feb 9, 2024
e42f3fe
Merge pull request #126 from SciML/ap/distributed_testing
avik-pal Feb 9, 2024
afb6691
Merge branch 'main' into qqy/downgrade_ci
ChrisRackauckas Feb 10, 2024
2d21672
Update Project.toml
ChrisRackauckas Feb 10, 2024
ef11257
Update Project.toml
ChrisRackauckas Feb 10, 2024
c860b4b
Merge pull request #110 from ErikQQY/qqy/downgrade_ci
ChrisRackauckas Feb 10, 2024
4d1c761
Format .jl files
ChrisRackauckas Feb 11, 2024
3dfa6a2
Merge pull request #128 from SciML/auto-juliaformatter-pr
ChrisRackauckas Feb 11, 2024
214fb0f
Dispatch didnot propagate problem kwargs
avik-pal Feb 9, 2024
3e8ffd0
Add a test for kwarg propagation
avik-pal Feb 15, 2024
05c80bb
Dont fail fast
avik-pal Feb 15, 2024
f809d0a
Merge pull request #127 from SciML/ap/propagate_kwargs
ChrisRackauckas Feb 15, 2024
05c6206
Static GPU compilation of Jacobian
avik-pal Feb 15, 2024
9a91e9f
Merge pull request #129 from SciML/ap/static_jacobian
ChrisRackauckas Feb 16, 2024
9203bc3
Julia version not allowed to be changed in patch release
avik-pal Feb 16, 2024
0166ee9
[skip ci] update downgrade CI repo
ArnoStrouwen Feb 18, 2024
a3f9a13
Merge pull request #130 from ArnoStrouwen/patch-1
ChrisRackauckas Feb 18, 2024
e831d1a
Forward Mode overloads for Least Squares Problem
avik-pal Feb 26, 2024
9bf42c3
Add implementation for NLLS Forward Mode
avik-pal Feb 26, 2024
c7930cc
Use custom vjp
avik-pal Feb 26, 2024
2b8b5e4
Formatting and Downgrade
avik-pal Feb 26, 2024
f6cb31f
Merge pull request #131 from avik-pal/ap/nlls_adjoint
avik-pal Feb 26, 2024
96874e9
Dont default to Polyester
avik-pal Mar 10, 2024
73038b7
Add ReverseDiff and Tracker entry points
avik-pal Mar 11, 2024
81ba5b9
Merge pull request #133 from SciML/ap/reversediff
avik-pal Mar 11, 2024
ec757e3
fix docstring of ITP
ranocha Mar 13, 2024
f7182db
Merge pull request #134 from SciML/ranocha-patch-1
ChrisRackauckas Mar 13, 2024
36814a2
Use the different norms for termination
avik-pal Mar 31, 2024
2711566
remove manifest
avik-pal Mar 31, 2024
3915d61
Merge pull request #136 from SciML/ap/nlls_term
ChrisRackauckas Mar 31, 2024
7f3cc72
Bump julia-actions/setup-julia from 1 to 2
dependabot[bot] Apr 1, 2024
e1e2d40
Merge pull request #138 from SciML/dependabot/github_actions/julia-ac…
ChrisRackauckas Apr 2, 2024
abf1a2f
CompatHelper: bump compat for ADTypes to 1, (keep existing compat)
Apr 19, 2024
f811c72
Merge pull request #140 from SciML/compathelper/new_version/2024-04-1…
avik-pal Apr 28, 2024
e3cf53a
Update Project.toml
Vaibhavdixit02 May 4, 2024
c8a259a
Merge pull request #142 from SciML/Vaibhavdixit02-patch-1
Vaibhavdixit02 May 4, 2024
f5240b6
Force ADTypes v1
gdalle May 16, 2024
59f0d7d
Bump version
gdalle May 16, 2024
eeac315
Merge pull request #143 from gdalle/gd/adtypes1
ChrisRackauckas May 17, 2024
a9f92b6
Clean up the testing
avik-pal May 17, 2024
358cc55
Merge pull request #144 from SciML/ap/testing
avik-pal May 17, 2024
2bb3bbb
---
dependabot[bot] May 20, 2024
f5a95ae
Merge pull request #145 from SciML/dependabot/github_actions/julia-ac…
ChrisRackauckas May 20, 2024
2dc8a7e
Support BigFloat
avik-pal May 25, 2024
aeef552
Increase timeout for Kernel Launch tests
avik-pal May 25, 2024
d80b885
Merge pull request #146 from SciML/ap/bigfloat
ChrisRackauckas May 25, 2024
bfc439b
Make explicit imports for extensions
avik-pal May 25, 2024
c5d1a7d
Run formatter
avik-pal May 25, 2024
efa09d8
Add explicit imports
avik-pal May 25, 2024
248088c
Resolve ambiguity
avik-pal May 25, 2024
c985602
Merge pull request #147 from SciML/ap/explicit_imports
avik-pal May 26, 2024
b84ee8f
Update Project.toml
avik-pal May 26, 2024
02160aa
Use DifferentiationInterface
avik-pal May 25, 2024
3c32525
Clean up AD
avik-pal May 26, 2024
86917a5
Remove the static arrays special casing
avik-pal May 26, 2024
4fd1bce
Add Halley to 23 test problems
avik-pal May 26, 2024
ff5be63
Merge pull request #148 from SciML/ap/di
avik-pal May 26, 2024
d4a6c2a
Bump DifferentiationInterface compat to 0.5
gdalle May 30, 2024
0f6311d
Merge pull request #150 from gdalle/gd/bump_di
ChrisRackauckas Jun 4, 2024
fdd16a7
Update Project.toml
ChrisRackauckas Jun 7, 2024
9702729
Remove recompile_invalidations
ChrisRackauckas Jun 27, 2024
9ea50fc
Update src/SimpleNonlinearSolve.jl
ChrisRackauckas Jun 27, 2024
2bf765b
Merge pull request #152 from SciML/ChrisRackauckas-patch-1
ChrisRackauckas Jun 27, 2024
b186343
Update Project.toml
ChrisRackauckas Jun 27, 2024
86da8b3
New default values
DaniGlez Jul 13, 2024
d309aea
add ImmutableNonlinearProblem
m-bossart Jul 16, 2024
96b40e1
convert to immutable in ad dispatch
m-bossart Jul 17, 2024
62c928e
Update test/core/adjoint_tests.jl
m-bossart Jul 22, 2024
d85408e
Update test/core/adjoint_tests.jl
m-bossart Jul 22, 2024
b50726f
Update src/ad.jl
m-bossart Jul 22, 2024
52fd380
Merge pull request #153 from HodgeLab/mb/immutable
ChrisRackauckas Jul 22, 2024
221759e
format
ChrisRackauckas Jul 22, 2024
5e5aed1
Update Project.toml
ChrisRackauckas Jul 22, 2024
232e91e
ci: update invalidations workflow to use centralised reusable workflow
thazhemadam Apr 29, 2024
35e0773
ci: update format check workflow to use centralised reusable workflow
thazhemadam Apr 29, 2024
231b114
ci: update tests workflow to use centralized reusable workflow
thazhemadam Jul 31, 2024
eb43c5a
ci(format-check): automatically comment formatting suggestions on PRs
thazhemadam Jul 31, 2024
76556a1
Merge remote-tracking branch 'upstream/main'
DaniGlez Aug 8, 2024
2e63a13
Docs, scaling factor
DaniGlez Aug 9, 2024
ec1e309
Docstring update
DaniGlez Aug 9, 2024
145d5f2
Fix ITP for generic output numbers
DaniGlez Aug 9, 2024
c8a8546
Merge pull request #155 from DaniGlez/main
ChrisRackauckas Aug 10, 2024
25df2d8
Merge pull request #154 from SciML/at/use-reusable-workflows
ChrisRackauckas Aug 10, 2024
0614b6a
Update Project.toml
ChrisRackauckas Aug 10, 2024
e799b10
fix: missing Tracker.data
avik-pal Sep 16, 2024
dfc4cca
Merge pull request #157 from SciML/ap/tracker_patch
ChrisRackauckas Sep 16, 2024
7b99472
Return InitialFailure from bracketing methods if not enclosing interval
Sep 23, 2024
8b2d0d7
Merge pull request #158 from TomRottier/main
ChrisRackauckas Sep 24, 2024
45d63d2
Update Project.toml
ChrisRackauckas Sep 24, 2024
5742f89
feat: update to new DI.jl
avik-pal Sep 25, 2024
bd92893
fix: install some test deps if needed
avik-pal Sep 25, 2024
96716b6
chore: update min DI version
avik-pal Sep 26, 2024
e9d3bfd
Merge pull request #160 from SciML/ap/up_di
ChrisRackauckas Sep 26, 2024
c77cee8
tweak warning message
ajwheeler Sep 27, 2024
093b1e4
Merge pull request #162 from ajwheeler/non_enclosing_interval_warning…
ChrisRackauckas Sep 27, 2024
b5f9025
ci: test with `1`, `lts` and `pre` versions of julia
thazhemadam Oct 17, 2024
5ec9808
Merge pull request #166 from SciML/at/julia-versions
ChrisRackauckas Oct 17, 2024
a14a699
Add Householder's method
tansongchen Oct 2, 2024
229bdb5
Add tests and doc
tansongchen Oct 8, 2024
32daa15
Fix format and add compat
tansongchen Oct 24, 2024
d1d681b
Merge pull request #163 from tansongchen/main
ChrisRackauckas Oct 29, 2024
3936d00
CompatHelper: bump compat for TaylorDiff in [weakdeps] to 0.3, (keep …
Oct 29, 2024
6f4a902
Merge pull request #167 from SciML/compathelper/new_version/2024-10-2…
ChrisRackauckas Oct 29, 2024
b3db1a2
docs: add note to readme
avik-pal Oct 31, 2024
1b24ae4
Merge branch 'main' of ../SimpleNonlinearSolve.jl into ap/simplenonli…
avik-pal Nov 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/SimpleNonlinearSolve/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.
3 changes: 1 addition & 2 deletions lib/SimpleNonlinearSolve/test/core/adjoint_tests.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
@testitem "Simple Adjoint Test" tags=[:adjoint] begin
using ForwardDiff, ReverseDiff, SciMLSensitivity, Tracker, Zygote, DiffEqBase,
SimpleNonlinearSolve
using ForwardDiff, ReverseDiff, SciMLSensitivity, Tracker, Zygote, DiffEqBase

ff(u, p) = u .^ 2 .- p

Expand Down
41 changes: 41 additions & 0 deletions lib/SimpleNonlinearSolve/test/core/least_squares_tests.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
@testitem "Nonlinear Least Squares" tags=[:core] begin
using LinearAlgebra

true_function(x, θ) = @. θ[1] * exp(θ[2] * x) * cos(θ[3] * x + θ[4])

θ_true = [1.0, 0.1, 2.0, 0.5]
x = [-1.0, -0.5, 0.0, 0.5, 1.0]
y_target = true_function(x, θ_true)

function loss_function(θ, p)
ŷ = true_function(p, θ)
return ŷ .- y_target
end

function loss_function!(resid, θ, p)
ŷ = true_function(p, θ)
@. resid = ŷ - y_target
return
end

θ_init = θ_true .+ 0.1
prob_oop = NonlinearLeastSquaresProblem{false}(loss_function, θ_init, x)

@testset "Solver: $(nameof(typeof(solver)))" for solver in [
SimpleNewtonRaphson(AutoForwardDiff()), SimpleGaussNewton(AutoForwardDiff()),
SimpleNewtonRaphson(AutoFiniteDiff()), SimpleGaussNewton(AutoFiniteDiff())]
sol = solve(prob_oop, solver)
@test norm(sol.resid, Inf) < 1e-12
end

prob_iip = NonlinearLeastSquaresProblem(
NonlinearFunction{true}(loss_function!, resid_prototype = zeros(length(y_target))),
θ_init, x)

@testset "Solver: $(nameof(typeof(solver)))" for solver in [
SimpleNewtonRaphson(AutoForwardDiff()), SimpleGaussNewton(AutoForwardDiff()),
SimpleNewtonRaphson(AutoFiniteDiff()), SimpleGaussNewton(AutoFiniteDiff())]
sol = solve(prob_iip, solver)
@test norm(sol.resid, Inf) < 1e-12
end
end
Loading