Skip to content

Commit 6998c81

Browse files
authored
Move some solvers to optional deps (#112)
* Move some solvers to optional deps
1 parent fcf1b39 commit 6998c81

File tree

12 files changed

+309
-211
lines changed

12 files changed

+309
-211
lines changed

Project.toml

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,48 +5,34 @@ version = "0.1.0"
55

66
[deps]
77
ADNLPModels = "54578032-b7ea-4c30-94aa-7cbd1cce6c9a"
8-
CaNNOLeS = "5a1c9e79-9c58-5ec0-afc4-3298fdea2875"
9-
DCISolver = "bee2e536-65f6-11e9-3844-e5bb4c9c55c9"
108
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
11-
FletcherPenaltySolver = "e59f0261-166d-4fee-8bf3-5e50457de5db"
129
JSOSolvers = "10dff2fc-5484-5881-a0e0-c90441020f8a"
1310
JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
14-
KNITRO = "67920dd8-b58e-52a8-8622-53c4cffbe346"
1511
LLSModels = "39f5bc3e-5160-4bf8-ac48-504fd2534d24"
1612
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1713
LinearOperators = "5c8ed15e-5a4c-59e4-a42b-c7e8811fb125"
1814
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
1915
NLPModels = "a4795742-8479-5a88-8948-cc11e1c8c1a6"
20-
NLPModelsIpopt = "f4238b75-b362-5c4c-b852-0801c9a21d71"
2116
NLPModelsJuMP = "792afdf1-32c1-5681-94e0-d7bf7a5df49e"
22-
NLPModelsKnitro = "bec4dd0d-7755-52d5-9a02-22f0ffc7efcb"
2317
NLPModelsModifiers = "e01155f1-5c6f-4375-a9d8-616dd036575f"
2418
Percival = "01435c0c-c90d-11e9-3788-63660f8fbccc"
2519
QuadraticModels = "f468eda6-eac5-11e8-05a5-ff9e497bcd19"
26-
RipQP = "1e40b3f8-35eb-4cd8-8edd-3e515bb9de08"
27-
SolverBenchmark = "581a75fa-a23a-52d0-a590-d6201de2218a"
20+
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
2821
SolverCore = "ff4d7338-4cf1-434d-91df-b86cb86fb843"
2922
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
3023

3124
[compat]
3225
ADNLPModels = "0.4, 0.5, 0.6, 0.7"
33-
CaNNOLeS = "0.7"
34-
DCISolver = "0.4"
3526
DataFrames = "1"
36-
FletcherPenaltySolver = "0.2"
3727
JSOSolvers = "0.10, 0.11"
3828
JuMP = "1"
39-
KNITRO = "0.13.0"
4029
LLSModels = "0.3.6"
4130
LinearOperators = "2"
4231
NLPModels = "0.19, 0.20"
43-
NLPModelsIpopt = "0.10"
4432
NLPModelsJuMP = "0.11, 0.12"
45-
NLPModelsKnitro = "0.7"
4633
NLPModelsModifiers = "0.6.2"
4734
Percival = "0.6, 0.7"
4835
QuadraticModels = "0.9.2"
49-
RipQP = "0.5, 0.6"
50-
SolverBenchmark = "0.5"
36+
Requires = "1"
5137
SolverCore = "0.3"
5238
julia = "^1.6.0"

docs/Project.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
[deps]
22
ADNLPModels = "54578032-b7ea-4c30-94aa-7cbd1cce6c9a"
33
CaNNOLeS = "5a1c9e79-9c58-5ec0-afc4-3298fdea2875"
4+
DCISolver = "bee2e536-65f6-11e9-3844-e5bb4c9c55c9"
45
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
56
GR = "28b8d3ca-fb5f-59d9-8090-bfdbd6d07a71"
67
JSOSolvers = "10dff2fc-5484-5881-a0e0-c90441020f8a"
78
JSOSuite = "ed6ae0be-a024-11e9-2788-05dbf8cd15d9"
89
JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
910
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
1011
NLPModels = "a4795742-8479-5a88-8948-cc11e1c8c1a6"
12+
NLPModelsIpopt = "f4238b75-b362-5c4c-b852-0801c9a21d71"
1113
NLPModelsJuMP = "792afdf1-32c1-5681-94e0-d7bf7a5df49e"
1214
OptimizationProblems = "5049e819-d29b-5fba-b941-0eee7e64c1c6"
1315
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
1416
QuadraticModels = "f468eda6-eac5-11e8-05a5-ff9e497bcd19"
17+
RipQP = "1e40b3f8-35eb-4cd8-8edd-3e515bb9de08"
1518
SolverBenchmark = "581a75fa-a23a-52d0-a590-d6201de2218a"
1619
SolverCore = "ff4d7338-4cf1-434d-91df-b86cb86fb843"
1720

docs/src/benchmark.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
Benchmarking is very important when researching new algorithms or selecting the most approriate ones.
44

5-
The package [`SolverBenchmark`](https://github.com/JuliaSmoothOptimizers/SolverBenchmark.jl) exports the function [`bmark_solvers`](https://github.com/JuliaSmoothOptimizers/SolverBenchmark.jl/blob/main/src/bmark_solvers.jl) that runs a set of solvers on a set of problems. `JSOSuite.jl` specialize this function, see [`bmark_solvers`](@ref).
6-
5+
The package [`SolverBenchmark`](https://github.com/JuliaSmoothOptimizers/SolverBenchmark.jl) exports the function [`bmark_solvers`](https://github.com/JuliaSmoothOptimizers/SolverBenchmark.jl/blob/main/src/bmark_solvers.jl) that runs a set of solvers on a set of problems. `JSOSuite.jl` specialize this function, see `bmark_solvers`.
76

87
The [JuliaSmoothOptimizers organization](https://juliasmoothoptimizers.github.io) contains several packages of test problems ready to use for benchmarking. The main ones are
98
- [`OptimizationProblems.jl`](https://github.com/JuliaSmoothOptimizers/OptimizationProblems.jl): This package provides a collection of optimization problems in JuMP and ADNLPModels syntax;
@@ -51,9 +50,10 @@ For the purpose of this example, we will consider 3 solvers.
5150
select = ["IPOPT", "TRUNK", "LBFGS"]
5251
```
5352

54-
Once the problems and solvers are chosen, the function [`bmark_solvers`](@ref) runs the benchmark.
53+
Once the problems and solvers are chosen, the function `bmark_solvers` runs the benchmark.
5554

5655
```@example op
56+
using SolverBenchmark
5757
stats = bmark_solvers(ad_problems, select, atol = 1e-3, max_time = 10.0, verbose = 0)
5858
```
5959

docs/src/nls.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ By default, `JSOSuite.solve` will use a solver tailored for nonlineat least squa
5757
Nevertheless, it is also possible to specify the solver to be used.
5858

5959
```@example ex1
60+
using NLPModelsIpopt
6061
stats = solve("IPOPT", F, x0, nres, c, l, l)
6162
```
6263

docs/src/qp.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,6 @@ using QuadraticModels, JSOSuite
5555
As usual, it is also possible to select manually the solver to be used.
5656

5757
```@example ex1
58+
using RipQP
5859
stats = solve("RipQP", c, H, A, lcon, ucon, name = "eqconqp_QP")
5960
```

src/JSOSuite.jl

Lines changed: 96 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
module JSOSuite
22

33
# other dependencies
4-
using DataFrames, JuMP, KNITRO
4+
using DataFrames, JuMP, Requires
55
# stdlib
66
using LinearAlgebra, Logging, SparseArrays
77
# JSO
88
using ADNLPModels, LLSModels, NLPModels, NLPModelsJuMP, QuadraticModels
99
using LinearOperators, NLPModelsModifiers, SolverCore
1010
# JSO solvers
11-
using CaNNOLeS,
12-
DCISolver, FletcherPenaltySolver, JSOSolvers, NLPModelsIpopt, JSOSolvers, Percival, RipQP
13-
if KNITRO.has_knitro()
14-
using NLPModelsKnitro
15-
end
11+
using JSOSolvers, Percival
1612

1713
"""
1814
solvers
@@ -58,7 +54,7 @@ push!(
5854
:KnitroSolver,
5955
"NLPModelsKnitro.jl",
6056
:knitro,
61-
KNITRO.has_knitro(),
57+
false,
6258
true,
6359
true,
6460
true,
@@ -191,7 +187,7 @@ push!(
191187
:CaNNOLeSSolver,
192188
"CaNNOLeS.jl",
193189
:cannoles,
194-
true,
190+
false,
195191
false,
196192
true,
197193
false,
@@ -210,7 +206,7 @@ push!(
210206
:IpoptSolver,
211207
"NLPModelsIpopt.jl",
212208
:ipopt,
213-
true,
209+
false,
214210
true,
215211
true,
216212
true,
@@ -229,7 +225,7 @@ push!(
229225
:DCIWorkspace,
230226
"DCISolver.jl",
231227
:dci,
232-
true,
228+
false,
233229
false,
234230
true,
235231
false,
@@ -248,7 +244,7 @@ push!(
248244
:FPSSSolver,
249245
"FletcherPenaltySolver.jl",
250246
:fps_solve,
251-
true,
247+
false,
252248
false,
253249
true,
254250
false,
@@ -286,7 +282,7 @@ push!(
286282
:RipQPSolver,
287283
"RipQP.jl",
288284
:ripqp,
289-
true,
285+
false,
290286
true,
291287
true,
292288
true,
@@ -375,14 +371,16 @@ The list of available solver can be obtained using `JSOSuite.solvers[!, :name]`
375371
376372
```jldoctest; output = false
377373
using JSOSuite
378-
stats = solve("DCISolver", x -> 100 * (x[2] - x[1]^2)^2 + (x[1] - 1)^2, [-1.2; 1.0], verbose = 0)
374+
stats = solve("TRON", x -> 100 * (x[2] - x[1]^2)^2 + (x[1] - 1)^2, [-1.2; 1.0], verbose = 0)
379375
stats
380376
381377
# output
382378
383379
"Execution stats: first-order stationary"
384380
```
385381
382+
Some solvers are available after loading only.
383+
386384
```jldoctest; output = false
387385
using JSOSuite
388386
# We solve here a quadratic problem with bound-constraints
@@ -420,9 +418,58 @@ include("solve_model.jl")
420418

421419
include("solve.jl")
422420

423-
using SolverBenchmark
421+
@init begin
422+
@require CaNNOLeS = "5a1c9e79-9c58-5ec0-afc4-3298fdea2875" begin
423+
JSOSuite.solvers[JSOSuite.solvers.name .== "CaNNOLeS", :is_available] .= 1
424+
function solve(::Val{:CaNNOLeS}, nlp; kwargs...)
425+
return CaNNOLeS.cannoles(nlp; linsolve = :ldlfactorizations, kwargs...)
426+
end
424427

425-
export bmark_solvers
428+
end
429+
end
430+
431+
@init begin
432+
@require DCISolver = "bee2e536-65f6-11e9-3844-e5bb4c9c55c9" begin
433+
JSOSuite.solvers[JSOSuite.solvers.name .== "DCISolver", :is_available] .= 1
434+
function solve(::Val{:DCISolver}, nlp; kwargs...)
435+
return DCISolver.dci(nlp; kwargs...)
436+
end
437+
end
438+
end
439+
440+
@init begin
441+
@require FletcherPenaltySolver = "e59f0261-166d-4fee-8bf3-5e50457de5db" begin
442+
JSOSuite.solvers[JSOSuite.solvers.name .== "FletcherPenaltySolver", :is_available] .= 1
443+
function solve(::Val{:FletcherPenaltySolver}, nlp; kwargs...)
444+
return FletcherPenaltySolver.fps_solve(nlp; kwargs...)
445+
end
446+
end
447+
end
448+
449+
@init begin
450+
@require NLPModelsIpopt = "f4238b75-b362-5c4c-b852-0801c9a21d71" begin
451+
JSOSuite.solvers[JSOSuite.solvers.name .== "IPOPT", :is_available] .= 1
452+
include("solvers/ipopt_solve.jl")
453+
end
454+
end
455+
456+
@init begin
457+
@require NLPModelsKnitro = "bec4dd0d-7755-52d5-9a02-22f0ffc7efcb" begin
458+
@init begin
459+
@require NLPModelsKnitro = "bec4dd0d-7755-52d5-9a02-22f0ffc7efcb" begin
460+
JSOSuite.solvers[JSOSuite.solvers.name .== "KNITRO", :is_available] .= KNITRO.has_knitro()
461+
end
462+
end
463+
include("solvers/knitro_solve.jl")
464+
end
465+
end
466+
467+
@init begin
468+
@require RipQP = "1e40b3f8-35eb-4cd8-8edd-3e515bb9de08" begin
469+
JSOSuite.solvers[JSOSuite.solvers.name .== "RipQP", :is_available] .= 1
470+
include("solvers/ripqp_solve.jl")
471+
end
472+
end
426473

427474
"""
428475
bmark_solvers(problems, solver_names::Vector{String}; kwargs...)
@@ -454,7 +501,7 @@ All the remaining keyword arguments are passed to the function `SolverBenchmark.
454501
# Examples
455502
456503
```jldoctest; output = false
457-
using ADNLPModels, JSOSuite
504+
using ADNLPModels, JSOSuite, SolverBenchmark
458505
nlps = (
459506
ADNLPModel(x -> 100 * (x[2] - x[1]^2)^2 + (x[1] - 1)^2, [-1.2; 1.0]),
460507
ADNLPModel(x -> 4 * (x[2] - x[1]^2)^2 + (x[1] - 1)^2, [-1.2; 1.0]),
@@ -480,7 +527,7 @@ KeySet for a Dict{Symbol, DataFrames.DataFrame} with 2 entries. Keys:
480527
The second example shows how to add you own solver to the benchmark.
481528
482529
```jldoctest; output = false
483-
using ADNLPModels, JSOSolvers, JSOSuite, Logging
530+
using ADNLPModels, JSOSolvers, JSOSuite, Logging, SolverBenchmark
484531
nlps = (
485532
ADNLPModel(x -> 100 * (x[2] - x[1]^2)^2 + (x[1] - 1)^2, [-1.2; 1.0]),
486533
ADNLPModel(x -> 4 * (x[2] - x[1]^2)^2 + (x[1] - 1)^2, [-1.2; 1.0]),
@@ -510,31 +557,39 @@ KeySet for a Dict{Symbol, DataFrames.DataFrame} with 3 entries. Keys:
510557
511558
```
512559
"""
513-
function SolverBenchmark.bmark_solvers(
514-
problems,
515-
solver_names::Vector{String},
516-
solvers::Dict{Symbol, Function} = Dict{Symbol, Function}();
517-
atol::Real = eps(),
518-
rtol::Real = eps(),
519-
verbose::Integer = 0,
520-
max_time::Float64 = 300.0,
521-
max_eval::Integer = 10000,
522-
max_iter::Integer = 10000,
523-
kwargs...,
524-
)
525-
for s in solver_names
526-
solvers[Symbol(s)] =
527-
nlp -> solve(
528-
s,
529-
nlp;
530-
atol = atol,
531-
rtol = rtol,
532-
verbose = verbose,
533-
max_time = max_time,
534-
max_eval = max_eval,
535-
)
560+
function bmark_solvers end
561+
562+
@init begin
563+
@require SolverBenchmark = "581a75fa-a23a-52d0-a590-d6201de2218a" begin
564+
565+
function SolverBenchmark.bmark_solvers(
566+
problems,
567+
solver_names::Vector{String},
568+
solvers::Dict{Symbol, Function} = Dict{Symbol, Function}();
569+
atol::Real = eps(),
570+
rtol::Real = eps(),
571+
verbose::Integer = 0,
572+
max_time::Float64 = 300.0,
573+
max_eval::Integer = 10000,
574+
max_iter::Integer = 10000,
575+
kwargs...,
576+
)
577+
for s in solver_names
578+
solvers[Symbol(s)] =
579+
nlp -> solve(
580+
s,
581+
nlp;
582+
atol = atol,
583+
rtol = rtol,
584+
verbose = verbose,
585+
max_time = max_time,
586+
max_eval = max_eval,
587+
)
588+
end
589+
return SolverBenchmark.bmark_solvers(solvers, problems; kwargs...)
590+
end
591+
536592
end
537-
return bmark_solvers(solvers, problems; kwargs...)
538593
end
539594

540595
"""

0 commit comments

Comments
 (0)