pyomo icon indicating copy to clipboard operation
pyomo copied to clipboard

DeveloperError when using sensitivity_toolbox.sens.get_dsdp with pyomo.dae.Integral

Open jialuw96 opened this issue 2 years ago • 2 comments

Summary

@adowling2, Ryan and I are working on a concrete model to simulate a rotary bed adsorption process. The model is square, with no degree of freedoms, and can be solved by IPOPT. When I continued to use pyomo.contrib.sensitivity_toolbox.sens.get_dsdp to achieve the sensitivity information, it shows a developer error:

DeveloperError: Internal Pyomo implementation error:

        "The '_data' dictionary and '_index' attribute are out of sync for
        indexed Expression 'Flow_kz': The ('N2', 1) entry in the '_data'
        dictionary does not map back to this component data object."
    Please report this to the Pyomo Developers.j

The indexed expression "Flow_kz" is a Pyomo.DAE.Integral expression, defined and used as in the following code:

@m.Integral(
        m.component_list,
        m.z,
        m.o,
        wrt=m.o,
        doc="Component flow integrated over theta, function of z [mol/s]",
    )
def Flow_kz(m, k, z, o):
    return m.Flux_kzo[k, z, o] * m.A_b

@m.Expression(m.z, doc="Total flow integrated over theta, function of z [mol/s]")
def Flow_z(m, z):
    return sum(m.Flow_kz[k, z] for k in m.component_list) 

Steps to reproduce the issue

The exampe is in https://github.com/jialuw96/pyomo/tree/dsdp_debug RPB_model_for_debug.py contains the model, RPB_model_dsdp.py can run the model and reproduce the issue. It will firstly solve the square model, then run the get_dsdp command to show the error.

$ python3 RPB_model_dsdp.py

Information on your system

Pyomo version: 6.6.2a0 Python version: 3.8.17 Operating system: Ubuntu 20.04.2 How Pyomo was installed (PyPI, conda, source): source Solver (if applicable): get_dsdp

jialuw96 avatar Aug 21 '23 03:08 jialuw96

@jsiirola @blnicho I think this is closely related to our conversations about revamping the Parmest and Pyomo.DoE interface to handle hierarchical models.

adowling2 avatar Aug 25 '23 16:08 adowling2

@jialuw96 just showed me this still happens with a standard model structure. @blnicho, do you have any ideas on how a DAE integral may cause issues with the dsdp interface?

adowling2 avatar Aug 25 '23 16:08 adowling2