Skip to content

Commit 431abfd

Browse files
arnavk23tmigot
andauthored
Bump JSOSolvers to 0.14 and in JSOSolvers tutorials (#148)
* docs(advanced-jsosolvers): update TRUNK/TRON subsolver usage to new keyword API (fixes #145) - Add migration note showing old subsolver_type => new subsolver=:symbol API - Update solver dictionary examples to use subsolver = :cgls, :crls, :lsqr, :lsmr - Add explicit TRUNK and TRON examples with subsolver, rtol, atol, max_time - Add reference to JSOSolvers allowed_subsolvers lists - Link to Krylov.jl docs for subsolver algorithm details - Fix grammar and copy edits (heading, wording, plurals) * docs(advanced-jsosolvers): add migration note and Krylov.jl docs link for complete #145 fix - Add migration note at top explaining subsolver_type => subsolver API change - Link to Krylov.jl documentation for subsolver algorithm details - Ensures users understand the new API and can find detailed subsolver info * test: fix runtests.jl to only check tutorial directories - Filter out non-directory items (like files in scripts/) - Only check for index.jmd and Project.toml (not generated files) - Fixes test suite that was failing on both main and fix branches * Update index.jmd * Update tutorials/advanced-jsosolvers/index.jmd Co-authored-by: Tangi Migot <[email protected]> * Revert to correct JSOSolvers 0.11 API The previous changes attempted to use `subsolver = :symbol` API which doesn't exist in JSOSolvers 0.11. Testing confirmed that JSOSolvers 0.11 uses `subsolver_type = Type` (e.g., CglsSolver, LsmrSolver). This commit reverts to the correct working API that is compatible with JSOSolvers 0.11.2. * Update runtests.jl * Update tutorials to use JSOSolvers 0.14 with Symbol-based subsolver API - Update JSOSolvers from 0.11 to 0.14 in Project.toml files - Update Krylov from 0.9 to 0.10 (required by JSOSolvers 0.14) - Replace Type-based subsolver API with Symbol-based API: * subsolver_type = CglsSolver → subsolver = :cgls * subsolver_type = LsmrSolver → subsolver = :lsmr * etc. - Remove Krylov.jl import (no longer needed for subsolver types) - Remove compatibility note about JSOSolvers 0.11 This addresses issue #145 by updating to the new subsolver API introduced in JSOSolvers 0.14.0. Affected tutorials: - tutorials/advanced-jsosolvers/ - tutorials/introduction-to-jsosolvers/ Tests: All package tests pass ✓ * intro tutorial: ensure `using JSOSolvers` precedes constants listing The version badge on the site is derived from the local Project.toml, so we test against tutorials/introduction-to-jsosolvers/Project.toml. This change guarantees the constants are referenced after importing JSOSolvers (v0.14+ Symbol subsolver API). * Delete tutorials/introduction-to-jsosolvers/Manifest.toml * Clean up code block formatting in index.jmd Removed unnecessary code block delimiters from documentation. * Modify import statements in index.jmd Updated import statements to include ADNLPModels with JSOSolvers. * Update tutorials/advanced-jsosolvers/Project.toml --------- Co-authored-by: Tangi Migot <[email protected]>
1 parent 8b527f4 commit 431abfd

File tree

4 files changed

+26
-19
lines changed

4 files changed

+26
-19
lines changed

tutorials/advanced-jsosolvers/Project.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ SolverBenchmark = "581a75fa-a23a-52d0-a590-d6201de2218a"
88

99
[compat]
1010
ADNLPModels = "0.7"
11-
JSOSolvers = "0.11"
12-
Krylov = "0.9"
11+
JSOSolvers = "0.14"
1312
OptimizationProblems = "0.7"
1413
Plots = "1"
1514
SolverBenchmark = "0.6"

tutorials/advanced-jsosolvers/index.jmd

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,15 @@ tags: ["solvers", "krylov", "benchmark", "least squares"]
44
author: "Tangi Migot"
55
---
66

7-
# Comparing subsolvers for nonlinear least squares JSOSolvers solvers
7+
# Comparing subsolvers for nonlinear least squares in JSOSolvers
88

99
This tutorial showcases some advanced features of solvers in JSOSolvers.
1010

11-
```julia
12-
using JSOSolvers
13-
```
14-
15-
We benchmark different subsolvers used in the solvers TRUNK for unconstrained nonlinear least squares problems.
11+
We benchmark different subsolvers used in the solver TRUNK for unconstrained nonlinear least squares problems.
1612
The first step is to select a set of problems that are nonlinear least squares.
1713

1814
```julia
19-
using ADNLPModels
15+
using JSOSolvers, ADNLPModels
2016
using OptimizationProblems
2117
using OptimizationProblems.ADNLPProblems
2218
df = OptimizationProblems.meta
@@ -38,27 +34,38 @@ For this task, several solvers are available.
3834
JSOSolvers.trunkls_allowed_subsolvers
3935
```
4036

41-
This benchmark could also be followed for the solver TRON where the following subsolver are available.
37+
This benchmark could also be followed for the solver TRON where the following subsolvers are available.
4238

4339
```julia
4440
JSOSolvers.tronls_allowed_subsolvers
4541
```
4642

4743
These 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:
4850

4951
```julia
50-
using Krylov
52+
stats = trunk(nls, subsolver = :cgls)
5153
```
5254

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.
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:
5562

5663
```julia
5764
solvers = Dict(
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)
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)
6269
)
6370
```
6471

@@ -91,5 +98,5 @@ profile_solvers(stats, costs, costnames)
9198
```
9299

93100
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.
94-
The size of the problems were rather small here, so this should be confirmed on larger instance.
101+
The size of the problems was rather small here, so this should be confirmed on larger instances.
95102
Moreover, the results may vary depending on the origin of the test problems.

tutorials/introduction-to-jsosolvers/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ SolverCore = "ff4d7338-4cf1-434d-91df-b86cb86fb843"
1212
ADNLPModels = "0.7"
1313
CSV = "0.10"
1414
DataFrames = "1.4"
15-
JSOSolvers = "0.11"
15+
JSOSolvers = "0.14"
1616
Plots = "1.38"
1717
SolverCore = "0.3"

tutorials/introduction-to-jsosolvers/index.jmd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ The following examples illustrate this specialization.
4747
To list the allowed least-squares subsolvers for these specializations:
4848

4949
```julia
50+
using JSOSolvers
5051
JSOSolvers.trunkls_allowed_subsolvers
5152
JSOSolvers.tronls_allowed_subsolvers
5253
```

0 commit comments

Comments
 (0)