Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 1 addition & 2 deletions tutorials/advanced-jsosolvers/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
39 changes: 23 additions & 16 deletions tutorials/advanced-jsosolvers/index.jmd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
)
```

Expand Down Expand Up @@ -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.
2 changes: 1 addition & 1 deletion tutorials/introduction-to-jsosolvers/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
1 change: 1 addition & 0 deletions tutorials/introduction-to-jsosolvers/index.jmd
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand Down
Loading