arfc / osier

Justice oriented energy system optimization framework
BSD 3-Clause "New" or "Revised" License
5 stars 5 forks source link

New Pyomo version bug? #50

Open samgdotson opened 4 months ago

samgdotson commented 4 months ago

Here's what I know, last week (2/20/2024) I could run an osier.CapacityExpansion problem just fine and the output would look something like this

Working configurations

platform python version pyomo version
Win10 3.9.3 6.4.1
==========================================================
n_gen  |  n_eval  | n_nds  |      eps      |   indicator  
==========================================================
     1 |       10 |      1 |             - |             -
     2 |       20 |      1 |  0.000000E+00 |             f
     3 |       30 |      1 |  0.000000E+00 |             f
     4 |       40 |      1 |  0.000000E+00 |             f
     5 |       50 |      1 |  0.000000E+00 |             f

Now, the problem still runs but the output is a lot less pretty

Broken configurations

platform python version pyomo version
Win10, MacOS Monterey 12.6 3.9.3. 3.10.13 6.7.1
==========================================================
n_gen  |  n_eval  | n_nds  |      eps      |   indicator  
==========================================================
     1 |       10 |      1 |             - |             -
ERROR: evaluating object as numeric value: x[NaturalGas_Conv,0]
        (object: <class 'pyomo.core.base.var._GeneralVarData'>)
    No value for uninitialized NumericValue object x[NaturalGas_Conv,0]
ERROR: evaluating object as numeric value: x[NaturalGas_Conv,0]
        (object: <class 'pyomo.core.base.var._GeneralVarData'>)
    No value for uninitialized NumericValue object x[NaturalGas_Conv,0]
ERROR: evaluating object as numeric value: x[NaturalGas_Conv,0]
        (object: <class 'pyomo.core.base.var._GeneralVarData'>)
     2 |       20 |      1 |  0.000000E+00 |             f
ERROR: evaluating object as numeric value: x[NaturalGas_Conv,0]
        (object: <class 'pyomo.core.base.var._GeneralVarData'>)
    No value for uninitialized NumericValue object x[NaturalGas_Conv,0]
ERROR: evaluating object as numeric value: x[NaturalGas_Conv,0]
        (object: <class 'pyomo.core.base.var._GeneralVarData'>)
    No value for uninitialized NumericValue object x[NaturalGas_Conv,0]
ERROR: evaluating object as numeric value: x[NaturalGas_Conv,0]
        (object: <class 'pyomo.core.base.var._GeneralVarData'>)
     3 |       30 |      1 |  0.000000E+00 |             f
ERROR: evaluating object as numeric value: x[NaturalGas_Conv,0]
        (object: <class 'pyomo.core.base.var._GeneralVarData'>)
    No value for uninitialized NumericValue object x[NaturalGas_Conv,0]
     4 |       40 |      1 |  0.000000E+00 |             f
     5 |       50 |      1 |  0.000000E+00 |             f

What I have tried

  1. I plugged the error into Google, found this post from 2018. I can verify that this problem only occurs when a model is unfeasible. However, that will be the case for many many models tested in osier because that's just how genetic algorithms work so it would be nice to turn off whatever error message is causing this.
  2. I checked the verbosity settings -- the verbosity is as high as it can possibly go.
    logging.getLogger('pyomo.core').setLevel(verbosity)`   # default = logging.Critical
  3. I also tried
    import warnings
    warnings.filter('ignore')
  4. I reinstalled osier in two fresh conda environments. One with Python 3.9 and the other with Python 3.10. I also tested it with Pyomo versions 6.4.1 and 6.7.1 (see above configurations) -- this behavior is only present with the most recent pyomo version, 6.7.1. This pyomo update was released this week which is consistent with the timeline where my code was working fine on Friday and today it is not. Especially since it was previously working on two other machines with more recent versions of pyomo, bet less recent than the current (until I updated them today and now they're broken).
  5. I have tried specifying the pyomo version in setup.py under the install_requires parameter, however doing so results in the following error message

    
    Obtaining file:///C:/Users/samgd/Research/osier
    Preparing metadata (setup.py) ... error
    error: subprocess-exited-with-error
    
    × python setup.py egg_info did not run successfully.
    │ exit code: 1
    ╰─> [28 lines of output]
      C:\Users\samgd\anaconda3\envs\pyomo64\lib\site-packages\setuptools\__init__.py:80: _DeprecatedInstaller: setuptools.installer and fetch_build_eggs are deprecated.
      !!
    
              ********************************************************************************
              Requirements should be satisfied by a PEP 517 installer.
              If you are using pip, you can try `pip install --use-pep517`.
              ********************************************************************************
    
      !!
        dist.fetch_build_eggs(dist.setup_requires)
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "C:\Users\samgd\Research\osier\setup.py", line 113, in <module>
          setup(**opts)
        File "C:\Users\samgd\anaconda3\envs\pyomo64\lib\site-packages\setuptools\__init__.py", line 103, in setup
          return distutils.core.setup(**attrs)
        File "C:\Users\samgd\anaconda3\envs\pyomo64\lib\site-packages\setuptools\_distutils\core.py", line 147, in setup
          _setup_distribution = dist = klass(attrs)
        File "C:\Users\samgd\anaconda3\envs\pyomo64\lib\site-packages\setuptools\dist.py", line 303, in __init__
          _Distribution.__init__(self, dist_attrs)
        File "C:\Users\samgd\anaconda3\envs\pyomo64\lib\site-packages\setuptools\_distutils\dist.py", line 258, in __init__
          getattr(self.metadata, "set_" + key)(val)
        File "C:\Users\samgd\anaconda3\envs\pyomo64\lib\site-packages\setuptools\_distutils\dist.py", line 1255, in set_requires
          distutils.versionpredicate.VersionPredicate(v)
        File "C:\Users\samgd\anaconda3\envs\pyomo64\lib\site-packages\setuptools\_distutils\versionpredicate.py", line 122, in __init__
          raise ValueError("expected parenthesized list: %r" % paren)
      ValueError: expected parenthesized list: '<=6.7.0'
      [end of output]
    
    note: This error originates from a subprocess, and is likely not a problem with pip.
    error: metadata-generation-failed

× Encountered error while generating package metadata. ╰─> See above for output.

note: This is an issue with the package mentioned above, not pip. hint: See above for details.



# What needs to change

This issue can be closed when `setup.py` specifies a version of  `pyomo<=6.7.0`. 

**OR**

Update the way `osier` is installed per the line in the error message `C:\Users\samgd\anaconda3\envs\pyomo64\lib\site-packages\setuptools\__init__.py:80: _DeprecatedInstaller: setuptools.installer and fetch_build_eggs are deprecated.`

@yardasol would you mind helping with this?
yardasol commented 1 month ago

@samgdotson I think your best bet for now is to fix your setup.py so you aren't using the deprecated setuptools.installer, AND put a version requirement on pyomo.