diff --git a/benches/test_lowpass.py b/benches/test_lowpass.py index 57422c0..946dc99 100644 --- a/benches/test_lowpass.py +++ b/benches/test_lowpass.py @@ -27,7 +27,7 @@ def run_lowpass(use_parallel_cut: bool, duration=0.000001): omega, Spsq = create_lowpass_case(N) options = Options() options.max_iters = 20000 - options.tol = 1e-8 + options.tol = 1e-20 h, _, num_iters = cutting_plane_optim(omega, ellip, Spsq, options) time.sleep(duration) return num_iters, h is not None diff --git a/src/ellalgo/ell_config.py b/src/ellalgo/ell_config.py index 868f681..c3061cb 100644 --- a/src/ellalgo/ell_config.py +++ b/src/ellalgo/ell_config.py @@ -13,7 +13,7 @@ class CutStatus(Enum): # 1e-8 respectively. class Options: max_iters: int = 2000 # maximum number of iterations - tol: float = 1e-8 # error tolerance + tol: float = 1e-20 # error tolerance # The `CInfo` class represents information about a computation, including whether it is feasible and diff --git a/tests/test_example1.py b/tests/test_example1.py index 8cc4c60..0d6e45c 100644 --- a/tests/test_example1.py +++ b/tests/test_example1.py @@ -3,7 +3,7 @@ import numpy as np -from ellalgo.cutting_plane import cutting_plane_optim +from ellalgo.cutting_plane import cutting_plane_optim, Options from ellalgo.ell import Ell from ellalgo.ell_typing import OracleFeas, OracleOptim @@ -79,8 +79,10 @@ def test_case_feasible(): """[summary]""" xinit = np.array([0.0, 0.0]) # initial xinit ellip = Ell(10.0, xinit) + options = Options() + options.tol = 1e-10 omega = MyOracle() - xbest, _, _ = cutting_plane_optim(omega, ellip, float("-inf")) + xbest, _, _ = cutting_plane_optim(omega, ellip, float("-inf"), options) assert xbest is not None # fmt = '{:f} {} {} {}' # print(fmt.format(fbest, niter, feasible, status)) diff --git a/tests/test_lmi.py b/tests/test_lmi.py index cc51554..7e36db3 100644 --- a/tests/test_lmi.py +++ b/tests/test_lmi.py @@ -95,7 +95,7 @@ def test_lmi_lazy(): ([type]): [description] """ result = run_lmi(LMIOracle) - assert result == 112 + assert result == 281 def test_lmi_old(): @@ -105,4 +105,4 @@ def test_lmi_old(): ([type]): [description] """ result = run_lmi(LMIOldOracle) - assert result == 112 + assert result == 281 diff --git a/tests/test_lowpass.py b/tests/test_lowpass.py index 00b5bf2..22070c9 100644 --- a/tests/test_lowpass.py +++ b/tests/test_lowpass.py @@ -22,12 +22,12 @@ def run_lowpass(use_parallel_cut: bool, duration=0.000001): N = 32 r0 = np.zeros(N) # initial xinit r0[0] = 0 - ellip = Ell(4.0, r0) + ellip = Ell(40.0, r0) ellip._helper.use_parallel_cut = use_parallel_cut omega, Spsq = create_lowpass_case(N) options = Options() - options.max_iters = 20000 - options.tol = 1e-8 + options.max_iters = 50000 + options.tol = 1e-14 h, _, num_iters = cutting_plane_optim(omega, ellip, Spsq, options) time.sleep(duration) return num_iters, h is not None @@ -37,5 +37,5 @@ def test_lowpass(): """Test the lowpass case with parallel cut""" result, feasible = run_lowpass(True) assert feasible - assert result >= 1075 - assert result <= 1194 + assert result >= 23000 + assert result <= 24000 diff --git a/tests/test_profit.py b/tests/test_profit.py index 8774b94..f8431c2 100644 --- a/tests/test_profit.py +++ b/tests/test_profit.py @@ -46,22 +46,22 @@ def run_profit_q(E): def test_profit_ell(): num_iters = run_profit(Ell) - assert num_iters == 36 + assert num_iters == 83 def test_profit_ell_stable(): num_iters = run_profit(EllStable) - assert num_iters == 36 + assert num_iters == 83 def test_profit_rb_ell(): num_iters = run_profit_rb(Ell) - assert num_iters == 41 + assert num_iters == 90 def test_profit_rb_ell_stable(): num_iters = run_profit_rb(EllStable) - assert num_iters == 41 + assert num_iters == 90 def test_profit_q_ell(): diff --git a/tests/test_quasicvx.py b/tests/test_quasicvx.py index 2a2d54d..ddaa3a7 100644 --- a/tests/test_quasicvx.py +++ b/tests/test_quasicvx.py @@ -65,7 +65,7 @@ def test_case_feasible(): omega = MyQuasicvxOracle() xbest, _, niters = cutting_plane_optim(omega, ellip, 0.0) assert xbest is not None - assert niters == 35 + assert niters == 83 # assert fbest == approx(0.4288673396685956) # assert xbest[0] * xbest[0] == approx(0.5029823096186075) # assert math.exp(xbest[1]) == approx(1.6536872634520428) diff --git a/tests/test_quasicvx2.py b/tests/test_quasicvx2.py index 5638fef..a6bf446 100644 --- a/tests/test_quasicvx2.py +++ b/tests/test_quasicvx2.py @@ -51,9 +51,9 @@ def test_case_feasible(): omega = MyQuasicvxOracle() xbest, fbest, _ = cutting_plane_optim(omega, ellip, 0.0) assert xbest is not None - assert fbest == approx(-0.4288673396685956) - assert xbest[0] == approx(0.5053830040042219) - assert xbest[1] == approx(1.6576289475891712) + assert fbest == approx(-0.42888194247600586) + assert xbest[0] == approx(0.5000004646814299) + assert xbest[1] == approx(1.6487220368468205) def test_case_infeasible1(): diff --git a/tests/test_quasicvx_stable.py b/tests/test_quasicvx_stable.py index 15c0a8d..0da96b6 100644 --- a/tests/test_quasicvx_stable.py +++ b/tests/test_quasicvx_stable.py @@ -47,9 +47,9 @@ def test_case_feasible(): omega = MyQuasicvxOracle() xbest, fbest, _ = cutting_plane_optim(omega, ellip, 0.0) assert xbest is not None - assert fbest == approx(0.4288673396685956) - assert xbest[0] * xbest[0] == approx(0.5029823096186075) - assert math.exp(xbest[1]) == approx(1.6536872634520428) + assert fbest == approx(0.4288819424771711) + assert xbest[0] * xbest[0] == approx(0.5000021895211592) + assert math.exp(xbest[1]) == approx(1.6487248806185175) def test_case_infeasible1():