Skip to content

Commit e8226cd

Browse files
authored
Merge pull request #120 from akisschinas/enhance_rounding_methods
Enhance rounding methods
2 parents d7077a1 + bf05fe6 commit e8226cd

File tree

3 files changed

+28
-6
lines changed

3 files changed

+28
-6
lines changed

dingo/bindings/bindings.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -452,14 +452,20 @@ void HPolytopeCPP::apply_rounding(int rounding_method, double* new_A, double* ne
452452
// run the rounding method
453453
if (rounding_method == 1) { // max ellipsoid
454454
round_res = inscribed_ellipsoid_rounding<MT, VT, NT>(P, CheBall.first);
455-
456455
} else if (rounding_method == 2) { // isotropization
457456
round_res = svd_rounding<AcceleratedBilliardWalk, MT, VT>(P, CheBall, 1, rng);
458457
} else if (rounding_method == 3) { // min ellipsoid
459-
round_res = min_sampling_covering_ellipsoid_rounding<AcceleratedBilliardWalk, MT, VT>(P,
460-
CheBall,
461-
walk_len,
462-
rng);
458+
round_res = min_sampling_covering_ellipsoid_rounding
459+
<AcceleratedBilliardWalk, MT, VT>(P, CheBall, walk_len, rng);
460+
} else if (rounding_method == 4) { // log barrier
461+
round_res = inscribed_ellipsoid_rounding
462+
<MT, VT, NT, decltype(P), decltype(CheBall.first), 2>(P, CheBall.first);
463+
} else if (rounding_method == 5) { // Vaidya barrier
464+
round_res = inscribed_ellipsoid_rounding
465+
<MT, VT, NT, decltype(P), decltype(CheBall.first), 3>(P, CheBall.first);
466+
} else if (rounding_method == 6) { // volumetric barrier
467+
round_res = inscribed_ellipsoid_rounding
468+
<MT, VT, NT, decltype(P), decltype(CheBall.first), 4>(P, CheBall.first);
463469
} else {
464470
throw std::runtime_error("Unknown rounding method.");
465471
}

dingo/volestipy.pyx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,12 @@ cdef class HPolytope:
162162
int_method = 2
163163
elif rounding_method == 'min_ellipsoid':
164164
int_method = 3
165+
elif rounding_method == 'log_barrier':
166+
int_method = 4
167+
elif rounding_method == 'vaidya_barrier':
168+
int_method = 5
169+
elif rounding_method == 'volumetric_barrier':
170+
int_method = 6
165171
else:
166172
raise RuntimeError("Uknown rounding method")
167173

tests/rounding.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,18 @@ def test_rounding_min_ellipsoid(self):
6464
def test_rounding_john_position(self):
6565
test_rounding(self, "john_position")
6666

67+
def test_rounding_log_barrier(self):
68+
test_rounding(self, "log_barrier")
69+
70+
def test_rounding_vaidya_barrier(self):
71+
test_rounding(self, "vaidya_barrier")
72+
73+
def test_rounding_volumetric_barrier(self):
74+
test_rounding(self, "volumetric_barrier")
75+
6776
if __name__ == "__main__":
6877
if len(sys.argv) > 1:
6978
set_default_solver(sys.argv[1])
7079
sys.argv.pop(1)
71-
unittest.main()
80+
unittest.main()
81+

0 commit comments

Comments
 (0)