Skip to content

Commit

Permalink
benchmark: add verbose option to main script
Browse files Browse the repository at this point in the history
  • Loading branch information
frapac committed Aug 25, 2021
1 parent f26a985 commit 9642f45
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 8 deletions.
7 changes: 6 additions & 1 deletion benchmark/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
To run benchmarks, run the following script.
```
# to compare current version and master using 10 cores and CUTEst and PowerModels.jl problems,
julia runbenchmarks.jl 10 power cutest current master
julia runbenchmarks.jl 10 power cutest current master
```

By default, logs are deactivated. To active them, please add `verbose` to the options:
```
julia runbenchmarks.jl 10 power cutest current master verbose
```
6 changes: 3 additions & 3 deletions benchmark/benchmark-cutest.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ end
@everywhere using CUTEst

if SOLVER == "master"
@everywhere solver = nlp -> madnlp(nlp,linear_solver=MadNLPMa57,max_wall_time=900.,tol=1e-6, print_level=MadNLP.ERROR)
@everywhere solver = nlp -> madnlp(nlp,linear_solver=MadNLPMa57,max_wall_time=900.,tol=1e-6, print_level=PRINT_LEVEL)
@everywhere using MadNLP, MadNLPHSL
elseif SOLVER == "current"
@everywhere solver = nlp -> madnlp(nlp,linear_solver=MadNLPMa57,max_wall_time=900.,tol=1e-6, print_level=MadNLP.ERROR)
@everywhere solver = nlp -> madnlp(nlp,linear_solver=MadNLPMa57,max_wall_time=900.,tol=1e-6, print_level=PRINT_LEVEL)
@everywhere using MadNLP, MadNLPHSL
elseif SOLVER == "ipopt"
@everywhere solver = nlp -> ipopt(nlp,linear_solver="ma57",max_cpu_time=900.,tol=1e-6, print_level=0)
@everywhere solver = nlp -> ipopt(nlp,linear_solver="ma57",max_cpu_time=900.,tol=1e-6, print_level=PRINT_LEVEL)
@everywhere using NLPModelsIpopt
elseif SOLVER == "knitro"
# TODO
Expand Down
6 changes: 3 additions & 3 deletions benchmark/benchmark-power.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ end
if SOLVER == "master"
@everywhere solver = prob ->
run_opf(joinpath(PGLIB_PATH,prob[1]), prob[2],
()->MadNLP.Optimizer(linear_solver=MadNLPMa57,max_wall_time=900.,tol=1e-6, print_level=MadNLP.ERROR))
()->MadNLP.Optimizer(linear_solver=MadNLPMa57,max_wall_time=900.,tol=1e-6, print_level=PRINT_LEVEL))
@everywhere using MadNLP, MadNLPHSL
elseif SOLVER == "current"
@everywhere solver = prob ->
run_opf(joinpath(PGLIB_PATH,prob[1]), prob[2],
()->MadNLP.Optimizer(linear_solver=MadNLPMa57,max_wall_time=900.,tol=1e-6, print_level=MadNLP.ERROR))
()->MadNLP.Optimizer(linear_solver=MadNLPMa57,max_wall_time=900.,tol=1e-6, print_level=PRINT_LEVEL))
@everywhere using MadNLP, MadNLPHSL
elseif SOLVER == "ipopt"
@everywhere solver = prob ->
run_opf(joinpath(PGLIB_PATH,prob[1]), prob[2],
()->Ipopt.Optimizer(linear_solver="ma57",max_cpu_time=900.,tol=1e-6, print_level=0))
()->Ipopt.Optimizer(linear_solver="ma57",max_cpu_time=900.,tol=1e-6, print_level=PRINT_LEVEL))
@everywhere using Ipopt
elseif SOLVER == "knitro"
# TODO
Expand Down
11 changes: 11 additions & 0 deletions benchmark/config.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ using Pkg, Distributed, DelimitedFiles
const NP = ARGS[1]
const SOLVER = ARGS[2]


addprocs(parse(Int,NP),exeflags="--project=.")
Pkg.instantiate()

Expand All @@ -19,3 +20,13 @@ elseif SOLVER == "knitro"
else
error("Proper ARGS should be given")
end

# Set verbose option
if SOLVER == "ipopt"
const PRINT_LEVEL = (ARGS[3] == "verbose") ? 5 : 0
elseif SOLVER == "knitro"
const PRINT_LEVEL = (ARGS[3] == "verbose") ? 3 : 0
else
using MadNLP
const PRINT_LEVEL = (ARGS[3] == "verbose") ? MadNLP.INFO : MadNLP.ERROR
end
3 changes: 2 additions & 1 deletion benchmark/runbenchmarks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const NP = ARGS[1]
const CLASSES = filter(e-> e in ["cutest","power"], ARGS)
const SOLVERS = filter(e-> e in ["current","master","ipopt","knitro"], ARGS)
const PROJECT_PATH = dirname(@__FILE__)
const VERBOSE = ("verbose" in ARGS) ? "verbose" : "none"

cp(
joinpath(PROJECT_PATH, ".Project.toml"),
Expand All @@ -13,7 +14,7 @@ cp(
for class in CLASSES
for solver in SOLVERS
launch_script = joinpath(PROJECT_PATH, "benchmark-$class.jl")
run(`julia --project=$PROJECT_PATH $launch_script $NP $solver`)
run(`julia --project=$PROJECT_PATH $launch_script $NP $solver $VERBOSE`)
end
end

Expand Down

0 comments on commit 9642f45

Please sign in to comment.