You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As discussed in #2964, the NL writer is expected to raise an InvalidValueError upon encountering an invalid constant. However, as of #3353, this may not necessarily happen in some cases.
File "/home/jasherma/Documents/cmu/phd-project/pyomo_repo/pyomo/pyomo/opt/base/solvers.py", line 598, in solve
self._presolve(*args, **kwds)
File "/home/jasherma/Documents/cmu/phd-project/pyomo_repo/pyomo/pyomo/opt/solver/shellcmd.py", line 223, in _pr
esolve
OptSolver._presolve(self, *args, **kwds)
File "/home/jasherma/Documents/cmu/phd-project/pyomo_repo/pyomo/pyomo/opt/base/solvers.py", line 704, in _preso
lve
self._convert_problem(
File "/home/jasherma/Documents/cmu/phd-project/pyomo_repo/pyomo/pyomo/opt/base/solvers.py", line 756, in _conve
rt_problem
return convert_problem(
File "/home/jasherma/Documents/cmu/phd-project/pyomo_repo/pyomo/pyomo/opt/base/convert.py", line 97, in convert
_problem
problem_files, symbol_map = converter.apply(*tmp, **tmpkw)
File "/home/jasherma/Documents/cmu/phd-project/pyomo_repo/pyomo/pyomo/solvers/plugins/converter/model.py", line
184, in apply
(problem_filename, symbol_map_id) = instance.write(
File "/home/jasherma/Documents/cmu/phd-project/pyomo_repo/pyomo/pyomo/core/base/block.py", line 1916, in write
(filename, smap) = problem_writer(self, filename, solver_capability, io_options)
File "/home/jasherma/Documents/cmu/phd-project/pyomo_repo/pyomo/pyomo/repn/plugins/nl_writer.py", line 350, in
__call__
info = self.write(model, FILE, ROWFILE, COLFILE, config=config)
File "/home/jasherma/Documents/cmu/phd-project/pyomo_repo/pyomo/pyomo/repn/plugins/nl_writer.py", line 408, in
write
return impl.write(model)
File "/home/jasherma/Documents/cmu/phd-project/pyomo_repo/pyomo/pyomo/repn/plugins/nl_writer.py", line 1457, in
write
self._write_nl_expression(info[1], True)
File "/home/jasherma/Documents/cmu/phd-project/pyomo_repo/pyomo/pyomo/repn/plugins/nl_writer.py", line 2025, in
_write_nl_expression
self.ostream.write(self.template.const % repn.const)
File "/home/jasherma/Documents/cmu/phd-project/pyomo_repo/pyomo/pyomo/repn/util.py", line 189, in __repr__
self._error(f'Cannot emit {str(self)} in compiled representation')
File "/home/jasherma/Documents/cmu/phd-project/pyomo_repo/pyomo/pyomo/repn/util.py", line 179, in _error
raise InvalidValueError(msg)
pyomo.common.errors.InvalidValueError: Cannot emit InvalidNumber(nan) in compiled representation
The InvalidNumber was generated by:
math domain error
WARNING: Exception encountered evaluating expression 'log(0)' message: math
domain error expression: log(w)
bad line 12 of /tmp/tmp1xgm4rp0.pyomo.nl: nInvalidNumber(nan)
terminate called after throwing an instance of 'Ipopt::TNLP::INVALID_TNLP'
Ipopt 3.13.2: ERROR: Solver (ipopt) returned non-zero return code (-6)
ERROR: See the solver log above for diagnostic information.
Traceback (most recent call last):
File "/home/jasherma/Documents/vim_example/pyomo_features_examples/test_ipopt_presolve_issue.py", line 21, in <
module>
pyo.SolverFactory("ipopt").solve(m, tee=True)
File "/home/jasherma/Documents/cmu/phd-project/pyomo_repo/pyomo/pyomo/opt/base/solvers.py", line 628, in solve
raise ApplicationError("Solver (%s) did not exit normally" % self.name)
pyomo.common.errors.ApplicationError: Solver (ipopt) did not exit normally
Summary
As discussed in #2964, the NL writer is expected to raise an
InvalidValueError
upon encountering an invalid constant. However, as of #3353, this may not necessarily happen in some cases.Steps to reproduce the issue
Consider the following setup:
Notice the objective (effectively) has a
log(0)
term, which should eventually trigger an exception.Running with Pyomo/main@29f8ede05e, the commit immediately preceding #3353, gives:
However, running with Pyomo/main@a6438bad0 (from #3353) yields:
Information on your system
Pyomo version: 6.7.4dev0
Numpy version: 2.0.2
Python version: 3.9.17
Operating system: Ubuntu 20.04
How Pyomo was installed (PyPI, conda, source): source
Solver (if applicable): IPOPT
The text was updated successfully, but these errors were encountered: