Skip to content

Commit 11b9d53

Browse files
arnavk23tmigotCopilot
authored
solver benchmark: specifying solver-specific options (#152)
* solver benchmark: specifying solver-specific options * Redoing index.jmd and Project.toml to fix SolverBenchmark tutorial * Apply suggestions from code review Co-authored-by: Tangi Migot <tangi.migot@gmail.com> * changes acc. to review * Fix newline issue at end of Project.toml * Update tutorials/introduction-to-solverbenchmark/index.jmd * Update tutorials/introduction-to-solverbenchmark/index.jmd * Apply suggestions from code review Co-authored-by: Tangi Migot <tangi.migot@gmail.com> * Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update tutorials/introduction-to-solverbenchmark/index.jmd Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * NLPModelsTest * Update index.jmd * Fix formatting for accessing isConvex column --------- Co-authored-by: Tangi Migot <tangi.migot@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent cc9ba36 commit 11b9d53

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
[deps]
22
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
3+
NLPModelsTest = "7998695d-6960-4d3a-85c4-e1bceb8cd856"
34
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
45
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
56
PyPlot = "d330b81b-6aea-500a-939a-2ce795aea3ee"
67
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
78
SolverBenchmark = "581a75fa-a23a-52d0-a590-d6201de2218a"
9+
SolverCore = "ff4d7338-4cf1-434d-91df-b86cb86fb843"
810

911
[compat]
1012

1113
DataFrames = "1.3.4"
14+
NLPModelsTest = "0.9"
1215
Plots = "1.31.7"
1316
PyPlot = "2.10.0"
1417
SolverBenchmark = "0.5.3"
18+
SolverCore = "0.3"

tutorials/introduction-to-solverbenchmark/index.jmd

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,3 +221,26 @@ p = profile_solvers(stats, costs, costnames)
221221
Here is a useful tutorial on how to use the benchmark with specific solver:
222222
[Run a benchmark with OptimizationProblems](https://jso.dev/OptimizationProblems.jl/dev/benchmark/)
223223
The tutorial covers how to use the problems from `OptimizationProblems` to run a benchmark for unconstrained optimization.
224+
225+
### Handling `solver_specific` in `stats`
226+
227+
If a solver's `GenericExecutionStats` contains a `solver_specific` dictionary, then when `bmark_solvers` processes the results it creates a column in the per-solver `DataFrame` for each key in that dictionary. These columns can then be analyzed and compared alongside the standard metrics such as `status` and `elapsed_time`.
228+
229+
Here is an example showing how to set a solver-specific flag so that it appears as a column in the resulting stats table and can be used for tabulation:
230+
```julia
231+
using NLPModelsTest, DataFrames, SolverCore, SolverBenchmark
232+
233+
function newton(nlp)
234+
stats = GenericExecutionStats(nlp)
235+
set_solver_specific!(stats, :isConvex, true)
236+
return stats
237+
end
238+
239+
solvers = Dict(:newton => newton)
240+
problems = [NLPModelsTest.BROWNDEN()]
241+
stats = bmark_solvers(solvers, problems)
242+
243+
# Access the solver-specific column `:isConvex` for the `:newton` solver
244+
df_newton = stats[:newton]
245+
df_newton.isConvex
246+
```

0 commit comments

Comments
 (0)