Pyomo Util Module Not Found

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-20 03:37:12

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!