Skip to content

Commit

Permalink
rework main block example to have a constraint, and do an assert on it.
Browse files Browse the repository at this point in the history
  • Loading branch information
peterdsharpe committed Oct 24, 2023
1 parent 5aa1d7b commit 70ede74
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions aerosandbox/optimization/opti.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 70ede74

Please sign in to comment.