ASL-Pyomo discrepancy with named expressions

7 views
Skip to first unread message

robbyb...@gmail.com

unread,
Jul 13, 2026, 5:40:25 PM (3 days ago) Jul 13
to Pyomo Forum
Hi all,

I'm seeing an odd discrepancy in a constraint's value when evaluating with Pyomo and ASL (via PyomoNLP). The discrepancy goes away if I avoid using named expressions.

This depends on a few repositories that aren't on PyPI. I've attached a requirements.txt for the dependencies and a script to reproduce. The relevant output I see is:

N. constraints: 1
Constraint value (Pyomo):    0.0 <= -1.1368683772161604e-17 <= 0.0
Constraint value (PyNumero): 0.0 <= -0.03976023724855888 <= 0.0
Pyomo version: 6.10.1
ASL date:      20241202

This discrepancy is much too large to be due to floating point error accumulation. My guess is that this is a bug in either ASL or Pyomo's NL writer. (Note that PyNumero uses WriterFactor("nl"), but IIRC I tried hardcoding it to use WriterFactory("nl_v2") and still got the same bug, which suggests a bug in ASL).

Have any of you noticed discrepancies like this? Do you have any recommendations on how to debug this? My plan is to write out the constraint in a self-contained file and comment out as much of the expression as possible while still reproducing the bug. (Hopefully the bug reproduces in a single-constraint model!)

I'm posting this here rather than in a GH issue as I don't know what library the bug is in yet... Let me know if this rings a bell or if you have any debugging ideas to try.

-Robby

requirements.txt
mwe.py

Siirola, John

unread,
Jul 14, 2026, 4:26:28 PM (3 days ago) Jul 14
to pyomo...@googlegroups.com

Robby,

 

My first guess is that Pyomo is probably writing out a “valid-looking” NL file that hits an edge case that the ASL is not designed for.  The NL writer is primarily derived from the “Writing .nl files” SAND report, but we have picked up a number of additional “rules” derived by observing NL files generated by AMPL and a bit of trial-and-error.  We have seen examples in the past where what “looks like a valid NL file” will not evaluate correctly in the ASL (one that comes to mind is constant expression arguments to external functions), and we generally work around those issues in the writer.  This is likely to be another edge case.

 

On recent Pyomo releases “nl” is an alias for “nl_v2”.

 

I’m happy to help diagnose – the place to start will be to dig through the NL file and see how the named expressions are being used / embedded.  We could make a lot of headway with the pickle of the model and the NL file.  If you want to carve out (delete) the irrelevant constraints, that should be fine.

 

John

 

 

From: pyomo...@googlegroups.com <pyomo...@googlegroups.com> On Behalf Of robbyb...@gmail.com
Sent: Monday, July 13, 2026 3:40 PM
To: Pyomo Forum <pyomo...@googlegroups.com>
Subject: [EXTERNAL] ASL-Pyomo discrepancy with named expressions

 

You don't often get email from robbyb...@gmail.com. Learn why this is important

--
You received this message because you are subscribed to the Google Groups "Pyomo Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyomo-forum...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/pyomo-forum/01587620-8df9-4f4f-8bbf-626ccc9d6161n%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages