Skip to content

Commit

Permalink
Add documentation for isnls in tuto (#182)
Browse files Browse the repository at this point in the history
* Add documentation for `isnls` in tuto
  • Loading branch information
tmigot authored Oct 4, 2024
1 parent 08ac46f commit 5223e94
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ ADNLPModels = "54578032-b7ea-4c30-94aa-7cbd1cce6c9a"
CaNNOLeS = "5a1c9e79-9c58-5ec0-afc4-3298fdea2875"
DCISolver = "bee2e536-65f6-11e9-3844-e5bb4c9c55c9"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
ExpressionTreeForge = "93090adf-0e31-445f-8c8f-44d91f61d7ad"
GR = "28b8d3ca-fb5f-59d9-8090-bfdbd6d07a71"
JSOSolvers = "10dff2fc-5484-5881-a0e0-c90441020f8a"
JSOSuite = "ed6ae0be-a024-11e9-2788-05dbf8cd15d9"
Expand Down
34 changes: 34 additions & 0 deletions docs/src/20-nls.md → docs/src/20-nonlinear-least-squares.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,40 @@ nls = MathOptNLSModel(model, [F1, F2], name="Ju-Rosenbrock")
stats = minimize(nls)
```

### JSOSuite automatic detection

The package can be used to try detecting NLS-pattern in a model.

```@example autodetection
using ADNLPModels, JSOSuite
f(x) = (x[2] - x[1]^3)^2 + (x[1] - 1)^2
x0 = [-1.2; 1.0]
nlp = ADNLPModel(f, x0)
stats_nlp = minimize(nlp)
```

The function `isnls` requires the package [ExpressionTreeForge.jl](https://github.com/JuliaSmoothOptimizers/ExpressionTreeForge.jl).
In this example, it detects that the objective function is a nonlinear least squares.

```@example autodetection
using ExpressionTreeForge
JSOSuite.isnls(nlp)
```

Therefore, defining an `ADNLSModel` might improve the solver's behavior.

```@example autodetection
F(x) = [x[2] - x[1]^3, x[1] - 1]
x0 = [-1.2; 1.0]
nls = ADNLSModel(F, x0, 2)
stats_nls = minimize(nls)
```

```@example autodetection
using NLPModels
(neval_obj(nlp), neval_obj(nls))
```

## Find a feasible point of an optimization problem or solve a nonlinear system

We show here how to find the feasible point of a given model.
Expand Down

0 comments on commit 5223e94

Please sign in to comment.