Skip to content

Commit

Permalink
Merge pull request #3222 from jsiirola/cyipopt-1.4.0-bug
Browse files Browse the repository at this point in the history
Work aroung bug in CyIpopt 1.4.0
  • Loading branch information
blnicho authored Apr 2, 2024
2 parents a2d546d + 50e2316 commit a9b9112
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
8 changes: 7 additions & 1 deletion pyomo/contrib/pynumero/algorithms/solvers/cyipopt_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,13 @@ def license_is_valid(self):
return True

def version(self):
return tuple(int(_) for _ in cyipopt.__version__.split("."))
def _int(x):
try:
return int(x)
except:
return x

return tuple(_int(_) for _ in cyipopt_interface.cyipopt.__version__.split("."))

def solve(self, model, **kwds):
config = self.config(kwds, preserve_implicit=True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,13 @@
raise unittest.SkipTest("Pynumero needs the ASL extension to run CyIpopt tests")

import pyomo.contrib.pynumero.algorithms.solvers.cyipopt_solver as cyipopt_solver
from pyomo.contrib.pynumero.interfaces.cyipopt_interface import cyipopt_available

if not cyipopt_solver.cyipopt_available:
if not cyipopt_available:
raise unittest.SkipTest("PyNumero needs CyIpopt installed to run CyIpopt tests")
import cyipopt as cyipopt_core


example_dir = os.path.join(this_file_dir(), '..')


Expand Down Expand Up @@ -266,6 +268,11 @@ def test_cyipopt_functor(self):
s = df['ca_bal']
self.assertAlmostEqual(s.iloc[6], 0, places=3)

@unittest.skipIf(
cyipopt_solver.PyomoCyIpoptSolver().version() == (1, 4, 0),
"Terminating Ipopt through a user callback is broken in CyIpopt 1.4.0 "
"(see mechmotum/cyipopt#249)",
)
def test_cyipopt_callback_halt(self):
ex = import_file(
os.path.join(example_dir, 'callback', 'cyipopt_callback_halt.py')
Expand Down

0 comments on commit a9b9112

Please sign in to comment.