diff --git a/CHANGELOG.rst b/CHANGELOG.rst index ba19673..c1fd24f 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -39,6 +39,14 @@ Version History [1.5.0.dev0] - XXXX-XX-XX ~~~~~~~~~~~~~~~~~~~~~~~~~ +[1.4.1] - 2024-04-02 +~~~~~~~~~~~~~~~~~~~~ + +Fixed ++++++ + +- Addressed regression in return value of ``intermediate_cb``. #250 + [1.4.0] - 2024-04-01 ~~~~~~~~~~~~~~~~~~~~ diff --git a/cyipopt/cython/ipopt_wrapper.pyx b/cyipopt/cython/ipopt_wrapper.pyx index 305b636..1497ed0 100644 --- a/cyipopt/cython/ipopt_wrapper.pyx +++ b/cyipopt/cython/ipopt_wrapper.pyx @@ -1278,7 +1278,7 @@ cdef Bool intermediate_cb(Index alg_mod, self.__exception = sys.exc_info() return True - return True + return ret_val class problem(Problem): diff --git a/cyipopt/tests/unit/test_ipopt_funcs.py b/cyipopt/tests/unit/test_ipopt_funcs.py index 789fca9..c0f91b0 100644 --- a/cyipopt/tests/unit/test_ipopt_funcs.py +++ b/cyipopt/tests/unit/test_ipopt_funcs.py @@ -391,3 +391,51 @@ def intermediate( np.testing.assert_allclose(pr_violations[-1], np.zeros(m), atol=1e-8) np.testing.assert_allclose(du_violations[-1], np.zeros(n), atol=1e-8) + + +def test_intermediate_cb( + hs071_initial_guess_fixture, + hs071_definition_instance_fixture, + hs071_variable_lower_bounds_fixture, + hs071_variable_upper_bounds_fixture, + hs071_constraint_lower_bounds_fixture, + hs071_constraint_upper_bounds_fixture, +): + x0 = hs071_initial_guess_fixture + lb = hs071_variable_lower_bounds_fixture + ub = hs071_variable_upper_bounds_fixture + cl = hs071_constraint_lower_bounds_fixture + cu = hs071_constraint_upper_bounds_fixture + n = len(x0) + m = len(cl) + + problem_definition = hs071_definition_instance_fixture + + def intermediate( + alg_mod, + iter_count, + obj_value, + inf_pr, + inf_du, + mu, + d_norm, + regularization_size, + alpha_du, + alpha_pr, + ls_trials, + ): + return False + + problem_definition.intermediate = intermediate + + nlp = cyipopt.Problem( + n=n, + m=m, + problem_obj=problem_definition, + lb=lb, + ub=ub, + cl=cl, + cu=cu, + ) + x, info = nlp.solve(x0) + assert b'premature termination' in info['status_msg']