Skip to content

Commit

Permalink
adding Hiop submodule, build script, and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
michel2323 committed Oct 12, 2020
1 parent 33ab130 commit dbb8f99
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 17 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Manifest.toml
build

## Core latex/pdflatex auxiliary files:
*.aux
Expand Down
1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
CatViews = "81a5f4ea-a946-549a-aa7e-2a7f63a27d31"
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
Hiop = "f890763e-d4e5-4bf9-9dfa-7ed54d93ce96"
Ipopt = "b6b21f68-93f8-5de0-b562-5493be1d77c9"
JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand Down
9 changes: 9 additions & 0 deletions build_hiop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

git submodule init
git submodule update

mkdir -p build
cd build
cmake -DHIOP_USE_MPI=OFF -DCMAKE_BUILD_TYPE=Debug -DHIOP_BUILD_SHARED=ON -DHIOP_BUILD_STATIC=ON -DCMAKE_INSTALL_PREFIX=$PWD ../hiop
make -j
13 changes: 13 additions & 0 deletions test/hiop.options
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
dualsUpdateType linear
dualsInitialization zero

Hessian analytical_exact
KKTLinsys auto
compute_mode cpu

verbosity_level 0
mu0 1e-1
fixed_var relax
max_iter 3000
kappa1 1e-8
kappa2 1e-8
69 changes: 52 additions & 17 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,22 @@ algparams = AlgParams()
algparams.parallel = false #algparams.parallel = (nprocs() > 1)
algparams.verbose = 0

solver_list = ["Ipopt", "MadNLP"]
if CUDA.has_cuda_gpu()
solver_list = ["Ipopt", "MadNLP", "MadNLPGPU"]
else
solver_list = ["Ipopt", "MadNLP"]
push!(solver_list, "MadNLPGPU")
end
if isfile(joinpath(dirname(@__FILE__), "..", "build/libhiop.so"))
push!(solver_list, "Hiop")
ENV["JULIA_HIOP_LIBRARY_PATH"] = joinpath(dirname(@__FILE__), "..", "build")
@info("Using Hiop at $(ENV["JULIA_HIOP_LIBRARY_PATH"])")
end

@testset "Test ProxAL on $(case)" begin
modelinfo.case_name = case

for solver in solver_list
@testset "$(solver)" begin
println("Testing using $(solver)")
if solver == "Ipopt"
using Ipopt
algparams.optimizer =
Expand Down Expand Up @@ -99,7 +104,7 @@ end
result = solve_fullmodel(opfdata, rawdata, modelinfo, algparams)
@test isapprox(result["objective_value_nondecomposed"], 11.258316111585623, rtol = rtol)
@test isapprox(result["primal"].Pg[:], [0.8979870694509675, 1.3432060120295906, 0.9418738103137331, 0.9840203268625166, 1.448040098924617, 1.0149638876964715], rtol = rtol)
if solver != "Ipopt"
if solver == "MadNLP" || solver == "MadNLPGPU" || solver == "Hiop"
@test_broken isapprox(result["primal"].Zt[:], [0.0, 0.0, 0.0, 2.7859277234613066e-6, 2.3533760802049378e-6, 2.0234235436650152e-6], rtol = rtol)
else
@test isapprox(result["primal"].Zt[:], [0.0, 0.0, 0.0, 2.7859277234613066e-6, 2.3533760802049378e-6, 2.0234235436650152e-6], rtol = rtol)
Expand Down Expand Up @@ -148,19 +153,32 @@ end
algparams.mode = :nondecomposed
result = solve_fullmodel(opfdata, rawdata, modelinfo, algparams)
@test isapprox(result["objective_value_nondecomposed"], 11.258316111574212, rtol = rtol)
@test isapprox(result["primal"].Pg[:], [0.8979870693416382, 1.3432060108971793, 0.9418738115511179, 0.9055318507524525, 1.3522597485901564, 0.9500221754747974, 0.9840203265549852, 1.4480400977338292, 1.014963889201792, 0.9932006221514175, 1.459056452449548, 1.024878608445939], rtol = rtol)
if solver != "Ipopt"
if solver == "Hiop"
@test_broken isapprox(result["primal"].Pg[:], [0.8979870693416382, 1.3432060108971793, 0.9418738115511179, 0.9055318507524525, 1.3522597485901564, 0.9500221754747974, 0.9840203265549852, 1.4480400977338292, 1.014963889201792, 0.9932006221514175, 1.459056452449548, 1.024878608445939], rtol = rtol)
else
@test isapprox(result["primal"].Pg[:], [0.8979870693416382, 1.3432060108971793, 0.9418738115511179, 0.9055318507524525, 1.3522597485901564, 0.9500221754747974, 0.9840203265549852, 1.4480400977338292, 1.014963889201792, 0.9932006221514175, 1.459056452449548, 1.024878608445939], rtol = rtol)
end
if solver == "MadNLP" || solver == "MadNLPGPU" || solver == "Hiop"
@test_broken isapprox(result["primal"].Zt[:], [0.0, 0.0, 0.0, 2.7857429391709934e-6, 2.353279608425683e-6, 2.023313001658965e-6], rtol = rtol)
else
@test isapprox(result["primal"].Zt[:], [0.0, 0.0, 0.0, 2.7857429391709934e-6, 2.353279608425683e-6, 2.023313001658965e-6], rtol = rtol)
end
@test isapprox(result["primal"].ωt[:], [0.0, -0.00012071650257302939, 0.0, -0.00014688472954291597], rtol = rtol)
if solver == "Hiop"
@test_broken isapprox(result["primal"].ωt[:], [0.0, -0.00012071650257302939, 0.0, -0.00014688472954291597], rtol = rtol)
else
@test isapprox(result["primal"].ωt[:], [0.0, -0.00012071650257302939, 0.0, -0.00014688472954291597], rtol = rtol)
end
end
@testset "Lyapunov bound" begin
algparams.mode = :lyapunov_bound
result = solve_fullmodel(opfdata, rawdata, modelinfo, algparams)
@test isapprox(result["objective_value_lyapunov_bound"], 11.258316111574207)
@test isapprox(result["primal"].Pg[:], [0.8979870693416395, 1.3432060108971777, 0.9418738115511173, 0.9055318507524539, 1.3522597485901549, 0.9500221754747968, 0.9840203265549855, 1.4480400977338292, 1.0149638892017916, 0.9932006221514178, 1.459056452449548, 1.0248786084459387], rtol = rtol)
if solver == "Hiop"
@test_broken isapprox(result["objective_value_lyapunov_bound"], 11.258316111574207)
@test_broken isapprox(result["primal"].Pg[:], [0.8979870693416395, 1.3432060108971777, 0.9418738115511173, 0.9055318507524539, 1.3522597485901549, 0.9500221754747968, 0.9840203265549855, 1.4480400977338292, 1.0149638892017916, 0.9932006221514178, 1.459056452449548, 1.0248786084459387], rtol = rtol)
else
@test isapprox(result["objective_value_lyapunov_bound"], 11.258316111574207)
@test isapprox(result["primal"].Pg[:], [0.8979870693416395, 1.3432060108971777, 0.9418738115511173, 0.9055318507524539, 1.3522597485901549, 0.9500221754747968, 0.9840203265549855, 1.4480400977338292, 1.0149638892017916, 0.9932006221514178, 1.459056452449548, 1.0248786084459387], rtol = rtol)
end
end

@testset "ProxALM" begin
Expand Down Expand Up @@ -201,33 +219,50 @@ end
algparams.mode = :nondecomposed
result = solve_fullmodel(opfdata, rawdata, modelinfo, algparams)
@test isapprox(result["objective_value_nondecomposed"], 11.258316111574212, rtol = rtol)
@test isapprox(result["primal"].Pg[:], [0.8979870693416382, 1.3432060108971793, 0.9418738115511179, 0.9055318507524525, 1.3522597485901564, 0.9500221754747974, 0.9840203265549852, 1.4480400977338292, 1.014963889201792, 0.9932006221514175, 1.459056452449548, 1.024878608445939], rtol = rtol)
if solver != "Ipopt"
if solver == "Hiop"
@test_broken isapprox(result["primal"].Pg[:], [0.8979870693416382, 1.3432060108971793, 0.9418738115511179, 0.9055318507524525, 1.3522597485901564, 0.9500221754747974, 0.9840203265549852, 1.4480400977338292, 1.014963889201792, 0.9932006221514175, 1.459056452449548, 1.024878608445939], rtol = rtol)
else
@test isapprox(result["primal"].Pg[:], [0.8979870693416382, 1.3432060108971793, 0.9418738115511179, 0.9055318507524525, 1.3522597485901564, 0.9500221754747974, 0.9840203265549852, 1.4480400977338292, 1.014963889201792, 0.9932006221514175, 1.459056452449548, 1.024878608445939], rtol = rtol)
end
if solver == "MadNLP" || solver == "MadNLPGPU" || solver == "Hiop"
@test_broken isapprox(result["primal"].Zt[:], [0.0, 0.0, 0.0, 2.7857429391709934e-6, 2.353279608425683e-6, 2.023313001658965e-6], rtol = rtol)
else
@test isapprox(result["primal"].Zt[:], [0.0, 0.0, 0.0, 2.7857429391709934e-6, 2.353279608425683e-6, 2.023313001658965e-6], rtol = rtol)
end
@test isapprox(result["primal"].ωt[:], [0.0, -0.00012071650257302939, 0.0, -0.00014688472954291597], rtol = rtol)
if solver == "Hiop"
@test_broken isapprox(result["primal"].ωt[:], [0.0, -0.00012071650257302939, 0.0, -0.00014688472954291597], rtol = rtol)
else
@test isapprox(result["primal"].ωt[:], [0.0, -0.00012071650257302939, 0.0, -0.00014688472954291597], rtol = rtol)
end
end
@testset "Lyapunov bound" begin
algparams.mode = :lyapunov_bound
result = solve_fullmodel(opfdata, rawdata, modelinfo, algparams)
@test isapprox(result["objective_value_lyapunov_bound"], 11.258316111574207)
if solver == "Hiop"
@test_broken isapprox(result["objective_value_lyapunov_bound"], 11.258316111574207)
else
@test isapprox(result["objective_value_lyapunov_bound"], 11.258316111574207)
end
@test isapprox(result["primal"].Pg[:], [0.8979870693416395, 1.3432060108971777, 0.9418738115511173, 0.9055318507524539, 1.3522597485901549, 0.9500221754747968, 0.9840203265549855, 1.4480400977338292, 1.0149638892017916, 0.9932006221514178, 1.459056452449548, 1.0248786084459387], rtol = rtol)
end
# MadNLP gets stuck here
if solver == "Ipopt"
if solver == "Ipopt" || solver == "Hiop"
@testset "ProxALM" begin
algparams.mode = :coldstart
runinfo = run_proxALM(opfdata, rawdata, modelinfo, algparams)
@test isapprox(runinfo.x.Pg[:], [0.8847566379915904, 1.3458885793645132, 0.9528041613516992, 0.8889877105252308, 1.3510255515317628, 0.9575214693720255, 0.9689518361922401, 1.4504831243374814, 1.0280553147660263, 0.9743778573888332, 1.4570143379662728, 1.0340634613139639], rtol = rtol)
@test isapprox(runinfo.x.ωt[:], [0.0, -6.872285646588893e-5, 0.0, -8.763210220007218e-5], rtol = rtol)
@test isapprox(runinfo.λ.ramping[:], [0.0, 0.0, 0.0, -0.02526641008086374, -0.03138993075214526, -0.022582337855672596], rtol = rtol)
@test isapprox(runinfo.λ.ctgs[:], [0.0, 0.0, 0.0, 0.029837851198013726, 0.0018123712232017784, -0.029641691338447657, 0.0, 0.0, 0.0, 0.03640088659004858, -0.0024938071819119163, -0.030934017357459445], rtol = rtol)
@test isapprox(runinfo.maxviol_c[end], 9.297964943270377e-5)
@test isapprox(runinfo.maxviol_t[end], 3.7014553733172306e-6, rtol = rtol)
if solver == "Hiop"
@test_broken isapprox(runinfo.maxviol_c[end], 9.297964943270377e-5)
@test_broken isapprox(runinfo.maxviol_t[end], 3.7014553733172306e-6, rtol = rtol)
else
@test isapprox(runinfo.maxviol_c[end], 9.297964943270377e-5)
@test isapprox(runinfo.maxviol_t[end], 3.7014553733172306e-6, rtol = rtol)
end
@test isapprox(runinfo.maxviol_d[end], 1.2901722926388947e-6, rtol = rtol)
if solver == Ipopt
if solver == "Ipopt"
@test runinfo.iter == 81
end
end
Expand Down

0 comments on commit dbb8f99

Please sign in to comment.