|
| 1 | +# Include useful packages |
| 2 | +using ADNLPModels, NLPModels, OptimizationProblems |
| 3 | +using BenchmarkTools |
| 4 | +# Most likely benchmark with JuMP as well |
| 5 | +using JuMP, NLPModelsJuMP |
| 6 | + |
| 7 | +const list_problems = Symbol.(OptimizationProblems.meta[!, :name]) |
| 8 | + |
| 9 | +# Should match the runtests |
| 10 | +const list_problems_not_ADNLPProblems = |
| 11 | + Symbol[:catmix, :gasoil, :glider, :methanol, :minsurf, :pinene, :rocket, :steering, :torsion] |
| 12 | +const list_problems_ADNLPProblems = setdiff(list_problems, list_problems_not_ADNLPProblems) |
| 13 | +const list_problems_not_PureJuMP = Symbol[] |
| 14 | +const list_problems_PureJuMP = setdiff(list_problems, list_problems_not_PureJuMP) |
| 15 | + |
| 16 | +# Run locally with `tune!(SUITE)` and then `run(SUITE)` |
| 17 | +const SUITE = BenchmarkGroup() |
| 18 | + |
| 19 | +const SAMPLES = 5 |
| 20 | +const EVALS = 1 |
| 21 | + |
| 22 | +SUITE["ADNLPProblems"] = BenchmarkGroup() |
| 23 | +SUITE["ADNLPProblems"]["NLP"] = BenchmarkGroup() |
| 24 | +SUITE["ADNLPProblems"]["NLP"]["constructor"] = BenchmarkGroup() |
| 25 | +SUITE["ADNLPProblems"]["NLP"]["obj"] = BenchmarkGroup() |
| 26 | +for pb in list_problems_ADNLPProblems |
| 27 | + problem_constructor = getproperty(OptimizationProblems.ADNLPProblems, Symbol(pb)) |
| 28 | + SUITE["ADNLPProblems"]["NLP"]["constructor"][pb] = @benchmarkable $(problem_constructor)() samples=SAMPLES evals=EVALS |
| 29 | + SUITE["ADNLPProblems"]["NLP"]["obj"][pb] = @benchmarkable obj(nlp, nlp.meta.x0) samples=SAMPLES evals=EVALS setup = (nlp = $(problem_constructor)()) |
| 30 | +end |
| 31 | + |
| 32 | +SUITE["ADNLPProblems"]["NLS"] = BenchmarkGroup() |
| 33 | +SUITE["ADNLPProblems"]["NLS"]["constructor"] = BenchmarkGroup() |
| 34 | +SUITE["ADNLPProblems"]["NLS"]["obj"] = BenchmarkGroup() |
| 35 | +list_problems_nls_ADNLPProblems = intersect(Symbol.(OptimizationProblems.meta[OptimizationProblems.meta.objtype .== :least_squares, :name]), list_problems_ADNLPProblems) |
| 36 | +for pb in list_problems_nls_ADNLPProblems |
| 37 | + problem_constructor = getproperty(OptimizationProblems.ADNLPProblems, Symbol(pb)) |
| 38 | + SUITE["ADNLPProblems"]["NLS"]["constructor"][pb] = @benchmarkable $(problem_constructor)(use_nls = true) samples=SAMPLES evals=EVALS |
| 39 | + SUITE["ADNLPProblems"]["NLS"]["obj"][pb] = @benchmarkable obj(nlp, nlp.meta.x0) samples=SAMPLES evals=EVALS setup = (nlp = $(problem_constructor)(use_nls = true)) |
| 40 | +end |
| 41 | +SUITE["PureJuMP"] = BenchmarkGroup() |
| 42 | +SUITE["PureJuMP"]["constructor"] = BenchmarkGroup() |
| 43 | +SUITE["PureJuMP"]["obj"] = BenchmarkGroup() |
| 44 | +for pb in list_problems_PureJuMP |
| 45 | + problem_constructor = getproperty(OptimizationProblems.PureJuMP, Symbol(pb)) |
| 46 | + SUITE["PureJuMP"]["constructor"][pb] = @benchmarkable $(problem_constructor)() samples=SAMPLES evals=EVALS |
| 47 | + SUITE["PureJuMP"]["obj"][pb] = @benchmarkable obj(nlp, nlp.meta.x0) samples=SAMPLES evals=EVALS setup = ( |
| 48 | + nlp = MathOptNLPModel($(problem_constructor)()) |
| 49 | + ) |
| 50 | +end |
0 commit comments