Skip to content

Commit 9ad3b2b

Browse files
committed
Redoing index.jmd and Project.toml to fix SolverBenchmark tutorial
1 parent 7690995 commit 9ad3b2b

File tree

2 files changed

+27
-23
lines changed

2 files changed

+27
-23
lines changed

Project.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@ version = "0.2.0"
55

66
[deps]
77
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
8+
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
89
IJulia = "7073ff75-c697-5162-941a-fcdaad2a7d2a"
910
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
11+
JSOSolvers = "10dff2fc-5484-5881-a0e0-c90441020f8a"
1012
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
13+
NLPModelsTest = "7998695d-6960-4d3a-85c4-e1bceb8cd856"
1114
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
1215
Weave = "44d3d7a6-8a23-5bf8-98c5-b353f8df5ec9"
1316
YAML = "ddb6d928-2868-570f-bddf-ab3f9cf99eb6"

tutorials/introduction-to-solverbenchmark/index.jmd

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -223,32 +223,33 @@ Here is a useful tutorial on how to use the benchmark with specific solver:
223223
The tutorial covers how to use the problems from `OptimizationProblems` to run a benchmark for unconstrained optimization.
224224

225225
## Handling `solver_specific` in benchmark runs
226+
If a solver's execution-stats object contains a `solver_specific` dictionary
227+
(accessible as `s.solver_specific`), `solve_problems` will create columns for
228+
each key in that dictionary in the per-solver `DataFrame`. (Note: `bmark_solvers`
229+
forwards keyword arguments to each solver, so ensure your solver wrapper populates
230+
`s.solver_specific` if you want those columns.)
226231

227-
`SolverBenchmark` accepts solver-specific options via the keyword argument `solver_specific` on benchmarking functions (for example, when calling the high-level benchmarking helpers such as `bmark_solvers`).
228-
229-
- `solver_specific` is a mapping that associates a solver identifier (typically a `Symbol` or the solver name you use in the benchmark) with a dictionary of options specific to that solver implementation.
230-
- Those options are passed through to the solver when the run is executed and are recorded as part of the run metadata.
231-
- As a result, runs that differ only by solver-specific options are treated as distinct entries in the benchmark results; you can group, filter or compare them in the produced `DataFrame`s.
232-
232+
Here is a example showing how to set a solver-specific flag and then access it for tabulation:
233233
```julia
234-
using SolverBenchmark, NLPModelsTest, JSOSolvers
235-
236-
solver_specific = Dict(
237-
:IPOPT => Dict("tol" => 1e-8, "max_iter" => 200),
238-
:KNITRO => Dict("maxit" => 500)
239-
)
234+
using NLPModelsTest, DataFrames, SolverCore, SolverBenchmark
240235

241-
results = bmark_solvers(solvers, problems; solver_specific = solver_specific)
236+
function newton(nlp)
237+
stats = GenericExecutionStats(nlp)
238+
set_solver_specific!(stats, :isConvex, true)
239+
return stats
240+
end
242241

243-
first(results)
244-
```
242+
solvers = Dict(:newton => newton)
243+
problems = [NLPModelsTest.BROWNDEN()]
244+
stats = bmark_solvers(solvers, problems)
245245

246-
Notes and tips:
246+
combined_stats = DataFrame(
247+
name = stats[:newton].name,
248+
nvars = stats[:newton].nvar,
249+
convex = stats[:newton].isConvex,
250+
newton_iters = stats[:newton].iter,
251+
)
247252

248-
- If you pass different option sets for the same solver, make sure the keys you use
249-
identify the intended solver variation unambiguously (e.g., distinct Symbols).
250-
- When creating tables or profiles, you can add or extract columns from the per-solver
251-
DataFrames to show which solver-specific options were used for each run.
252-
- If you prefer the solver-specific settings to appear as explicit columns, you can
253-
preprocess the DataFrames (extract the dict entries into columns) before creating
254-
joined tables or profile plots.
253+
combined_stats.convex = string.(combined_stats.convex)
254+
pretty_stats(combined_stats)
255+
```

0 commit comments

Comments
 (0)