Skip to content

Commit 945d7bc

Browse files
committed
Unconstrained problem benchmarks
1 parent df933d4 commit 945d7bc

File tree

1 file changed

+74
-4
lines changed

1 file changed

+74
-4
lines changed

benchmarks/OptimizationCUTEst/CUTEst.jmd

Lines changed: 74 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@ title: Benchmarking with the problems in CUTEst
33
author: Alonso M. Cisneros
44
---
55

6-
> This would likely turn into either contributions to CUTEst or wrappers to CUTEst (hosted
7-
> in SciML) which which transform the NLPModels form into Optimization.jl, and a
8-
> benchmarking script that loops over all optimization problems and applies a set of
9-
> optimizers to each of them, computing summary statistics at the bottom.
6+
# Introduction
107

118
CUTEst, the Constraind and Unconstrained Testing Environment is, as the name suggests is a
129
collection of around 1500 problems for general nonlinear optimization used to test
@@ -15,5 +12,78 @@ optimization routines. The wrapper
1512
to the problem collection, which we can leverage to test the optimizers made available by
1613
Optimization.jl.
1714

15+
This benchmark uses the following packages:
16+
17+
```julia
18+
using Optimization
19+
using OptimizationNLPModels
20+
using CUTEst
21+
using OptimizationOptimJL
22+
using Ipopt
23+
using OptimizationMOI
24+
using DataFrames
25+
```
26+
27+
# Benchmarks
28+
29+
The CUTEst suite contains almost 1,500 problems that can be broadly divided into several
30+
categories:
31+
- Unconstrained problems,
32+
- Equality/inequality constrained with unbounded variables,
33+
- Equality/inequality constrained with bounded variables,
34+
- Quadratic programs with linear constraints
35+
36+
We will be testing the [Ipopt]() and the [LBFGS]() optimizers on these classes of
37+
problems.
38+
1839
```julia
40+
optimizers = [Optimization.LBFGS(),
41+
OptimizationMOI.MOI.OptimizerWithAtributes(Ipopt.Optimizer, "print_level" => 0)
42+
]
43+
44+
function get_stats(sol, ::Optimization.LBFGS)
45+
return (length(sol.u), sol.stats.time, "LBFGS", Symbol(sol.retcode))
46+
end
47+
48+
function get_stats(sol, ::MathOptInterface.OptimizerWithAtributes)
49+
return (length(sol.u), sol.original.solve_time, "Ipopt", Symbol(sol.retcode))
50+
end
51+
```
52+
53+
## Unconstrained problems
54+
55+
CUTEst contains 286 unconstrained problems. We will compare how the optimizers behave in
56+
terms of the time to solution with respect to the number of variables.
57+
58+
```julia
59+
unc_problems = CUTEst.select(contype="unc")
60+
n = length(unc_problems)
61+
optz = length(optimizers)
62+
63+
problem = String[]
64+
n_vars = Int64[]
65+
secs = Float64[]
66+
solver = String[]
67+
retcode = Symbol[]
68+
69+
broadcast(c -> sizehint!(c, optz * n), [problem, n_vars, secs, solver, retcode])
70+
71+
for prob_name in unc_problems
72+
nlp_prob = CUTEstModel(prob_name)
73+
prob = OptimizationProblem(nlp_prob, Optimization.AutoForwardDiff())
74+
for optimizer in optimizers
75+
sol = solve(prob, optimizer; maxiters = 1e7)
76+
77+
vars, time, alg, code = get_stats(sol, optimizer)
78+
79+
push!(problem, prob_name)
80+
push!(n_vars, vars)
81+
push!(secs, time)
82+
push!(solver, alg)
83+
push!(retcode, code)
84+
end
85+
86+
finalize(nlp_prob)
87+
end
88+
1989
```

0 commit comments

Comments
 (0)