Skip to content

Commit a9b9112

Browse files
authored
Merge pull request #3222 from jsiirola/cyipopt-1.4.0-bug
Work aroung bug in CyIpopt 1.4.0
2 parents a2d546d + 50e2316 commit a9b9112

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

Diff for: pyomo/contrib/pynumero/algorithms/solvers/cyipopt_solver.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,13 @@ def license_is_valid(self):
319319
return True
320320

321321
def version(self):
322-
return tuple(int(_) for _ in cyipopt.__version__.split("."))
322+
def _int(x):
323+
try:
324+
return int(x)
325+
except:
326+
return x
327+
328+
return tuple(_int(_) for _ in cyipopt_interface.cyipopt.__version__.split("."))
323329

324330
def solve(self, model, **kwds):
325331
config = self.config(kwds, preserve_implicit=True)

Diff for: pyomo/contrib/pynumero/examples/tests/test_cyipopt_examples.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,13 @@
4444
raise unittest.SkipTest("Pynumero needs the ASL extension to run CyIpopt tests")
4545

4646
import pyomo.contrib.pynumero.algorithms.solvers.cyipopt_solver as cyipopt_solver
47+
from pyomo.contrib.pynumero.interfaces.cyipopt_interface import cyipopt_available
4748

48-
if not cyipopt_solver.cyipopt_available:
49+
if not cyipopt_available:
4950
raise unittest.SkipTest("PyNumero needs CyIpopt installed to run CyIpopt tests")
5051
import cyipopt as cyipopt_core
5152

53+
5254
example_dir = os.path.join(this_file_dir(), '..')
5355

5456

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

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

0 commit comments

Comments
 (0)