Skip to content

Commit 64f693e

Browse files
authored
Use L-BFGS if the Hessian of the Lagrangian is not available (#148)
1 parent ad1cf0f commit 64f693e

6 files changed

Lines changed: 31 additions & 15 deletions

File tree

.github/workflows/Breakage.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,14 @@ jobs:
159159
fi
160160
done >> summary.md
161161
162+
- name: Display summary in CI logs
163+
run: |
164+
echo "### Breakage Summary" >> $GITHUB_STEP_SUMMARY
165+
cat breakage/summary.md >> $GITHUB_STEP_SUMMARY
166+
162167
- name: PR comment with file
163-
uses: actions/github-script@v6
168+
if: github.event.pull_request.head.repo.fork == false
169+
uses: actions/github-script@main
164170
with:
165171
github-token: ${{ secrets.GITHUB_TOKEN }}
166172
script: |

.github/workflows/ci.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,26 @@ jobs:
1313
strategy:
1414
fail-fast: false
1515
matrix:
16-
version: ['1.6', '1']
17-
os: [ubuntu-latest, macOS-latest, windows-latest]
16+
version: ['lts', '1']
17+
os: [ubuntu-latest, macos-latest, windows-latest]
1818
arch: [x64]
1919
allow_failure: [false]
2020
include:
21-
- version: 'nightly'
21+
- version: 'pre'
2222
os: ubuntu-latest
2323
arch: x64
2424
allow_failure: true
25-
- version: 'nightly'
26-
os: macOS-latest
25+
- version: 'pre'
26+
os: macos-latest
2727
arch: x64
2828
allow_failure: true
29-
- version: 'nightly'
29+
- version: 'pre'
3030
os: windows-latest
3131
arch: x64
3232
allow_failure: true
3333
steps:
3434
- uses: actions/checkout@v2
35-
- uses: julia-actions/setup-julia@v1
35+
- uses: julia-actions/setup-julia@v2
3636
with:
3737
version: ${{ matrix.version }}
3838
arch: ${{ matrix.arch }}

Project.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ NLPModelsModifiers = "e01155f1-5c6f-4375-a9d8-616dd036575f"
99
SolverCore = "ff4d7338-4cf1-434d-91df-b86cb86fb843"
1010

1111
[compat]
12-
Ipopt = "1"
13-
NLPModels = "0.19, 0.20, 0.21"
12+
Ipopt = "1.11"
13+
NLPModels = "0.21.6"
1414
NLPModelsModifiers = "0.7"
1515
SolverCore = "0.3"
16-
julia = "^1.6"
16+
julia = "1.10"
1717

1818
[extras]
1919
ADNLPModels = "54578032-b7ea-4c30-94aa-7cbd1cce6c9a"

docs/Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ NLPModels = "a4795742-8479-5a88-8948-cc11e1c8c1a6"
99
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
1010

1111
[compat]
12-
ADNLPModels = "0.7"
12+
ADNLPModels = "0.8"
1313
Documenter = "1.0"
14-
NLPModels = "0.20"
14+
NLPModels = "0.21.6"

docs/src/tutorial.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@ You can call Ipopt with the L-BFGS Hessian approximation by passing the followin
66
stats_ipopt = ipopt(nlp,
77
hessian_approximation="limited-memory",
88
limited_memory_update_type="bfgs",
9-
limited_memory_max_history=10)
9+
limited_memory_max_history=6)
1010
```
1111

12-
This will use the L-BFGS method for Hessian approximation with a history size of 10.
12+
This will use the L-BFGS method for Hessian approximation with a history size of 6.
13+
Note that these options are used by default in `NLPModelsIpopt.jl` if `nlp.meta.hess_available` is `false`.
1314

1415
Reference:
1516
- [Ipopt.jl Manual: Hessian approximation](https://coin-or.github.io/Ipopt/OPTIONS.html#OPT_Hessian_Approximation)
17+
1618
# Tutorial
1719

1820
NLPModelsIpopt is a thin IPOPT wrapper for NLPModels. In this tutorial we show examples of problems created with NLPModels and solved with Ipopt.

src/NLPModelsIpopt.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ mutable struct IpoptSolver <: AbstractOptimizationSolver
6161
end
6262

6363
function IpoptSolver(nlp::AbstractNLPModel)
64+
@assert nlp.meta.grad_available && (nlp.meta.ncon == 0 || nlp.meta.jac_available)
6465
eval_f, eval_g, eval_grad_f, eval_jac_g, eval_h = set_callbacks(nlp)
6566

6667
problem = CreateIpoptProblem(
@@ -248,6 +249,13 @@ function SolverCore.solve!(
248249
SolverCore.reset!(stats)
249250
kwargs = Dict(kwargs)
250251

252+
# Use L-BFGS if the sparse hessian of the Lagrangian is not available
253+
if !nlp.meta.hess_available
254+
AddIpoptStrOption(problem, "hessian_approximation", "limited-memory")
255+
AddIpoptStrOption(problem, "limited_memory_update_type", "bfgs")
256+
AddIpoptIntOption(problem, "limited_memory_max_history", 6)
257+
end
258+
251259
# see if user wants to warm start from an initial primal-dual guess
252260
if all(k keys(kwargs) for k [:x0, :y0, :zL0, :zU0])
253261
AddIpoptStrOption(problem, "warm_start_init_point", "yes")

0 commit comments

Comments
 (0)