Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solver issue with compute_infeasibility_explanation() in Diagnostic Toolbox #1520

Closed
luohezhiming opened this issue Nov 4, 2024 · 4 comments · Fixed by Pyomo/pyomo#3403
Closed
Assignees
Labels
bug Something isn't working

Comments

@luohezhiming
Copy link
Contributor

The compute_infeasibility_explanation() fails to solve after the numerical issues are reported.
The errors are:

ERROR: Unable to clone Pyomo component attribute. Component 'FiniteSetOf'
contains an uncopyable field '_ref' (<class 'dict_keys'>).  Setting field to
`None` on new object
ERROR: Unable to clone Pyomo component attribute. Component 'FiniteSetOf'
contains an uncopyable field '_ref' (<class 'dict_keys'>).  Setting field to
`None` on new object
ERROR: Unable to clone Pyomo component attribute. Component 'FiniteSetOf'
contains an uncopyable field '_ref' (<class 'dict_keys'>).  Setting field to
`None` on new object
WARNING: model contains export suffix 'scaling_factor' that contains 1134
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix 'scaling_factor' that contains 274 keys
that are not Var, Constraint, Objective, or the model.  Skipping.
WARNING: model contains export suffix 'scaling_factor' that contains 1134
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix 'scaling_factor' that contains 274 keys
that are not Var, Constraint, Objective, or the model.  Skipping.
WARNING: model contains export suffix 'scaling_factor' that contains 92
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix 'scaling_factor' that contains 274 keys
that are not Var, Constraint, Objective, or the model.  Skipping.
WARNING: model contains export suffix 'scaling_factor' that contains 1135
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix 'scaling_factor' that contains 274 keys
that are not Var, Constraint, Objective, or the model.  Skipping.
Could not find a feasible solution with violated constraints or bounds. This model is likely unstable
WARNING: model contains export suffix 'scaling_factor' that contains 2263
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix 'scaling_factor' that contains 274 keys
that are not Var, Constraint, Objective, or the model.  Skipping.
Traceback (most recent call last):
  File "C:\Users\wcy78\anaconda3\envs\watertap-dev\Lib\site-packages\IPython\core\interactiveshell.py", line 3577, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-2-4381b6494d21>", line 1, in <module>
    runfile('D:/Keylogic/WaterTap_Chenyu/watertap/watertap/flowsheets/electroNP/BSM2_electroNP_surrogate_bioP_initialization_refined.py', wdir='D:/Keylogic/WaterTap_Chenyu/watertap/watertap/flowsheets/electroNP')
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2021.3.2\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_umd.py", line 198, in runfile
    pydev_imports.execfile(filename, global_vars, local_vars)  # execute the script
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2021.3.2\plugins\python-ce\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "D:/Keylogic/WaterTap_Chenyu/watertap/watertap/flowsheets/electroNP/BSM2_electroNP_surrogate_bioP_initialization_refined.py", line 1438, in <module>
    m, results = main(has_electroNP=True)
                 ^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:/Keylogic/WaterTap_Chenyu/watertap/watertap/flowsheets/electroNP/BSM2_electroNP_surrogate_bioP_initialization_refined.py", line 165, in main
    dt.compute_infeasibility_explanation()
  File "C:\Users\wcy78\anaconda3\envs\watertap-dev\Lib\site-packages\idaes\core\util\model_diagnostics.py", line 775, in compute_infeasibility_explanation
    mis.compute_infeasibility_explanation(
  File "C:\Users\wcy78\anaconda3\envs\watertap-dev\Lib\site-packages\pyomo\contrib\iis\mis.py", line 290, in compute_infeasibility_explanation
    if pyo.check_optimal_termination(results):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\wcy78\anaconda3\envs\watertap-dev\Lib\site-packages\pyomo\opt\results\solver.py", line 152, in check_optimal_termination
    if results.solver.status == SolverStatus.ok and (
       ^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'solver'
@luohezhiming luohezhiming added the bug Something isn't working label Nov 4, 2024
@adam-a-a
Copy link
Contributor

adam-a-a commented Nov 5, 2024

I was just about to report the same issue that I had put off posting. The problem is here https://github.com/Pyomo/pyomo/blob/main/pyomo/contrib/iis/mis.py#L285-L290:

    try:
        results = solver.solve(modified_model, tee=tee)
    except:
        results = None

When the solve fails and check_optimal_termination is called on results which is None, we get back this unhelpful error.

I guess the question is--assuming that being able to solve the problem at hand would not be trivial or possible---can we return a better exception? And I suppose that this issue might technically belong on Pyomo.

@andrewlee94
Copy link
Member

I am fairly certain this is a Pyomo issue - @jsiirola @blnicho @bknueven any ideas on the best course of action?

@bknueven
Copy link
Contributor

bknueven commented Nov 5, 2024

https://github.com/Pyomo/pyomo/blob/ad90ee2b050f58a85cc27aa733499851e5f44557/pyomo/contrib/iis/mis.py#L290

This conditional should first check that results is not None before pyo.check_optimal_termination(results).

@luohezhiming
Copy link
Contributor Author

I was just about to report the same issue that I had put off posting. The problem is here https://github.com/Pyomo/pyomo/blob/main/pyomo/contrib/iis/mis.py#L285-L290:

    try:
        results = solver.solve(modified_model, tee=tee)
    except:
        results = None

When the solve fails and check_optimal_termination is called on results which is None, we get back this unhelpful error.

I guess the question is--assuming that being able to solve the problem at hand would not be trivial or possible---can we return a better exception? And I suppose that this issue might technically belong on Pyomo.

My case is kind of similar to you, I use Degeneracy Hunter to run this problem and it diverge to a infeasible point

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants