Skip to content

bug: lp-file error: Unrecognized variable bound #541

@FBumann

Description

@FBumann

Version Checks (indicate both or one)

  • I have confirmed this bug exists on the lastest release of Linopy.

  • I have confirmed this bug exists on the current master branch of Linopy.

Issue Description

When solving a linopy model through the lp-api get the following solver log from gurobipy:

Set parameter Username
Academic license - for non-commercial use only - expires 2026-12-18
Error reading LP format file /private/var/folders/7j/18_93__x4wl2px44pq3f570m0000gn/T/linopy-problem-zxm32_f3.lp at line 21326335
Unrecognized variable bound
Neighboring tokens: " +-0.0 <= x76271 <= +0.0 +-0.0 <= x76272 <= "

With such an exeption:

Traceback (most recent call last):
  File "/Users/felix/PycharmProjects/flixopt_719231/.venv/lib/python3.11/site-packages/IPython/core/interactiveshell.py", line 3699, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-2-a472136007b0>", line 9, in <module>
    m.solve(solver_name="gurobi")
  File "/Users/felix/PycharmProjects/flixopt_719231/.venv/lib/python3.11/site-packages/linopy/model.py", line 1246, in solve
    result = solver.solve_problem_from_file(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/felix/PycharmProjects/flixopt_719231/.venv/lib/python3.11/site-packages/linopy/solvers.py", line 1065, in solve_problem_from_file
    m = gurobipy.read(problem_fn_, env=env_)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "src/gurobipy/gurobi.pxi", line 336, in gurobipy._core.read
  File "src/gurobipy/gurobi.pxi", line 121, in gurobipy._core.gurobi.read
gurobipy._exception.GurobiError: Unable to read file

Reproducible Example

"""Minimal reproducible example for the -0.0 (negative zero) LP file bug."""

import numpy as np
import linopy

m = linopy.Model()
x = m.add_variables(lower=np.float64(-0.0), upper=1.0, name="x")
m.add_objective(x)
m.solve(solver_name="gurobi")

Expected Behavior

Handling -0.0 and 0.0 equally

Installed Versions

Details bottleneck==1.6.0 cachetools==6.2.4 certifi==2025.11.12 charset-normalizer==3.4.4 click==8.3.1 cloudpickle==3.1.2 dask==2025.12.0 deprecation==2.1.0 fsspec==2025.12.0 google-api-core==2.28.1 google-auth==2.45.0 google-cloud-core==2.5.0 google-cloud-storage==3.7.0 google-crc32c==1.8.0 google-resumable-media==2.8.0 googleapis-common-protos==1.72.0 gurobipy==13.0.0 idna==3.11 linopy==0.5.8 locket==1.0.0 numexpr==2.14.1 numpy==2.4.0 packaging==25.0 pandas==2.3.3 partd==1.4.2 pip==25.3 polars==1.36.1 polars-runtime-32==1.36.1 proto-plus==1.27.0 protobuf==6.33.2 pyasn1==0.6.1 pyasn1-modules==0.4.2 python-dateutil==2.9.0.post0 pytz==2025.2 pyyaml==6.0.3 requests==2.32.5 rsa==4.9.1 scipy==1.16.3 six==1.17.0 toolz==1.1.0 tqdm==4.67.1 tzdata==2025.3 urllib3==2.6.2 xarray==2025.12.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions