From 70ede740422401917d277ec0f3aecf6f23e79280 Mon Sep 17 00:00:00 2001 From: Peter Sharpe Date: Tue, 24 Oct 2023 14:23:13 -0400 Subject: [PATCH] rework main block example to have a constraint, and do an assert on it. --- aerosandbox/optimization/opti.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/aerosandbox/optimization/opti.py b/aerosandbox/optimization/opti.py index 9a5100652..5b6fc81f6 100644 --- a/aerosandbox/optimization/opti.py +++ b/aerosandbox/optimization/opti.py @@ -1430,8 +1430,11 @@ def show_infeasibilities(self, tol: float = 1e-3) -> None: f = (a - x) ** 2 + b * (y - x ** 2) ** 2 opti.minimize(f) + opti.subject_to([ + x ** 2 + y ** 2 <= 1 + ]) + # Optimize sol = opti.solve() - for i in [x, y]: - assert sol.value(i) == pytest.approx(1, abs=1e-4) + assert sol([x, y]) == pytest.approx([0.7864, 0.6177], abs=1e-3)