pyomo icon indicating copy to clipboard operation
pyomo copied to clipboard

.nl file writer does not eliminate constant constraints

Open dilr opened this issue 7 years ago • 5 comments

I have written two examples in which BARON chokes on a constant constraint passed through the ASL interface. In both cases, the .nl writer simplifies the constraint to 0 == 0, but writes it anyways.

This has a constraint which is constant (with respect to the solver) because both variables in it are "fixed" in the Pyomo model. kmn_model.py.txt

This has a constraint which is constant because the constraint is of the form Constant == Parameter kmnc_model.py.txt

Note that the line number on the syntax error refers to the .bar file which baron generates from the .nl file, not the .nl file itself.

dilr avatar Jul 16 '18 20:07 dilr

This is a known issue. I can't recall why the *.nl writer behaves in such a way, but if you want to get around the problem, try TransformationFactory('contrib.deactivate_trivial_constraints').apply_to(model). Before solving.

qtothec avatar Jul 16 '18 20:07 qtothec

@jsiirola - Is this still a valid concern given the recent NL writer rewrite?

mrmundt avatar Jan 03 '24 21:01 mrmundt

This is still an issue: NLv2 has improved handling of trivial constraints, but for backwards compatibility, skip_trivial_constraints still defaults to False. We should eventually move to defaulting it to True, and at the same time, it should verivy that any eliminated nonlinear expressions are still numerically valid at the solution returned by the solver.

jsiirola avatar Jan 05 '24 16:01 jsiirola