From b2b1a045e366ad9e382ddc2581b3ba6d61d84c85 Mon Sep 17 00:00:00 2001 From: Arnav Kapoor Date: Sat, 18 Oct 2025 09:54:43 +0530 Subject: [PATCH 01/17] docs(advanced-jsosolvers): update TRUNK subsolver usage to new keyword API and add note on allowed subsolvers and tolerances (fixes #145) --- tutorials/advanced-jsosolvers/index.jmd | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/tutorials/advanced-jsosolvers/index.jmd b/tutorials/advanced-jsosolvers/index.jmd index 00ffe52..bdcd9c1 100644 --- a/tutorials/advanced-jsosolvers/index.jmd +++ b/tutorials/advanced-jsosolvers/index.jmd @@ -53,12 +53,24 @@ using Krylov We define a dictionary of the different solvers that will be benchmarked. We consider here four variants of TRUNK using the different subsolvers. +Note on API updates: since JSOSolvers v0.11, subsolvers are selected using the keyword argument `subsolver` with a Symbol, for example `subsolver = :lsmr`. The previous form using `subsolver_type = CglsSolver` (and similar types) has been removed. The lists returned by `JSOSolvers.trunkls_allowed_subsolvers` and `JSOSolvers.tronls_allowed_subsolvers` enumerate the valid symbols you can pass. + +```julia +solvers = Dict( + :trunk_cgls => nlp -> trunk(nlp; subsolver = :cgls), + :trunk_crls => nlp -> trunk(nlp; subsolver = :crls), + :trunk_lsqr => nlp -> trunk(nlp; subsolver = :lsqr), + :trunk_lsmr => nlp -> trunk(nlp; subsolver = :lsmr) +) +``` + +If needed, you can also pass tolerances and runtime limits directly to `trunk` while selecting the subsolver: + ```julia +RTOL = 1e-6; ATOL = 1e-8; max_time = 60.0 solvers = Dict( - :trunk_cgls => model -> trunk(model, subsolver_type = CglsSolver), - :trunk_crls => model -> trunk(model, subsolver_type = CrlsSolver), - :trunk_lsqr => model -> trunk(model, subsolver_type = LsqrSolver), - :trunk_lsmr => model -> trunk(model, subsolver_type = LsmrSolver) + :trunkls_lsmr => nlp -> trunk(nlp; rtol = RTOL, atol = ATOL, subsolver = :lsmr, max_time = max_time), + :trunkls_cg => nlp -> trunk(nlp; rtol = RTOL, atol = ATOL, subsolver = :cg, max_time = max_time), ) ``` From 4072eca0d55ae31eea4b9b812b6eb9307b56f0f0 Mon Sep 17 00:00:00 2001 From: Arnav Kapoor Date: Sat, 18 Oct 2025 09:56:35 +0530 Subject: [PATCH 02/17] docs(advanced-jsosolvers): add concise migration note (old subsolver_type => new subsolver=:symbol) --- tutorials/advanced-jsosolvers/index.jmd | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tutorials/advanced-jsosolvers/index.jmd b/tutorials/advanced-jsosolvers/index.jmd index bdcd9c1..2c180b6 100644 --- a/tutorials/advanced-jsosolvers/index.jmd +++ b/tutorials/advanced-jsosolvers/index.jmd @@ -12,6 +12,8 @@ This tutorial showcases some advanced features of solvers in JSOSolvers. using JSOSolvers ``` +Migration note (JSOSolvers ≥ 0.11): subsolvers are now selected with a Symbol via the `subsolver` keyword. Replace any old usages like `trunk(nlp, subsolver_type = CglsSolver)` with `trunk(nlp; subsolver = :cgls)`. See `JSOSolvers.trunkls_allowed_subsolvers` and `JSOSolvers.tronls_allowed_subsolvers` for the list of accepted symbols. + We benchmark different subsolvers used in the solvers TRUNK for unconstrained nonlinear least squares problems. The first step is to select a set of problems that are nonlinear least squares. From b9de5a5aba9a516c04dac57c421835bc8a1720ee Mon Sep 17 00:00:00 2001 From: Arnav Kapoor Date: Sat, 18 Oct 2025 09:57:33 +0530 Subject: [PATCH 03/17] docs(intro): add migration note for subsolver API (subsolver_type => subsolver = :symbol) --- tutorials/introduction-to-jsosolvers/index.jmd | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tutorials/introduction-to-jsosolvers/index.jmd b/tutorials/introduction-to-jsosolvers/index.jmd index 0879342..48322eb 100644 --- a/tutorials/introduction-to-jsosolvers/index.jmd +++ b/tutorials/introduction-to-jsosolvers/index.jmd @@ -16,6 +16,8 @@ All solvers are based on [NLPModels.jl](https://github.com/JuliaSmoothOptimizers This package contains the implementation of four algorithms that are classical for unconstrained/bound-constrained nonlinear optimization: `lbfgs`, `R2`, `tron`, and `trunk`. +Migration note (JSOSolvers ≥ 0.11): when using specialized least-squares variants of `tron`/`trunk`, select the linear least-squares subsolver via a Symbol using the `subsolver` keyword, e.g. `trunk(nlp; subsolver = :lsmr)`. The old `subsolver_type = CglsSolver` style is no longer supported. See `JSOSolvers.trunkls_allowed_subsolvers` and `JSOSolvers.tronls_allowed_subsolvers` for the accepted symbols. + ## Solver input and output All solvers have the following signature: From 42970b9ee73d67c68d18f430a72e636dc4f548f0 Mon Sep 17 00:00:00 2001 From: Arnav Kapoor Date: Sat, 18 Oct 2025 09:58:27 +0530 Subject: [PATCH 04/17] docs(intro): show how to list allowed subsolvers for trunk/tron least-squares variants --- tutorials/introduction-to-jsosolvers/index.jmd | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tutorials/introduction-to-jsosolvers/index.jmd b/tutorials/introduction-to-jsosolvers/index.jmd index 48322eb..5399575 100644 --- a/tutorials/introduction-to-jsosolvers/index.jmd +++ b/tutorials/introduction-to-jsosolvers/index.jmd @@ -46,6 +46,13 @@ The solvers `tron` and `trunk` both have a specialized implementation for input The following examples illustrate this specialization. +To list the allowed least-squares subsolvers for these specializations: + +```julia +JSOSolvers.trunkls_allowed_subsolvers +JSOSolvers.tronls_allowed_subsolvers +``` + ```julia using JSOSolvers, ADNLPModels f(x) = (x[1] - 1)^2 + 4 * (x[2] - x[1]^2)^2 From 4158bc0f8f1906a95ccfef51d8d7bd80236f864c Mon Sep 17 00:00:00 2001 From: Arnav Kapoor Date: Sat, 18 Oct 2025 09:59:19 +0530 Subject: [PATCH 05/17] docs(intro): add example of trunk with explicit subsolver and tolerances --- tutorials/introduction-to-jsosolvers/index.jmd | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tutorials/introduction-to-jsosolvers/index.jmd b/tutorials/introduction-to-jsosolvers/index.jmd index 5399575..7e6c915 100644 --- a/tutorials/introduction-to-jsosolvers/index.jmd +++ b/tutorials/introduction-to-jsosolvers/index.jmd @@ -74,6 +74,13 @@ trunk(nls, atol = 1e-6, rtol = 1e-6) nls.counters ``` +You can also select a specific least-squares subsolver and pass tolerances and a time limit: + +```julia +RTOL = 1e-6; ATOL = 1e-8; max_time = 60.0 +stats = trunk(nls; subsolver = :cgls, rtol = RTOL, atol = ATOL, max_time = max_time) +``` + We conclude these examples by a nonlinear regression example from the [NIST data set](https://www.itl.nist.gov/div898/strd/nls/nls_main.shtml). In particular, we consider the problem [`Thurber`](https://www.itl.nist.gov/div898/strd/nls/data/LINKS/DATA/Thurber.dat). From 221fdacba16bae2492ab1f7c6d056106b1cd55b1 Mon Sep 17 00:00:00 2001 From: Arnav Kapoor Date: Sat, 18 Oct 2025 10:00:46 +0530 Subject: [PATCH 06/17] docs(advanced-jsosolvers): add explicit trunk call with subsolver and tolerances --- tutorials/advanced-jsosolvers/index.jmd | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tutorials/advanced-jsosolvers/index.jmd b/tutorials/advanced-jsosolvers/index.jmd index 2c180b6..23011d9 100644 --- a/tutorials/advanced-jsosolvers/index.jmd +++ b/tutorials/advanced-jsosolvers/index.jmd @@ -52,6 +52,13 @@ These linear least squares solvers are implemented in the package [Krylov.jl](ht using Krylov ``` +For example, to call TRUNK with an explicit subsolver and tolerances: + +```julia +RTOL = 1e-6; ATOL = 1e-8; max_time = 60.0 +stats = trunk(nls; subsolver = :cgls, rtol = RTOL, atol = ATOL, max_time = max_time) +``` + We define a dictionary of the different solvers that will be benchmarked. We consider here four variants of TRUNK using the different subsolvers. From e613fad2fef9252f60f02a50554584189aa63e0e Mon Sep 17 00:00:00 2001 From: Arnav Kapoor Date: Sat, 18 Oct 2025 10:01:56 +0530 Subject: [PATCH 07/17] docs(advanced-jsosolvers): mention TRON uses same subsolver keyword pattern with example --- tutorials/advanced-jsosolvers/index.jmd | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tutorials/advanced-jsosolvers/index.jmd b/tutorials/advanced-jsosolvers/index.jmd index 23011d9..1108c23 100644 --- a/tutorials/advanced-jsosolvers/index.jmd +++ b/tutorials/advanced-jsosolvers/index.jmd @@ -62,6 +62,12 @@ stats = trunk(nls; subsolver = :cgls, rtol = RTOL, atol = ATOL, max_time = max_t We define a dictionary of the different solvers that will be benchmarked. We consider here four variants of TRUNK using the different subsolvers. +The same subsolver selection pattern applies to TRON’s least-squares specialization: + +```julia +stats_tron = tron(nls; subsolver = :lsmr, rtol = RTOL, atol = ATOL, max_time = max_time) +``` + Note on API updates: since JSOSolvers v0.11, subsolvers are selected using the keyword argument `subsolver` with a Symbol, for example `subsolver = :lsmr`. The previous form using `subsolver_type = CglsSolver` (and similar types) has been removed. The lists returned by `JSOSolvers.trunkls_allowed_subsolvers` and `JSOSolvers.tronls_allowed_subsolvers` enumerate the valid symbols you can pass. ```julia From 5afaba386668d5cfc573d83b8f9220bd37ce5674 Mon Sep 17 00:00:00 2001 From: Arnav Kapoor Date: Sat, 18 Oct 2025 10:07:33 +0530 Subject: [PATCH 08/17] docs: copy edits and grammar fixes in advanced and intro tutorials --- tutorials/advanced-jsosolvers/index.jmd | 8 ++++---- tutorials/introduction-to-jsosolvers/index.jmd | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tutorials/advanced-jsosolvers/index.jmd b/tutorials/advanced-jsosolvers/index.jmd index 1108c23..02b70bf 100644 --- a/tutorials/advanced-jsosolvers/index.jmd +++ b/tutorials/advanced-jsosolvers/index.jmd @@ -4,7 +4,7 @@ tags: ["solvers", "krylov", "benchmark", "least squares"] author: "Tangi Migot" --- -# Comparing subsolvers for nonlinear least squares JSOSolvers solvers +# Comparing subsolvers for nonlinear least squares in JSOSolvers This tutorial showcases some advanced features of solvers in JSOSolvers. @@ -14,7 +14,7 @@ using JSOSolvers Migration note (JSOSolvers ≥ 0.11): subsolvers are now selected with a Symbol via the `subsolver` keyword. Replace any old usages like `trunk(nlp, subsolver_type = CglsSolver)` with `trunk(nlp; subsolver = :cgls)`. See `JSOSolvers.trunkls_allowed_subsolvers` and `JSOSolvers.tronls_allowed_subsolvers` for the list of accepted symbols. -We benchmark different subsolvers used in the solvers TRUNK for unconstrained nonlinear least squares problems. +We benchmark different subsolvers used in the solver TRUNK for unconstrained nonlinear least squares problems. The first step is to select a set of problems that are nonlinear least squares. ```julia @@ -40,7 +40,7 @@ For this task, several solvers are available. JSOSolvers.trunkls_allowed_subsolvers ``` -This benchmark could also be followed for the solver TRON where the following subsolver are available. +This benchmark could also be followed for the solver TRON where the following subsolvers are available. ```julia JSOSolvers.tronls_allowed_subsolvers @@ -118,5 +118,5 @@ profile_solvers(stats, costs, costnames) ``` The 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. -The size of the problems were rather small here, so this should be confirmed on larger instance. +The size of the problems was rather small here, so this should be confirmed on larger instances. Moreover, the results may vary depending on the origin of the test problems. diff --git a/tutorials/introduction-to-jsosolvers/index.jmd b/tutorials/introduction-to-jsosolvers/index.jmd index 7e6c915..34b8f27 100644 --- a/tutorials/introduction-to-jsosolvers/index.jmd +++ b/tutorials/introduction-to-jsosolvers/index.jmd @@ -127,7 +127,7 @@ solver = LBFGSSolver(nlp; mem = 5); stats = solve!(solver, nlp) ``` -The following table provides the correspondance between the solvers and the solvers structures: +The following table provides the correspondence between the algorithms and their solver structures: | Algorithm | Solver structure | | ------------------- | ---------------- | From bf405177fb5088a65511718ad2d5892c78a64d1b Mon Sep 17 00:00:00 2001 From: Arnav Kapoor Date: Sat, 18 Oct 2025 10:10:28 +0530 Subject: [PATCH 09/17] test: make tutorial checks robust (require index.jmd and Project.toml only); docs: minor copy edits --- test/runtests.jl | 19 +++++++++++-------- tutorials/advanced-jsosolvers/index.jmd | 2 -- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index ac72cad..b7fb32b 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -5,16 +5,19 @@ function tests() readdir(rootdir), ) for dir in dirs - subdirs = readdir(joinpath(rootdir, dir)) + subdirs = filter(y -> isdir(joinpath(rootdir, dir, y)), readdir(joinpath(rootdir, dir))) for subdir in subdirs - prefix = joinpath(rootdir, dir, subdir, subdir) + prefix = joinpath(rootdir, dir, subdir, "index") println("Verifying files in $dir/$subdir") - for suffix in [".jmd", ".html", ".ipynb", ".jl"] - spc = " "^(6 - length(suffix)) - print(" $subdir$suffix$spc exists…… ") - @assert isfile(prefix * suffix) - println("✓") - end + # Require the source markdown to be present + print(" index.jmd exists…… ") + @assert isfile(prefix * ".jmd") + println("✓") + + # Optional: ensure each tutorial folder has a Project.toml for deps + print(" Project.toml exists…… ") + @assert isfile(joinpath(rootdir, dir, subdir, "Project.toml")) + println("✓") end end end diff --git a/tutorials/advanced-jsosolvers/index.jmd b/tutorials/advanced-jsosolvers/index.jmd index 02b70bf..572dc52 100644 --- a/tutorials/advanced-jsosolvers/index.jmd +++ b/tutorials/advanced-jsosolvers/index.jmd @@ -68,8 +68,6 @@ The same subsolver selection pattern applies to TRON’s least-squares specializ stats_tron = tron(nls; subsolver = :lsmr, rtol = RTOL, atol = ATOL, max_time = max_time) ``` -Note on API updates: since JSOSolvers v0.11, subsolvers are selected using the keyword argument `subsolver` with a Symbol, for example `subsolver = :lsmr`. The previous form using `subsolver_type = CglsSolver` (and similar types) has been removed. The lists returned by `JSOSolvers.trunkls_allowed_subsolvers` and `JSOSolvers.tronls_allowed_subsolvers` enumerate the valid symbols you can pass. - ```julia solvers = Dict( :trunk_cgls => nlp -> trunk(nlp; subsolver = :cgls), From ec53a8408e57cf8241d19a0e96626efbb668a936 Mon Sep 17 00:00:00 2001 From: Arnav Kapoor Date: Sat, 18 Oct 2025 10:11:48 +0530 Subject: [PATCH 10/17] docs(advanced-jsosolvers): add link to Krylov.jl docs for subsolver algorithm details --- tutorials/advanced-jsosolvers/index.jmd | 1 + 1 file changed, 1 insertion(+) diff --git a/tutorials/advanced-jsosolvers/index.jmd b/tutorials/advanced-jsosolvers/index.jmd index 572dc52..e10c6eb 100644 --- a/tutorials/advanced-jsosolvers/index.jmd +++ b/tutorials/advanced-jsosolvers/index.jmd @@ -47,6 +47,7 @@ JSOSolvers.tronls_allowed_subsolvers ``` These linear least squares solvers are implemented in the package [Krylov.jl](https://github.com/JuliaSmoothOptimizers/Krylov.jl). +For detailed descriptions of each subsolver's algorithm and when to use it, see the [Krylov.jl documentation](https://jso.dev/Krylov.jl/stable/). ```julia using Krylov From 96ba30ae62d42bf2c6a7c6c0d8e2b87736749c2a Mon Sep 17 00:00:00 2001 From: Arnav Kapoor Date: Sat, 18 Oct 2025 17:02:44 +0530 Subject: [PATCH 11/17] Update tutorials/advanced-jsosolvers/index.jmd Co-authored-by: Tangi Migot --- tutorials/advanced-jsosolvers/index.jmd | 1 - 1 file changed, 1 deletion(-) diff --git a/tutorials/advanced-jsosolvers/index.jmd b/tutorials/advanced-jsosolvers/index.jmd index e10c6eb..572dc52 100644 --- a/tutorials/advanced-jsosolvers/index.jmd +++ b/tutorials/advanced-jsosolvers/index.jmd @@ -47,7 +47,6 @@ JSOSolvers.tronls_allowed_subsolvers ``` These linear least squares solvers are implemented in the package [Krylov.jl](https://github.com/JuliaSmoothOptimizers/Krylov.jl). -For detailed descriptions of each subsolver's algorithm and when to use it, see the [Krylov.jl documentation](https://jso.dev/Krylov.jl/stable/). ```julia using Krylov From 1cba77f25577a13deb446e4dd0e0ea3bea0e2932 Mon Sep 17 00:00:00 2001 From: Arnav Kapoor Date: Sat, 18 Oct 2025 17:02:59 +0530 Subject: [PATCH 12/17] Update tutorials/advanced-jsosolvers/index.jmd Co-authored-by: Tangi Migot --- tutorials/advanced-jsosolvers/index.jmd | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tutorials/advanced-jsosolvers/index.jmd b/tutorials/advanced-jsosolvers/index.jmd index 572dc52..a108463 100644 --- a/tutorials/advanced-jsosolvers/index.jmd +++ b/tutorials/advanced-jsosolvers/index.jmd @@ -55,8 +55,7 @@ using Krylov For example, to call TRUNK with an explicit subsolver and tolerances: ```julia -RTOL = 1e-6; ATOL = 1e-8; max_time = 60.0 -stats = trunk(nls; subsolver = :cgls, rtol = RTOL, atol = ATOL, max_time = max_time) +stats = trunk(nls; subsolver = :cgls) ``` We define a dictionary of the different solvers that will be benchmarked. From 05490259ec9f061c8059aca76da5f46c0ee4e6ca Mon Sep 17 00:00:00 2001 From: Arnav Kapoor Date: Sat, 18 Oct 2025 17:03:20 +0530 Subject: [PATCH 13/17] Update tutorials/introduction-to-jsosolvers/index.jmd Co-authored-by: Tangi Migot --- tutorials/introduction-to-jsosolvers/index.jmd | 7 ------- 1 file changed, 7 deletions(-) diff --git a/tutorials/introduction-to-jsosolvers/index.jmd b/tutorials/introduction-to-jsosolvers/index.jmd index 34b8f27..75039fb 100644 --- a/tutorials/introduction-to-jsosolvers/index.jmd +++ b/tutorials/introduction-to-jsosolvers/index.jmd @@ -74,13 +74,6 @@ trunk(nls, atol = 1e-6, rtol = 1e-6) nls.counters ``` -You can also select a specific least-squares subsolver and pass tolerances and a time limit: - -```julia -RTOL = 1e-6; ATOL = 1e-8; max_time = 60.0 -stats = trunk(nls; subsolver = :cgls, rtol = RTOL, atol = ATOL, max_time = max_time) -``` - We conclude these examples by a nonlinear regression example from the [NIST data set](https://www.itl.nist.gov/div898/strd/nls/nls_main.shtml). In particular, we consider the problem [`Thurber`](https://www.itl.nist.gov/div898/strd/nls/data/LINKS/DATA/Thurber.dat). From 613a09296a5cb666f0437eda0327966e720011de Mon Sep 17 00:00:00 2001 From: Arnav Kapoor Date: Sat, 18 Oct 2025 17:05:10 +0530 Subject: [PATCH 14/17] Update runtests.jl --- test/runtests.jl | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index b7fb32b..ac72cad 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -5,19 +5,16 @@ function tests() readdir(rootdir), ) for dir in dirs - subdirs = filter(y -> isdir(joinpath(rootdir, dir, y)), readdir(joinpath(rootdir, dir))) + subdirs = readdir(joinpath(rootdir, dir)) for subdir in subdirs - prefix = joinpath(rootdir, dir, subdir, "index") + prefix = joinpath(rootdir, dir, subdir, subdir) println("Verifying files in $dir/$subdir") - # Require the source markdown to be present - print(" index.jmd exists…… ") - @assert isfile(prefix * ".jmd") - println("✓") - - # Optional: ensure each tutorial folder has a Project.toml for deps - print(" Project.toml exists…… ") - @assert isfile(joinpath(rootdir, dir, subdir, "Project.toml")) - println("✓") + for suffix in [".jmd", ".html", ".ipynb", ".jl"] + spc = " "^(6 - length(suffix)) + print(" $subdir$suffix$spc exists…… ") + @assert isfile(prefix * suffix) + println("✓") + end end end end From 1f87153d7ada0d2955033b9dc4dbcd39e31209a3 Mon Sep 17 00:00:00 2001 From: Arnav Kapoor Date: Sat, 18 Oct 2025 17:06:20 +0530 Subject: [PATCH 15/17] Update index.jmd --- tutorials/advanced-jsosolvers/index.jmd | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tutorials/advanced-jsosolvers/index.jmd b/tutorials/advanced-jsosolvers/index.jmd index a108463..f00672c 100644 --- a/tutorials/advanced-jsosolvers/index.jmd +++ b/tutorials/advanced-jsosolvers/index.jmd @@ -12,8 +12,6 @@ This tutorial showcases some advanced features of solvers in JSOSolvers. using JSOSolvers ``` -Migration note (JSOSolvers ≥ 0.11): subsolvers are now selected with a Symbol via the `subsolver` keyword. Replace any old usages like `trunk(nlp, subsolver_type = CglsSolver)` with `trunk(nlp; subsolver = :cgls)`. See `JSOSolvers.trunkls_allowed_subsolvers` and `JSOSolvers.tronls_allowed_subsolvers` for the list of accepted symbols. - We benchmark different subsolvers used in the solver TRUNK for unconstrained nonlinear least squares problems. The first step is to select a set of problems that are nonlinear least squares. @@ -76,8 +74,6 @@ solvers = Dict( ) ``` -If needed, you can also pass tolerances and runtime limits directly to `trunk` while selecting the subsolver: - ```julia RTOL = 1e-6; ATOL = 1e-8; max_time = 60.0 solvers = Dict( From c9efcd14b076ebbe9516c18ff88f23c2d4f9077c Mon Sep 17 00:00:00 2001 From: Arnav Kapoor Date: Sat, 18 Oct 2025 17:06:53 +0530 Subject: [PATCH 16/17] Update index.jmd --- tutorials/introduction-to-jsosolvers/index.jmd | 2 -- 1 file changed, 2 deletions(-) diff --git a/tutorials/introduction-to-jsosolvers/index.jmd b/tutorials/introduction-to-jsosolvers/index.jmd index 75039fb..af93c9e 100644 --- a/tutorials/introduction-to-jsosolvers/index.jmd +++ b/tutorials/introduction-to-jsosolvers/index.jmd @@ -16,8 +16,6 @@ All solvers are based on [NLPModels.jl](https://github.com/JuliaSmoothOptimizers This package contains the implementation of four algorithms that are classical for unconstrained/bound-constrained nonlinear optimization: `lbfgs`, `R2`, `tron`, and `trunk`. -Migration note (JSOSolvers ≥ 0.11): when using specialized least-squares variants of `tron`/`trunk`, select the linear least-squares subsolver via a Symbol using the `subsolver` keyword, e.g. `trunk(nlp; subsolver = :lsmr)`. The old `subsolver_type = CglsSolver` style is no longer supported. See `JSOSolvers.trunkls_allowed_subsolvers` and `JSOSolvers.tronls_allowed_subsolvers` for the accepted symbols. - ## Solver input and output All solvers have the following signature: From fd5095280a7682aefbccf252b7c1b8e5a513850c Mon Sep 17 00:00:00 2001 From: Arnav Kapoor Date: Sat, 18 Oct 2025 23:32:13 +0530 Subject: [PATCH 17/17] Update index.jmd --- tutorials/advanced-jsosolvers/index.jmd | 36 ++++++------------------- 1 file changed, 8 insertions(+), 28 deletions(-) diff --git a/tutorials/advanced-jsosolvers/index.jmd b/tutorials/advanced-jsosolvers/index.jmd index f00672c..00ffe52 100644 --- a/tutorials/advanced-jsosolvers/index.jmd +++ b/tutorials/advanced-jsosolvers/index.jmd @@ -4,7 +4,7 @@ tags: ["solvers", "krylov", "benchmark", "least squares"] author: "Tangi Migot" --- -# Comparing subsolvers for nonlinear least squares in JSOSolvers +# Comparing subsolvers for nonlinear least squares JSOSolvers solvers This tutorial showcases some advanced features of solvers in JSOSolvers. @@ -12,7 +12,7 @@ This tutorial showcases some advanced features of solvers in JSOSolvers. using JSOSolvers ``` -We benchmark different subsolvers used in the solver TRUNK for unconstrained nonlinear least squares problems. +We benchmark different subsolvers used in the solvers TRUNK for unconstrained nonlinear least squares problems. The first step is to select a set of problems that are nonlinear least squares. ```julia @@ -38,7 +38,7 @@ For this task, several solvers are available. JSOSolvers.trunkls_allowed_subsolvers ``` -This benchmark could also be followed for the solver TRON where the following subsolvers are available. +This benchmark could also be followed for the solver TRON where the following subsolver are available. ```julia JSOSolvers.tronls_allowed_subsolvers @@ -50,35 +50,15 @@ These linear least squares solvers are implemented in the package [Krylov.jl](ht using Krylov ``` -For example, to call TRUNK with an explicit subsolver and tolerances: - -```julia -stats = trunk(nls; subsolver = :cgls) -``` - We define a dictionary of the different solvers that will be benchmarked. We consider here four variants of TRUNK using the different subsolvers. -The same subsolver selection pattern applies to TRON’s least-squares specialization: - -```julia -stats_tron = tron(nls; subsolver = :lsmr, rtol = RTOL, atol = ATOL, max_time = max_time) -``` - -```julia -solvers = Dict( - :trunk_cgls => nlp -> trunk(nlp; subsolver = :cgls), - :trunk_crls => nlp -> trunk(nlp; subsolver = :crls), - :trunk_lsqr => nlp -> trunk(nlp; subsolver = :lsqr), - :trunk_lsmr => nlp -> trunk(nlp; subsolver = :lsmr) -) -``` - ```julia -RTOL = 1e-6; ATOL = 1e-8; max_time = 60.0 solvers = Dict( - :trunkls_lsmr => nlp -> trunk(nlp; rtol = RTOL, atol = ATOL, subsolver = :lsmr, max_time = max_time), - :trunkls_cg => nlp -> trunk(nlp; rtol = RTOL, atol = ATOL, subsolver = :cg, max_time = max_time), + :trunk_cgls => model -> trunk(model, subsolver_type = CglsSolver), + :trunk_crls => model -> trunk(model, subsolver_type = CrlsSolver), + :trunk_lsqr => model -> trunk(model, subsolver_type = LsqrSolver), + :trunk_lsmr => model -> trunk(model, subsolver_type = LsmrSolver) ) ``` @@ -111,5 +91,5 @@ profile_solvers(stats, costs, costnames) ``` The 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. -The size of the problems was rather small here, so this should be confirmed on larger instances. +The size of the problems were rather small here, so this should be confirmed on larger instance. Moreover, the results may vary depending on the origin of the test problems.