@@ -4,15 +4,19 @@ tags: ["solvers", "krylov", "benchmark", "least squares"]
44author: "Tangi Migot"
55---
66
7- # Comparing subsolvers for nonlinear least squares in JSOSolvers
7+ # Comparing subsolvers for nonlinear least squares JSOSolvers solvers
88
99This tutorial showcases some advanced features of solvers in JSOSolvers.
1010
11- We benchmark different subsolvers used in the solver TRUNK for unconstrained nonlinear least squares problems.
11+ ```julia
12+ using JSOSolvers
13+ ```
14+
15+ We benchmark different subsolvers used in the solvers TRUNK for unconstrained nonlinear least squares problems.
1216The first step is to select a set of problems that are nonlinear least squares.
1317
1418```julia
15- using JSOSolvers, ADNLPModels
19+ using ADNLPModels
1620using OptimizationProblems
1721using OptimizationProblems.ADNLPProblems
1822df = OptimizationProblems.meta
@@ -34,38 +38,27 @@ For this task, several solvers are available.
3438JSOSolvers.trunkls_allowed_subsolvers
3539```
3640
37- This benchmark could also be followed for the solver TRON where the following subsolvers are available.
41+ This benchmark could also be followed for the solver TRON where the following subsolver are available.
3842
3943```julia
4044JSOSolvers.tronls_allowed_subsolvers
4145```
4246
4347These linear least squares solvers are implemented in the package [Krylov.jl](https://github.com/JuliaSmoothOptimizers/Krylov.jl).
44- For detailed descriptions of each subsolver's algorithm and when to use it, see the [Krylov.jl documentation](https://jso.dev/Krylov.jl/stable/).
45-
46- We define a dictionary of the different solvers that will be benchmarked.
47- We consider here four variants of TRUNK using the different subsolvers.
48-
49- For example, to call TRUNK with an explicit subsolver:
5048
5149```julia
52- stats = trunk(nls, subsolver = :cgls)
50+ using Krylov
5351```
5452
55- The same subsolver selection pattern applies to TRON's least-squares specialization:
56-
57- ```julia
58- stats_tron = tron(nls, subsolver = :lsmr)
59- ```
60-
61- Now we define the solver dictionary for benchmarking:
53+ We define a dictionary of the different solvers that will be benchmarked.
54+ We consider here four variants of TRUNK using the different subsolvers.
6255
6356```julia
6457solvers = Dict(
65- :trunk_cgls => model -> trunk(model, subsolver = :cgls ),
66- :trunk_crls => model -> trunk(model, subsolver = :crls ),
67- :trunk_lsqr => model -> trunk(model, subsolver = :lsqr ),
68- :trunk_lsmr => model -> trunk(model, subsolver = :lsmr )
58+ :trunk_cgls => model -> trunk(model, subsolver_type = CglsSolver ),
59+ :trunk_crls => model -> trunk(model, subsolver_type = CrlsSolver ),
60+ :trunk_lsqr => model -> trunk(model, subsolver_type = LsqrSolver ),
61+ :trunk_lsmr => model -> trunk(model, subsolver_type = LsmrSolver )
6962)
7063```
7164
@@ -98,5 +91,5 @@ profile_solvers(stats, costs, costnames)
9891```
9992
10093The CRLS and CGLS variants are the ones solving more problems, and even though the difference is rather small the CGLS variant is consistently faster which seems to indicate that it is the most appropriate subsolver for TRUNK.
101- The size of the problems was rather small here, so this should be confirmed on larger instances .
94+ The size of the problems were rather small here, so this should be confirmed on larger instance .
10295Moreover, the results may vary depending on the origin of the test problems.
0 commit comments