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

LP writer dies given a Var with an empty domain #3240

Open
emma58 opened this issue Apr 18, 2024 · 0 comments
Open

LP writer dies given a Var with an empty domain #3240

emma58 opened this issue Apr 18, 2024 · 0 comments
Labels

Comments

@emma58
Copy link
Contributor

emma58 commented Apr 18, 2024

Summary

If I create a Var that has an empty domain created by intersecting Binary and $\{2, 3\}$ (the model is structurally infeasible), the LP writer croaks somewhere in figuring out the domain (I think).

Steps to reproduce the issue

from pyomo.environ import *

m = ConcreteModel()
m.thing = Set(initialize=[2, 3])
m.x = Var(domain=Binary & m.thing)

m.c = Constraint(expr=m.x >= 0.5)

m.obj = Objective(expr=m.x)

SolverFactory('gurobi').solve(m, tee=True)

Error Message

Traceback (most recent call last):
  File "/home/esjohn/src/pyomo/pyomo/core/base/set.py", line 729, in _get_discrete_interval
    step = min(abs(r.step) for r in ranges if r.step != 0)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: min() arg is an empty sequence

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/esjohn/src/pyomo/just_checking.py", line 11, in <module>
    SolverFactory('gurobi').solve(m, tee=True)
  File "/home/esjohn/src/pyomo/pyomo/opt/base/solvers.py", line 598, in solve
    self._presolve(*args, **kwds)
  File "/home/esjohn/src/pyomo/pyomo/solvers/plugins/solvers/GUROBI.py", line 249, in _presolve
    ILMLicensedSystemCallSolver._presolve(self, *args, **kwds)
  File "/home/esjohn/src/pyomo/pyomo/opt/solver/shellcmd.py", line 223, in _presolve
    OptSolver._presolve(self, *args, **kwds)
  File "/home/esjohn/src/pyomo/pyomo/opt/base/solvers.py", line 704, in _presolve
    self._convert_problem(
  File "/home/esjohn/src/pyomo/pyomo/opt/base/solvers.py", line 756, in _convert_problem
    return convert_problem(
           ^^^^^^^^^^^^^^^^
  File "/home/esjohn/src/pyomo/pyomo/opt/base/convert.py", line 97, in convert_problem
    problem_files, symbol_map = converter.apply(*tmp, **tmpkw)
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/esjohn/src/pyomo/pyomo/solvers/plugins/converter/model.py", line 78, in apply
    (problem_filename, symbol_map_id) = instance.write(
                                        ^^^^^^^^^^^^^^^
  File "/home/esjohn/src/pyomo/pyomo/core/base/block.py", line 1940, in write
    (filename, smap) = problem_writer(self, filename, solver_capability, io_options)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/esjohn/src/pyomo/pyomo/repn/plugins/lp_writer.py", line 208, in __call__
    info = self.write(model, FILE, **io_options)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/esjohn/src/pyomo/pyomo/repn/plugins/lp_writer.py", line 241, in write
    return _LPWriter_impl(ostream, config).write(model)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/esjohn/src/pyomo/pyomo/repn/plugins/lp_writer.py", line 522, in write
    if v.is_binary():
       ^^^^^^^^^^^^^
  File "/home/esjohn/src/pyomo/pyomo/core/base/var.py", line 190, in is_binary
    return domain.get_interval() == (0, 1, 1)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/esjohn/src/pyomo/pyomo/core/base/set.py", line 704, in get_interval
    return self._get_discrete_interval()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/esjohn/src/pyomo/pyomo/core/base/set.py", line 738, in _get_discrete_interval
    return (vals[0], vals[0], 0)
            ~~~~^^^
IndexError: list index out of range

Information on your system

Pyomo version: main
Python version: 3.11
Operating system:
How Pyomo was installed (PyPI, conda, source):
Solver (if applicable):

@emma58 emma58 added the bug label Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant