From bf05fe62f1a117104759b633f5976c5c58bb95ef Mon Sep 17 00:00:00 2001 From: akisschinas Date: Tue, 9 Sep 2025 16:41:22 +0300 Subject: [PATCH] Enhance rounding methods --- dingo/bindings/bindings.cpp | 16 +++++++++++----- dingo/volestipy.pyx | 6 ++++++ tests/rounding.py | 12 +++++++++++- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/dingo/bindings/bindings.cpp b/dingo/bindings/bindings.cpp index cbdb1246..8f29d28d 100644 --- a/dingo/bindings/bindings.cpp +++ b/dingo/bindings/bindings.cpp @@ -462,14 +462,20 @@ void HPolytopeCPP::apply_rounding(int rounding_method, double* new_A, double* ne // run the rounding method if (rounding_method == 1) { // max ellipsoid round_res = inscribed_ellipsoid_rounding(P, CheBall.first); - } else if (rounding_method == 2) { // isotropization round_res = svd_rounding(P, CheBall, 1, rng); } else if (rounding_method == 3) { // min ellipsoid - round_res = min_sampling_covering_ellipsoid_rounding(P, - CheBall, - walk_len, - rng); + round_res = min_sampling_covering_ellipsoid_rounding + (P, CheBall, walk_len, rng); + } else if (rounding_method == 4) { // log barrier + round_res = inscribed_ellipsoid_rounding + (P, CheBall.first); + } else if (rounding_method == 5) { // Vaidya barrier + round_res = inscribed_ellipsoid_rounding + (P, CheBall.first); + } else if (rounding_method == 6) { // volumetric barrier + round_res = inscribed_ellipsoid_rounding + (P, CheBall.first); } else { throw std::runtime_error("Unknown rounding method."); } diff --git a/dingo/volestipy.pyx b/dingo/volestipy.pyx index 6e8d3a98..77359798 100644 --- a/dingo/volestipy.pyx +++ b/dingo/volestipy.pyx @@ -162,6 +162,12 @@ cdef class HPolytope: int_method = 2 elif rounding_method == 'min_ellipsoid': int_method = 3 + elif rounding_method == 'log_barrier': + int_method = 4 + elif rounding_method == 'vaidya_barrier': + int_method = 5 + elif rounding_method == 'volumetric_barrier': + int_method = 6 else: raise RuntimeError("Uknown rounding method") diff --git a/tests/rounding.py b/tests/rounding.py index e3d97c62..1b6f5ab4 100644 --- a/tests/rounding.py +++ b/tests/rounding.py @@ -64,8 +64,18 @@ def test_rounding_min_ellipsoid(self): def test_rounding_john_position(self): test_rounding(self, "john_position") + def test_rounding_log_barrier(self): + test_rounding(self, "log_barrier") + + def test_rounding_vaidya_barrier(self): + test_rounding(self, "vaidya_barrier") + + def test_rounding_volumetric_barrier(self): + test_rounding(self, "volumetric_barrier") + if __name__ == "__main__": if len(sys.argv) > 1: set_default_solver(sys.argv[1]) sys.argv.pop(1) - unittest.main() \ No newline at end of file + unittest.main() +