cog-imperial / suspect

Special Structure Detection for Pyomo
https://cog-imperial.github.io/suspect/
Apache License 2.0
26 stars 4 forks source link

AttributeError: 'NoneType' object has no attribute 'get' #8

Closed ZedongPeng closed 4 years ago

ZedongPeng commented 4 years ago

When I tested the small example in README.rst, the following error is reported.

>>> from suspect import detect_special_structure
>>> import pyomo.environ as aml
>>> model = aml.ConcreteModel()
>>> model.x = aml.Var()
>>> model.y = aml.Var()
>>> model.obj = aml.Objective(expr=(model.y - model.x)**3)
>>> model.c1 = aml.Constraint(expr=model.y - model.x >= 0)
>>> info = detect_special_structure(model)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/zedongpeng/Github/suspect/suspect/summary.py", line 121, in detect_special_structure
    bounds = perform_fbbt(problem)
  File "/Users/zedongpeng/Github/suspect/suspect/fbbt/main.py", line 65, in perform_fbbt
    obj_lower, obj_upper = objective_bounds.get(objective, (None, None))
AttributeError: 'NoneType' object has no attribute 'get'

The python version on my computer is Python 3.8.3. The version of the required packages in my environment is the following:

alabaster                 0.7.12                   pypi_0    pypi
appdirs                   1.4.4                    pypi_0    pypi
attrs                     19.3.0                   pypi_0    pypi
babel                     2.8.0                    pypi_0    pypi
boto3                     1.14.13                  pypi_0    pypi
botocore                  1.17.13                  pypi_0    pypi
ca-certificates           2020.6.20            hecda079_0    conda-forge
certifi                   2020.6.20        py38h32f6830_0    conda-forge
chardet                   3.0.4                    pypi_0    pypi
coverage                  5.1                      pypi_0    pypi
distlib                   0.3.1                    pypi_0    pypi
docutils                  0.16                     pypi_0    pypi
filelock                  3.0.12                   pypi_0    pypi
idna                      2.10                     pypi_0    pypi
imagesize                 1.2.0                    pypi_0    pypi
jinja2                    2.11.2                   pypi_0    pypi
jmespath                  0.10.0                   pypi_0    pypi
libcxx                    10.0.0               h1af66ff_2    conda-forge
libffi                    3.2.1             h4a8c4bd_1007    conda-forge
markupsafe                1.1.1                    pypi_0    pypi
more-itertools            8.4.0                    pypi_0    pypi
mpmath                    1.0.0                    pypi_0    pypi
ncurses                   6.1               h0a44026_1002    conda-forge
nose                      1.3.7                    pypi_0    pypi
numpy                     1.19.0                   pypi_0    pypi
openssl                   1.1.1g               h0b31af3_0    conda-forge
packaging                 20.4                     pypi_0    pypi
pandas                    1.0.5                    pypi_0    pypi
pip                       20.1.1                     py_1    conda-forge
pluggy                    0.13.1                   pypi_0    pypi
ply                       3.11                     pypi_0    pypi
py                        1.9.0                    pypi_0    pypi
pygments                  2.6.1                    pypi_0    pypi
pyomo                     5.7                      pypi_0    pypi
pyparsing                 2.4.7                    pypi_0    pypi
pytest                    5.4.3                    pypi_0    pypi
pytest-cov                2.10.0                   pypi_0    pypi
pytest-runner             5.2                      pypi_0    pypi
python                    3.8.3           cpython_hd5f0129_0    conda-forge
python-dateutil           2.8.1                    pypi_0    pypi
python_abi                3.8                      1_cp38    conda-forge
pytz                      2020.1                   pypi_0    pypi
pyutilib                  6.0.0                    pypi_0    pypi
readline                  8.0                  hcfe32e1_0    conda-forge
requests                  2.24.0                   pypi_0    pypi
s3transfer                0.3.3                    pypi_0    pypi
setuptools                47.3.1           py38h32f6830_0    conda-forge
simpy                     4.0.1                    pypi_0    pypi
six                       1.15.0                   pypi_0    pypi
snowballstemmer           2.0.0                    pypi_0    pypi
sphinx                    3.1.1                    pypi_0    pypi
sphinxcontrib-applehelp   1.0.2                    pypi_0    pypi
sphinxcontrib-devhelp     1.0.2                    pypi_0    pypi
sphinxcontrib-htmlhelp    1.0.3                    pypi_0    pypi
sphinxcontrib-jsmath      1.0.1                    pypi_0    pypi
sphinxcontrib-qthelp      1.0.3                    pypi_0    pypi
sphinxcontrib-serializinghtml 1.1.4                    pypi_0    pypi
sqlite                    3.32.3               h93121df_0    conda-forge
tk                        8.6.10               hbbe82c9_0    conda-forge
toml                      0.10.1                   pypi_0    pypi
tox                       3.16.1                   pypi_0    pypi
urllib3                   1.25.9                   pypi_0    pypi
virtualenv                20.0.25                  pypi_0    pypi
wcwidth                   0.2.5                    pypi_0    pypi
wheel                     0.34.2                     py_1    conda-forge
xz                        5.2.5                h0b31af3_0    conda-forge
zlib                      1.2.11            h0b31af3_1006    conda-forge
fracek commented 4 years ago

Thank you for opening an issue!

The issue is that I updated perform_fbbt recently and forgot to update detect_special_structure. I will push an update to pypi shortly.

fracek commented 4 years ago

I uploaded version 2.0.1 to pypi, this should fix the bug. You can upgrade with pip install --upgrade cog-suspect.

I will close the issue for now, but if it's still not working for you please reopen the issue.