Fix some _compute_gap corner cases; add tests

This commit is contained in:
2021-01-20 08:56:02 -06:00
parent a536d2ecc6
commit 69a82172b9
2 changed files with 16 additions and 3 deletions

View File

@@ -35,3 +35,13 @@ def test_benchmark():
benchmark = BenchmarkRunner(test_solvers)
benchmark.load_results("/tmp/benchmark.csv")
assert benchmark.raw_results().values.shape == (12, 14)
def test_gap():
assert BenchmarkRunner._compute_gap(ub=0.0, lb=0.0) == 0.0
assert BenchmarkRunner._compute_gap(ub=1.0, lb=0.5) == 0.5
assert BenchmarkRunner._compute_gap(ub=1.0, lb=1.0) == 0.0
assert BenchmarkRunner._compute_gap(ub=1.0, lb=-1.0) == 1.0
assert BenchmarkRunner._compute_gap(ub=1.0, lb=None) == 1.0
assert BenchmarkRunner._compute_gap(ub=None, lb=1.0) == 1.0
assert BenchmarkRunner._compute_gap(ub=None, lb=None) == 1.0