Skip to content

Commit

Permalink
Merge pull request #229 from mdhaber/test_gh1758
Browse files Browse the repository at this point in the history
TST: minimize_ipopt: add back test_gh1758
  • Loading branch information
moorepants authored Sep 25, 2023
2 parents f68a639 + cdcfcf1 commit d000880
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions cyipopt/tests/unit/test_scipy_ipopt_from_scipy.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,32 +458,32 @@ def solve(self):
problem = NestedProblem()
problem.solve()

# def test_gh1758(self):
# # minimize_ipopt finds this to be infeasible
#
# # the test suggested in gh1758
# # https://nlopt.readthedocs.io/en/latest/NLopt_Tutorial/
# # implement two equality constraints, in R^2.
# def fun(x):
# return np.sqrt(x[1])
#
# def f_eqcon(x):
# """ Equality constraint """
# return x[1] - (2 * x[0]) ** 3
#
# def f_eqcon2(x):
# """ Equality constraint """
# return x[1] - (-x[0] + 1) ** 3
#
# c1 = {'type': 'eq', 'fun': f_eqcon}
# c2 = {'type': 'eq', 'fun': f_eqcon2}
#
# res = minimize(fun, [8, 0.25], method=None,
# constraints=[c1, c2], bounds=[(-0.5, 1), (0, 8)])
#
# np.testing.assert_allclose(res.fun, 0.5443310539518)
# np.testing.assert_allclose(res.x, [0.33333333, 0.2962963])
# assert res.success
def test_gh1758(self):
# minimize_ipopt finds this to be infeasible

# the test suggested in gh1758
# https://nlopt.readthedocs.io/en/latest/NLopt_Tutorial/
# implement two equality constraints, in R^2.
def fun(x):
return np.sqrt(x[1])

def f_eqcon(x):
""" Equality constraint """
return x[1] - (2 * x[0]) ** 3

def f_eqcon2(x):
""" Equality constraint """
return x[1] - (-x[0] + 1) ** 3

c1 = {'type': 'eq', 'fun': f_eqcon}
c2 = {'type': 'eq', 'fun': f_eqcon2}

res = minimize(fun, [8, 0.25], method=None,
constraints=[c1, c2], bounds=[(-0.5, 1), (0, 8)])

np.testing.assert_allclose(res.fun, 0.5443310539518)
np.testing.assert_allclose(res.x, [0.33333333, 0.2962963])
assert res.success

def test_gh9640(self):
np.random.seed(10)
Expand Down

0 comments on commit d000880

Please sign in to comment.