问题
So I asked a question a month ago. I had a really nice answer to that question. I wanted to test if the answer works right now. But I am getting ModuleNotFoundError
.
I did following before testing:
conda install -c conda-forge pyomo
conda install -c conda-forge pyomo.extras
I want to run this script in my code (copy/pasted from the other question):
from pyomo.util.infeasible import log_infeasible_constraints
...
SolverFactory('your_solver').solve(model)
...
log_infeasible_constraints(model)
Error I encounter:
N:\urbs>python runme.py
Traceback (most recent call last):
File "runme.py", line 9, in <module>
from pyomo.util.infeasible import log_infeasible_constraints
ModuleNotFoundError: No module named 'pyomo.util.infeasible'
How to install it then? I checked doc etc..., could not find a way.
回答1:
Pyomo 5.5 (the latest released version as of 23 August 2018) does not yet have that feature. I had mistakenly assumed that it was included. You can either change your version of pyomo to track master
, or more easily, you can simply take the function at https://github.com/Pyomo/pyomo/blob/master/pyomo/util/infeasible.py and place it in your own code (along with the associated required imports).
来源:https://stackoverflow.com/questions/51985436/pyomo-util-module-not-found