diff --git a/tutorials/advanced-jsosolvers/Project.toml b/tutorials/advanced-jsosolvers/Project.toml index 7e401b6..fe9bd19 100644 --- a/tutorials/advanced-jsosolvers/Project.toml +++ b/tutorials/advanced-jsosolvers/Project.toml @@ -8,8 +8,7 @@ SolverBenchmark = "581a75fa-a23a-52d0-a590-d6201de2218a" [compat] ADNLPModels = "0.7" -JSOSolvers = "0.11" -Krylov = "0.9" +JSOSolvers = "0.14" OptimizationProblems = "0.7" Plots = "1" SolverBenchmark = "0.6" diff --git a/tutorials/advanced-jsosolvers/index.jmd b/tutorials/advanced-jsosolvers/index.jmd index 00ffe52..0540a30 100644 --- a/tutorials/advanced-jsosolvers/index.jmd +++ b/tutorials/advanced-jsosolvers/index.jmd @@ -4,19 +4,15 @@ 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. -```julia -using JSOSolvers -``` - -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 -using ADNLPModels +using JSOSolvers, ADNLPModels using OptimizationProblems using OptimizationProblems.ADNLPProblems df = OptimizationProblems.meta @@ -38,27 +34,38 @@ 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 ``` 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/). + +We define a dictionary of the different solvers that will be benchmarked. +We consider here four variants of TRUNK using the different subsolvers. + +For example, to call TRUNK with an explicit subsolver: ```julia -using Krylov +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) +``` + +Now we define the solver dictionary for benchmarking: ```julia 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) + :trunk_cgls => model -> trunk(model, subsolver = :cgls), + :trunk_crls => model -> trunk(model, subsolver = :crls), + :trunk_lsqr => model -> trunk(model, subsolver = :lsqr), + :trunk_lsmr => model -> trunk(model, subsolver = :lsmr) ) ``` @@ -91,5 +98,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/Project.toml b/tutorials/introduction-to-jsosolvers/Project.toml index db61db4..809d022 100644 --- a/tutorials/introduction-to-jsosolvers/Project.toml +++ b/tutorials/introduction-to-jsosolvers/Project.toml @@ -12,6 +12,6 @@ SolverCore = "ff4d7338-4cf1-434d-91df-b86cb86fb843" ADNLPModels = "0.7" CSV = "0.10" DataFrames = "1.4" -JSOSolvers = "0.11" +JSOSolvers = "0.14" Plots = "1.38" SolverCore = "0.3" diff --git a/tutorials/introduction-to-jsosolvers/index.jmd b/tutorials/introduction-to-jsosolvers/index.jmd index af93c9e..43fa0de 100644 --- a/tutorials/introduction-to-jsosolvers/index.jmd +++ b/tutorials/introduction-to-jsosolvers/index.jmd @@ -47,6 +47,7 @@ The following examples illustrate this specialization. To list the allowed least-squares subsolvers for these specializations: ```julia +using JSOSolvers JSOSolvers.trunkls_allowed_subsolvers JSOSolvers.tronls_allowed_subsolvers ```