|
| 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 | +SUITE["ADNLPProblems"] = BenchmarkGroup() |
| 19 | +SUITE["ADNLPProblems"]["NLP"] = BenchmarkGroup() |
| 20 | +SUITE["ADNLPProblems"]["NLP"]["constructor"] = BenchmarkGroup() |
| 21 | +SUITE["ADNLPProblems"]["NLP"]["obj"] = BenchmarkGroup() |
| 22 | +for pb in list_problems_ADNLPProblems |
| 23 | + SUITE["ADNLPProblems"]["NLP"]["constructor"][pb] = |
| 24 | + @benchmarkable eval(Meta.parse("OptimizationProblems.ADNLPProblems.$pb()")) |
| 25 | + SUITE["ADNLPProblems"]["NLP"]["obj"][pb] = @benchmarkable obj(nlp, nlp.meta.x0) setup = |
| 26 | + (nlp = eval(Meta.parse("OptimizationProblems.ADNLPProblems.$pb()"))) |
| 27 | +end |
| 28 | + |
| 29 | +SUITE["ADNLPProblems"]["NLS"] = BenchmarkGroup() |
| 30 | +for pb in |
| 31 | + intersect(Symbol.(meta[meta.objtype .== :least_squares, :name]), list_problems_ADNLPProblems) |
| 32 | + SUITE["ADNLPProblems"]["NLS"]["constructor"] = |
| 33 | + @benchmarkable eval(Meta.parse("OptimizationProblems.ADNLPProblems.$pb(use_nls = true)")) |
| 34 | + SUITE["ADNLPProblems"]["NLS"]["obj"] = @benchmarkable obj(nlp, nlp.meta.x0) setup = |
| 35 | + (nlp = eval(Meta.parse("OptimizationProblems.ADNLPProblems.$pb(use_nls = true)"))) |
| 36 | +end |
| 37 | +SUITE["PureJuMP"] = BenchmarkGroup() |
| 38 | +for pb in list_problems_ADNLPProblems |
| 39 | + SUITE["PureJuMP"]["constructor"] = |
| 40 | + @benchmarkable eval(Meta.parse("OptimizationProblems.PureJuMP.$pb()")) |
| 41 | + SUITE["PureJuMP"]["obj"] = @benchmarkable obj(nlp, nlp.meta.x0) setup = |
| 42 | + (nlp = MathOptNLPModel(eval(Meta.parse("OptimizationProblems.PureJuMP.$pb()")))) |
| 43 | +end |
0 commit comments